2007-03-12 [wwp] 2.8.1cvs6
authorTristan Chabredier <wwp@claws-mail.org>
Mon, 12 Mar 2007 10:46:37 +0000 (10:46 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Mon, 12 Mar 2007 10:46:37 +0000 (10:46 +0000)
* src/folderview.c
* src/prefs_common.c
* src/prefs_common.h
* src/prefs_summaries.c
Changed the option that displays unread messages count
next to the folder name in folder list: it is now
possible to either display nothing, display the
unread messages number only or the unread and total messages
numbers. The patch includes this extra feature as well
as some minor fixes by rewriting the algo in folderview.c.
Thanks to Paul for the original idea and implementation, plus
testing and proof-reading!

ChangeLog
PATCHSETS
configure.ac
src/folderview.c
src/prefs_common.c
src/prefs_common.h
src/prefs_summaries.c

index 7e49e8adff8b1c2a362da76c87a6db6b6605c96c..e262db4c42ddd5e7e634adc7ea432ce09e9a770a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2007-03-12 [wwp]       2.8.1cvs6
+
+       * src/folderview.c
+       * src/prefs_common.c
+       * src/prefs_common.h
+       * src/prefs_summaries.c
+               Changed the option that displays unread messages count
+               next to the folder name in folder list: it is now
+               possible to either display nothing, display the
+               unread messages number only or the unread and total messages
+               numbers. The patch includes this extra feature as well
+               as some minor fixes by rewriting the algo in folderview.c.
+               Thanks to Paul for the original idea and implementation, plus
+               testing and proof-reading!
+
 2007-03-09 [paul]      2.8.1cvs5
 
        * tools/Makefile.am
index ec73c0bf22c1151d55bda796fcd548c0dc1dc8bf..8e0e5436664de2aaa4d0a552343544401b7530de 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.8.2.14 -r 1.8.2.15 src/quote_fmt.c;  cvs diff -u -r 1.8.2.8 -r 1.8.2.9 src/quote_fmt_lex.l;  cvs diff -u -r 1.22.2.27 -r 1.22.2.28 src/quote_fmt_parse.y;  ) > 2.8.1cvs3.patchset
 ( cvs diff -u -r 1.27.2.34 -r 1.27.2.35 src/addr_compl.c;  cvs diff -u -r 1.8.2.9 -r 1.8.2.10 src/addr_compl.h;  cvs diff -u -r 1.60.2.28 -r 1.60.2.29 src/filtering.c;  ) > 2.8.1cvs4.patchset
 ( cvs diff -u -r 1.25.2.17 -r 1.25.2.18 tools/Makefile.am;  cvs diff -u -r 1.30.2.17 -r 1.30.2.18 tools/README;  diff -u /dev/null tools/claws-mail-compose-insert-files.pl;  ) > 2.8.1cvs5.patchset
+( cvs diff -u -r 1.207.2.150 -r 1.207.2.151 src/folderview.c;  cvs diff -u -r 1.204.2.122 -r 1.204.2.123 src/prefs_common.c;  cvs diff -u -r 1.103.2.76 -r 1.103.2.77 src/prefs_common.h;  cvs diff -u -r 1.1.2.38 -r 1.1.2.39 src/prefs_summaries.c;  ) > 2.8.1cvs6.patchset
index f60ed7875e96f835943a1778e350ca48f04eef8c..b559865c28ec753c0b805562ac320dcd134137c3 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=5
+EXTRA_VERSION=6
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 17113fcce73ea9d2ab9788665231f63f1e1970d9..2ecc795889df14bd413a46a0b4cea66e76630cd2 100644 (file)
@@ -1530,37 +1530,55 @@ static void folderview_update_node(FolderView *folderview, GtkCTreeNode *node)
                mask = openmask = searchmask;
        }
 
