From 495030c715bc440ab4a57f7e6f49d8b711953906 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 4 Jan 2001 17:08:40 +0000 Subject: 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 --- mail/folder-browser.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'mail/folder-browser.c') 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), -- cgit