2006-09-04 [colin] 2.4.0cvs142
authorColin Leroy <colin@colino.net>
Mon, 4 Sep 2006 16:52:28 +0000 (16:52 +0000)
committerColin Leroy <colin@colino.net>
Mon, 4 Sep 2006 16:52:28 +0000 (16:52 +0000)
* src/plugins/trayicon/trayicon.c
Fix annoyance when removing a folder with
unread mails: trayicon didn't update

ChangeLog
PATCHSETS
configure.ac
src/plugins/trayicon/trayicon.c

index 717e5c882c411865f7db8ff5cba38801d669518f..b64f73fd987be35b16f6c8d2dd6e4808e8f11d38 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-09-04 [colin]     2.4.0cvs142
+
+       * src/plugins/trayicon/trayicon.c
+               Fix annoyance when removing a folder with 
+               unread mails: trayicon didn't update
+
 2006-09-04 [paul]      2.4.0cvs141
 
        * src/gtk/icon_legend.c
 2006-09-04 [paul]      2.4.0cvs141
 
        * src/gtk/icon_legend.c
index 4ac3b91e4134d3c5db6e8eb5adf981da463337ed..50eb2461ac3710191abb66ae047cc6d6f575639b 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.2.2 -r 1.1.2.3 tools/make.themes.project;  ) > 2.4.0cvs139.patchset
 ( cvs diff -u -r 1.59.2.41 -r 1.59.2.42 src/prefs_filtering.c;  ) > 2.4.0cvs140.patchset
 ( cvs diff -u -r 1.1.2.9 -r 1.1.2.10 src/gtk/icon_legend.c;  ) > 2.4.0cvs141.patchset
 ( cvs diff -u -r 1.1.2.2 -r 1.1.2.3 tools/make.themes.project;  ) > 2.4.0cvs139.patchset
 ( cvs diff -u -r 1.59.2.41 -r 1.59.2.42 src/prefs_filtering.c;  ) > 2.4.0cvs140.patchset
 ( cvs diff -u -r 1.1.2.9 -r 1.1.2.10 src/gtk/icon_legend.c;  ) > 2.4.0cvs141.patchset
+( cvs diff -u -r 1.14.2.37 -r 1.14.2.38 src/plugins/trayicon/trayicon.c;  ) > 2.4.0cvs142.patchset
index 21572ed6ae7096b00641021198d7ffc3b51a75d4..a239389fcf68ef38469e50066fb152fd4f957cce 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=4
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=141
+EXTRA_VERSION=142
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 40958aba04bfce44f4618700bc88a9af75dd401a..65d9eb9371816c2a9f41708b49a0af0dfc6a48ee 100644 (file)
@@ -49,7 +49,8 @@
 #include "unreadmail.xpm"
 #include "nomail.xpm"
 
 #include "unreadmail.xpm"
 #include "nomail.xpm"
 
-static guint hook_id;
+static guint item_hook_id;
+static guint folder_hook_id;
 
 static GdkPixmap *newmail_pixmap;
 static GdkPixmap *newmail_bitmap;
 
 static GdkPixmap *newmail_pixmap;
 static GdkPixmap *newmail_bitmap;
@@ -138,13 +139,19 @@ static void set_trayicon_pixmap(TrayIconType icontype)
        last_pixmap = pixmap;
 }
 
        last_pixmap = pixmap;
 }
 
-static void update(void)
+static void update(FolderItem *removed_item)
 {
        guint new, unread, unreadmarked, marked, total;
        gchar *buf;
        TrayIconType icontype = TRAYICON_NOTHING;
 
        folder_count_total_msgs(&new, &unread, &unreadmarked, &marked, &total);
 {
        guint new, unread, unreadmarked, marked, total;
        gchar *buf;
        TrayIconType icontype = TRAYICON_NOTHING;
 
        folder_count_total_msgs(&new, &unread, &unreadmarked, &marked, &total);
+       if (removed_item) {
+               total -= removed_item->total_msgs;
+               new -= removed_item->new_msgs;
+               unread -= removed_item->unread_msgs;
+       }
+
        buf = g_strdup_printf(_("New %d, Unread: %d, Total: %d"), new, unread, total);
 
         gtk_tooltips_set_tip(tooltips, eventbox, buf, "");
        buf = g_strdup_printf(_("New %d, Unread: %d, Total: %d"), new, unread, total);
 
         gtk_tooltips_set_tip(tooltips, eventbox, buf, "");
@@ -165,7 +172,19 @@ static void update(void)
 
 static gboolean folder_item_update_hook(gpointer source, gpointer data)
 {
 
 static gboolean folder_item_update_hook(gpointer source, gpointer data)
 {
-       update();
+       update(NULL);
+
+       return FALSE;
+}
+
+static gboolean folder_update_hook(gpointer source, gpointer data)
+{
+       FolderUpdateData *hookdata;
+       hookdata = source;
+       if (hookdata->update_flags & FOLDER_REMOVE_FOLDERITEM)
+               update(hookdata->item);
+       else
+               update(NULL);
 
        return FALSE;
 }
 
        return FALSE;
 }
@@ -173,7 +192,7 @@ static gboolean folder_item_update_hook(gpointer source, gpointer data)
 static void resize_cb(GtkWidget *widget, GtkRequisition *req,
                      gpointer user_data)
 {
 static void resize_cb(GtkWidget *widget, GtkRequisition *req,
                      gpointer user_data)
 {
-       update();
+       update(NULL);
 }
 
 static gboolean click_cb(GtkWidget * widget,
 }
 
 static gboolean click_cb(GtkWidget * widget,
@@ -267,7 +286,7 @@ static void create_trayicon()
 
        gtk_widget_show_all(GTK_WIDGET(trayicon));
 
 
        gtk_widget_show_all(GTK_WIDGET(trayicon));
 
-       update();
+       update(NULL);
 }
 
 int plugin_init(gchar **error)
 }
 
 int plugin_init(gchar **error)
@@ -282,12 +301,18 @@ int plugin_init(gchar **error)
                return -1;
        }
 
                return -1;
        }
 
-       hook_id = hooks_register_hook (FOLDER_ITEM_UPDATE_HOOKLIST, folder_item_update_hook, NULL);
-       if (hook_id == -1) {
+       item_hook_id = hooks_register_hook (FOLDER_ITEM_UPDATE_HOOKLIST, folder_item_update_hook, NULL);
+       if (item_hook_id == -1) {
                *error = g_strdup(_("Failed to register folder item update hook"));
                return -1;
        }
 
                *error = g_strdup(_("Failed to register folder item update hook"));
                return -1;
        }
 
+       folder_hook_id = hooks_register_hook (FOLDER_UPDATE_HOOKLIST, folder_update_hook, NULL);
+       if (folder_hook_id == -1) {
+               *error = g_strdup(_("Failed to register folder update hook"));
+               return -1;
+       }
+
        create_trayicon();
 
        return 0;
        create_trayicon();
 
        return 0;
@@ -301,7 +326,8 @@ void plugin_done(void)
        g_signal_handler_disconnect(G_OBJECT(trayicon), destroy_signal_id);
        
        gtk_widget_destroy(GTK_WIDGET(trayicon));
        g_signal_handler_disconnect(G_OBJECT(trayicon), destroy_signal_id);
        
        gtk_widget_destroy(GTK_WIDGET(trayicon));
-       hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_id);
+       hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, item_hook_id);
+       hooks_unregister_hook(FOLDER_UPDATE_HOOKLIST, folder_hook_id);
 
        while (gtk_events_pending()) {
                gtk_main_iteration();
 
        while (gtk_events_pending()) {
                gtk_main_iteration();