Add "Delete duplicates" (delete duplicated messages in current folder) to
authorwwp <wwp@free.fr>
Thu, 19 Jan 2017 13:49:06 +0000 (14:49 +0100)
committerwwp <wwp@free.fr>
Thu, 19 Jan 2017 13:49:06 +0000 (14:49 +0100)
the main window's toolbar, including a brand new (not so shining) icon.

src/Makefile.am
src/mainwindow.c
src/mainwindow.h
src/pixmaps/delete_dup_btn.xpm [new file with mode: 0644]
src/prefs_toolbar.c
src/stock_pixmap.c
src/stock_pixmap.h
src/toolbar.c
src/toolbar.h

index 5c0de96..b78a58d 100644 (file)
@@ -399,6 +399,7 @@ EXTRA_DIST = \
        pixmaps/continue.xpm \
        pixmaps/copied.xpm \
        pixmaps/delete_btn.xpm \
+       pixmaps/delete_dup_btn.xpm \
        pixmaps/deleted.xpm \
        pixmaps/dir_close.xpm \
        pixmaps/dir_close_hrm.xpm \
index 6c8aa07..8b36262 100644 (file)
@@ -4694,9 +4694,8 @@ static void attract_by_subject_cb(GtkAction *action, gpointer data)
        summary_attract_by_subject(mainwin->summaryview);
 }
 
-static void delete_duplicated_cb(GtkAction *action, gpointer data)
+void mainwindow_delete_duplicated(MainWindow *mainwin)
 {
-       MainWindow *mainwin = (MainWindow *)data;
        FolderItem *item;
 
        item = folderview_get_selected_item(mainwin->folderview);
@@ -4712,6 +4711,11 @@ static void delete_duplicated_cb(GtkAction *action, gpointer data)
        }
 }
 
