diff options
author | Dan Winship <danw@src.gnome.org> | 2001-01-05 01:08:40 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2001-01-05 01:08:40 +0800 |
commit | 495030c715bc440ab4a57f7e6f49d8b711953906 (patch) | |
tree | cb0a371388ebd39d6415c0f9d480fa414d36661c /mail/folder-browser.c | |
parent | f9f6c398725a2e0969e23753106edfb896ea5930 (diff) | |
download | gsoc2013-evolution-495030c715bc440ab4a57f7e6f49d8b711953906.tar.gz gsoc2013-evolution-495030c715bc440ab4a57f7e6f49d8b711953906.tar.zst gsoc2013-evolution-495030c715bc440ab4a57f7e6f49d8b711953906.zip |
Connect to "message_changed" on the folder if it's on a remote storage.
* folder-browser.c (got_folder): Connect to "message_changed" on
the folder if it's on a remote storage.
(update_unread_count): Update the folder unread count / highlight
in the shell when the unread message count changes
svn path=/trunk/; revision=7249
Diffstat (limited to 'mail/folder-browser.c')
-rw-r--r-- | mail/folder-browser.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/mail/folder-browser.c b/mail/folder-browser.c index b05b474686..e61d317704 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -107,7 +107,38 @@ folder_browser_class_init (GtkObjectClass *object_class) * } */ -#define EQUAL(a,b) (strcmp (a,b) == 0) +static void +update_unread_count_main(CamelObject *object, gpointer event_data, gpointer user_data) +{ + CamelFolder *folder = (CamelFolder *)object; + FolderBrowser *fb = user_data; + EvolutionStorage *storage; + char *name; + + storage = mail_lookup_storage (folder->parent_store); + + if (fb->unread_count == 0) + name = g_strdup (camel_folder_get_name (folder)); + else + name = g_strdup_printf ("%s (%d)", camel_folder_get_name (folder), fb->unread_count); + + evolution_storage_update_folder_by_uri (storage, fb->uri, name, fb->unread_count != 0); + g_free (name); +} + +static void +update_unread_count(CamelObject *object, gpointer event_data, gpointer user_data) +{ + CamelFolder *folder = (CamelFolder *)object; + FolderBrowser *fb = user_data; + int unread; + + unread = camel_folder_get_unread_message_count (folder); + if (unread == fb->unread_count) + return; + fb->unread_count = unread; + mail_proxy_event (update_unread_count_main, object, event_data, user_data); +} static void got_folder(char *uri, CamelFolder *folder, void *data) @@ -130,6 +161,12 @@ got_folder(char *uri, CamelFolder *folder, void *data) camel_object_ref((CamelObject *)folder); + if (mail_lookup_storage (folder->parent_store)) { + fb->unread_count = -1; + camel_object_hook_event ((CamelObject *)folder, "message_changed", + update_unread_count, fb); + } + gtk_widget_set_sensitive (GTK_WIDGET (fb->search->entry), camel_folder_has_search_capability (folder)); gtk_widget_set_sensitive (GTK_WIDGET (fb->search->option), |