[evolution/kill-bonobo] Bug 592032 - Marks message as read when preview is off



commit cee7273ff2f7a81f84dc3ca099e689e37fe1b63e
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Aug 17 14:14:03 2009 -0400

    Bug 592032 - Marks message as read when preview is off

 mail/e-mail-browser.c               |    8 ++------
 mail/e-mail-reader-utils.c          |    3 +--
 mail/e-mail-reader.c                |   28 +++++++++++++++++++---------
 mail/e-mail-reader.h                |    6 ++----
 modules/mail/e-mail-shell-backend.c |    3 +--
 modules/mail/e-mail-shell-content.c |   14 +++++++++++++-
 6 files changed, 38 insertions(+), 24 deletions(-)
---
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c
index 1dd3fae..fb79932 100644
--- a/mail/e-mail-browser.c
+++ b/mail/e-mail-browser.c
@@ -553,8 +553,7 @@ mail_browser_get_window (EMailReader *reader)
 
 static void
 mail_browser_set_message (EMailReader *reader,
-                          const gchar *uid,
-                          gboolean mark_read)
+                          const gchar *uid)
 {
 	EMailReaderIface *iface;
 	MessageList *message_list;
@@ -563,7 +562,7 @@ mail_browser_set_message (EMailReader *reader,
 
 	/* Chain up to parent's set_message() method. */
 	iface = g_type_default_interface_peek (E_TYPE_MAIL_READER);
-	iface->set_message (reader, uid, mark_read);
+	iface->set_message (reader, uid);
 
 	if (uid == NULL) {
 		e_mail_browser_close (E_MAIL_BROWSER (reader));
@@ -581,9 +580,6 @@ mail_browser_set_message (EMailReader *reader,
 			camel_message_info_subject (info));
 		camel_folder_free_message_info (folder, info);
 	}
-
-	if (mark_read)
-		e_mail_reader_mark_as_read (reader, uid);
 }
 
 static void
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index b9bde5b..ddede8c 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -280,8 +280,7 @@ e_mail_reader_open_selected (EMailReader *reader)
 		browser = e_mail_browser_new (shell_backend);
 		e_mail_reader_set_folder (
 			E_MAIL_READER (browser), folder, folder_uri);
-		e_mail_reader_set_message (
-			E_MAIL_READER (browser), uid, FALSE);
+		e_mail_reader_set_message (E_MAIL_READER (browser), uid);
 		gtk_widget_show (browser);
 	}
 
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 111b1ef..38d5648 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -859,7 +859,7 @@ action_mail_show_source_cb (GtkAction *action,
 	html_display = e_mail_reader_get_html_display (reader);
 	em_format_set_mode (EM_FORMAT (html_display), EM_FORMAT_SOURCE);
 	e_mail_reader_set_folder (reader, folder, folder_uri);
-	e_mail_reader_set_message (reader, uids->pdata[0], FALSE);
+	e_mail_reader_set_message (reader, uids->pdata[0]);
 	gtk_widget_show (browser);
 
 	message_list_free_uids (message_list, uids);
@@ -1787,7 +1787,18 @@ mail_reader_message_selected_timeout_cb (EMailReader *reader)
 	format_uid = EM_FORMAT (html_display)->uid;
 
 	if (message_list->last_sel_single) {
-		if (g_strcmp0 (cursor_uid, format_uid) != 0)
+		GtkWidget *widget;
+		gboolean html_display_visible;
+		gboolean selected_uid_changed;
+
+		/* Decide whether to download the full message now. */
+
+		widget = GTK_WIDGET (EM_FORMAT_HTML (html_display)->html);
+
+		html_display_visible = GTK_WIDGET_MAPPED (widget);
+		selected_uid_changed = g_strcmp0 (cursor_uid, format_uid);
+
+		if (html_display_visible && selected_uid_changed)
 			mail_get_messagex (
 				message_list->folder, cursor_uid,
 				mail_reader_message_loaded_cb,
@@ -1810,8 +1821,9 @@ mail_reader_message_selected_cb (EMailReader *reader,
 	guint source_id;
 	gpointer data;
 
-	/* XXX This is kludgy, but we have no other place to store
-	 *     timeout state information. */
+	/* XXX This is kludgy, but we have no other place to store timeout
+	 * state information.  Addendum: See EAttachmentView for an example
+	 * of storing private data in an interface.  Clunky but works. */
 
 	key = "message-selected-timeout";
 	data = g_object_get_data (G_OBJECT (reader), key);
@@ -1864,8 +1876,7 @@ mail_reader_set_folder (EMailReader *reader,
 
 static void
 mail_reader_set_message (EMailReader *reader,
-                         const gchar *uid,
-                         gboolean mark_read)
+                         const gchar *uid)
 {
 	MessageList *message_list;
 
@@ -2681,8 +2692,7 @@ e_mail_reader_set_folder_uri (EMailReader *reader,
 
 void
 e_mail_reader_set_message (EMailReader *reader,
-                           const gchar *uid,
-                           gboolean mark_read)
+                           const gchar *uid)
 {
 	EMailReaderIface *iface;
 
@@ -2691,7 +2701,7 @@ e_mail_reader_set_message (EMailReader *reader,
 	iface = E_MAIL_READER_GET_IFACE (reader);
 	g_return_if_fail (iface->set_message != NULL);
 
-	iface->set_message (reader, uid, mark_read);
+	iface->set_message (reader, uid);
 }
 
 void
diff --git a/mail/e-mail-reader.h b/mail/e-mail-reader.h
index 0fb557f..6830e4f 100644
--- a/mail/e-mail-reader.h
+++ b/mail/e-mail-reader.h
@@ -90,8 +90,7 @@ struct _EMailReaderIface {
 						 CamelFolder *folder,
 						 const gchar *folder_uri);
 	void		(*set_message)		(EMailReader *reader,
-						 const gchar *uid,
-						 gboolean mark_read);
+						 const gchar *uid);
 
 	/* Signals */
 	void		(*show_search_bar)	(EMailReader *reader);
@@ -118,8 +117,7 @@ void		e_mail_reader_set_folder	(EMailReader *reader,
 void		e_mail_reader_set_folder_uri	(EMailReader *reader,
 						 const gchar *folder_uri);
 void		e_mail_reader_set_message	(EMailReader *reader,
-						 const gchar *uid,
-						 gboolean mark_read);
+						 const gchar *uid);
 void		e_mail_reader_create_charset_menu
 						(EMailReader *reader,
 						 GtkUIManager *ui_manager,
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index 3da217d..80922ce 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -356,8 +356,7 @@ mail_shell_backend_handle_email_uri_cb (gchar *folder_uri,
 		browser = e_mail_browser_new (shell_backend);
 		e_mail_reader_set_folder (
 			E_MAIL_READER (browser), folder, folder_uri);
-		e_mail_reader_set_message (
-			E_MAIL_READER (browser), uid, FALSE);
+		e_mail_reader_set_message (E_MAIL_READER (browser), uid);
 		gtk_widget_show (browser);
 	}
 
diff --git a/modules/mail/e-mail-shell-content.c b/modules/mail/e-mail-shell-content.c
index b801093..0efe1f1 100644
--- a/modules/mail/e-mail-shell-content.c
+++ b/modules/mail/e-mail-shell-content.c
@@ -230,7 +230,7 @@ mail_shell_content_message_list_built_cb (EMailShellContent *mail_shell_content,
 			EMailReader *reader;
 
 			reader = E_MAIL_READER (mail_shell_content);
-			e_mail_reader_set_message (reader, uid, TRUE);
+			e_mail_reader_set_message (reader, uid);
 			camel_folder_free_message_info (folder, info);
 		}
 
@@ -788,6 +788,18 @@ e_mail_shell_content_set_preview_visible (EMailShellContent *mail_shell_content,
 	else
 		gtk_widget_hide (child);
 
+	/* If we're showing the preview, tell EMailReader to reload the
+	 * selected message.  This should force it to download the full
+	 * message if necessary, so we don't get an empty preview. */
+	if (preview_visible) {
+		EMailReader *reader;
+		MessageList *message_list;
+
+		reader = E_MAIL_READER (mail_shell_content);
+		message_list = e_mail_reader_get_message_list (reader);
+		e_mail_reader_set_message (reader, message_list->cursor_uid);
+	}
+
 	mail_shell_content->priv->preview_visible = preview_visible;
 
 	g_object_notify (G_OBJECT (mail_shell_content), "preview-visible");



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