Internal API change: split read/unread marking features from functions used
authorwwp <wwp@free.fr>
Tue, 13 Dec 2016 07:56:27 +0000 (08:56 +0100)
committerwwp <wwp@free.fr>
Tue, 13 Dec 2016 07:56:27 +0000 (08:56 +0100)
to mark as read/all read using a parameter.

src/folderutils.c
src/mainwindow.c
src/summaryview.c
src/summaryview.h
src/toolbar.c

index 939b019..0a4c95c 100644 (file)
@@ -132,7 +132,7 @@ void folderutils_mark_all_read(FolderItem *item)
        if (mainwin && mainwin->summaryview &&
            mainwin->summaryview->folder_item == item) {
                debug_print("folder opened, using summary\n");
-               summary_mark_all_read(mainwin->summaryview, TRUE);
+               summary_mark_all_read(mainwin->summaryview);
        } else {
                msglist = folder_item_get_msg_list(item);
                debug_print("got msglist %p\n", msglist);
@@ -172,7 +172,7 @@ void folderutils_mark_all_unread(FolderItem *item)
        if (mainwin && mainwin->summaryview &&
            mainwin->summaryview->folder_item == item) {
                debug_print("folder opened, using summary\n");
-               summary_mark_all_read(mainwin->summaryview, FALSE);
+               summary_mark_all_unread(mainwin->summaryview);
        } else {
                msglist = folder_item_get_msg_list(item);
                debug_print("got msglist %p\n", msglist);
index 19b98bd..64b2583 100644 (file)
@@ -4468,25 +4468,25 @@ static void unmark_cb(GtkAction *action, gpointer data)
 static void mark_as_read_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
-       summary_mark_as_read(mainwin->summaryview, TRUE);
+       summary_mark_as_read(mainwin->summaryview);
 }
 
 static void mark_as_unread_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
-       summary_mark_as_read(mainwin->summaryview, FALSE);
+       summary_mark_as_unread(mainwin->summaryview);
 }
 
 static void mark_all_read_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
-       summary_mark_all_read(mainwin->summaryview, TRUE);
+       summary_mark_all_read(mainwin->summaryview);
 }
 
 static void mark_all_unread_cb(GtkAction *action, gpointer data)
 {
        MainWindow *mainwin = (MainWindow *)data;
-       summary_mark_all_read(mainwin->summaryview, FALSE);
+       summary_mark_all_unread(mainwin->summaryview);
 }
 
 static void mark_as_spam_cb(GtkAction *action, gpointer data)
index 4757b10..c2a9362 100644 (file)
@@ -4045,7 +4045,7 @@ static void summary_mark_row_as_unread(SummaryView *summaryview,
                msginfo->msgnum);
 }
 
-void summary_mark_as_read(SummaryView *summaryview, gboolean read)
+void summary_mark_as_read(SummaryView *summaryview)
 {
        GtkCMCTree *ctree = GTK_CMCTREE(summaryview->ctree);
        GList *cur;
@@ -4056,12 +4056,27 @@ void summary_mark_as_read(SummaryView *summaryview, gboolean read)
        START_LONG_OPERATION(summaryview, FALSE);
        folder_item_set_batch(summaryview->folder_item, TRUE);
        for (cur = GTK_CMCLIST(ctree)->selection; cur != NULL && cur->data != NULL; cur = cur->next)
-               if (read)
-                       summary_mark_row_as_read(summaryview,
-                                                GTK_CMCTREE_NODE(cur->data));
-               else
-                       summary_mark_row_as_unread(summaryview,
-                                                GTK_CMCTREE_NODE(cur->data));
+               summary_mark_row_as_read(summaryview,
+                                        GTK_CMCTREE_NODE(cur->data));
+       folder_item_set_batch(summaryview->folder_item, FALSE);
+       END_LONG_OPERATION(summaryview);
+       
+       summary_status_show(summaryview);
+}
+
+void summary_mark_as_unread(SummaryView *summaryview)
+{
+       GtkCMCTree *ctree = GTK_CMCTREE(summaryview->ctree);
+       GList *cur;
+       gboolean froze = FALSE;
+
+       if (summary_is_locked(summaryview))
+               return;
+       START_LONG_OPERATION(summaryview, FALSE);
+       folder_item_set_batch(summaryview->folder_item, TRUE);
+       for (cur = GTK_CMCLIST(ctree)->selection; cur != NULL && cur->data != NULL; cur = cur->next)
+               summary_mark_row_as_unread(summaryview,
+                                        GTK_CMCTREE_NODE(cur->data));
        folder_item_set_batch(summaryview->folder_item, FALSE);
        END_LONG_OPERATION(summaryview);
        
@@ -4102,25 +4117,53 @@ void summary_msgs_unlock(SummaryView *summaryview)
        summary_status_show(summaryview);
 }
 
