[evolution-patches] 68958, vfolder forgetting last visited message




seems to work, not heavily tested for side-effects.

Index: mail/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.3444.2.26
diff -u -p -r1.3444.2.26 ChangeLog
--- mail/ChangeLog	19 Nov 2004 00:45:55 -0000	1.3444.2.26
+++ mail/ChangeLog	30 Nov 2004 07:23:07 -0000
@@ -1,3 +1,13 @@
+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.
+
 2004-11-10  Not Zed  <NotZed Ximian com>
 
 	** See bug #68794.
Index: mail/em-folder-browser.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-browser.c,v
retrieving revision 1.50
diff -u -p -r1.50 em-folder-browser.c
--- mail/em-folder-browser.c	10 Jul 2004 01:31:04 -0000	1.50
+++ mail/em-folder-browser.c	30 Nov 2004 07:23:07 -0000
@@ -91,7 +91,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;
@@ -100,6 +100,7 @@ struct _EMFolderBrowserPrivate {
 	guint list_built_id;	/* hook onto list-built for delayed 'select first unread' stuff */
 	
 	char *select_uid;
+	guint folder_changed_id;
 };
 
 static void emfb_activate(EMFolderView *emfv, BonoboUIComponent *uic, int state);
@@ -245,6 +246,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);
 }
@@ -824,6 +828,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
@@ -837,9 +866,17 @@ emfb_list_built (MessageList *ml, EMFold
 	
 	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);
@@ -876,7 +913,10 @@ emfb_set_folder(EMFolderView *emfv, Came
 		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_parent->set_folder(emfv, folder, uri);
 	
 	/* This is required since we get activated the first time
@@ -886,6 +926,9 @@ emfb_set_folder(EMFolderView *emfv, Came
 		char *sstate;
 		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"))) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]