talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit fed3e19ea57b2a9332b42c22183bdf55d64af2e9
parent c3112d84245d05b471ecdaebb4a6cea5ff3af6dd
Author: Ricardo Mones <ricardo@mones.org>
Date:   Thu, 28 May 2015 21:07:30 +0200

Fix bug #1941 ‘recursive "mark read all"’

Based on the original patch from Robert David which unfortunately
didn't marked as read the folder currently open on summary view.

Diffstat:
MAUTHORS | 1+
Msrc/folderutils.c | 24++++++++++++++++++++++++
Msrc/folderutils.h | 1+
Msrc/folderview.c | 28+++++++++++++++++++++++++---
Msrc/gtk/authors.h | 1+
5 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/AUTHORS b/AUTHORS @@ -313,3 +313,4 @@ contributors (in addition to the above; based on Changelog) Daniel Zaoui Johan Vromans Charles Lehner + Robert David diff --git a/src/folderutils.c b/src/folderutils.c @@ -158,3 +158,27 @@ void folderutils_mark_all_read(FolderItem *item) } folder_item_update_thaw(); } + +void folderutils_mark_all_read_recursive(FolderItem *item) +{ + GNode *node; + + cm_return_if_fail(item != NULL); + + folderutils_mark_all_read(item); + + cm_return_if_fail(item->folder != NULL); + cm_return_if_fail(item->folder->node != NULL); + + node = item->folder->node; + node = g_node_find(node, G_PRE_ORDER, G_TRAVERSE_ALL, item); + node = node->children; + + while (node != NULL) { + if (node->data != NULL) { + FolderItem *sub_item = (FolderItem *) node->data; + node = node->next; + folderutils_mark_all_read_recursive(sub_item); + } + } +} diff --git a/src/folderutils.h b/src/folderutils.h @@ -30,5 +30,6 @@ typedef enum { gint folderutils_delete_duplicates(FolderItem *item, DeleteDuplicatesMode mode); void folderutils_mark_all_read (FolderItem *item); +void folderutils_mark_all_read_recursive (FolderItem *item); #endif /* FOLDERUTILS_H */ diff --git a/src/folderview.c b/src/folderview.c @@ -163,8 +163,14 @@ static void folderview_col_resized (GtkCMCList *clist, gint width, FolderView *folderview); +static void mark_all_read_handler (GtkAction *action, + gpointer data, + gboolean recursive); + static void mark_all_read_cb (GtkAction *action, gpointer data); +static void mark_all_read_recursive_cb (GtkAction *action, + gpointer data); static void folderview_empty_trash_cb (GtkAction *action, gpointer data); @@ -228,6 +234,7 @@ static GtkActionEntry folderview_common_popup_entries[] = { {"FolderViewPopup", NULL, "FolderViewPopup" }, {"FolderViewPopup/MarkAllRead", NULL, N_("Mark all re_ad"), NULL, NULL, G_CALLBACK(mark_all_read_cb) }, + {"FolderViewPopup/MarkAllReadRec", NULL, N_("Mark all read recursi_ve"), NULL, NULL, G_CALLBACK(mark_all_read_recursive_cb) }, {"FolderViewPopup/---", NULL, "---" }, {"FolderViewPopup/RunProcessing", NULL, N_("R_un processing rules"), NULL, NULL, G_CALLBACK(folderview_run_processing_cb) }, {"FolderViewPopup/SearchFolder", NULL, N_("_Search folder..."), NULL, NULL, G_CALLBACK(folderview_search_cb) }, @@ -810,6 +817,16 @@ void folderview_select(FolderView *folderview, FolderItem *item) static void mark_all_read_cb(GtkAction *action, gpointer data) { + mark_all_read_handler(action, data, FALSE); +} + +static void mark_all_read_recursive_cb(GtkAction *action, gpointer data) +{ + mark_all_read_handler(action, data, TRUE); +} + +static void mark_all_read_handler(GtkAction *action, gpointer data, gboolean recursive) +{ FolderView *folderview = (FolderView *)data; FolderItem *item; AlertValue val; @@ -833,14 +850,17 @@ static void mark_all_read_cb(GtkAction *action, gpointer data) folder_item_update_freeze(); - if (folderview->summaryview->folder_item != item) + if (folderview->summaryview->folder_item != item && !recursive) summary_lock(folderview->summaryview); else summary_freeze(folderview->summaryview); - folderutils_mark_all_read(item); + if (recursive) + folderutils_mark_all_read_recursive(item); + else + folderutils_mark_all_read(item); - if (folderview->summaryview->folder_item != item) + if (folderview->summaryview->folder_item != item && !recursive) summary_unlock(folderview->summaryview); else summary_thaw(folderview->summaryview); @@ -1820,6 +1840,7 @@ static void folderview_set_sens_and_popup_menu(FolderView *folderview, gint row, fpopup->add_menuitems(ui_manager, item); MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "MarkAllRead", "FolderViewPopup/MarkAllRead", GTK_UI_MANAGER_MENUITEM) + MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "MarkAllReadRec", "FolderViewPopup/MarkAllReadRec", GTK_UI_MANAGER_MENUITEM) MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "Separator1", "FolderViewPopup/---", GTK_UI_MANAGER_SEPARATOR) MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "RunProcessing", "FolderViewPopup/RunProcessing", GTK_UI_MANAGER_MENUITEM) MENUITEM_ADDUI_MANAGER(ui_manager, "/Popup/FolderViewPopup", "SearchFolder", "FolderViewPopup/SearchFolder", GTK_UI_MANAGER_MENUITEM) @@ -1850,6 +1871,7 @@ static void folderview_set_sens_and_popup_menu(FolderView *folderview, gint row, cm_menu_set_sensitive_full(ui_manager, "Popup/"name, sens) SET_SENS("FolderViewPopup/MarkAllRead", item->unread_msgs >= 1); + SET_SENS("FolderViewPopup/MarkAllReadRec", folderview_have_unread_children(folderview,item)); SET_SENS("FolderViewPopup/SearchFolder", item->total_msgs >= 1 && folderview->selected == folderview->opened); SET_SENS("FolderViewPopup/Properties", TRUE); diff --git a/src/gtk/authors.h b/src/gtk/authors.h @@ -111,6 +111,7 @@ static char *CONTRIBS_LIST[] = { "Christian Cornelssen", "Palmer Dabbelt", "George Danchev", +"Robert David", "Kevin Day", "Matthieu Dazy", "Ben Deering",