+static void delete_duplicated_cb(GtkAction *action, gpointer data)
+{
+       mainwindow_delete_duplicated((MainWindow *)data);
+}
+
 struct DelDupsData
 {
        guint   dups;
index e4763b5..551173e 100644 (file)
@@ -216,6 +216,7 @@ void mainwindow_jump_to                           (const gchar       *target,
                                               gboolean popup);
 void mainwindow_show_error                   (void);
 void mainwindow_clear_error                  (MainWindow *mainwin);
+void mainwindow_delete_duplicated     (MainWindow *mainwin);
 gboolean mainwindow_is_obscured                      (void);
 void mainwindow_exit_folder                  (MainWindow *mainwin);
 void mainwindow_enter_folder                 (MainWindow *mainwin);
diff --git a/src/pixmaps/delete_dup_btn.xpm b/src/pixmaps/delete_dup_btn.xpm
new file mode 100644 (file)
index 0000000..6d92856
--- /dev/null
@@ -0,0 +1,33 @@
+/* XPM */
+static char * delete_dup_btn_xpm[] = {
+"24 24 6 1",
+"      c None",
+".     c #000000",
+"+     c #808080",
+"@     c #FFFFFF",
+"#     c #FF0000",
+"$     c #E00000",
+"                        ",
+"                        ",
+" .....                  ",
+".+@@@+.                 ",
+".@+@+@.                 ",
+".@@+@@.                 ",
+".@@@@@.                 ",
+" .....     ..           ",
+"           .#.          ",
+" .....  ....##.   ..... ",
+".+@@@+. .######. .+@@@+.",
+".@+@+@. .######$..@+@+@.",
+".@@+@@. .######. .@@+@@.",
+".@@@@@. ....##.  .@@@@@.",
+" .....     .#.    ..... ",
+"           ..           ",
+" .....                  ",
+".+@@@+.                 ",
+".@+@+@.                 ",
+".@@+@@.                 ",
+".@@@@@.                 ",
+" .....                  ",
+"                        ",
+"                        "};
index b86835b..b59c1b4 100644 (file)
@@ -145,6 +145,7 @@ static const gint ToolbarIcons[] =
        STOCK_PIXMAP_HAM_BTN,
        STOCK_PIXMAP_TRASH,
        STOCK_PIXMAP_DELETE,
+       STOCK_PIXMAP_DELETE_DUP,
        STOCK_PIXMAP_CANCEL,
        STOCK_PIXMAP_MARK_IGNORETHREAD,
        STOCK_PIXMAP_MARK_WATCHTHREAD,
index b73ebc2..2fd5a7b 100644 (file)
 #include "pixmaps/mime_message.xpm"
 #include "pixmaps/address_search.xpm"
 #include "pixmaps/check_spelling.xpm"
-
 #include "pixmaps/dir_close.xpm"
 #include "pixmaps/dir_close_hrm.xpm"
 #include "pixmaps/dir_open.xpm"
 #include "pixmaps/trash_open.xpm"
 #include "pixmaps/trash_close.xpm"
 #include "pixmaps/delete_btn.xpm"
+#include "pixmaps/delete_dup_btn.xpm"
 #include "pixmaps/cancel.xpm"
 #include "pixmaps/trash_btn.xpm"
 #include "pixmaps/trash_open_hrm.xpm"
@@ -402,6 +402,7 @@ static StockPixmapData pixmaps[] =
     {claws_mail_icon_64_xpm           , NULL, NULL, "claws_mail_icon_64", NULL, NULL},
     {read_xpm                         , NULL, NULL, "read", NULL, NULL},
     {delete_btn_xpm                   , NULL, NULL, "delete_btn", NULL, NULL},
+    {delete_dup_btn_xpm               , NULL, NULL, "delete_dup_btn", NULL, NULL},
     {cancel_xpm                       , NULL, NULL, "cancel", NULL, NULL},
     {trash_btn_xpm                    , NULL, NULL, "trash_btn", NULL, NULL},
     {claws_mail_compose_logo_xpm      , NULL, NULL, "claws_mail_compose_logo", NULL, NULL},
index 9995cfe..0e7a96b 100644 (file)
@@ -164,6 +164,7 @@ typedef enum
        STOCK_PIXMAP_CLAWS_MAIL_ICON_64,
        STOCK_PIXMAP_READ,
        STOCK_PIXMAP_DELETE,
+       STOCK_PIXMAP_DELETE_DUP,
        STOCK_PIXMAP_CANCEL,
        STOCK_PIXMAP_TRASH,
        STOCK_PIXMAP_MAIL_COMPOSE_LOGO,
index c41b487..4ffd6bb 100644 (file)
@@ -103,13 +103,20 @@ static void activate_compose_button               (Toolbar        *toolbar,
 /* 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_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);
 
@@ -229,6 +236,7 @@ struct {
        { "A_FORWARD",          N_("Forward Message")                      }, 
        { "A_TRASH",            N_("Trash Message")                        },
        { "A_DELETE_REAL",      N_("Delete Message")                       },
+       { "A_DELETE_DUP",       N_("Delete duplicate messages in current folder") },
        { "A_EXECUTE",          N_("Execute")                              },
        { "A_GOTO_PREV",        N_("Go to Previous Unread Message")        },
        { "A_GOTO_NEXT",        N_("Go to Next Unread Message")            },
@@ -367,11 +375,11 @@ GList *toolbar_get_action_items(ToolbarType source)
                                        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++)  {
@@ -480,6 +488,7 @@ const gchar *toolbar_get_short_text(int action) {
        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");
@@ -538,6 +547,7 @@ gint toolbar_get_icon(int action) {
        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;
@@ -1194,6 +1204,25 @@ static void toolbar_delete_cb(GtkWidget *widget, gpointer data)
        }
 }
 
+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
@@ -1955,6 +1984,7 @@ static void toolbar_buttons_cb(GtkWidget   *widget,
                { 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                 },
@@ -2149,7 +2179,7 @@ Toolbar *toolbar_create(ToolbarType        type,
                        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:
@@ -2207,6 +2237,10 @@ Toolbar *toolbar_create(ToolbarType       type,
                        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:
+                       TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,_("Delete duplicates"));
+                       toolbar_data->delete_dup_btn = item;
+                       break;
                case A_REPLY_MESSAGE:
 #ifndef GENERIC_UMPC
                        TOOLBAR_MENUITEM(item,icon_wid,toolbar_item->text,
@@ -2589,7 +2623,7 @@ do { \
        } 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);
@@ -2598,6 +2632,10 @@ do { \
                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_ALLOW_DELETE, M_SUMMARY_ISLIST);
+
        if (toolbar->exec_btn)
                SET_WIDGET_COND(toolbar->exec_btn, 
                        M_DELAY_EXEC);
@@ -2727,6 +2765,7 @@ static void toolbar_init(Toolbar * toolbar)
        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;
index 4b84bb6..6047a88 100644 (file)
@@ -69,6 +69,7 @@ struct _Toolbar {
        
        GtkWidget *trash_btn;
        GtkWidget *delete_btn;
+       GtkWidget *delete_dup_btn;
        GtkWidget *prev_btn;
        GtkWidget *next_btn;
        GtkWidget *exec_btn;
@@ -168,6 +169,7 @@ enum {
        A_FORWARD,
        A_TRASH,
        A_DELETE_REAL,
+       A_DELETE_DUP,
        A_EXECUTE,
        A_GOTO_PREV,
        A_GOTO_NEXT,