/*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2001-2013 Hiroyuki Yamamoto and the Claws Mail team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2001-2017 Hiroyuki Yamamoto and the Claws Mail team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/*
- * General functions for accessing address book files.
*/
#ifdef HAVE_CONFIG_H
static gint toolbar_ret_val_from_text (const gchar *text);
static gchar *toolbar_ret_text_from_val (gint val);
-static void toolbar_set_default_main (void);
-static void toolbar_set_default_compose (void);
-static void toolbar_set_default_msgview (void);
+typedef struct _DefaultToolbar DefaultToolbar;
+struct _DefaultToolbar {
+ gint action;
+};
+static void toolbar_set_default_generic(ToolbarType toolbar_type,
+ DefaultToolbar *default_toolbar);
static void toolbar_style (ToolbarType type,
guint action,
/* toolbar callbacks */
static void toolbar_reply (gpointer data,
guint action);
+
static void toolbar_learn (gpointer data,
guint action);
-static void toolbar_delete_cb (GtkWidget *widget,
- gpointer data);
+
+static void toolbar_delete_dup (gpointer data,
+ guint action);
+
static void toolbar_trash_cb (GtkWidget *widget,
gpointer data);
+static void toolbar_delete_cb (GtkWidget *widget,
+ gpointer data);
+
+static void toolbar_delete_dup_cb (GtkWidget *widget,
+
+ gpointer data);
+
static void toolbar_compose_cb (GtkWidget *widget,
gpointer data);
static void toolbar_lock_cb (GtkWidget *widget,
gpointer data);
-static void toolbar_ulock_cb (GtkWidget *widget,
+static void toolbar_unlock_cb (GtkWidget *widget,
gpointer data);
static void toolbar_all_read_cb (GtkWidget *widget,
{ "A_FORWARD", N_("Forward Message") },
{ "A_TRASH", N_("Trash Message") },
{ "A_DELETE_REAL", N_("Delete Message") },
+ { "A_DELETE_DUP", N_("Delete duplicate messages") },
{ "A_EXECUTE", N_("Execute") },
{ "A_GOTO_PREV", N_("Go to Previous Unread Message") },
{ "A_GOTO_NEXT", N_("Go to Next Unread Message") },
A_RECEIVE_ALL, A_RECEIVE_CUR, A_SEND_QUEUED,
A_COMPOSE_EMAIL, A_REPLY_MESSAGE, A_REPLY_SENDER,
A_REPLY_ALL, A_REPLY_ML, A_OPEN_MAIL, A_FORWARD,
- A_TRASH, A_DELETE_REAL, A_EXECUTE, A_GOTO_PREV,
- A_GOTO_NEXT, A_IGNORE_THREAD, A_WATCH_THREAD, A_MARK,
- A_UNMARK, A_LOCK, A_UNLOCK, A_ALL_READ,
- A_ALL_UNREAD, A_READ, A_UNREAD, A_PRINT,
- A_ADDRBOOK, A_LEARN_SPAM, A_GO_FOLDERS,
+ A_TRASH, A_DELETE_REAL, A_DELETE_DUP, A_EXECUTE,
+ A_GOTO_PREV, A_GOTO_NEXT, A_IGNORE_THREAD, A_WATCH_THREAD,
+ A_MARK, A_UNMARK, A_LOCK, A_UNLOCK,
+ A_ALL_READ, A_ALL_UNREAD, A_READ, A_UNREAD,
+ A_PRINT, A_ADDRBOOK, A_LEARN_SPAM, A_GO_FOLDERS,
A_CANCEL_INC, A_CANCEL_SEND, A_CANCEL_ALL, A_PREFERENCES };
for (i = 0; i < sizeof main_items / sizeof main_items[0]; i++) {
item->text = g_strdup(C_("Toolbar", "Trash"));
*rewrite = TRUE;
}
+ if (!strcmp(item->file, "mail") && !strcmp(value, "A_DRAFT")) {
+ /* switch icon file */
+ g_free(item->file);
+ item->file = g_strdup("mail_draft");
+ *rewrite = TRUE;
+ }
if (item->index == -1) {
/* item not found in table: try migrating old action names to current ones */
gint i;
case A_FORWARD: return _("Forward");
case A_TRASH: return C_("Toolbar", "Trash");
case A_DELETE_REAL: return _("Delete");
+ case A_DELETE_DUP: return _("Delete duplicates");
case A_EXECUTE: return _("Execute");
case A_GOTO_PREV: return _("Prev");
case A_GOTO_NEXT: return _("Next");
case A_FORWARD: return STOCK_PIXMAP_MAIL_FORWARD;
case A_TRASH: return STOCK_PIXMAP_TRASH;
case A_DELETE_REAL: return STOCK_PIXMAP_DELETE;
+ case A_DELETE_DUP: return STOCK_PIXMAP_DELETE_DUP;
case A_EXECUTE: return STOCK_PIXMAP_EXEC;
case A_GOTO_PREV: return STOCK_PIXMAP_UP_ARROW;
case A_GOTO_NEXT: return STOCK_PIXMAP_DOWN_ARROW;
case A_READ: return STOCK_PIXMAP_MARK_READ;
case A_UNREAD: return STOCK_PIXMAP_MARK_UNREAD;
- case A_PRINT: return STOCK_PIXMAP_PRINTER;
+ case A_PRINT: return STOCK_PIXMAP_PRINTER_BTN;
case A_LEARN_SPAM: return STOCK_PIXMAP_SPAM_BTN;
case A_GO_FOLDERS: return STOCK_PIXMAP_GO_FOLDERS;
case A_PREFERENCES: return STOCK_PIXMAP_PREFERENCES;
case A_SEND: return STOCK_PIXMAP_MAIL_SEND;
case A_SEND_LATER: return STOCK_PIXMAP_MAIL_SEND_QUEUE;
- case A_DRAFT: return STOCK_PIXMAP_MAIL;
+ case A_DRAFT: return STOCK_PIXMAP_MAIL_DRAFT;
case A_INSERT: return STOCK_PIXMAP_INSERT_FILE;
case A_ATTACH: return STOCK_PIXMAP_MAIL_ATTACH;
case A_SIG: return STOCK_PIXMAP_MAIL_SIGN;
}
}
-static void toolbar_set_default_main(void)
+static void toolbar_set_default_generic(ToolbarType toolbar_type, DefaultToolbar *default_toolbar)
{
- struct {
- gint action;
- } default_toolbar[] = {
+ gint i;
+
+ g_return_if_fail(default_toolbar != NULL);
+
+ for (i = 0; default_toolbar[i].action != N_ACTION_VAL; i++) {
+
+ ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
+
+ if (default_toolbar[i].action != A_SEPARATOR) {
+ gchar *file = NULL;
+ gint icon;
+
+ icon = toolbar_get_icon(default_toolbar[i].action);
+ if (icon > -1) {
+ file = stock_pixmap_get_name((StockPixmap)icon);
+ }
+ toolbar_item->file = g_strdup(file);
+ toolbar_item->index = default_toolbar[i].action;
+ toolbar_item->text = g_strdup(toolbar_get_short_text(default_toolbar[i].action));
+ } else {
+ toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
+ toolbar_item->index = A_SEPARATOR;
+ }
+
+ if (toolbar_item->index != -1) {
+ if (!toolbar_is_duplicate(toolbar_item->index, toolbar_type))
+ toolbar_config[toolbar_type].item_list =
+ g_slist_append(toolbar_config[toolbar_type].item_list, toolbar_item);
+ }
+ }
+}
+
+void toolbar_set_default(ToolbarType source)
+{
+ DefaultToolbar default_toolbar_main[] = {
#ifdef GENERIC_UMPC
{ A_GO_FOLDERS},
{ A_OPEN_MAIL},
{ A_LEARN_SPAM},
#endif
{ A_SEPARATOR},
- { A_GOTO_NEXT}
+ { A_GOTO_NEXT},
+ { N_ACTION_VAL}
};
-
- gint i;
-
- for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
-
- ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
-
- if (default_toolbar[i].action != A_SEPARATOR) {
-
- gchar *file = NULL;
- if (toolbar_get_icon(default_toolbar[i].action) > -1) {
- file = stock_pixmap_get_name((StockPixmap)toolbar_get_icon(default_toolbar[i].action));
- }
-
- toolbar_item->file = g_strdup(file);
- toolbar_item->index = default_toolbar[i].action;
- toolbar_item->text = g_strdup(toolbar_get_short_text(default_toolbar[i].action));
- } else {
-
- toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
- toolbar_item->index = A_SEPARATOR;
- }
-
- if (toolbar_item->index != -1) {
- if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_MAIN))
- toolbar_config[TOOLBAR_MAIN].item_list =
- g_slist_append(toolbar_config[TOOLBAR_MAIN].item_list, toolbar_item);
- }
- }
-}
-
-static void toolbar_set_default_compose(void)
-{
- struct {
- gint action;
- } default_toolbar[] = {
+ DefaultToolbar default_toolbar_compose[] = {
#ifdef GENERIC_UMPC
{ A_CLOSE},
{ A_SEPARATOR},
#endif
{ A_ATTACH},
{ A_SEPARATOR},
- { A_ADDRBOOK}
+ { A_ADDRBOOK},
+ { N_ACTION_VAL}
};
-
- gint i;
-
- for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
-
- ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
-
- if (default_toolbar[i].action != A_SEPARATOR) {
-
- gchar *file = NULL;
- if (toolbar_get_icon(default_toolbar[i].action) > -1) {
- file = stock_pixmap_get_name((StockPixmap)toolbar_get_icon(default_toolbar[i].action));
- }
- toolbar_item->file = g_strdup(file);
- toolbar_item->index = default_toolbar[i].action;
- toolbar_item->text = g_strdup(toolbar_get_short_text(default_toolbar[i].action));
- } else {
- toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
- toolbar_item->index = A_SEPARATOR;
- }
-
- if (toolbar_item->index != -1) {
- if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_COMPOSE))
- toolbar_config[TOOLBAR_COMPOSE].item_list =
- g_slist_append(toolbar_config[TOOLBAR_COMPOSE].item_list, toolbar_item);
- }
- }
-}
-
-static void toolbar_set_default_msgview(void)
-{
- struct {
- gint action;
- } default_toolbar[] = {
+ DefaultToolbar default_toolbar_msgview[] = {
#ifdef GENERIC_UMPC
{ A_CLOSE},
{ A_SEPARATOR},
#ifndef GENERIC_UMPC
{ A_LEARN_SPAM},
#endif
- { A_GOTO_NEXT}
+ { A_GOTO_NEXT},
+ { N_ACTION_VAL}
};
- gint i;
-
- for (i = 0; i < sizeof(default_toolbar) / sizeof(default_toolbar[0]); i++) {
-
- ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
-
- if (default_toolbar[i].action != A_SEPARATOR) {
- gchar *file = NULL;
- if (toolbar_get_icon(default_toolbar[i].action) > -1) {
- file = stock_pixmap_get_name((StockPixmap)toolbar_get_icon(default_toolbar[i].action));
- }
-
- toolbar_item->file = g_strdup(file);
- toolbar_item->index = default_toolbar[i].action;
- toolbar_item->text = g_strdup(toolbar_get_short_text(default_toolbar[i].action));
- } else {
-
- toolbar_item->file = g_strdup(TOOLBAR_TAG_SEPARATOR);
- toolbar_item->index = A_SEPARATOR;
- }
-
- if (toolbar_item->index != -1) {
- if ( !toolbar_is_duplicate(toolbar_item->index, TOOLBAR_MSGVIEW))
- toolbar_config[TOOLBAR_MSGVIEW].item_list =
- g_slist_append(toolbar_config[TOOLBAR_MSGVIEW].item_list, toolbar_item);
- }
- }
-}
-
-void toolbar_set_default(ToolbarType source)
-{
if (source == TOOLBAR_MAIN)
- toolbar_set_default_main();
+ toolbar_set_default_generic(TOOLBAR_MAIN, default_toolbar_main);
else if (source == TOOLBAR_COMPOSE)
- toolbar_set_default_compose();
+ toolbar_set_default_generic(TOOLBAR_COMPOSE, default_toolbar_compose);
else if (source == TOOLBAR_MSGVIEW)
- toolbar_set_default_msgview();
+ toolbar_set_default_generic(TOOLBAR_MSGVIEW, default_toolbar_msgview);
}
void toolbar_save_config_file(ToolbarType source)
}
}
+static void toolbar_delete_dup(gpointer data, guint all)
+{
+ ToolbarItem *toolbar_item = (ToolbarItem*)data;
+ MainWindow *mainwin = NULL;
+
+ cm_return_if_fail(toolbar_item != NULL);
+
+ switch (toolbar_item->type) {
+ case TOOLBAR_MAIN:
+ mainwin = (MainWindow*)toolbar_item->parent;
+ if (all)
+ mainwindow_delete_duplicated_all(mainwin);
+ else
+ mainwindow_delete_duplicated(mainwin);
+ break;
+ case TOOLBAR_COMPOSE:
+ case TOOLBAR_MSGVIEW:
+ break;
+ default:
+ debug_print("toolbar event not supported\n");
+ return;
+ }
+}
+
+static void toolbar_delete_dup_cb(GtkWidget *widget, gpointer data)
+{
+ ToolbarItem *toolbar_item = (ToolbarItem*)data;
+ MainWindow *mainwin = NULL;
+
+ cm_return_if_fail(toolbar_item != NULL);
+
+ switch (toolbar_item->type) {
+ case TOOLBAR_MAIN:
+ mainwin = (MainWindow*)toolbar_item->parent;
+ mainwindow_delete_duplicated(mainwin);
+ break;
+ case TOOLBAR_COMPOSE:
+ case TOOLBAR_MSGVIEW:
+ break;
+ default:
+ return;
+ }
+}
/*
* Compose new message
switch (toolbar_item->type) {
case TOOLBAR_MAIN:
mainwin = (MainWindow *) toolbar_item->parent;
- summary_mark_all_read(mainwin->summaryview);
+ summary_mark_all_read(mainwin->summaryview, TRUE);
break;
case TOOLBAR_MSGVIEW:
/* TODO: see toolbar_next_unread_cb() if you need
switch (toolbar_item->type) {
case TOOLBAR_MAIN:
mainwin = (MainWindow *) toolbar_item->parent;
- summary_mark_all_unread(mainwin->summaryview);
+ summary_mark_all_unread(mainwin->summaryview, TRUE);
break;
case TOOLBAR_MSGVIEW:
/* TODO: see toolbar_next_unread_cb() if you need
{ A_UNREAD, toolbar_unread_cb },
{ A_PRINT, toolbar_print_cb },
{ A_LEARN_SPAM, toolbar_learn_cb },
+ { A_DELETE_DUP, toolbar_delete_dup_cb },
{ A_GO_FOLDERS, toolbar_go_folders_cb },
{ A_SEND, toolbar_send_cb },
toolbar_learn(toolbar_item, GPOINTER_TO_INT(int_value));
}
+static void toolbar_delete_dup_menu_cb(GtkWidget *widget, gpointer data)
+{
+ gpointer int_value = g_object_get_data(G_OBJECT(widget), "int-value");
+ ToolbarItem *toolbar_item = (ToolbarItem *)data;
+
+ toolbar_delete_dup(toolbar_item, GPOINTER_TO_INT(int_value));
+}
+
/**
* Create a new toolbar with specified type
* if a callback list is passed it will be used before the
toolbar_data->getall_btn = item;
break;
case A_RECEIVE_CUR:
- TOOLBAR_ITEM(item,icon_wid,toolbar_item->text, _("Receive Mail from current Account"));
+ TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Receive Mail from current Account"));
toolbar_data->get_btn = item;
break;
case A_SEND_QUEUED:
ADD_MENU_ITEM(_("Learn as _Ham"), toolbar_learn_menu_cb, FALSE);
gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->learn_spam_btn), menu);
break;
+ case A_DELETE_DUP:
+#ifndef GENERIC_UMPC
+ TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
+ _("Delete duplicates"),
+ _("Delete duplicates options"));
+ toolbar_data->delete_dup_btn = item;
+
+ menu = gtk_menu_new();
+ ADD_MENU_ITEM(_("Delete duplicates in selected folder"), toolbar_delete_dup_menu_cb, FALSE);
+ ADD_MENU_ITEM(_("Delete duplicates in all folders"), toolbar_delete_dup_menu_cb, TRUE);
+ gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolbar_data->delete_dup_btn), menu);
+#else
+ TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Delete duplicates"));
+ toolbar_data->delete_dup_btn = item;
+#endif
+ break;
case A_REPLY_MESSAGE:
#ifndef GENERIC_UMPC
TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
} else {
SET_WIDGET_COND(toolbar->next_btn, -1);
}
-
+
if (toolbar->trash_btn)
SET_WIDGET_COND(toolbar->trash_btn,
M_TARGET_EXIST, M_ALLOW_DELETE, M_NOT_NEWS);
SET_WIDGET_COND(toolbar->delete_btn,
M_TARGET_EXIST, M_ALLOW_DELETE);
+ if (toolbar->delete_dup_btn)
+ SET_WIDGET_COND(toolbar->delete_dup_btn,
+ M_MSG_EXIST, M_ALLOW_DELETE, M_SUMMARY_ISLIST);
+
if (toolbar->exec_btn)
SET_WIDGET_COND(toolbar->exec_btn,
M_DELAY_EXEC);
toolbar->fwd_btn = NULL;
toolbar->trash_btn = NULL;
toolbar->delete_btn = NULL;
+ toolbar->delete_dup_btn = NULL;
toolbar->prev_btn = NULL;
toolbar->next_btn = NULL;
toolbar->exec_btn = NULL;