-       if (folder_has_parent_of_type(item, F_QUEUE) && item->total_msgs > 0 &&
-           prefs_common.display_folder_unread) {
-               str = g_strdup_printf("%s (%d%s)", name, item->total_msgs,
-                                     add_unread_mark ? "+" : "");
-               gtk_sctree_set_node_info(ctree, node, str, FOLDER_SPACING,
-                                       xpm, mask, openxpm, openmask,
-                                       FALSE, GTK_CTREE_ROW(node)->expanded);
-               g_free(str);
-       } else if (((item->unread_msgs > 0 || add_unread_mark) &&
-                   prefs_common.display_folder_unread) 
-                  || add_sub_match_mark) {
-
-               if (item->unread_msgs > 0)
-                       str = g_strdup_printf("%s (%d%s%s)", name, item->unread_msgs,
-                                             add_unread_mark || add_sub_match_mark ? "+" : "", 
-                                             item->unreadmarked_msgs > 0 ? "!":"");
-               else
-                       str = g_strdup_printf("%s (+)", name);
-               gtk_sctree_set_node_info(ctree, node, str, FOLDER_SPACING,
-                                       xpm, mask, openxpm, openmask,
-                                       FALSE, GTK_CTREE_ROW(node)->expanded);
-               g_free(str);
+       str = NULL;
+       if (prefs_common.display_folder_unread) {
+               if (folder_has_parent_of_type(item, F_QUEUE)) {
+                       /* only total_msgs matters here */
+                       if (item->total_msgs > 0) {
+                               /* show total number (should be equal to the unread number)
+                                  and signs if any */
+                               str = g_strdup_printf("%s (%d%s%s)",
+                                                       name, item->total_msgs,
+                                                       (add_unread_mark || add_sub_match_mark) ? "+" : "", 
+                                                       (item->unreadmarked_msgs > 0) ? "!" : "");
+                       }
        } else {
-               str = g_strdup_printf("%s%s", name, 
-                                     item->unreadmarked_msgs > 0 ? " (!)":"");
-       
+                       if (prefs_common.display_folder_unread == 1) {
+                               if (item->unread_msgs > 0) {
+                                       /* show unread number and signs */
+                                       str = g_strdup_printf("%s (%d%s%s)",
+                                                               name, item->unread_msgs,
+                                                               (add_unread_mark || add_sub_match_mark) ? "+" : "", 
+                                                               (item->unreadmarked_msgs > 0) ? "!" : "");
+                               }
+                       } else {
+                               if (item->total_msgs > 0) {
+                                       /* show unread number, total number and signs if any */
+                                       str = g_strdup_printf("%s (%d/%d%s%s)",
+                                                               name, item->unread_msgs, item->total_msgs,
+                                                               (add_unread_mark || add_sub_match_mark) ? "+" : "", 
+                                                               (item->unreadmarked_msgs > 0) ? "!" : "");
+                               }
+                       }
+               }
+               if ((str == NULL) &&
+                       (add_unread_mark || add_sub_match_mark || (item->unreadmarked_msgs > 0))) {
+                       /* no unread/total numbers, but at least one sign */
+                       str = g_strdup_printf("%s (%s%s)",
+                                               name,
+                                               (add_unread_mark || add_sub_match_mark) ? "+" : "", 
+                                               (item->unreadmarked_msgs > 0) ? "!" : "");
+               }
+       }
+       if (str == NULL) {
+               /* last fallback, folder name only or with ! sign */
+               str = g_strdup_printf("%s%s",
+                                       name, (item->unreadmarked_msgs > 0) ? " (!)" : "");
+       }
                gtk_sctree_set_node_info(ctree, node, str, FOLDER_SPACING,
                                        xpm, mask, openxpm, openmask,
                                        FALSE, GTK_CTREE_ROW(node)->expanded);
                g_free(str);
-       }
        g_free(name);
 
        if (!folder_item_parent(item)) {
index 73890fd153edf806ed74c60a7d41ab83d3f1864d..f6ba59102ca4fb9efa093851ae48465368226539 100644 (file)
@@ -377,8 +377,8 @@ static PrefParam param[] = {
        {"inline_image", "TRUE", &prefs_common.inline_img, P_BOOL,
         NULL, NULL, NULL},
 
-       {"display_folder_unread_num", "FALSE",
-        &prefs_common.display_folder_unread, P_BOOL,
+       {"display_folder_unread_num", "0",
+        &prefs_common.display_folder_unread, P_INT,
         NULL, NULL, NULL},
        {"newsgroup_abbrev_len", "16",
         &prefs_common.ng_abbrev_len, P_INT,
index 36edddea4acdbfc05621178712c5e9fcc413f87f..3088f71d77b5d69d20f03032bb3e820c5cbff763 100644 (file)
@@ -179,7 +179,7 @@ struct _PrefsCommon
        gboolean inline_img;
 
        gboolean trans_hdr;
-       gboolean display_folder_unread;
+       gint display_folder_unread;
        gint ng_abbrev_len;
 
        gboolean show_searchbar;
index ff4740a4e7934a06d1ce52586af7f5a2d4f04a28..6d68239cf2639a1f88bc8c63f7c5dbdae2e3266a 100644 (file)
@@ -49,7 +49,7 @@ typedef struct _SummariesPage
        GtkWidget *window;
 
        GtkWidget *checkbtn_transhdr;
-       GtkWidget *checkbtn_folder_unread;
+       GtkWidget *optmenu_folder_unread;
        GtkWidget *spinbtn_ng_abbrev_len;
        GtkWidget *checkbtn_useaddrbook;
        GtkWidget *checkbtn_threadsubj;
@@ -304,7 +304,8 @@ static void prefs_summaries_create_widget(PrefsPage *_page, GtkWindow *window,
        
        GtkWidget *vbox1;
        GtkWidget *checkbtn_transhdr;
-       GtkWidget *checkbtn_folder_unread;
+       GtkWidget *hbox0;
+       GtkWidget *optmenu_folder_unread;
        GtkWidget *hbox1;
        GtkWidget *label_ng_abbrev;
        GtkWidget *spinbtn_ng_abbrev_len;
@@ -344,8 +345,24 @@ static void prefs_summaries_create_widget(PrefsPage *_page, GtkWindow *window,
        
        vbox2 = gtkut_get_options_frame(vbox1, &folderview_frame, _("Folder list"));
 
-       PACK_CHECK_BUTTON (vbox2, checkbtn_folder_unread,
-                          _("Display unread number next to folder name"));
+       hbox0 = gtk_hbox_new (FALSE, 8);
+       gtk_widget_show (hbox0);
+       gtk_box_pack_start(GTK_BOX (vbox2), hbox0, FALSE, FALSE, 0);
+
+       label = gtk_label_new (_("Display message number next to folder name"));
+       gtk_widget_show (label);
+       gtk_box_pack_start(GTK_BOX(hbox0), label, FALSE, FALSE, 0);
+
+       optmenu_folder_unread = gtk_option_menu_new ();
+       gtk_widget_show (optmenu_folder_unread);
+       
+       menu = gtk_menu_new ();
+       MENUITEM_ADD (menu, menuitem, _("No"), 0);
+       MENUITEM_ADD (menu, menuitem, _("Unread messages"), 1);
+       MENUITEM_ADD (menu, menuitem, _("Unread and Total messages"), 2);
+
+       gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_folder_unread), menu);
+       gtk_box_pack_start(GTK_BOX(hbox0), optmenu_folder_unread, FALSE, FALSE, 0);
 
        hbox1 = gtk_hbox_new (FALSE, 8);
        gtk_widget_show (hbox1);
@@ -545,7 +562,7 @@ static void prefs_summaries_create_widget(PrefsPage *_page, GtkWindow *window,
        
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_transhdr),
                        prefs_common.trans_hdr);
-       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_folder_unread),
+       gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu_folder_unread),
                        prefs_common.display_folder_unread);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_useaddrbook),
                        prefs_common.use_addr_book);
