[evolution] Minor EMailReader cleanup.



commit 7f6f4dfde87156779c89f57b0ebc8150c7acca7e
Author: Matthew Barnes <mbarnes redhat com>
Date:   Fri Mar 26 11:05:06 2010 -0400

    Minor EMailReader cleanup.
    
    Add a load_string() method to EWebView.  Have EMailDisplay override
    load_string() and check that the formatter is not busy before loading
    the string.  Have EMailReader call e_web_view_load_string() directly
    on the EMailDisplay instance, and eliminate update_webview_content().

 mail/e-mail-display.c     |   20 ++++++++++++++++++++
 mail/e-mail-reader.c      |   38 ++++++++++++--------------------------
 widgets/misc/e-web-view.c |   21 +++++++++++++++++----
 widgets/misc/e-web-view.h |    2 ++
 4 files changed, 51 insertions(+), 30 deletions(-)
---
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index 70789c0..9f9569d 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -208,6 +208,22 @@ mail_display_style_set (GtkWidget *widget,
 }
 
 static void
+mail_display_load_string (EWebView *web_view,
+                          const gchar *string)
+{
+	EMailDisplayPrivate *priv;
+
+	priv = E_MAIL_DISPLAY_GET_PRIVATE (web_view);
+	g_return_if_fail (priv->formatter != NULL);
+
+	if (em_format_busy (EM_FORMAT (priv->formatter)))
+		return;
+
+	/* Chain up to parent's load_string() method. */
+	E_WEB_VIEW_CLASS (parent_class)->load_string (web_view, string);
+}
+
+static void
 mail_display_url_requested (GtkHTML *html,
                             const gchar *uri,
                             GtkHTMLStream *stream)
@@ -270,6 +286,7 @@ mail_display_class_init (EMailDisplayClass *class)
 {
 	GObjectClass *object_class;
 	GtkWidgetClass *widget_class;
+	EWebViewClass *web_view_class;
 	GtkHTMLClass *html_class;
 
 	parent_class = g_type_class_peek_parent (class);
@@ -284,6 +301,9 @@ mail_display_class_init (EMailDisplayClass *class)
 	widget_class->realize = mail_display_realize;
 	widget_class->style_set = mail_display_style_set;
 
+	web_view_class = E_WEB_VIEW_CLASS (class);
+	web_view_class->load_string = mail_display_load_string;
+
 	html_class = GTK_HTML_CLASS (class);
 	html_class->url_requested = mail_display_url_requested;
 	html_class->link_clicked = mail_display_link_clicked;
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 6448f5b..d3ffde3 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -1787,28 +1787,6 @@ mail_reader_message_read_cb (EMailReader *reader)
 }
 
 static void
