[evolution] Prefer EWebView calls over direct GtkHTML calls.



commit 4e19b2d0ec87c894dc518fda98d80854f1360779
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Nov 17 14:49:49 2009 -0500

    Prefer EWebView calls over direct GtkHTML calls.

 mail/e-mail-reader.c      |   51 ++++++++++++++++++++++++--------------------
 widgets/misc/e-web-view.c |   24 +++++++++++++++++++++
 widgets/misc/e-web-view.h |    3 ++
 3 files changed, 55 insertions(+), 23 deletions(-)
---
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 02739f0..3bfa077 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -177,12 +177,12 @@ action_mail_clipboard_copy_cb (GtkAction *action,
                                EMailReader *reader)
 {
 	EMFormatHTMLDisplay *html_display;
-	GtkHTML *html;
+	EWebView *web_view;
 
 	html_display = e_mail_reader_get_html_display (reader);
-	html = EM_FORMAT_HTML (html_display)->html;
+	web_view = E_WEB_VIEW (EM_FORMAT_HTML (html_display)->html);
 
-	gtk_html_copy (html);
+	e_web_view_clipboard_copy (web_view);
 }
 
 static void
@@ -880,18 +880,18 @@ action_mail_select_all_cb (GtkAction *action,
                            EMailReader *reader)
 {
 	EMFormatHTMLDisplay *html_display;
-	GtkHTML *html;
+	EWebView *web_view;
 	const gchar *action_name;
 	gboolean selection_active;
 
 	html_display = e_mail_reader_get_html_display (reader);
-	html = EM_FORMAT_HTML (html_display)->html;
+	web_view = E_WEB_VIEW (EM_FORMAT_HTML (html_display)->html);
 
-	gtk_html_select_all (html);
+	e_web_view_select_all (web_view);
 
 	action_name = "mail-clipboard-copy";
 	action = e_mail_reader_get_action (reader, action_name);
-	selection_active = gtk_html_command (html, "is-selection-active");
+	selection_active = e_web_view_is_selection_active (web_view);
 	gtk_action_set_sensitive (action, selection_active);
 }
 
@@ -992,12 +992,12 @@ action_mail_zoom_100_cb (GtkAction *action,
                          EMailReader *reader)
 {
 	EMFormatHTMLDisplay *html_display;
-	GtkHTML *html;
+	EWebView *web_view;
 
 	html_display = e_mail_reader_get_html_display (reader);
-	html = EM_FORMAT_HTML (html_display)->html;
+	web_view = E_WEB_VIEW (EM_FORMAT_HTML (html_display)->html);
 
-	gtk_html_zoom_reset (html);
+	e_web_view_zoom_100 (web_view);
 }
 
 static void
@@ -1005,12 +1005,12 @@ action_mail_zoom_in_cb (GtkAction *action,
                         EMailReader *reader)
 {
 	EMFormatHTMLDisplay *html_display;
-	GtkHTML *html;
+	EWebView *web_view;
 
 	html_display = e_mail_reader_get_html_display (reader);
-	html = EM_FORMAT_HTML (html_display)->html;
+	web_view = E_WEB_VIEW (EM_FORMAT_HTML (html_display)->html);
 
-	gtk_html_zoom_out (html);
+	e_web_view_zoom_in (web_view);
 }
 
 static void
@@ -1018,12 +1018,12 @@ action_mail_zoom_out_cb (GtkAction *action,
                          EMailReader *reader)
 {
 	EMFormatHTMLDisplay *html_display;
-	GtkHTML *html;
+	EWebView *web_view;
 
 	html_display = e_mail_reader_get_html_display (reader);
-	html = EM_FORMAT_HTML (html_display)->html;
+	web_view = E_WEB_VIEW (EM_FORMAT_HTML (html_display)->html);
 
-	gtk_html_zoom_out (html);
+	e_web_view_zoom_out (web_view);
 }
 
 static void
@@ -1654,12 +1654,14 @@ mail_reader_button_release_event_cb (EMailReader *reader,
                                      GtkHTML *html)
 {
 	GtkAction *action;
+	EWebView *web_view;
 	const gchar *action_name;
 	gboolean selection_active;
 
+	web_view = E_WEB_VIEW (html);
 	action_name = "mail-clipboard-copy";
 	action = e_mail_reader_get_action (reader, action_name);
-	selection_active = gtk_html_command (html, "is-selection-active");
+	selection_active = e_web_view_is_selection_active (web_view);
 	gtk_action_set_sensitive (action, selection_active);
 
 	return FALSE;
@@ -1848,16 +1850,19 @@ mail_reader_message_loaded_cb (CamelFolder *folder,
 			mail_reader_message_read_cb, reader);
 
 	} else if (camel_exception_is_set (ex)) {
-		GtkHTMLStream *stream;
+		EWebView *web_view;
+		gchar *string;
+
+		web_view = E_WEB_VIEW (EM_FORMAT_HTML (html_display)->html);
 
 		/* Display the error inline and clear the exception. */
-		stream = gtk_html_begin (
-			EM_FORMAT_HTML (html_display)->html);
-		gtk_html_stream_printf (
-			stream, "<h2>%s</h2><p>%s</p>",
+		string = g_strdup_printf (
+			"<h2>%s</h2><p>%s</p>",
 			_("Unable to retrieve message"),
 			ex->desc);
-		gtk_html_stream_close (stream, GTK_HTML_STREAM_OK);
+		e_web_view_load_string (web_view, string);
+		g_free (string);
+
 		camel_exception_clear (ex);
 	}
 
diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c
index a71bf82..f52d739 100644
--- a/widgets/misc/e-web-view.c
+++ b/widgets/misc/e-web-view.c
@@ -1458,6 +1458,30 @@ e_web_view_unselect_all (EWebView *web_view)
 	gtk_html_command (GTK_HTML (web_view), "unselect-all");
 }
 
+void
+e_web_view_zoom_100 (EWebView *web_view)
+{
+	g_return_if_fail (E_IS_WEB_VIEW (web_view));
+
+	gtk_html_command (GTK_HTML (web_view), "zoom-reset");
+}
+
+void
+e_web_view_zoom_in (EWebView *web_view)
+{
+	g_return_if_fail (E_IS_WEB_VIEW (web_view));
+
+	gtk_html_command (GTK_HTML (web_view), "zoom-in");
+}
+
+void
+e_web_view_zoom_out (EWebView *web_view)
+{
+	g_return_if_fail (E_IS_WEB_VIEW (web_view));
+
+	gtk_html_command (GTK_HTML (web_view), "zoom-out");
+}
+
 GtkUIManager *
 e_web_view_get_ui_manager (EWebView *web_view)
 {
diff --git a/widgets/misc/e-web-view.h b/widgets/misc/e-web-view.h
index 37c289a..4a30b4b 100644
--- a/widgets/misc/e-web-view.h
+++ b/widgets/misc/e-web-view.h
@@ -124,6 +124,9 @@ gboolean	e_web_view_scroll_forward	(EWebView *web_view);
 gboolean	e_web_view_scroll_backward	(EWebView *web_view);
 void		e_web_view_select_all		(EWebView *web_view);
 void		e_web_view_unselect_all		(EWebView *web_view);
+void		e_web_view_zoom_100		(EWebView *web_view);
+void		e_web_view_zoom_in		(EWebView *web_view);
+void		e_web_view_zoom_out		(EWebView *web_view);
 GtkUIManager *	e_web_view_get_ui_manager	(EWebView *web_view);
 GtkWidget *	e_web_view_get_popup_menu	(EWebView *web_view);
 void		e_web_view_show_popup_menu	(EWebView *web_view,



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