@@ -573,7 +590,7 @@ static void prefs_summaries_create_widget(PrefsPage *_page, GtkWindow *window,
                        prefs_common.next_unread_msg_dialog);
 
        prefs_summaries->checkbtn_transhdr = checkbtn_transhdr;
-       prefs_summaries->checkbtn_folder_unread = checkbtn_folder_unread;
+       prefs_summaries->optmenu_folder_unread = optmenu_folder_unread;
        prefs_summaries->spinbtn_ng_abbrev_len = spinbtn_ng_abbrev_len;
        prefs_summaries->checkbtn_useaddrbook = checkbtn_useaddrbook;
        prefs_summaries->checkbtn_threadsubj = checkbtn_threadsubj;
@@ -598,8 +615,12 @@ static void prefs_summaries_save(PrefsPage *_page)
 
        prefs_common.trans_hdr = gtk_toggle_button_get_active(
                        GTK_TOGGLE_BUTTON(page->checkbtn_transhdr));
-       prefs_common.display_folder_unread = gtk_toggle_button_get_active(
-                       GTK_TOGGLE_BUTTON(page->checkbtn_folder_unread));
+
+       menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(page->optmenu_folder_unread));
+       menuitem = gtk_menu_get_active(GTK_MENU(menu));
+       prefs_common.display_folder_unread = GPOINTER_TO_INT
+               (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
+
        prefs_common.use_addr_book = gtk_toggle_button_get_active(
                        GTK_TOGGLE_BUTTON(page->checkbtn_useaddrbook));
        prefs_common.thread_by_subject = gtk_toggle_button_get_active(