-void summary_mark_all_read(SummaryView *summaryview, gboolean read)
+void summary_mark_all_read(SummaryView *summaryview)
 {
        GtkCMCTree *ctree = GTK_CMCTREE(summaryview->ctree);
        GtkCMCTreeNode *node;
        AlertValue val;
        gboolean froze = FALSE;
-       gchar *message;
-       gchar *title;
 
-       if (read) {
-               title = _("Mark all as read");
-               message = _("Do you really want to mark all mails in this folder as read?");
-       } else {
-               title = _("Mark all as unread");
-               message = _("Do you really want to mark all mails in this folder as unread?");
+       if (prefs_common.ask_mark_all_read) {
+               val = alertpanel_full(_("Mark all as read"),
+                         _("Do you really want to mark all mails in this folder as read?"),
+                         GTK_STOCK_NO, GTK_STOCK_YES, NULL,
+                         TRUE, NULL, ALERT_QUESTION, G_ALERTDEFAULT);
+
+               if ((val & ~G_ALERTDISABLE) != G_ALERTALTERNATE)
+                       return;
+               else if (val & G_ALERTDISABLE)
+                       prefs_common.ask_mark_all_read = FALSE;
        }
+       
+       if (summary_is_locked(summaryview))
+               return;
+       START_LONG_OPERATION(summaryview, TRUE);
+       folder_item_set_batch(summaryview->folder_item, TRUE);
+       for (node = GTK_CMCTREE_NODE(GTK_CMCLIST(ctree)->row_list); node != NULL;
+            node = gtkut_ctree_node_next(ctree, node))
+               summary_mark_row_as_read(summaryview, node);
+       folder_item_set_batch(summaryview->folder_item, FALSE);
+       for (node = GTK_CMCTREE_NODE(GTK_CMCLIST(ctree)->row_list); node != NULL;
+            node = gtkut_ctree_node_next(ctree, node)) {
+               if (!GTK_CMCTREE_ROW(node)->expanded)
+                       summary_set_row_marks(summaryview, node);
+       }
+       END_LONG_OPERATION(summaryview);
+       
+       summary_status_show(summaryview);
+}
+
+void summary_mark_all_unread(SummaryView *summaryview)
+{
+       GtkCMCTree *ctree = GTK_CMCTREE(summaryview->ctree);
+       GtkCMCTreeNode *node;
+       AlertValue val;
+       gboolean froze = FALSE;
 
        if (prefs_common.ask_mark_all_read) {
-               val = alertpanel_full(title, message,
+               val = alertpanel_full(_("Mark all as unread"),
+                         _("Do you really want to mark all mails in this folder as unread?"),
                          GTK_STOCK_NO, GTK_STOCK_YES, NULL,
                          TRUE, NULL, ALERT_QUESTION, G_ALERTDEFAULT);
 
@@ -4136,10 +4179,7 @@ void summary_mark_all_read(SummaryView *summaryview, gboolean read)
        folder_item_set_batch(summaryview->folder_item, TRUE);
        for (node = GTK_CMCTREE_NODE(GTK_CMCLIST(ctree)->row_list); node != NULL;
             node = gtkut_ctree_node_next(ctree, node))
-               if (read)
-                       summary_mark_row_as_read(summaryview, node);
-               else
-                       summary_mark_row_as_unread(summaryview, node);
+               summary_mark_row_as_unread(summaryview, node);
        folder_item_set_batch(summaryview->folder_item, FALSE);
        for (node = GTK_CMCTREE_NODE(GTK_CMCLIST(ctree)->row_list); node != NULL;
             node = gtkut_ctree_node_next(ctree, node)) {
@@ -4218,27 +4258,6 @@ void summary_mark_as_spam(SummaryView *summaryview, guint action, GtkWidget *wid
        summary_status_show(summaryview);       
 }
 
-
-void summary_mark_as_unread(SummaryView *summaryview)
-{
-       GtkCMCTree *ctree = GTK_CMCTREE(summaryview->ctree);
-       GList *cur;
-       gboolean froze = FALSE;
-
-       if (summary_is_locked(summaryview))
-               return;
-       START_LONG_OPERATION(summaryview, FALSE);
-       folder_item_set_batch(summaryview->folder_item, TRUE);
-       for (cur = GTK_CMCLIST(ctree)->selection; cur != NULL && cur->data != NULL; 
-               cur = cur->next)
-               summary_mark_row_as_unread(summaryview,
-                                          GTK_CMCTREE_NODE(cur->data));
-       folder_item_set_batch(summaryview->folder_item, FALSE);
-       END_LONG_OPERATION(summaryview);
-       
-       summary_status_show(summaryview);
-}
-
 static gboolean check_permission(SummaryView *summaryview, MsgInfo * msginfo)
 {
        GList * cur;
index dee8068..66c0c4d 100644 (file)
@@ -272,10 +272,12 @@ void summary_save_as                (SummaryView          *summaryview);
 void summary_print               (SummaryView          *summaryview);
 void summary_mark                (SummaryView          *summaryview);
 void summary_unmark              (SummaryView          *summaryview);
-void summary_mark_as_read        (SummaryView          *summaryview, gboolean);
+void summary_mark_as_read        (SummaryView          *summaryview);
+void summary_mark_as_unread      (SummaryView          *summaryview);
 void summary_msgs_lock           (SummaryView          *summaryview);
 void summary_msgs_unlock         (SummaryView          *summaryview);
-void summary_mark_all_read       (SummaryView          *summaryview, gboolean);
+void summary_mark_all_read       (SummaryView          *summaryview);
+void summary_mark_all_unread     (SummaryView          *summaryview);
 void summary_mark_as_spam        (SummaryView          *summaryview, 
                                   guint                 action, 
                                   GtkWidget            *widget);
index 13d58ed..b48b804 100644 (file)
@@ -1624,7 +1624,7 @@ static void toolbar_all_read_cb(GtkWidget *widget, gpointer data)
        switch (toolbar_item->type) {
        case TOOLBAR_MAIN:
                mainwin = (MainWindow *) toolbar_item->parent;
-               summary_mark_all_read(mainwin->summaryview, TRUE);
+               summary_mark_all_read(mainwin->summaryview);
                break;
        case TOOLBAR_MSGVIEW:
                /* TODO: see toolbar_next_unread_cb() if you need
@@ -1646,7 +1646,7 @@ static void toolbar_all_unread_cb(GtkWidget *widget, gpointer data)
        switch (toolbar_item->type) {
        case TOOLBAR_MAIN:
                mainwin = (MainWindow *) toolbar_item->parent;
-               summary_mark_all_read(mainwin->summaryview, FALSE);
+               summary_mark_all_unread(mainwin->summaryview);
                break;
        case TOOLBAR_MSGVIEW:
                /* TODO: see toolbar_next_unread_cb() if you need
@@ -1668,7 +1668,7 @@ static void toolbar_read_cb(GtkWidget *widget, gpointer data)
        switch (toolbar_item->type) {
        case TOOLBAR_MAIN:
                mainwin = (MainWindow *) toolbar_item->parent;
-               summary_mark_as_read(mainwin->summaryview, TRUE);
+               summary_mark_as_read(mainwin->summaryview);
                break;
        case TOOLBAR_MSGVIEW:
                /* TODO: see toolbar_next_unread_cb() if you need
@@ -1690,7 +1690,7 @@ static void toolbar_unread_cb(GtkWidget *widget, gpointer data)
        switch (toolbar_item->type) {
        case TOOLBAR_MAIN:
                mainwin = (MainWindow *) toolbar_item->parent;
-               summary_mark_as_read(mainwin->summaryview, FALSE);
+               summary_mark_as_unread(mainwin->summaryview);
                break;
        case TOOLBAR_MSGVIEW:
                /* TODO: see toolbar_next_unread_cb() if you need