diff options
author | Not Zed <NotZed@Ximian.com> | 2004-12-01 11:18:14 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-12-01 11:18:14 +0800 |
commit | ac0a49bc0bbddad44c9e9661229b135b7760d03a (patch) | |
tree | 9f0f7cb035cb9cbd98740a8b21b21f8584ce7386 /mail/em-folder-browser.c | |
parent | 97110c53cd3f87f43a34f640df78bc4ec2201916 (diff) | |
download | gsoc2013-evolution-ac0a49bc0bbddad44c9e9661229b135b7760d03a.tar.gz gsoc2013-evolution-ac0a49bc0bbddad44c9e9661229b135b7760d03a.tar.zst gsoc2013-evolution-ac0a49bc0bbddad44c9e9661229b135b7760d03a.zip |
** See bug #68958.
2004-11-30 Not Zed <NotZed@Ximian.com>
** See bug #68958.
* em-folder-browser.c (emfb_list_built): if the pending selected
uid isn't in the folder (yet), don't clear it, just keep it
around. Hook/unhook folder_changed events.
(emfb_folder_changed, emfb_gui_folder_changed): if a select_uid is
set, and the message is now available, then select it.
svn path=/trunk/; revision=28022
Diffstat (limited to 'mail/em-folder-browser.c')
-rw-r--r-- | mail/em-folder-browser.c | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/mail/em-folder-browser.c b/mail/em-folder-browser.c index 03ce51f33c..141d675e0d 100644 --- a/mail/em-folder-browser.c +++ b/mail/em-folder-browser.c @@ -92,7 +92,7 @@ struct _EMFolderBrowserPrivate { guint search_menu_activated_id; guint search_activated_id; guint search_query_changed_id; - + double default_scroll_position; guint idle_scroll_id; guint list_scrolled_id; @@ -101,6 +101,7 @@ struct _EMFolderBrowserPrivate { guint list_built_id; /* hook onto list-built for delayed 'select first unread' stuff */ char *select_uid; + guint folder_changed_id; EMMenu *menu; /* toplevel menu manager */ }; @@ -248,6 +249,9 @@ emfb_destroy(GtkObject *o) g_source_remove (emfb->priv->idle_scroll_id); emfb->priv->idle_scroll_id = 0; } + + if (emfb->view.folder && emfb->priv->folder_changed_id) + camel_object_remove_event(emfb->view.folder, emfb->priv->folder_changed_id); ((GtkObjectClass *)emfb_parent)->destroy(o); } @@ -836,6 +840,31 @@ scroll_idle_cb (EMFolderBrowser *emfb) return FALSE; } +static void +emfb_gui_folder_changed(CamelFolder *folder, void *dummy, EMFolderBrowser *emfb) +{ + if (emfb->priv->select_uid) { + CamelMessageInfo *mi; + + mi = camel_folder_get_message_info(emfb->view.folder, emfb->priv->select_uid); + if (mi) { + camel_folder_free_message_info(emfb->view.folder, mi); + em_folder_view_set_message(&emfb->view, emfb->priv->select_uid, TRUE); + g_free (emfb->priv->select_uid); + emfb->priv->select_uid = NULL; + } + } + + g_object_unref(emfb); +} + +static void +emfb_folder_changed(CamelFolder *folder, CamelFolderChangeInfo *changes, EMFolderBrowser *emfb) +{ + g_object_ref(emfb); + mail_async_event_emit(emfb->view.async, MAIL_ASYNC_GUI, (MailAsyncFunc)emfb_gui_folder_changed, folder, NULL, emfb); +} + /* TODO: This should probably be handled by message-list, by storing/queueing up the select operation if its busy rebuilding the message-list */ static void @@ -849,9 +878,17 @@ emfb_list_built (MessageList *ml, EMFolderBrowser *emfb) if (emfv->list->cursor_uid == NULL) { if (emfb->priv->select_uid) { - em_folder_view_set_message(emfv, emfb->priv->select_uid, TRUE); - g_free (emfb->priv->select_uid); - emfb->priv->select_uid = NULL; + CamelMessageInfo *mi; + + /* If the message isn't in the folder yet, keep select_uid around, it could be caught by + folder_changed, at some later date */ + mi = camel_folder_get_message_info(emfv->folder, emfb->priv->select_uid); + if (mi) { + camel_folder_free_message_info(emfv->folder, mi); + em_folder_view_set_message(emfv, emfb->priv->select_uid, TRUE); + g_free (emfb->priv->select_uid); + emfb->priv->select_uid = NULL; + } /* change the default to the current position */ position = message_list_get_scrollbar_position (ml); @@ -888,7 +925,12 @@ emfb_set_folder(EMFolderView *emfv, CamelFolder *folder, const char *uri) g_source_remove (emfb->priv->idle_scroll_id); emfb->priv->idle_scroll_id = 0; } - + + if (emfb->view.folder) { + camel_object_remove_event(emfb->view.folder, emfb->priv->folder_changed_id); + emfb->priv->folder_changed_id = 0; + } + emfb_parent->set_folder(emfv, folder, uri); /* This is required since we get activated the first time @@ -899,6 +941,9 @@ emfb_set_folder(EMFolderView *emfv, CamelFolder *folder, const char *uri) int state; GConfClient *gconf = mail_config_get_gconf_client(); + emfb->priv->folder_changed_id = camel_object_hook_event(folder, "folder_changed", + (CamelObjectEventHookFunc)emfb_folder_changed, emfb); + /* FIXME: this mostly copied from activate() */ if ((sstate = camel_object_meta_get(folder, "evolution:show_preview"))) { state = sstate[0] != '0'; |