-update_webview_content (EMailReader *reader, const gchar *content)
-{
-	EMFormatHTMLDisplay *html_display;
-	EWebView *web_view;
-
-	g_return_if_fail (reader != NULL);
-	g_return_if_fail (content != NULL);
-
-	html_display = e_mail_reader_get_html_display (reader);
-	g_return_if_fail (html_display != NULL);
-
-	/* skip the progress message when it's formatting something */
-	if (em_format_busy (EM_FORMAT (html_display)))
-		return;
-
-	web_view = E_WEB_VIEW (EM_FORMAT_HTML (html_display)->html);
-	g_return_if_fail (web_view != NULL);
-
-	e_web_view_load_string (web_view, content);
-}
-
-static void
 mail_reader_message_loaded_cb (CamelFolder *folder,
                                const gchar *message_uid,
                                CamelMimeMessage *message,
@@ -1822,6 +1800,7 @@ mail_reader_message_loaded_cb (CamelFolder *folder,
 	EShellBackend *shell_backend;
 	EShellSettings *shell_settings;
 	EShell *shell;
+	EWebView *web_view;
 	EMEvent *event;
 	EMEventTargetMessage *target;
 	const gchar *cursor_uid;
@@ -1839,6 +1818,8 @@ mail_reader_message_loaded_cb (CamelFolder *folder,
 
 	cursor_uid = MESSAGE_LIST (message_list)->cursor_uid;
 
+	web_view = E_WEB_VIEW (EM_FORMAT_HTML (html_display)->html);
+
 	/* If the user picked a different message in the time it took
 	 * to fetch this message, then don't bother rendering it. */
 	if (g_strcmp0 (cursor_uid, message_uid) != 0)
@@ -1897,10 +1878,11 @@ mail_reader_message_loaded_cb (CamelFolder *folder,
 					_("Unable to retrieve message"),
 					ex->desc);
 		} else {
-			string = g_strdup_printf (_("Retrieving message '%s'"), cursor_uid);
+			string = g_strdup_printf (
+				_("Retrieving message '%s'"), cursor_uid);
 		}
 
-		update_webview_content (reader, string);
+		e_web_view_load_string (web_view, string);
 		g_free (string);
 
 		camel_exception_clear (ex);
@@ -1919,6 +1901,7 @@ mail_reader_message_selected_timeout_cb (EMailReader *reader)
 	EMailReaderPrivate *priv;
 	EMFormatHTMLDisplay *html_display;
 	GtkWidget *message_list;
+	EWebView *web_view;
 	CamelFolder *folder;
 	const gchar *cursor_uid;
 	const gchar *format_uid;
@@ -1932,6 +1915,8 @@ mail_reader_message_selected_timeout_cb (EMailReader *reader)
 	cursor_uid = MESSAGE_LIST (message_list)->cursor_uid;
 	format_uid = EM_FORMAT (html_display)->uid;
 
+	web_view = E_WEB_VIEW (EM_FORMAT_HTML (html_display)->html);
+
 	if (MESSAGE_LIST (message_list)->last_sel_single) {
 		GtkWidget *widget;
 		gboolean html_display_visible;
@@ -1954,8 +1939,9 @@ mail_reader_message_selected_timeout_cb (EMailReader *reader)
 			gboolean store_async;
 			MailMsgDispatchFunc disp_func;
 
-			string = g_strdup_printf (_("Retrieving message '%s'"), cursor_uid);
-			update_webview_content (reader, string);
+			string = g_strdup_printf (
+				_("Retrieving message '%s'"), cursor_uid);
+			e_web_view_load_string (web_view, string);
 			g_free (string);
 
 			store_async = folder->parent_store->flags & CAMEL_STORE_ASYNC;
diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c
index c65f9cf..d245437 100644
--- a/widgets/misc/e-web-view.c
+++ b/widgets/misc/e-web-view.c
@@ -857,6 +857,16 @@ web_view_extract_uri (EWebView *web_view,
 }
 
 static void
+web_view_load_string (EWebView *web_view,
+                      const gchar *string)
+{
+	if (string != NULL && *string != '\0')
+		gtk_html_load_from_string (GTK_HTML (web_view), string, -1);
+	else
+		e_web_view_clear (web_view);
+}
+
+static void
 web_view_copy_clipboard (EWebView *web_view)
 {
 	gtk_html_command (GTK_HTML (web_view), "copy");
@@ -1078,6 +1088,7 @@ e_web_view_class_init (EWebViewClass *class)
 	html_class->iframe_created = web_view_iframe_created;
 
 	class->extract_uri = web_view_extract_uri;
+	class->load_string = web_view_load_string;
 	class->copy_clipboard = web_view_copy_clipboard;
 	class->cut_clipboard = web_view_cut_clipboard;
 	class->paste_clipboard = web_view_paste_clipboard;
@@ -1435,12 +1446,14 @@ void
 e_web_view_load_string (EWebView *web_view,
                         const gchar *string)
 {
+	EWebViewClass *class;
+
 	g_return_if_fail (E_IS_WEB_VIEW (web_view));
 
-	if (string != NULL && *string != '\0')
-		gtk_html_load_from_string (GTK_HTML (web_view), string, -1);
-	else
-		e_web_view_clear (web_view);
+	class = E_WEB_VIEW_GET_CLASS (web_view);
+	g_return_if_fail (class->load_string != NULL);
+
+	class->load_string (web_view, string);
 }
 
 gboolean
diff --git a/widgets/misc/e-web-view.h b/widgets/misc/e-web-view.h
index 0fea6eb..7d8eb4c 100644
--- a/widgets/misc/e-web-view.h
+++ b/widgets/misc/e-web-view.h
@@ -69,6 +69,8 @@ struct _EWebViewClass {
 	gchar *		(*extract_uri)		(EWebView *web_view,
 						 GdkEventButton *event,
 						 GtkHTML *frame);
+	void		(*load_string)		(EWebView *web_view,
+						 const gchar *load_string);
 
 	/* Signals */
 	void		(*copy_clipboard)	(EWebView *web_view);



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