[evolution] WebKit port - port widgets



commit 6bd1c6833a2c51898ac45865767dd01ba66a95c5
Author: Dan VrÃtil <dvratil redhat com>
Date:   Wed Mar 28 18:37:35 2012 +0200

    WebKit port - port widgets

 widgets/misc/Makefile.am             |    9 +-
 widgets/misc/e-attachment-button.c   |   58 +-
 widgets/misc/e-attachment-button.h   |    4 +-
 widgets/misc/e-attachment-store.h    |    1 +
 widgets/misc/e-contact-map-window.c  |    4 +-
 widgets/misc/e-contact-map.c         |    4 +-
 widgets/misc/e-contact-marker.c      |    4 +-
 widgets/misc/e-port-entry.c          |    2 +-
 widgets/misc/e-preview-pane.c        |    4 +-
 widgets/misc/e-search-bar.c          |  129 +--
 widgets/misc/e-search-bar.h          |    3 -
 widgets/misc/e-searching-tokenizer.c | 1210 ------------------
 widgets/misc/e-searching-tokenizer.h |   91 --
 widgets/misc/e-web-view-gtkhtml.c    | 2301 ++++++++++++++++++++++++++++++++++
 widgets/misc/e-web-view-gtkhtml.h    |  173 +++
 widgets/misc/e-web-view.c            | 1402 ++++++++++++++-------
 widgets/misc/e-web-view.h            |   79 +-
 17 files changed, 3560 insertions(+), 1918 deletions(-)
---
diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am
index 1772e7a..ab7efa0 100644
--- a/widgets/misc/Makefile.am
+++ b/widgets/misc/Makefile.am
@@ -49,7 +49,6 @@ widgetsinclude_HEADERS =			\
 	e-preview-pane.h			\
 	e-printable.h				\
 	e-search-bar.h				\
-	e-searching-tokenizer.h			\
 	e-selectable.h				\
 	e-selection-model.h			\
 	e-selection-model-array.h		\
@@ -63,6 +62,7 @@ widgetsinclude_HEADERS =			\
 	e-signature-tree-view.h			\
 	e-url-entry.h				\
 	e-web-view.h				\
+	e-web-view-gtkhtml.h			\
 	e-web-view-preview.h			\
 	ea-calendar-cell.h			\
 	ea-calendar-item.h			\
@@ -76,13 +76,14 @@ libemiscwidgets_la_CPPFLAGS =						\
 	-I$(top_srcdir)/widgets						\
 	-DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\"			\
 	-DEVOLUTION_UIDIR=\""$(uidir)"\"				\
+	-DEVOLUTION_PRIVDATADIR=\""$(privdatadir)"\"    		\
 	-DG_LOG_DOMAIN=__FILE__						\
 	$(EVOLUTION_DATA_SERVER_CFLAGS)					\
 	$(GNOME_PLATFORM_CFLAGS)					\
+	$(GTKHTML_CFLAGS)						\
 	$(CHAMPLAIN_CFLAGS)						\
 	$(GEOCLUE_CFLAGS)						\
-	$(CLUTTER_CFLAGS)						\
-	$(GTKHTML_CFLAGS)
+	$(CLUTTER_CFLAGS)
 
 libemiscwidgets_la_SOURCES =			\
 	$(widgetsinclude_HEADERS)		\
@@ -130,7 +131,6 @@ libemiscwidgets_la_SOURCES =			\
 	e-preview-pane.c			\
 	e-printable.c				\
 	e-search-bar.c				\
-	e-searching-tokenizer.c			\
 	e-selectable.c				\
 	e-selection-model.c			\
 	e-selection-model-array.c		\
@@ -144,6 +144,7 @@ libemiscwidgets_la_SOURCES =			\
 	e-signature-tree-view.c			\
 	e-url-entry.c				\
 	e-web-view.c				\
+	e-web-view-gtkhtml.c			\
 	e-web-view-preview.c			\
 	ea-calendar-cell.c			\
 	ea-calendar-item.c			\
diff --git a/widgets/misc/e-attachment-button.c b/widgets/misc/e-attachment-button.c
index 44bd372..0d46807 100644
--- a/widgets/misc/e-attachment-button.c
+++ b/widgets/misc/e-attachment-button.c
@@ -355,27 +355,6 @@ attachment_button_toggle_button_press_event_cb (EAttachmentButton *button,
 }
 
 static void
-attachment_button_set_view (EAttachmentButton *button,
-                            EAttachmentView *view)
-{
-	GtkWidget *popup_menu;
-
-	g_return_if_fail (button->priv->view == NULL);
-
-	button->priv->view = g_object_ref (view);
-
-	popup_menu = e_attachment_view_get_popup_menu (view);
-
-	g_signal_connect_swapped (
-		popup_menu, "deactivate",
-		G_CALLBACK (attachment_button_menu_deactivate_cb), button);
-
-	/* Keep a reference to the popup menu so we can
-	 * disconnect the signal handler in dispose(). */
-	button->priv->popup_menu = g_object_ref (popup_menu);
-}
-
-static void
 attachment_button_set_property (GObject *object,
                                 guint property_id,
                                 const GValue *value,
@@ -401,7 +380,7 @@ attachment_button_set_property (GObject *object,
 			return;
 
 		case PROP_VIEW:
-			attachment_button_set_view (
+			e_attachment_button_set_view (
 				E_ATTACHMENT_BUTTON (object),
 				g_value_get_object (value));
 			return;
@@ -566,8 +545,7 @@ e_attachment_button_class_init (EAttachmentButtonClass *class)
 			"View",
 			NULL,
 			E_TYPE_ATTACHMENT_VIEW,
-			G_PARAM_READWRITE |
-			G_PARAM_CONSTRUCT_ONLY));
+			G_PARAM_READWRITE));
 }
 
 static void
@@ -701,13 +679,10 @@ e_attachment_button_init (EAttachmentButton *button)
 }
 
 GtkWidget *
-e_attachment_button_new (EAttachmentView *view)
+e_attachment_button_new ()
 {
-	g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), NULL);
-
 	return g_object_new (
-		E_TYPE_ATTACHMENT_BUTTON,
-		"view", view, NULL);
+		E_TYPE_ATTACHMENT_BUTTON, NULL);
 }
 
 EAttachmentView *
@@ -718,6 +693,31 @@ e_attachment_button_get_view (EAttachmentButton *button)
 	return button->priv->view;
 }
 
+void
+e_attachment_button_set_view (EAttachmentButton *button,
+                              EAttachmentView *view)
+{
+	GtkWidget *popup_menu;
+
+	g_return_if_fail (button->priv->view == NULL);
+
+	if (button->priv->view)
+		g_object_unref (button->priv->view);
+	button->priv->view = g_object_ref (view);
+
+	popup_menu = e_attachment_view_get_popup_menu (view);
+
+	g_signal_connect_swapped (
+		popup_menu, "deactivate",
+		G_CALLBACK (attachment_button_menu_deactivate_cb), button);
+
+	/* Keep a reference to the popup menu so we can
+	 * disconnect the signal handler in dispose(). */
+	if (button->priv->popup_menu)
+		g_object_unref (button->priv->popup_menu);
+	button->priv->popup_menu = g_object_ref (popup_menu);
+}
+
 EAttachment *
 e_attachment_button_get_attachment (EAttachmentButton *button)
 {
diff --git a/widgets/misc/e-attachment-button.h b/widgets/misc/e-attachment-button.h
index a27d8ae..b8a0cbb 100644
--- a/widgets/misc/e-attachment-button.h
+++ b/widgets/misc/e-attachment-button.h
@@ -61,9 +61,11 @@ struct _EAttachmentButtonClass {
 };
 
 GType		e_attachment_button_get_type	(void);
-GtkWidget *	e_attachment_button_new	(EAttachmentView *view);
+GtkWidget *	e_attachment_button_new	(void);
 EAttachmentView *
 		e_attachment_button_get_view	(EAttachmentButton *button);
+void		e_attachment_button_set_view	(EAttachmentButton *button,
+						 EAttachmentView *view);
 EAttachment *	e_attachment_button_get_attachment
 						(EAttachmentButton *button);
 void		e_attachment_button_set_attachment
diff --git a/widgets/misc/e-attachment-store.h b/widgets/misc/e-attachment-store.h
index 7309dd9..a963f05 100644
--- a/widgets/misc/e-attachment-store.h
+++ b/widgets/misc/e-attachment-store.h
@@ -130,3 +130,4 @@ gchar **	e_attachment_store_save_finish	(EAttachmentStore *store,
 G_END_DECLS
 
 #endif /* E_ATTACHMENT_STORE_H */
+
diff --git a/widgets/misc/e-contact-map-window.c b/widgets/misc/e-contact-map-window.c
index d80aa17..38fe56c 100644
--- a/widgets/misc/e-contact-map-window.c
+++ b/widgets/misc/e-contact-map-window.c
@@ -40,8 +40,8 @@
 #include <glib-object.h>
 
 #define E_CONTACT_MAP_WINDOW_GET_PRIVATE(obj) \
-	(G_TYPE_INSTANCE_GET_PRIVATE \
-	((obj), E_TYPE_CONTACT_MAP, EContactMapWindowPrivate))
+        (G_TYPE_INSTANCE_GET_PRIVATE \
+        ((obj), E_TYPE_CONTACT_MAP_WINDOW, EContactMapWindowPrivate))
 
 G_DEFINE_TYPE (EContactMapWindow, e_contact_map_window, GTK_TYPE_WINDOW)
 
diff --git a/widgets/misc/e-contact-map.c b/widgets/misc/e-contact-map.c
index b9c2a99..6e20ac1 100644
--- a/widgets/misc/e-contact-map.c
+++ b/widgets/misc/e-contact-map.c
@@ -43,8 +43,8 @@
 #include <math.h>
 
 #define E_CONTACT_MAP_GET_PRIVATE(obj) \
-	(G_TYPE_INSTANCE_GET_PRIVATE \
-	((obj), E_TYPE_CONTACT_MAP, EContactMapPrivate))
+        (G_TYPE_INSTANCE_GET_PRIVATE \
+        ((obj), E_TYPE_CONTACT_MAP, EContactMapPrivate))
 
 G_DEFINE_TYPE (EContactMap, e_contact_map, GTK_CHAMPLAIN_TYPE_EMBED)
 
diff --git a/widgets/misc/e-contact-marker.c b/widgets/misc/e-contact-marker.c
index d7e5ad6..98f1ea1 100644
--- a/widgets/misc/e-contact-marker.c
+++ b/widgets/misc/e-contact-marker.c
@@ -39,8 +39,8 @@
 #include <string.h>
 
 #define E_CONTACT_MARKER_GET_PRIVATE(obj) \
-	(G_TYPE_INSTANCE_GET_PRIVATE \
-	((obj), E_TYPE_CONTACT_MARKER, EContactMarkerPrivate))
+        (G_TYPE_INSTANCE_GET_PRIVATE \
+        ((obj), E_TYPE_CONTACT_MARKER, EContactMarkerPrivate))
 
 G_DEFINE_TYPE (EContactMarker, e_contact_marker, CHAMPLAIN_TYPE_LABEL);
 
diff --git a/widgets/misc/e-port-entry.c b/widgets/misc/e-port-entry.c
index 470249a..cf857b5 100644
--- a/widgets/misc/e-port-entry.c
+++ b/widgets/misc/e-port-entry.c
@@ -128,7 +128,7 @@ port_entry_method_changed (EPortEntry *port_entry)
 	if (valid && port_entry->priv->entries != NULL) {
 		for (ii = 0; port_entry->priv->entries[ii].port > 0 && (!have_ssl || !have_nossl); ii++) {
 			/* Use only the first SSL/no-SSL port as a default in the list
-			   and skip the others */
+			 * and skip the others */
 			if (port_entry->priv->entries[ii].is_ssl) {
 				if (have_ssl)
 					continue;
diff --git a/widgets/misc/e-preview-pane.c b/widgets/misc/e-preview-pane.c
index a94b313..92644ec 100644
--- a/widgets/misc/e-preview-pane.c
+++ b/widgets/misc/e-preview-pane.c
@@ -157,14 +157,12 @@ preview_pane_constructed (GObject *object)
 	/* EAlertBar controls its own visibility. */
 
 	widget = gtk_scrolled_window_new (NULL, NULL);
-	gtk_scrolled_window_set_policy (
-		GTK_SCROLLED_WINDOW (widget),
-		GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
 	gtk_scrolled_window_set_shadow_type (
 		GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
 	gtk_box_pack_start (GTK_BOX (object), widget, TRUE, TRUE, 0);
 	gtk_container_add (GTK_CONTAINER (widget), priv->web_view);
 	gtk_widget_show (widget);
+	gtk_widget_show (priv->web_view);
 
 	widget = e_search_bar_new (E_WEB_VIEW (priv->web_view));
 	gtk_box_pack_start (GTK_BOX (object), widget, FALSE, FALSE, 0);
diff --git a/widgets/misc/e-search-bar.c b/widgets/misc/e-search-bar.c
index eafb1b6..9ed0c2d 100644
--- a/widgets/misc/e-search-bar.c
+++ b/widgets/misc/e-search-bar.c
@@ -27,7 +27,6 @@
 
 #include <glib/gi18n.h>
 #include <gdk/gdkkeysyms.h>
-#include <gtkhtml/gtkhtml-search.h>
 
 #define E_SEARCH_BAR_GET_PRIVATE(obj) \
 	(G_TYPE_INSTANCE_GET_PRIVATE \
@@ -41,7 +40,6 @@ struct _ESearchBarPrivate {
 	GtkWidget *wrapped_prev_box;
 	GtkWidget *matches_label;
 
-	ESearchingTokenizer *tokenizer;
 	gchar *active_search;
 
 	guint rerun_search : 1;
@@ -69,46 +67,33 @@ G_DEFINE_TYPE (
 	GTK_TYPE_HBOX)
 
 static void
-search_bar_update_matches (ESearchBar *search_bar)
+search_bar_update_matches (ESearchBar *search_bar,
+                           guint matches)
 {
-	ESearchingTokenizer *tokenizer;
 	GtkWidget *matches_label;
-	gint matches;
 	gchar *text;
 
 	search_bar->priv->rerun_search = FALSE;
-
-	tokenizer = e_search_bar_get_tokenizer (search_bar);
 	matches_label = search_bar->priv->matches_label;
 
-	matches = e_searching_tokenizer_match_count (tokenizer);
-	text = g_strdup_printf (_("Matches: %d"), matches);
-
+	text = g_strdup_printf (_("Matches: %u"), matches);
 	gtk_label_set_text (GTK_LABEL (matches_label), text);
 	gtk_widget_show (matches_label);
-
 	g_free (text);
 }
 
 static void
-search_bar_update_tokenizer (ESearchBar *search_bar)
+search_bar_update_highlights (ESearchBar *search_bar)
 {
-	ESearchingTokenizer *tokenizer;
-	gboolean case_sensitive;
-	gchar *active_search;
+	EWebView *web_view;
+	gboolean visible;
 
-	tokenizer = e_search_bar_get_tokenizer (search_bar);
-	case_sensitive = e_search_bar_get_case_sensitive (search_bar);
+	web_view = e_search_bar_get_web_view (search_bar);
 
-	if (gtk_widget_get_visible (GTK_WIDGET (search_bar)))
-		active_search = search_bar->priv->active_search;
-	else
-		active_search = NULL;
+	visible = gtk_widget_get_visible (GTK_WIDGET (search_bar));
 
-	e_searching_tokenizer_set_primary_case_sensitivity (
-		tokenizer, case_sensitive);
-	e_searching_tokenizer_set_primary_search_string (
-		tokenizer, active_search);
+	webkit_web_view_set_highlight_text_matches (
+		WEBKIT_WEB_VIEW (web_view), visible);
 
 	e_search_bar_changed (search_bar);
 }
@@ -122,6 +107,7 @@ search_bar_find (ESearchBar *search_bar,
 	gboolean case_sensitive;
 	gboolean new_search;
 	gboolean wrapped = FALSE;
+	gboolean success;
 	gchar *text;
 
 	web_view = e_search_bar_get_web_view (search_bar);
@@ -138,44 +124,30 @@ search_bar_find (ESearchBar *search_bar,
 		(search_bar->priv->active_search == NULL) ||
 		(g_strcmp0 (text, search_bar->priv->active_search) != 0);
 
-	/* XXX On a new search, the HTMLEngine's search state gets
-	 *     destroyed when we redraw the message with highlighted
-	 *     matches (EMHTMLStream's write() method triggers this,
-	 *     but it's really GtkHtml's fault).  That's why the first
-	 *     match isn't selected automatically.  It also causes
-	 *     gtk_html_engine_search_next() to return FALSE, which we
-	 *     assume to mean the search wrapped.
-	 *
-	 *     So to avoid mistakenly thinking the search wrapped when
-	 *     it hasn't, we have to trap the first button click after a
-	 *     search and re-run the search to recreate the HTMLEngine's
-	 *     search state, so that gtk_html_engine_search_next() will
-	 *     succeed. */
 	if (new_search) {
-		g_free (search_bar->priv->active_search);
-		search_bar->priv->active_search = text;
-		search_bar->priv->rerun_search = TRUE;
-		search_bar_update_tokenizer (search_bar);
-	} else if (search_bar->priv->rerun_search) {
-		gtk_html_engine_search (
-			GTK_HTML (web_view),
-			search_bar->priv->active_search,
-			case_sensitive, search_forward, FALSE);
-		search_bar->priv->rerun_search = FALSE;
-		g_free (text);
-	} else {
-		gtk_html_engine_search_set_forward (
-			GTK_HTML (web_view), search_forward);
-		if (!gtk_html_engine_search_next (GTK_HTML (web_view)))
-			wrapped = TRUE;
-		g_free (text);
+		guint matches;
+
+		webkit_web_view_unmark_text_matches (
+			WEBKIT_WEB_VIEW (web_view));
+		matches = webkit_web_view_mark_text_matches (
+			WEBKIT_WEB_VIEW (web_view),
+			text, case_sensitive, 0);
+		webkit_web_view_set_highlight_text_matches (
+			WEBKIT_WEB_VIEW (web_view), TRUE);
+		search_bar_update_matches (search_bar, matches);
 	}
 
-	if (new_search || wrapped)
-		gtk_html_engine_search (
-			GTK_HTML (web_view),
-			search_bar->priv->active_search,
-			case_sensitive, search_forward, FALSE);
+	success = webkit_web_view_search_text (
+		WEBKIT_WEB_VIEW (web_view),
+		text, case_sensitive, search_forward, FALSE);
+
+	if (!success)
+		wrapped = webkit_web_view_search_text (
+			WEBKIT_WEB_VIEW (web_view),
+			text, case_sensitive, search_forward, TRUE);
+
+	g_free (search_bar->priv->active_search);
+	search_bar->priv->active_search = text;
 
 	g_object_notify (G_OBJECT (search_bar), "active-search");
 
@@ -239,16 +211,10 @@ static void
 search_bar_set_web_view (ESearchBar *search_bar,
                          EWebView *web_view)
 {
-	GtkHTML *html;
-	ESearchingTokenizer *tokenizer;
-
+	g_return_if_fail (E_IS_WEB_VIEW (web_view));
 	g_return_if_fail (search_bar->priv->web_view == NULL);
 
 	search_bar->priv->web_view = g_object_ref (web_view);
-
-	html = GTK_HTML (web_view);
-	tokenizer = e_search_bar_get_tokenizer (search_bar);
-	gtk_html_set_tokenizer (html, HTML_TOKENIZER (tokenizer));
 }
 
 static void
@@ -352,11 +318,6 @@ search_bar_dispose (GObject *object)
 		priv->matches_label = NULL;
 	}
 
-	if (priv->tokenizer != NULL) {
-		g_object_unref (priv->tokenizer);
-		priv->tokenizer = NULL;
-	}
-
 	/* Chain up to parent's dispose() method. */
 	G_OBJECT_CLASS (e_search_bar_parent_class)->dispose (object);
 }
@@ -403,7 +364,7 @@ search_bar_show (GtkWidget *widget)
 
 	gtk_widget_grab_focus (search_bar->priv->entry);
 
-	search_bar_update_tokenizer (search_bar);
+	search_bar_update_highlights (search_bar);
 }
 
 static void
@@ -416,7 +377,7 @@ search_bar_hide (GtkWidget *widget)
 	/* Chain up to parent's hide() method. */
 	GTK_WIDGET_CLASS (e_search_bar_parent_class)->hide (widget);
 
-	search_bar_update_tokenizer (search_bar);
+	search_bar_update_highlights (search_bar);
 }
 
 static gboolean
@@ -438,6 +399,8 @@ search_bar_key_press_event (GtkWidget *widget,
 static void
 search_bar_clear (ESearchBar *search_bar)
 {
+	WebKitWebView *web_view;
+
 	g_free (search_bar->priv->active_search);
 	search_bar->priv->active_search = NULL;
 
@@ -447,7 +410,10 @@ search_bar_clear (ESearchBar *search_bar)
 	gtk_widget_hide (search_bar->priv->wrapped_prev_box);
 	gtk_widget_hide (search_bar->priv->matches_label);
 
-	search_bar_update_tokenizer (search_bar);
+	search_bar_update_highlights (search_bar);
+
+	web_view = WEBKIT_WEB_VIEW (search_bar->priv->web_view);
+	webkit_web_view_unmark_text_matches (web_view);
 
 	g_object_notify (G_OBJECT (search_bar), "active-search");
 }
@@ -542,11 +508,6 @@ e_search_bar_init (ESearchBar *search_bar)
 	GtkWidget *container;
 
 	search_bar->priv = E_SEARCH_BAR_GET_PRIVATE (search_bar);
-	search_bar->priv->tokenizer = e_searching_tokenizer_new ();
-
-	g_signal_connect_swapped (
-		search_bar->priv->tokenizer, "match",
-		G_CALLBACK (search_bar_update_matches), search_bar);
 
 	gtk_box_set_spacing (GTK_BOX (search_bar), 12);
 
@@ -743,14 +704,6 @@ e_search_bar_get_web_view (ESearchBar *search_bar)
 	return search_bar->priv->web_view;
 }
 
-ESearchingTokenizer *
-e_search_bar_get_tokenizer (ESearchBar *search_bar)
-{
-	g_return_val_if_fail (E_IS_SEARCH_BAR (search_bar), NULL);
-
-	return search_bar->priv->tokenizer;
-}
-
 gboolean
 e_search_bar_get_active_search (ESearchBar *search_bar)
 {
diff --git a/widgets/misc/e-search-bar.h b/widgets/misc/e-search-bar.h
index 87e1023..4df8c97 100644
--- a/widgets/misc/e-search-bar.h
+++ b/widgets/misc/e-search-bar.h
@@ -23,7 +23,6 @@
 #define E_SEARCH_BAR_H
 
 #include <gtk/gtk.h>
-#include <misc/e-searching-tokenizer.h>
 #include <misc/e-web-view.h>
 
 /* Standard GObject macros */
@@ -69,8 +68,6 @@ GtkWidget *	e_search_bar_new		(EWebView *web_view);
 void		e_search_bar_clear		(ESearchBar *search_bar);
 void		e_search_bar_changed		(ESearchBar *search_bar);
 EWebView *	e_search_bar_get_web_view	(ESearchBar *search_bar);
-ESearchingTokenizer *
-		e_search_bar_get_tokenizer	(ESearchBar *search_bar);
 gboolean	e_search_bar_get_active_search
 						(ESearchBar *search_bar);
 gboolean	e_search_bar_get_case_sensitive
diff --git a/widgets/misc/e-web-view-gtkhtml.c b/widgets/misc/e-web-view-gtkhtml.c
new file mode 100644
index 0000000..be8b1c5
--- /dev/null
+++ b/widgets/misc/e-web-view-gtkhtml.c
@@ -0,0 +1,2301 @@
+/*
+ * e-web-view-gtkhtml.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "e-web-view-gtkhtml.h"
+
+#include <string.h>
+#include <glib/gi18n-lib.h>
+
+#include <camel/camel.h>
+
+#include <e-util/e-util.h>
+#include <e-util/e-plugin-ui.h>
+#include <libevolution-utils/e-alert-dialog.h>
+#include <libevolution-utils/e-alert-sink.h>
+
+#include <libebackend/e-extensible.h>
+
+#include "e-popup-action.h"
+#include "e-selectable.h"
+
+#define E_WEB_VIEW_GTKHTML_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE \
+	((obj), E_TYPE_WEB_VIEW_GTKHTML, EWebViewGtkHTMLPrivate))
+
+typedef struct _EWebViewGtkHTMLRequest EWebViewGtkHTMLRequest;
+
+struct _EWebViewGtkHTMLPrivate {
+	GList *requests;
+	GtkUIManager *ui_manager;
+	gchar *selected_uri;
+	GdkPixbufAnimation *cursor_image;
+
+	GtkAction *open_proxy;
+	GtkAction *print_proxy;
+	GtkAction *save_as_proxy;
+
+	GtkTargetList *copy_target_list;
+	GtkTargetList *paste_target_list;
+
+	/* Lockdown Options */
+	guint disable_printing     : 1;
+	guint disable_save_to_disk : 1;
+};
+
+struct _EWebViewGtkHTMLRequest {
+	GFile *file;
+	EWebViewGtkHTML *web_view;
+	GCancellable *cancellable;
+	GInputStream *input_stream;
+	GtkHTMLStream *output_stream;
+	gchar buffer[4096];
+};
+
+enum {
+	PROP_0,
+	PROP_ANIMATE,
+	PROP_CARET_MODE,
+	PROP_COPY_TARGET_LIST,
+	PROP_DISABLE_PRINTING,
+	PROP_DISABLE_SAVE_TO_DISK,
+	PROP_EDITABLE,
+	PROP_INLINE_SPELLING,
+	PROP_MAGIC_LINKS,
+	PROP_MAGIC_SMILEYS,
+	PROP_OPEN_PROXY,
+	PROP_PASTE_TARGET_LIST,
+	PROP_PRINT_PROXY,
+	PROP_SAVE_AS_PROXY,
+	PROP_SELECTED_URI,
+	PROP_CURSOR_IMAGE
+};
+
+enum {
+	COPY_CLIPBOARD,
+	CUT_CLIPBOARD,
+	PASTE_CLIPBOARD,
+	POPUP_EVENT,
+	STATUS_MESSAGE,
+	STOP_LOADING,
+	UPDATE_ACTIONS,
+	PROCESS_MAILTO,
+	LAST_SIGNAL
+};
+
+static gpointer parent_class;
+static guint signals[LAST_SIGNAL];
+
+static const gchar *ui =
+"<ui>"
+"  <popup name='context'>"
+"    <menuitem action='copy-clipboard'/>"
+"    <separator/>"
+"    <placeholder name='custom-actions-1'>"
+"      <menuitem action='open'/>"
+"      <menuitem action='save-as'/>"
+"      <menuitem action='http-open'/>"
+"      <menuitem action='send-message'/>"
+"      <menuitem action='print'/>"
+"    </placeholder>"
+"    <placeholder name='custom-actions-2'>"
+"      <menuitem action='uri-copy'/>"
+"      <menuitem action='mailto-copy'/>"
+"      <menuitem action='image-copy'/>"
+"    </placeholder>"
+"    <placeholder name='custom-actions-3'/>"
+"    <separator/>"
+"    <menuitem action='select-all'/>"
+"  </popup>"
+"</ui>";
+
+/* Forward Declarations */
+static void e_web_view_gtkhtml_alert_sink_init (EAlertSinkInterface *interface);
+static void e_web_view_gtkhtml_selectable_init (ESelectableInterface *interface);
+
+G_DEFINE_TYPE_WITH_CODE (
+	EWebViewGtkHTML,
+	e_web_view_gtkhtml,
+	GTK_TYPE_HTML,
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_EXTENSIBLE, NULL)
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_ALERT_SINK,
+		e_web_view_gtkhtml_alert_sink_init)
+	G_IMPLEMENT_INTERFACE (
+		E_TYPE_SELECTABLE,
+		e_web_view_gtkhtml_selectable_init))
+
+static EWebViewGtkHTMLRequest *
+web_view_gtkhtml_request_new (EWebViewGtkHTML *web_view,
+                      const gchar *uri,
+                      GtkHTMLStream *stream)
+{
+	EWebViewGtkHTMLRequest *request;
+	GList *list;
+
+	request = g_slice_new (EWebViewGtkHTMLRequest);
+
+	/* Try to detect file paths posing as URIs. */
+	if (*uri == '/')
+		request->file = g_file_new_for_path (uri);
+	else
+		request->file = g_file_new_for_uri (uri);
+
+	request->web_view = g_object_ref (web_view);
+	request->cancellable = g_cancellable_new ();
+	request->input_stream = NULL;
+	request->output_stream = stream;
+
+	list = request->web_view->priv->requests;
+	list = g_list_prepend (list, request);
+	request->web_view->priv->requests = list;
+
+	return request;
+}
+
+static void
+web_view_gtkhtml_request_free (EWebViewGtkHTMLRequest *request)
+{
+	GList *list;
+
+	list = request->web_view->priv->requests;
+	list = g_list_remove (list, request);
+	request->web_view->priv->requests = list;
+
+	g_object_unref (request->file);
+	g_object_unref (request->web_view);
+	g_object_unref (request->cancellable);
+
+	if (request->input_stream != NULL)
+		g_object_unref (request->input_stream);
+
+	g_slice_free (EWebViewGtkHTMLRequest, request);
+}
+
+static void
+web_view_gtkhtml_request_cancel (EWebViewGtkHTMLRequest *request)
+{
+	g_cancellable_cancel (request->cancellable);
+}
+
+static gboolean
+web_view_gtkhtml_request_check_for_error (EWebViewGtkHTMLRequest *request,
+                                  GError *error)
+{
+	GtkHTML *html;
+	GtkHTMLStream *stream;
+
+	if (error == NULL)
+		return FALSE;
+
+	if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) {
+		/* use this error, but do not close the stream */
+		g_error_free (error);
+		return TRUE;
+	}
+
+	/* XXX Should we log errors that are not cancellations? */
+
+	html = GTK_HTML (request->web_view);
+	stream = request->output_stream;
+
+	gtk_html_end (html, stream, GTK_HTML_STREAM_ERROR);
+	web_view_gtkhtml_request_free (request);
+	g_error_free (error);
+
+	return TRUE;
+}
+
+static void
+web_view_gtkhtml_request_stream_read_cb (GInputStream *input_stream,
+                                 GAsyncResult *result,
+                                 EWebViewGtkHTMLRequest *request)
+{
+	gssize bytes_read;
+	GError *error = NULL;
+
+	bytes_read = g_input_stream_read_finish (input_stream, result, &error);
+
+	if (web_view_gtkhtml_request_check_for_error (request, error))
+		return;
+
+	if (bytes_read == 0) {
+		gtk_html_end (
+			GTK_HTML (request->web_view),
+			request->output_stream, GTK_HTML_STREAM_OK);
+		web_view_gtkhtml_request_free (request);
+		return;
+	}
+
+	gtk_html_write (
+		GTK_HTML (request->web_view),
+		request->output_stream, request->buffer, bytes_read);
+
+	g_input_stream_read_async (
+		request->input_stream, request->buffer,
+		sizeof (request->buffer), G_PRIORITY_DEFAULT,
+		request->cancellable, (GAsyncReadyCallback)
+		web_view_gtkhtml_request_stream_read_cb, request);
+}
+
+static void
+web_view_gtkhtml_request_read_cb (GFile *file,
+                          GAsyncResult *result,
+                          EWebViewGtkHTMLRequest *request)
+{
+	GFileInputStream *input_stream;
+	GError *error = NULL;
+
+	/* Input stream might be NULL, so don't use cast macro. */
+	input_stream = g_file_read_finish (file, result, &error);
+	request->input_stream = (GInputStream *) input_stream;
+
+	if (web_view_gtkhtml_request_check_for_error (request, error))
+		return;
+
+	g_input_stream_read_async (
+		request->input_stream, request->buffer,
+		sizeof (request->buffer), G_PRIORITY_DEFAULT,
+		request->cancellable, (GAsyncReadyCallback)
+		web_view_gtkhtml_request_stream_read_cb, request);
+}
+
+static void
+action_copy_clipboard_cb (GtkAction *action,
+                          EWebViewGtkHTML *web_view)
+{
+	e_web_view_gtkhtml_copy_clipboard (web_view);
+}
+
+static void
+action_http_open_cb (GtkAction *action,
+                     EWebViewGtkHTML *web_view)
+{
+	const gchar *uri;
+	gpointer parent;
+
+	parent = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
+	parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
+
+	uri = e_web_view_gtkhtml_get_selected_uri (web_view);
+	g_return_if_fail (uri != NULL);
+
+	e_show_uri (parent, uri);
+}
+
+static void
+action_mailto_copy_cb (GtkAction *action,
+                       EWebViewGtkHTML *web_view)
+{
+	CamelURL *curl;
+	CamelInternetAddress *inet_addr;
+	GtkClipboard *clipboard;
+	const gchar *uri;
+	gchar *text;
+
+	uri = e_web_view_gtkhtml_get_selected_uri (web_view);
+	g_return_if_fail (uri != NULL);
+
+	/* This should work because we checked it in update_actions(). */
+	curl = camel_url_new (uri, NULL);
+	g_return_if_fail (curl != NULL);
+
+	inet_addr = camel_internet_address_new ();
+	camel_address_decode (CAMEL_ADDRESS (inet_addr), curl->path);
+	text = camel_address_format (CAMEL_ADDRESS (inet_addr));
+	if (text == NULL || *text == '\0')
+		text = g_strdup (uri + strlen ("mailto:";));
+
+	g_object_unref (inet_addr);
+	camel_url_free (curl);
+
+	clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
+	gtk_clipboard_set_text (clipboard, text, -1);
+	gtk_clipboard_store (clipboard);
+
+	clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+	gtk_clipboard_set_text (clipboard, text, -1);
+	gtk_clipboard_store (clipboard);
+
+	g_free (text);
+}
+
+static void
+action_select_all_cb (GtkAction *action,
+                      EWebViewGtkHTML *web_view)
+{
+	e_web_view_gtkhtml_select_all (web_view);
+}
+
+static void
+action_send_message_cb (GtkAction *action,
+                        EWebViewGtkHTML *web_view)
+{
+	const gchar *uri;
+	gpointer parent;
+	gboolean handled;
+
+	parent = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
+	parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
+
+	uri = e_web_view_gtkhtml_get_selected_uri (web_view);
+	g_return_if_fail (uri != NULL);
+
+	handled = FALSE;
+	g_signal_emit (web_view, signals[PROCESS_MAILTO], 0, uri, &handled);
+
+	if (!handled)
+		e_show_uri (parent, uri);
+}
+
+static void
+action_uri_copy_cb (GtkAction *action,
+                    EWebViewGtkHTML *web_view)
+{
+	GtkClipboard *clipboard;
+	const gchar *uri;
+
+	clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+	uri = e_web_view_gtkhtml_get_selected_uri (web_view);
+	g_return_if_fail (uri != NULL);
+
+	gtk_clipboard_set_text (clipboard, uri, -1);
+	gtk_clipboard_store (clipboard);
+}
+
+static void
+action_image_copy_cb (GtkAction *action,
+                    EWebViewGtkHTML *web_view)
+{
+	GtkClipboard *clipboard;
+	GdkPixbufAnimation *animation;
+	GdkPixbuf *pixbuf;
+
+	clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+	animation = e_web_view_gtkhtml_get_cursor_image (web_view);
+	g_return_if_fail (animation != NULL);
+
+	pixbuf = gdk_pixbuf_animation_get_static_image (animation);
+	if (!pixbuf)
+		return;
+
+	gtk_clipboard_set_image (clipboard, pixbuf);
+	gtk_clipboard_store (clipboard);
+}
+
+static GtkActionEntry uri_entries[] = {
+
+	{ "uri-copy",
+	  GTK_STOCK_COPY,
+	  N_("_Copy Link Location"),
+	  NULL,
+	  N_("Copy the link to the clipboard"),
+	  G_CALLBACK (action_uri_copy_cb) }
+};
+
+static GtkActionEntry http_entries[] = {
+
+	{ "http-open",
+	  "emblem-web",
+	  N_("_Open Link in Browser"),
+	  NULL,
+	  N_("Open the link in a web browser"),
+	  G_CALLBACK (action_http_open_cb) }
+};
+
+static GtkActionEntry mailto_entries[] = {
+
+	{ "mailto-copy",
+	  GTK_STOCK_COPY,
+	  N_("_Copy Email Address"),
+	  NULL,
+	  N_("Copy the email address to the clipboard"),
+	  G_CALLBACK (action_mailto_copy_cb) },
+
+	{ "send-message",
+	  "mail-message-new",
+	  N_("_Send New Message To..."),
+	  NULL,
+	  N_("Send a mail message to this address"),
+	  G_CALLBACK (action_send_message_cb) }
+};
+
+static GtkActionEntry image_entries[] = {
+
+	{ "image-copy",
+	  GTK_STOCK_COPY,
+	  N_("_Copy Image"),
+	  NULL,
+	  N_("Copy the image to the clipboard"),
+	  G_CALLBACK (action_image_copy_cb) }
+};
+
+static GtkActionEntry selection_entries[] = {
+
+	{ "copy-clipboard",
+	  GTK_STOCK_COPY,
+	  NULL,
+	  NULL,
+	  N_("Copy the selection"),
+	  G_CALLBACK (action_copy_clipboard_cb) },
+};
+
+static GtkActionEntry standard_entries[] = {
+
+	{ "select-all",
+	  GTK_STOCK_SELECT_ALL,
+	  NULL,
+	  NULL,
+	  N_("Select all text and images"),
+	  G_CALLBACK (action_select_all_cb) }
+};
+
+static gboolean
+web_view_gtkhtml_button_press_event_cb (EWebViewGtkHTML *web_view,
+                                GdkEventButton *event,
+                                GtkHTML *frame)
+{
+	gboolean event_handled = FALSE;
+	gchar *uri = NULL;
+
+	if (event) {
+		GdkPixbufAnimation *anim;
+
+		if (frame == NULL)
+			frame = GTK_HTML (web_view);
+
+		anim = gtk_html_get_image_at (frame, event->x, event->y);
+		e_web_view_gtkhtml_set_cursor_image (web_view, anim);
+		if (anim != NULL)
+			g_object_unref (anim);
+	}
+
+	if (event != NULL && event->button != 3)
+		return FALSE;
+
+	/* Only extract a URI if no selection is active.  Selected text
+	 * implies the user is more likely to want to copy the selection
+	 * to the clipboard than open a link within the selection. */
+	if (!e_web_view_gtkhtml_is_selection_active (web_view))
+		uri = e_web_view_gtkhtml_extract_uri (web_view, event, frame);
+
+	if (uri != NULL && g_str_has_prefix (uri, "##")) {
+		g_free (uri);
+		return FALSE;
+	}
+
+	g_signal_emit (
+		web_view, signals[POPUP_EVENT], 0,
+		event, uri, &event_handled);
+
+	g_free (uri);
+
+	return event_handled;
+}
+
+static void
+web_view_gtkhtml_menu_item_select_cb (EWebViewGtkHTML *web_view,
+                              GtkWidget *widget)
+{
+	GtkAction *action;
+	GtkActivatable *activatable;
+	const gchar *tooltip;
+
+	activatable = GTK_ACTIVATABLE (widget);
+	action = gtk_activatable_get_related_action (activatable);
+	tooltip = gtk_action_get_tooltip (action);
+
+	if (tooltip == NULL)
+		return;
+
+	e_web_view_gtkhtml_status_message (web_view, tooltip);
+}
+
+static void
+web_view_gtkhtml_menu_item_deselect_cb (EWebViewGtkHTML *web_view)
+{
+	e_web_view_gtkhtml_status_message (web_view, NULL);
+}
+
+static void
+web_view_gtkhtml_connect_proxy_cb (EWebViewGtkHTML *web_view,
+                           GtkAction *action,
+                           GtkWidget *proxy)
+{
+	if (!GTK_IS_MENU_ITEM (proxy))
+		return;
+
+	g_signal_connect_swapped (
+		proxy, "select",
+		G_CALLBACK (web_view_gtkhtml_menu_item_select_cb), web_view);
+
+	g_signal_connect_swapped (
+		proxy, "deselect",
+		G_CALLBACK (web_view_gtkhtml_menu_item_deselect_cb), web_view);
+}
+
+static void
+web_view_gtkhtml_set_property (GObject *object,
+                       guint property_id,
+                       const GValue *value,
+                       GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_ANIMATE:
+			e_web_view_gtkhtml_set_animate (
+				E_WEB_VIEW_GTKHTML (object),
+				g_value_get_boolean (value));
+			return;
+
+		case PROP_CARET_MODE:
+			e_web_view_gtkhtml_set_caret_mode (
+				E_WEB_VIEW_GTKHTML (object),
+				g_value_get_boolean (value));
+			return;
+
+		case PROP_DISABLE_PRINTING:
+			e_web_view_gtkhtml_set_disable_printing (
+				E_WEB_VIEW_GTKHTML (object),
+				g_value_get_boolean (value));
+			return;
+
+		case PROP_DISABLE_SAVE_TO_DISK:
+			e_web_view_gtkhtml_set_disable_save_to_disk (
+				E_WEB_VIEW_GTKHTML (object),
+				g_value_get_boolean (value));
+			return;
+
+		case PROP_EDITABLE:
+			e_web_view_gtkhtml_set_editable (
+				E_WEB_VIEW_GTKHTML (object),
+				g_value_get_boolean (value));
+			return;
+
+		case PROP_INLINE_SPELLING:
+			e_web_view_gtkhtml_set_inline_spelling (
+				E_WEB_VIEW_GTKHTML (object),
+				g_value_get_boolean (value));
+			return;
+
+		case PROP_MAGIC_LINKS:
+			e_web_view_gtkhtml_set_magic_links (
+				E_WEB_VIEW_GTKHTML (object),
+				g_value_get_boolean (value));
+			return;
+
+		case PROP_MAGIC_SMILEYS:
+			e_web_view_gtkhtml_set_magic_smileys (
+				E_WEB_VIEW_GTKHTML (object),
+				g_value_get_boolean (value));
+			return;
+
+		case PROP_OPEN_PROXY:
+			e_web_view_gtkhtml_set_open_proxy (
+				E_WEB_VIEW_GTKHTML (object),
+				g_value_get_object (value));
+			return;
+
+		case PROP_PRINT_PROXY:
+			e_web_view_gtkhtml_set_print_proxy (
+				E_WEB_VIEW_GTKHTML (object),
+				g_value_get_object (value));
+			return;
+
+		case PROP_SAVE_AS_PROXY:
+			e_web_view_gtkhtml_set_save_as_proxy (
+				E_WEB_VIEW_GTKHTML (object),
+				g_value_get_object (value));
+			return;
+
+		case PROP_SELECTED_URI:
+			e_web_view_gtkhtml_set_selected_uri (
+				E_WEB_VIEW_GTKHTML (object),
+				g_value_get_string (value));
+			return;
+		case PROP_CURSOR_IMAGE:
+			e_web_view_gtkhtml_set_cursor_image (
+				E_WEB_VIEW_GTKHTML (object),
+				g_value_get_object (value));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+web_view_gtkhtml_get_property (GObject *object,
+                       guint property_id,
+                       GValue *value,
+                       GParamSpec *pspec)
+{
+	switch (property_id) {
+		case PROP_ANIMATE:
+			g_value_set_boolean (
+				value, e_web_view_gtkhtml_get_animate (
+				E_WEB_VIEW_GTKHTML (object)));
+			return;
+
+		case PROP_CARET_MODE:
+			g_value_set_boolean (
+				value, e_web_view_gtkhtml_get_caret_mode (
+				E_WEB_VIEW_GTKHTML (object)));
+			return;
+
+		case PROP_COPY_TARGET_LIST:
+			g_value_set_boxed (
+				value, e_web_view_gtkhtml_get_copy_target_list (
+				E_WEB_VIEW_GTKHTML (object)));
+			return;
+
+		case PROP_DISABLE_PRINTING:
+			g_value_set_boolean (
+				value, e_web_view_gtkhtml_get_disable_printing (
+				E_WEB_VIEW_GTKHTML (object)));
+			return;
+
+		case PROP_DISABLE_SAVE_TO_DISK:
+			g_value_set_boolean (
+				value, e_web_view_gtkhtml_get_disable_save_to_disk (
+				E_WEB_VIEW_GTKHTML (object)));
+			return;
+
+		case PROP_EDITABLE:
+			g_value_set_boolean (
+				value, e_web_view_gtkhtml_get_editable (
+				E_WEB_VIEW_GTKHTML (object)));
+			return;
+
+		case PROP_INLINE_SPELLING:
+			g_value_set_boolean (
+				value, e_web_view_gtkhtml_get_inline_spelling (
+				E_WEB_VIEW_GTKHTML (object)));
+			return;
+
+		case PROP_MAGIC_LINKS:
+			g_value_set_boolean (
+				value, e_web_view_gtkhtml_get_magic_links (
+				E_WEB_VIEW_GTKHTML (object)));
+			return;
+
+		case PROP_MAGIC_SMILEYS:
+			g_value_set_boolean (
+				value, e_web_view_gtkhtml_get_magic_smileys (
+				E_WEB_VIEW_GTKHTML (object)));
+			return;
+
+		case PROP_OPEN_PROXY:
+			g_value_set_object (
+				value, e_web_view_gtkhtml_get_open_proxy (
+				E_WEB_VIEW_GTKHTML (object)));
+			return;
+
+		case PROP_PASTE_TARGET_LIST:
+			g_value_set_boxed (
+				value, e_web_view_gtkhtml_get_paste_target_list (
+				E_WEB_VIEW_GTKHTML (object)));
+			return;
+
+		case PROP_PRINT_PROXY:
+			g_value_set_object (
+				value, e_web_view_gtkhtml_get_print_proxy (
+				E_WEB_VIEW_GTKHTML (object)));
+			return;
+
+		case PROP_SAVE_AS_PROXY:
+			g_value_set_object (
+				value, e_web_view_gtkhtml_get_save_as_proxy (
+				E_WEB_VIEW_GTKHTML (object)));
+			return;
+
+		case PROP_SELECTED_URI:
+			g_value_set_string (
+				value, e_web_view_gtkhtml_get_selected_uri (
+				E_WEB_VIEW_GTKHTML (object)));
+			return;
+
+		case PROP_CURSOR_IMAGE:
+			g_value_set_object (
+				value, e_web_view_gtkhtml_get_cursor_image (
+				E_WEB_VIEW_GTKHTML (object)));
+			return;
+	}
+
+	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+web_view_gtkhtml_dispose (GObject *object)
+{
+	EWebViewGtkHTMLPrivate *priv;
+
+	priv = E_WEB_VIEW_GTKHTML_GET_PRIVATE (object);
+
+	if (priv->ui_manager != NULL) {
+		g_object_unref (priv->ui_manager);
+		priv->ui_manager = NULL;
+	}
+
+	if (priv->open_proxy != NULL) {
+		g_object_unref (priv->open_proxy);
+		priv->open_proxy = NULL;
+	}
+
+	if (priv->print_proxy != NULL) {
+		g_object_unref (priv->print_proxy);
+		priv->print_proxy = NULL;
+	}
+
+	if (priv->save_as_proxy != NULL) {
+		g_object_unref (priv->save_as_proxy);
+		priv->save_as_proxy = NULL;
+	}
+
+	if (priv->copy_target_list != NULL) {
+		gtk_target_list_unref (priv->copy_target_list);
+		priv->copy_target_list = NULL;
+	}
+
+	if (priv->paste_target_list != NULL) {
+		gtk_target_list_unref (priv->paste_target_list);
+		priv->paste_target_list = NULL;
+	}
+
+	if (priv->cursor_image != NULL) {
+		g_object_unref (priv->cursor_image);
+		priv->cursor_image = NULL;
+	}
+
+	/* Chain up to parent's dispose() method. */
+	G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
+web_view_gtkhtml_finalize (GObject *object)
+{
+	EWebViewGtkHTMLPrivate *priv;
+
+	priv = E_WEB_VIEW_GTKHTML_GET_PRIVATE (object);
+
+	/* All URI requests should be complete or cancelled by now. */
+	if (priv->requests != NULL)
+		g_warning ("Finalizing EWebViewGtkHTML with active URI requests");
+
+	g_free (priv->selected_uri);
+
+	/* Chain up to parent's finalize() method. */
+	G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+web_view_gtkhtml_constructed (GObject *object)
+{
+#ifndef G_OS_WIN32
+	GSettings *settings;
+
+	settings = g_settings_new ("org.gnome.desktop.lockdown");
+
+	g_settings_bind (
+		settings, "disable-printing",
+		object, "disable-printing",
+		G_SETTINGS_BIND_GET);
+
+	g_settings_bind (
+		settings, "disable-save-to-disk",
+		object, "disable-save-to-disk",
+		G_SETTINGS_BIND_GET);
+
+	g_object_unref (settings);
+#endif
+
+	/* Chain up to parent's constructed() method. */
+	G_OBJECT_CLASS (parent_class)->constructed (object);
+}
+
+static gboolean
+web_view_gtkhtml_button_press_event (GtkWidget *widget,
+                             GdkEventButton *event)
+{
+	GtkWidgetClass *widget_class;
+	EWebViewGtkHTML *web_view;
+
+	web_view = E_WEB_VIEW_GTKHTML (widget);
+
+	if (web_view_gtkhtml_button_press_event_cb (web_view, event, NULL))
+		return TRUE;
+
+	/* Chain up to parent's button_press_event() method. */
+	widget_class = GTK_WIDGET_CLASS (parent_class);
+	return widget_class->button_press_event (widget, event);
+}
+
+static gboolean
+web_view_gtkhtml_scroll_event (GtkWidget *widget,
+                       GdkEventScroll *event)
+{
+	if (event->state & GDK_CONTROL_MASK) {
+		switch (event->direction) {
+			case GDK_SCROLL_UP:
+				gtk_html_zoom_in (GTK_HTML (widget));
+				return TRUE;
+			case GDK_SCROLL_DOWN:
+				gtk_html_zoom_out (GTK_HTML (widget));
+				return TRUE;
+			default:
+				break;
+		}
+	}
+
+	return FALSE;
+}
+
+static void
+web_view_gtkhtml_url_requested (GtkHTML *html,
+                        const gchar *uri,
+                        GtkHTMLStream *stream)
+{
+	EWebViewGtkHTMLRequest *request;
+
+	request = web_view_gtkhtml_request_new (E_WEB_VIEW_GTKHTML (html), uri, stream);
+
+	g_file_read_async (
+		request->file, G_PRIORITY_DEFAULT,
+		request->cancellable, (GAsyncReadyCallback)
+		web_view_gtkhtml_request_read_cb, request);
+}
+
+static void
+web_view_gtkhtml_gtkhtml_link_clicked (GtkHTML *html,
+                               const gchar *uri)
+{
+	EWebViewGtkHTMLClass *class;
+	EWebViewGtkHTML *web_view;
+
+	web_view = E_WEB_VIEW_GTKHTML (html);
+
+	class = E_WEB_VIEW_GTKHTML_GET_CLASS (web_view);
+	g_return_if_fail (class->link_clicked != NULL);
+
+	class->link_clicked (web_view, uri);
+}
+
+static void
+web_view_gtkhtml_on_url (GtkHTML *html,
+                 const gchar *uri)
+{
+	EWebViewGtkHTMLClass *class;
+	EWebViewGtkHTML *web_view;
+
+	web_view = E_WEB_VIEW_GTKHTML (html);
+
+	class = E_WEB_VIEW_GTKHTML_GET_CLASS (web_view);
+	g_return_if_fail (class->hovering_over_link != NULL);
+
+	/* XXX WebKit would supply a title here. */
+	class->hovering_over_link (web_view, NULL, uri);
+}
+
+static void
+web_view_gtkhtml_iframe_created (GtkHTML *html,
+                         GtkHTML *iframe)
+{
+	g_signal_connect_swapped (
+		iframe, "button-press-event",
+		G_CALLBACK (web_view_gtkhtml_button_press_event_cb), html);
+}
+
+static gchar *
+web_view_gtkhtml_extract_uri (EWebViewGtkHTML *web_view,
+                      GdkEventButton *event,
+                      GtkHTML *html)
+{
+	gchar *uri;
+
+	if (event != NULL)
+		uri = gtk_html_get_url_at (html, event->x, event->y);
+	else
+		uri = gtk_html_get_cursor_url (html);
+
+	return uri;
+}
+
+static void
+web_view_gtkhtml_hovering_over_link (EWebViewGtkHTML *web_view,
+                             const gchar *title,
+                             const gchar *uri)
+{
+	CamelInternetAddress *address;
+	CamelURL *curl;
+	const gchar *format = NULL;
+	gchar *message = NULL;
+	gchar *who;
+
+	if (uri == NULL || *uri == '\0')
+		goto exit;
+
+	if (g_str_has_prefix (uri, "mailto:";))
+		format = _("Click to mail %s");
+	else if (g_str_has_prefix (uri, "callto:"))
+		format = _("Click to call %s");
+	else if (g_str_has_prefix (uri, "h323:"))
+		format = _("Click to call %s");
+	else if (g_str_has_prefix (uri, "sip:"))
+		format = _("Click to call %s");
+	else if (g_str_has_prefix (uri, "##"))
+		message = g_strdup (_("Click to hide/unhide addresses"));
+	else
+		message = g_strdup_printf (_("Click to open %s"), uri);
+
+	if (format == NULL)
+		goto exit;
+
+	/* XXX Use something other than Camel here.  Surely
+	 *     there's other APIs around that can do this. */
+	curl = camel_url_new (uri, NULL);
+	address = camel_internet_address_new ();
+	camel_address_decode (CAMEL_ADDRESS (address), curl->path);
+	who = camel_address_format (CAMEL_ADDRESS (address));
+	g_object_unref (address);
+	camel_url_free (curl);
+
+	if (who == NULL)
+		who = g_strdup (strchr (uri, ':') + 1);
+
+	message = g_strdup_printf (format, who);
+
+	g_free (who);
+
+exit:
+	e_web_view_gtkhtml_status_message (web_view, message);
+
+	g_free (message);
+}
+
+static void
+web_view_gtkhtml_link_clicked (EWebViewGtkHTML *web_view,
+                       const gchar *uri)
+{
+	gpointer parent;
+
+	parent = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
+	parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
+
+	e_show_uri (parent, uri);
+}
+
+static void
+web_view_gtkhtml_load_string (EWebViewGtkHTML *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_gtkhtml_clear (web_view);
+}
+
+static void
+web_view_gtkhtml_copy_clipboard (EWebViewGtkHTML *web_view)
+{
+	gtk_html_command (GTK_HTML (web_view), "copy");
+}
+
+static void
+web_view_gtkhtml_cut_clipboard (EWebViewGtkHTML *web_view)
+{
+	if (e_web_view_gtkhtml_get_editable (web_view))
+		gtk_html_command (GTK_HTML (web_view), "cut");
+}
+
+static void
+web_view_gtkhtml_paste_clipboard (EWebViewGtkHTML *web_view)
+{
+	if (e_web_view_gtkhtml_get_editable (web_view))
+		gtk_html_command (GTK_HTML (web_view), "paste");
+}
+
+static gboolean
+web_view_gtkhtml_popup_event (EWebViewGtkHTML *web_view,
+                      GdkEventButton *event,
+                      const gchar *uri)
+{
+	e_web_view_gtkhtml_set_selected_uri (web_view, uri);
+	e_web_view_gtkhtml_show_popup_menu (web_view, event, NULL, NULL);
+
+	return TRUE;
+}
+
+static void
+web_view_gtkhtml_stop_loading (EWebViewGtkHTML *web_view)
+{
+	g_list_foreach (
+		web_view->priv->requests, (GFunc)
+		web_view_gtkhtml_request_cancel, NULL);
+
+	gtk_html_stop (GTK_HTML (web_view));
+}
+
+static void
+web_view_gtkhtml_update_actions (EWebViewGtkHTML *web_view)
+{
+	GtkActionGroup *action_group;
+	gboolean have_selection;
+	gboolean scheme_is_http = FALSE;
+	gboolean scheme_is_mailto = FALSE;
+	gboolean uri_is_valid = FALSE;
+	gboolean has_cursor_image;
+	gboolean visible;
+	const gchar *group_name;
+	const gchar *uri;
+
+	uri = e_web_view_gtkhtml_get_selected_uri (web_view);
+	have_selection = e_web_view_gtkhtml_is_selection_active (web_view);
+	has_cursor_image = e_web_view_gtkhtml_get_cursor_image (web_view) != NULL;
+
+	/* Parse the URI early so we know if the actions will work. */
+	if (uri != NULL) {
+		CamelURL *curl;
+
+		curl = camel_url_new (uri, NULL);
+		uri_is_valid = (curl != NULL);
+		camel_url_free (curl);
+
+		scheme_is_http =
+			(g_ascii_strncasecmp (uri, "http:", 5) == 0) ||
+			(g_ascii_strncasecmp (uri, "https:", 6) == 0);
+
+		scheme_is_mailto =
+			(g_ascii_strncasecmp (uri, "mailto:";, 7) == 0);
+	}
+
+	/* Allow copying the URI even if it's malformed. */
+	group_name = "uri";
+	visible = (uri != NULL) && !scheme_is_mailto;
+	action_group = e_web_view_gtkhtml_get_action_group (web_view, group_name);
+	gtk_action_group_set_visible (action_group, visible);
+
+	group_name = "http";
+	visible = uri_is_valid && scheme_is_http;
+	action_group = e_web_view_gtkhtml_get_action_group (web_view, group_name);
+	gtk_action_group_set_visible (action_group, visible);
+
+	group_name = "mailto";
+	visible = uri_is_valid && scheme_is_mailto;
+	action_group = e_web_view_gtkhtml_get_action_group (web_view, group_name);
+	gtk_action_group_set_visible (action_group, visible);
+
+	group_name = "image";
+	visible = has_cursor_image;
+	action_group = e_web_view_gtkhtml_get_action_group (web_view, group_name);
+	gtk_action_group_set_visible (action_group, visible);
+
+	group_name = "selection";
+	visible = have_selection;
+	action_group = e_web_view_gtkhtml_get_action_group (web_view, group_name);
+	gtk_action_group_set_visible (action_group, visible);
+
+	group_name = "standard";
+	visible = (uri == NULL);
+	action_group = e_web_view_gtkhtml_get_action_group (web_view, group_name);
+	gtk_action_group_set_visible (action_group, visible);
+
+	group_name = "lockdown-printing";
+	visible = (uri == NULL) && !web_view->priv->disable_printing;
+	action_group = e_web_view_gtkhtml_get_action_group (web_view, group_name);
+	gtk_action_group_set_visible (action_group, visible);
+
+	group_name = "lockdown-save-to-disk";
+	visible = (uri == NULL) && !web_view->priv->disable_save_to_disk;
+	action_group = e_web_view_gtkhtml_get_action_group (web_view, group_name);
+	gtk_action_group_set_visible (action_group, visible);
+}
+
+static void
+web_view_gtkhtml_submit_alert (EAlertSink *alert_sink,
+                       EAlert *alert)
+{
+	GtkIconInfo *icon_info;
+	EWebViewGtkHTML *web_view;
+	GtkWidget *dialog;
+	GString *buffer;
+	const gchar *icon_name = NULL;
+	const gchar *filename;
+	gpointer parent;
+	gchar *icon_uri;
+	gint size = 0;
+	GError *error = NULL;
+
+	web_view = E_WEB_VIEW_GTKHTML (alert_sink);
+
+	parent = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
+	parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
+
+	/* We use equivalent named icons instead of stock IDs,
+	 * since it's easier to get the filename of the icon. */
+	switch (e_alert_get_message_type (alert)) {
+		case GTK_MESSAGE_INFO:
+			icon_name = "dialog-information";
+			break;
+
+		case GTK_MESSAGE_WARNING:
+			icon_name = "dialog-warning";
+			break;
+
+		case GTK_MESSAGE_ERROR:
+			icon_name = "dialog-error";
+			break;
+
+		default:
+			dialog = e_alert_dialog_new (parent, alert);
+			gtk_dialog_run (GTK_DIALOG (dialog));
+			gtk_widget_destroy (dialog);
+			return;
+	}
+
+	gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &size, NULL);
+
+	icon_info = gtk_icon_theme_lookup_icon (
+		gtk_icon_theme_get_default (),
+		icon_name, size, GTK_ICON_LOOKUP_NO_SVG);
+	g_return_if_fail (icon_info != NULL);
+
+	filename = gtk_icon_info_get_filename (icon_info);
+	icon_uri = g_filename_to_uri (filename, NULL, &error);
+
+	if (error != NULL) {
+		g_warning ("%s", error->message);
+		g_clear_error (&error);
+	}
+
+	buffer = g_string_sized_new (512);
+
+	g_string_append (
+		buffer,
+		"<html>"
+		"<head>"
+		"<meta http-equiv=\"content-type\""
+		" content=\"text/html; charset=utf-8\">"
+		"</head>"
+		"<body>");
+
+	g_string_append (
+		buffer,
+		"<table bgcolor='#000000' width='100%'"
+		" cellpadding='1' cellspacing='0'>"
+		"<tr>"
+		"<td>"
+		"<table bgcolor='#dddddd' width='100%' cellpadding='6'>"
+		"<tr>");
+
+	g_string_append_printf (
+		buffer,
+		"<tr>"
+		"<td valign='top'>"
+		"<img src='%s'/>"
+		"</td>"
+		"<td align='left' width='100%%'>"
+		"<h3>%s</h3>"
+		"%s"
+		"</td>"
+		"</tr>",
+		icon_uri,
+		e_alert_get_primary_text (alert),
+		e_alert_get_secondary_text (alert));
+
+	g_string_append (
+		buffer,
+		"</table>"
+		"</td>"
+		"</tr>"
+		"</table>"
+		"</body>"
+		"</html>");
+
+	e_web_view_gtkhtml_load_string (web_view, buffer->str);
+
+	g_string_free (buffer, TRUE);
+
+	gtk_icon_info_free (icon_info);
+	g_free (icon_uri);
+}
+
+static void
+web_view_gtkhtml_selectable_update_actions (ESelectable *selectable,
+                                    EFocusTracker *focus_tracker,
+                                    GdkAtom *clipboard_targets,
+                                    gint n_clipboard_targets)
+{
+	EWebViewGtkHTML *web_view;
+	GtkAction *action;
+	/*GtkTargetList *target_list;*/
+	gboolean can_paste = FALSE;
+	gboolean editable;
+	gboolean have_selection;
+	gboolean sensitive;
+	const gchar *tooltip;
+	/*gint ii;*/
+
+	web_view = E_WEB_VIEW_GTKHTML (selectable);
+	editable = e_web_view_gtkhtml_get_editable (web_view);
+	have_selection = e_web_view_gtkhtml_is_selection_active (web_view);
+
+	/* XXX GtkHtml implements its own clipboard instead of using
+	 *     GDK_SELECTION_CLIPBOARD, so we don't get notifications
+	 *     when the clipboard contents change.  The logic below
+	 *     is what we would do if GtkHtml worked properly.
+	 *     Instead, we need to keep the Paste action sensitive so
+	 *     its accelerator overrides GtkHtml's key binding. */
+#if 0
+	target_list = e_selectable_get_paste_target_list (selectable);
+	for (ii = 0; ii < n_clipboard_targets && !can_paste; ii++)
+		can_paste = gtk_target_list_find (
+			target_list, clipboard_targets[ii], NULL);
+#endif
+	can_paste = TRUE;
+
+	action = e_focus_tracker_get_cut_clipboard_action (focus_tracker);
+	sensitive = editable && have_selection;
+	tooltip = _("Cut the selection");
+	gtk_action_set_sensitive (action, sensitive);
+	gtk_action_set_tooltip (action, tooltip);
+
+	action = e_focus_tracker_get_copy_clipboard_action (focus_tracker);
+	sensitive = have_selection;
+	tooltip = _("Copy the selection");
+	gtk_action_set_sensitive (action, sensitive);
+	gtk_action_set_tooltip (action, tooltip);
+
+	action = e_focus_tracker_get_paste_clipboard_action (focus_tracker);
+	sensitive = editable && can_paste;
+	tooltip = _("Paste the clipboard");
+	gtk_action_set_sensitive (action, sensitive);
+	gtk_action_set_tooltip (action, tooltip);
+
+	action = e_focus_tracker_get_select_all_action (focus_tracker);
+	sensitive = TRUE;
+	tooltip = _("Select all text and images");
+	gtk_action_set_sensitive (action, sensitive);
+	gtk_action_set_tooltip (action, tooltip);
+}
+
+static void
+web_view_gtkhtml_selectable_cut_clipboard (ESelectable *selectable)
+{
+	e_web_view_gtkhtml_cut_clipboard (E_WEB_VIEW_GTKHTML (selectable));
+}
+
+static void
+web_view_gtkhtml_selectable_copy_clipboard (ESelectable *selectable)
+{
+	e_web_view_gtkhtml_copy_clipboard (E_WEB_VIEW_GTKHTML (selectable));
+}
+
+static void
+web_view_gtkhtml_selectable_paste_clipboard (ESelectable *selectable)
+{
+	e_web_view_gtkhtml_paste_clipboard (E_WEB_VIEW_GTKHTML (selectable));
+}
+
+static void
+web_view_gtkhtml_selectable_select_all (ESelectable *selectable)
+{
+	e_web_view_gtkhtml_select_all (E_WEB_VIEW_GTKHTML (selectable));
+}
+
+static void
+e_web_view_gtkhtml_class_init (EWebViewGtkHTMLClass *class)
+{
+	GObjectClass *object_class;
+	GtkWidgetClass *widget_class;
+	GtkHTMLClass *html_class;
+
+	parent_class = g_type_class_peek_parent (class);
+	g_type_class_add_private (class, sizeof (EWebViewGtkHTMLPrivate));
+
+	object_class = G_OBJECT_CLASS (class);
+	object_class->set_property = web_view_gtkhtml_set_property;
+	object_class->get_property = web_view_gtkhtml_get_property;
+	object_class->dispose = web_view_gtkhtml_dispose;
+	object_class->finalize = web_view_gtkhtml_finalize;
+	object_class->constructed = web_view_gtkhtml_constructed;
+
+	widget_class = GTK_WIDGET_CLASS (class);
+	widget_class->button_press_event = web_view_gtkhtml_button_press_event;
+	widget_class->scroll_event = web_view_gtkhtml_scroll_event;
+
+	html_class = GTK_HTML_CLASS (class);
+	html_class->url_requested = web_view_gtkhtml_url_requested;
+	html_class->link_clicked = web_view_gtkhtml_gtkhtml_link_clicked;
+	html_class->on_url = web_view_gtkhtml_on_url;
+	html_class->iframe_created = web_view_gtkhtml_iframe_created;
+
+	class->extract_uri = web_view_gtkhtml_extract_uri;
+	class->hovering_over_link = web_view_gtkhtml_hovering_over_link;
+	class->link_clicked = web_view_gtkhtml_link_clicked;
+	class->load_string = web_view_gtkhtml_load_string;
+	class->copy_clipboard = web_view_gtkhtml_copy_clipboard;
+	class->cut_clipboard = web_view_gtkhtml_cut_clipboard;
+	class->paste_clipboard = web_view_gtkhtml_paste_clipboard;
+	class->popup_event = web_view_gtkhtml_popup_event;
+	class->stop_loading = web_view_gtkhtml_stop_loading;
+	class->update_actions = web_view_gtkhtml_update_actions;
+
+	g_object_class_install_property (
+		object_class,
+		PROP_ANIMATE,
+		g_param_spec_boolean (
+			"animate",
+			"Animate Images",
+			NULL,
+			FALSE,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_CARET_MODE,
+		g_param_spec_boolean (
+			"caret-mode",
+			"Caret Mode",
+			NULL,
+			FALSE,
+			G_PARAM_READWRITE));
+
+	/* Inherited from ESelectableInterface */
+	g_object_class_override_property (
+		object_class,
+		PROP_COPY_TARGET_LIST,
+		"copy-target-list");
+
+	g_object_class_install_property (
+		object_class,
+		PROP_DISABLE_PRINTING,
+		g_param_spec_boolean (
+			"disable-printing",
+			"Disable Printing",
+			NULL,
+			FALSE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_DISABLE_SAVE_TO_DISK,
+		g_param_spec_boolean (
+			"disable-save-to-disk",
+			"Disable Save-to-Disk",
+			NULL,
+			FALSE,
+			G_PARAM_READWRITE |
+			G_PARAM_CONSTRUCT));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_EDITABLE,
+		g_param_spec_boolean (
+			"editable",
+			"Editable",
+			NULL,
+			FALSE,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_INLINE_SPELLING,
+		g_param_spec_boolean (
+			"inline-spelling",
+			"Inline Spelling",
+			NULL,
+			FALSE,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_MAGIC_LINKS,
+		g_param_spec_boolean (
+			"magic-links",
+			"Magic Links",
+			NULL,
+			FALSE,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_MAGIC_SMILEYS,
+		g_param_spec_boolean (
+			"magic-smileys",
+			"Magic Smileys",
+			NULL,
+			FALSE,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_OPEN_PROXY,
+		g_param_spec_object (
+			"open-proxy",
+			"Open Proxy",
+			NULL,
+			GTK_TYPE_ACTION,
+			G_PARAM_READWRITE));
+
+	/* Inherited from ESelectableInterface */
+	g_object_class_override_property (
+		object_class,
+		PROP_PASTE_TARGET_LIST,
+		"paste-target-list");
+
+	g_object_class_install_property (
+		object_class,
+		PROP_PRINT_PROXY,
+		g_param_spec_object (
+			"print-proxy",
+			"Print Proxy",
+			NULL,
+			GTK_TYPE_ACTION,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_SAVE_AS_PROXY,
+		g_param_spec_object (
+			"save-as-proxy",
+			"Save As Proxy",
+			NULL,
+			GTK_TYPE_ACTION,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_SELECTED_URI,
+		g_param_spec_string (
+			"selected-uri",
+			"Selected URI",
+			NULL,
+			NULL,
+			G_PARAM_READWRITE));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_CURSOR_IMAGE,
+		g_param_spec_object (
+			"cursor-image",
+			"Image animation at the mouse cursor",
+			NULL,
+			GDK_TYPE_PIXBUF_ANIMATION,
+			G_PARAM_READWRITE));
+
+	signals[COPY_CLIPBOARD] = g_signal_new (
+		"copy-clipboard",
+		G_TYPE_FROM_CLASS (class),
+		G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+		G_STRUCT_OFFSET (EWebViewGtkHTMLClass, copy_clipboard),
+		NULL, NULL,
+		g_cclosure_marshal_VOID__VOID,
+		G_TYPE_NONE, 0);
+
+	signals[CUT_CLIPBOARD] = g_signal_new (
+		"cut-clipboard",
+		G_TYPE_FROM_CLASS (class),
+		G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+		G_STRUCT_OFFSET (EWebViewGtkHTMLClass, cut_clipboard),
+		NULL, NULL,
+		g_cclosure_marshal_VOID__VOID,
+		G_TYPE_NONE, 0);
+
+	signals[PASTE_CLIPBOARD] = g_signal_new (
+		"paste-clipboard",
+		G_TYPE_FROM_CLASS (class),
+		G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+		G_STRUCT_OFFSET (EWebViewGtkHTMLClass, paste_clipboard),
+		NULL, NULL,
+		g_cclosure_marshal_VOID__VOID,
+		G_TYPE_NONE, 0);
+
+	signals[POPUP_EVENT] = g_signal_new (
+		"popup-event",
+		G_TYPE_FROM_CLASS (class),
+		G_SIGNAL_RUN_LAST,
+		G_STRUCT_OFFSET (EWebViewGtkHTMLClass, popup_event),
+		g_signal_accumulator_true_handled, NULL,
+		e_marshal_BOOLEAN__BOXED_STRING,
+		G_TYPE_BOOLEAN, 2,
+		GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE,
+		G_TYPE_STRING);
+
+	signals[STATUS_MESSAGE] = g_signal_new (
+		"status-message",
+		G_TYPE_FROM_CLASS (class),
+		G_SIGNAL_RUN_LAST,
+		G_STRUCT_OFFSET (EWebViewGtkHTMLClass, status_message),
+		NULL, NULL,
+		g_cclosure_marshal_VOID__STRING,
+		G_TYPE_NONE, 1,
+		G_TYPE_STRING);
+
+	signals[STOP_LOADING] = g_signal_new (
+		"stop-loading",
+		G_TYPE_FROM_CLASS (class),
+		G_SIGNAL_RUN_LAST,
+		G_STRUCT_OFFSET (EWebViewGtkHTMLClass, stop_loading),
+		NULL, NULL,
+		g_cclosure_marshal_VOID__VOID,
+		G_TYPE_NONE, 0);
+
+	signals[UPDATE_ACTIONS] = g_signal_new (
+		"update-actions",
+		G_TYPE_FROM_CLASS (class),
+		G_SIGNAL_RUN_LAST,
+		G_STRUCT_OFFSET (EWebViewGtkHTMLClass, update_actions),
+		NULL, NULL,
+		g_cclosure_marshal_VOID__VOID,
+		G_TYPE_NONE, 0);
+
+	/* return TRUE when a signal handler processed the mailto URI */
+	signals[PROCESS_MAILTO] = g_signal_new (
+		"process-mailto",
+		G_TYPE_FROM_CLASS (class),
+		G_SIGNAL_RUN_LAST,
+		G_STRUCT_OFFSET (EWebViewGtkHTMLClass, process_mailto),
+		NULL, NULL,
+		e_marshal_BOOLEAN__STRING,
+		G_TYPE_BOOLEAN, 1, G_TYPE_STRING);
+}
+
+static void
+e_web_view_gtkhtml_alert_sink_init (EAlertSinkInterface *interface)
+{
+	interface->submit_alert = web_view_gtkhtml_submit_alert;
+}
+
+static void
+e_web_view_gtkhtml_selectable_init (ESelectableInterface *interface)
+{
+	interface->update_actions = web_view_gtkhtml_selectable_update_actions;
+	interface->cut_clipboard = web_view_gtkhtml_selectable_cut_clipboard;
+	interface->copy_clipboard = web_view_gtkhtml_selectable_copy_clipboard;
+	interface->paste_clipboard = web_view_gtkhtml_selectable_paste_clipboard;
+	interface->select_all = web_view_gtkhtml_selectable_select_all;
+}
+
+static void
+e_web_view_gtkhtml_init (EWebViewGtkHTML *web_view)
+{
+	GtkUIManager *ui_manager;
+	GtkActionGroup *action_group;
+	GtkTargetList *target_list;
+	EPopupAction *popup_action;
+	const gchar *domain = GETTEXT_PACKAGE;
+	const gchar *id;
+	GError *error = NULL;
+
+	web_view->priv = E_WEB_VIEW_GTKHTML_GET_PRIVATE (web_view);
+
+	ui_manager = gtk_ui_manager_new ();
+	web_view->priv->ui_manager = ui_manager;
+
+	g_signal_connect_swapped (
+		ui_manager, "connect-proxy",
+		G_CALLBACK (web_view_gtkhtml_connect_proxy_cb), web_view);
+
+	target_list = gtk_target_list_new (NULL, 0);
+	web_view->priv->copy_target_list = target_list;
+
+	target_list = gtk_target_list_new (NULL, 0);
+	web_view->priv->paste_target_list = target_list;
+
+	action_group = gtk_action_group_new ("uri");
+	gtk_action_group_set_translation_domain (action_group, domain);
+	gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
+	g_object_unref (action_group);
+
+	gtk_action_group_add_actions (
+		action_group, uri_entries,
+		G_N_ELEMENTS (uri_entries), web_view);
+
+	action_group = gtk_action_group_new ("http");
+	gtk_action_group_set_translation_domain (action_group, domain);
+	gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
+	g_object_unref (action_group);
+
+	gtk_action_group_add_actions (
+		action_group, http_entries,
+		G_N_ELEMENTS (http_entries), web_view);
+
+	action_group = gtk_action_group_new ("mailto");
+	gtk_action_group_set_translation_domain (action_group, domain);
+	gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
+	g_object_unref (action_group);
+
+	gtk_action_group_add_actions (
+		action_group, mailto_entries,
+		G_N_ELEMENTS (mailto_entries), web_view);
+
+	action_group = gtk_action_group_new ("image");
+	gtk_action_group_set_translation_domain (action_group, domain);
+	gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
+	g_object_unref (action_group);
+
+	gtk_action_group_add_actions (
+		action_group, image_entries,
+		G_N_ELEMENTS (image_entries), web_view);
+
+	action_group = gtk_action_group_new ("selection");
+	gtk_action_group_set_translation_domain (action_group, domain);
+	gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
+	g_object_unref (action_group);
+
+	gtk_action_group_add_actions (
+		action_group, selection_entries,
+		G_N_ELEMENTS (selection_entries), web_view);
+
+	action_group = gtk_action_group_new ("standard");
+	gtk_action_group_set_translation_domain (action_group, domain);
+	gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
+	g_object_unref (action_group);
+
+	gtk_action_group_add_actions (
+		action_group, standard_entries,
+		G_N_ELEMENTS (standard_entries), web_view);
+
+	popup_action = e_popup_action_new ("open");
+	gtk_action_group_add_action (action_group, GTK_ACTION (popup_action));
+	g_object_unref (popup_action);
+
+	g_object_bind_property (
+		web_view, "open-proxy",
+		popup_action, "related-action",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	/* Support lockdown. */
+
+	action_group = gtk_action_group_new ("lockdown-printing");
+	gtk_action_group_set_translation_domain (action_group, domain);
+	gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
+	g_object_unref (action_group);
+
+	popup_action = e_popup_action_new ("print");
+	gtk_action_group_add_action (action_group, GTK_ACTION (popup_action));
+	g_object_unref (popup_action);
+
+	g_object_bind_property (
+		web_view, "print-proxy",
+		popup_action, "related-action",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	action_group = gtk_action_group_new ("lockdown-save-to-disk");
+	gtk_action_group_set_translation_domain (action_group, domain);
+	gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
+	g_object_unref (action_group);
+
+	popup_action = e_popup_action_new ("save-as");
+	gtk_action_group_add_action (action_group, GTK_ACTION (popup_action));
+	g_object_unref (popup_action);
+
+	g_object_bind_property (
+		web_view, "save-as-proxy",
+		popup_action, "related-action",
+		G_BINDING_BIDIRECTIONAL |
+		G_BINDING_SYNC_CREATE);
+
+	/* Because we are loading from a hard-coded string, there is
+	 * no chance of I/O errors.  Failure here implies a malformed
+	 * UI definition.  Full stop. */
+	gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
+	if (error != NULL)
+		g_error ("%s", error->message);
+
+	id = "org.gnome.evolution.webview";
+	e_plugin_ui_register_manager (ui_manager, id, web_view);
+	e_plugin_ui_enable_manager (ui_manager, id);
+
+	e_extensible_load_extensions (E_EXTENSIBLE (web_view));
+}
+
+GtkWidget *
+e_web_view_gtkhtml_new (void)
+{
+	return g_object_new (E_TYPE_WEB_VIEW_GTKHTML, NULL);
+}
+
+void
+e_web_view_gtkhtml_clear (EWebViewGtkHTML *web_view)
+{
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	gtk_html_load_empty (GTK_HTML (web_view));
+}
+
+void
+e_web_view_gtkhtml_load_string (EWebViewGtkHTML *web_view,
+                        const gchar *string)
+{
+	EWebViewGtkHTMLClass *class;
+
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	class = E_WEB_VIEW_GTKHTML_GET_CLASS (web_view);
+	g_return_if_fail (class->load_string != NULL);
+
+	class->load_string (web_view, string);
+}
+
+gboolean
+e_web_view_gtkhtml_get_animate (EWebViewGtkHTML *web_view)
+{
+	/* XXX This is just here to maintain symmetry
+	 *     with e_web_view_set_animate(). */
+
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
+
+	return gtk_html_get_animate (GTK_HTML (web_view));
+}
+
+void
+e_web_view_gtkhtml_set_animate (EWebViewGtkHTML *web_view,
+                        gboolean animate)
+{
+	/* XXX GtkHTML does not utilize GObject properties as well
+	 *     as it could.  This just wraps gtk_html_set_animate()
+	 *     so we can get a "notify::animate" signal. */
+
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	gtk_html_set_animate (GTK_HTML (web_view), animate);
+
+	g_object_notify (G_OBJECT (web_view), "animate");
+}
+
+gboolean
+e_web_view_gtkhtml_get_caret_mode (EWebViewGtkHTML *web_view)
+{
+	/* XXX This is just here to maintain symmetry
+	 *     with e_web_view_set_caret_mode(). */
+
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
+
+	return gtk_html_get_caret_mode (GTK_HTML (web_view));
+}
+
+void
+e_web_view_gtkhtml_set_caret_mode (EWebViewGtkHTML *web_view,
+                           gboolean caret_mode)
+{
+	/* XXX GtkHTML does not utilize GObject properties as well
+	 *     as it could.  This just wraps gtk_html_set_caret_mode()
+	 *     so we can get a "notify::caret-mode" signal. */
+
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	gtk_html_set_caret_mode (GTK_HTML (web_view), caret_mode);
+
+	g_object_notify (G_OBJECT (web_view), "caret-mode");
+}
+
+GtkTargetList *
+e_web_view_gtkhtml_get_copy_target_list (EWebViewGtkHTML *web_view)
+{
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), NULL);
+
+	return web_view->priv->copy_target_list;
+}
+
+gboolean
+e_web_view_gtkhtml_get_disable_printing (EWebViewGtkHTML *web_view)
+{
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
+
+	return web_view->priv->disable_printing;
+}
+
+void
+e_web_view_gtkhtml_set_disable_printing (EWebViewGtkHTML *web_view,
+                                 gboolean disable_printing)
+{
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	web_view->priv->disable_printing = disable_printing;
+
+	g_object_notify (G_OBJECT (web_view), "disable-printing");
+}
+
+gboolean
+e_web_view_gtkhtml_get_disable_save_to_disk (EWebViewGtkHTML *web_view)
+{
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
+
+	return web_view->priv->disable_save_to_disk;
+}
+
+void
+e_web_view_gtkhtml_set_disable_save_to_disk (EWebViewGtkHTML *web_view,
+                                     gboolean disable_save_to_disk)
+{
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	web_view->priv->disable_save_to_disk = disable_save_to_disk;
+
+	g_object_notify (G_OBJECT (web_view), "disable-save-to-disk");
+}
+
+gboolean
+e_web_view_gtkhtml_get_editable (EWebViewGtkHTML *web_view)
+{
+	/* XXX This is just here to maintain symmetry
+	 *     with e_web_view_set_editable(). */
+
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
+
+	return gtk_html_get_editable (GTK_HTML (web_view));
+}
+
+void
+e_web_view_gtkhtml_set_editable (EWebViewGtkHTML *web_view,
+                         gboolean editable)
+{
+	/* XXX GtkHTML does not utilize GObject properties as well
+	 *     as it could.  This just wraps gtk_html_set_editable()
+	 *     so we can get a "notify::editable" signal. */
+
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	gtk_html_set_editable (GTK_HTML (web_view), editable);
+
+	g_object_notify (G_OBJECT (web_view), "editable");
+}
+
+gboolean
+e_web_view_gtkhtml_get_inline_spelling (EWebViewGtkHTML *web_view)
+{
+	/* XXX This is just here to maintain symmetry
+	 *     with e_web_view_set_inline_spelling(). */
+
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
+
+	return gtk_html_get_inline_spelling (GTK_HTML (web_view));
+}
+
+void
+e_web_view_gtkhtml_set_inline_spelling (EWebViewGtkHTML *web_view,
+                                gboolean inline_spelling)
+{
+	/* XXX GtkHTML does not utilize GObject properties as well
+	 *     as it could.  This just wraps gtk_html_set_inline_spelling()
+	 *     so we get a "notify::inline-spelling" signal. */
+
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	gtk_html_set_inline_spelling (GTK_HTML (web_view), inline_spelling);
+
+	g_object_notify (G_OBJECT (web_view), "inline-spelling");
+}
+
+gboolean
+e_web_view_gtkhtml_get_magic_links (EWebViewGtkHTML *web_view)
+{
+	/* XXX This is just here to maintain symmetry
+	 *     with e_web_view_set_magic_links(). */
+
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
+
+	return gtk_html_get_magic_links (GTK_HTML (web_view));
+}
+
+void
+e_web_view_gtkhtml_set_magic_links (EWebViewGtkHTML *web_view,
+                            gboolean magic_links)
+{
+	/* XXX GtkHTML does not utilize GObject properties as well
+	 *     as it could.  This just wraps gtk_html_set_magic_links()
+	 *     so we can get a "notify::magic-links" signal. */
+
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	gtk_html_set_magic_links (GTK_HTML (web_view), magic_links);
+
+	g_object_notify (G_OBJECT (web_view), "magic-links");
+}
+
+gboolean
+e_web_view_gtkhtml_get_magic_smileys (EWebViewGtkHTML *web_view)
+{
+	/* XXX This is just here to maintain symmetry
+	 *     with e_web_view_set_magic_smileys(). */
+
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
+
+	return gtk_html_get_magic_smileys (GTK_HTML (web_view));
+}
+
+void
+e_web_view_gtkhtml_set_magic_smileys (EWebViewGtkHTML *web_view,
+                              gboolean magic_smileys)
+{
+	/* XXX GtkHTML does not utilize GObject properties as well
+	 *     as it could.  This just wraps gtk_html_set_magic_smileys()
+	 *     so we can get a "notify::magic-smileys" signal. */
+
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	gtk_html_set_magic_smileys (GTK_HTML (web_view), magic_smileys);
+
+	g_object_notify (G_OBJECT (web_view), "magic-smileys");
+}
+
+const gchar *
+e_web_view_gtkhtml_get_selected_uri (EWebViewGtkHTML *web_view)
+{
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), NULL);
+
+	return web_view->priv->selected_uri;
+}
+
+void
+e_web_view_gtkhtml_set_selected_uri (EWebViewGtkHTML *web_view,
+                             const gchar *selected_uri)
+{
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	g_free (web_view->priv->selected_uri);
+	web_view->priv->selected_uri = g_strdup (selected_uri);
+
+	g_object_notify (G_OBJECT (web_view), "selected-uri");
+}
+
+GdkPixbufAnimation *
+e_web_view_gtkhtml_get_cursor_image (EWebViewGtkHTML *web_view)
+{
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), NULL);
+
+	return web_view->priv->cursor_image;
+}
+
+void
+e_web_view_gtkhtml_set_cursor_image (EWebViewGtkHTML *web_view,
+                             GdkPixbufAnimation *image)
+{
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	if (image != NULL)
+		g_object_ref (image);
+
+	if (web_view->priv->cursor_image != NULL)
+		g_object_unref (web_view->priv->cursor_image);
+
+	web_view->priv->cursor_image = image;
+
+	g_object_notify (G_OBJECT (web_view), "cursor-image");
+}
+
+GtkAction *
+e_web_view_gtkhtml_get_open_proxy (EWebViewGtkHTML *web_view)
+{
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
+
+	return web_view->priv->open_proxy;
+}
+
+void
+e_web_view_gtkhtml_set_open_proxy (EWebViewGtkHTML *web_view,
+                           GtkAction *open_proxy)
+{
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	if (open_proxy != NULL) {
+		g_return_if_fail (GTK_IS_ACTION (open_proxy));
+		g_object_ref (open_proxy);
+	}
+
+	if (web_view->priv->open_proxy != NULL)
+		g_object_unref (web_view->priv->open_proxy);
+
+	web_view->priv->open_proxy = open_proxy;
+
+	g_object_notify (G_OBJECT (web_view), "open-proxy");
+}
+
+GtkTargetList *
+e_web_view_gtkhtml_get_paste_target_list (EWebViewGtkHTML *web_view)
+{
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), NULL);
+
+	return web_view->priv->paste_target_list;
+}
+
+GtkAction *
+e_web_view_gtkhtml_get_print_proxy (EWebViewGtkHTML *web_view)
+{
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
+
+	return web_view->priv->print_proxy;
+}
+
+void
+e_web_view_gtkhtml_set_print_proxy (EWebViewGtkHTML *web_view,
+                            GtkAction *print_proxy)
+{
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	if (print_proxy != NULL) {
+		g_return_if_fail (GTK_IS_ACTION (print_proxy));
+		g_object_ref (print_proxy);
+	}
+
+	if (web_view->priv->print_proxy != NULL)
+		g_object_unref (web_view->priv->print_proxy);
+
+	web_view->priv->print_proxy = print_proxy;
+
+	g_object_notify (G_OBJECT (web_view), "print-proxy");
+}
+
+GtkAction *
+e_web_view_gtkhtml_get_save_as_proxy (EWebViewGtkHTML *web_view)
+{
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
+
+	return web_view->priv->save_as_proxy;
+}
+
+void
+e_web_view_gtkhtml_set_save_as_proxy (EWebViewGtkHTML *web_view,
+                              GtkAction *save_as_proxy)
+{
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	if (save_as_proxy != NULL) {
+		g_return_if_fail (GTK_IS_ACTION (save_as_proxy));
+		g_object_ref (save_as_proxy);
+	}
+
+	if (web_view->priv->save_as_proxy != NULL)
+		g_object_unref (web_view->priv->save_as_proxy);
+
+	web_view->priv->save_as_proxy = save_as_proxy;
+
+	g_object_notify (G_OBJECT (web_view), "save-as-proxy");
+}
+
+GtkAction *
+e_web_view_gtkhtml_get_action (EWebViewGtkHTML *web_view,
+                       const gchar *action_name)
+{
+	GtkUIManager *ui_manager;
+
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), NULL);
+	g_return_val_if_fail (action_name != NULL, NULL);
+
+	ui_manager = e_web_view_gtkhtml_get_ui_manager (web_view);
+
+	return e_lookup_action (ui_manager, action_name);
+}
+
+GtkActionGroup *
+e_web_view_gtkhtml_get_action_group (EWebViewGtkHTML *web_view,
+                             const gchar *group_name)
+{
+	GtkUIManager *ui_manager;
+
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), NULL);
+	g_return_val_if_fail (group_name != NULL, NULL);
+
+	ui_manager = e_web_view_gtkhtml_get_ui_manager (web_view);
+
+	return e_lookup_action_group (ui_manager, group_name);
+}
+
+gchar *
+e_web_view_gtkhtml_extract_uri (EWebViewGtkHTML *web_view,
+                        GdkEventButton *event,
+                        GtkHTML *frame)
+{
+	EWebViewGtkHTMLClass *class;
+
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), NULL);
+
+	if (frame == NULL)
+		frame = GTK_HTML (web_view);
+
+	class = E_WEB_VIEW_GTKHTML_GET_CLASS (web_view);
+	g_return_val_if_fail (class->extract_uri != NULL, NULL);
+
+	return class->extract_uri (web_view, event, frame);
+}
+
+void
+e_web_view_gtkhtml_copy_clipboard (EWebViewGtkHTML *web_view)
+{
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	g_signal_emit (web_view, signals[COPY_CLIPBOARD], 0);
+}
+
+void
+e_web_view_gtkhtml_cut_clipboard (EWebViewGtkHTML *web_view)
+{
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	g_signal_emit (web_view, signals[CUT_CLIPBOARD], 0);
+}
+
+gboolean
+e_web_view_gtkhtml_is_selection_active (EWebViewGtkHTML *web_view)
+{
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
+
+	return gtk_html_command (GTK_HTML (web_view), "is-selection-active");
+}
+
+void
+e_web_view_gtkhtml_paste_clipboard (EWebViewGtkHTML *web_view)
+{
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	g_signal_emit (web_view, signals[PASTE_CLIPBOARD], 0);
+}
+
+gboolean
+e_web_view_gtkhtml_scroll_forward (EWebViewGtkHTML *web_view)
+{
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
+
+	return gtk_html_command (GTK_HTML (web_view), "scroll-forward");
+}
+
+gboolean
+e_web_view_gtkhtml_scroll_backward (EWebViewGtkHTML *web_view)
+{
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), FALSE);
+
+	return gtk_html_command (GTK_HTML (web_view), "scroll-backward");
+}
+
+void
+e_web_view_gtkhtml_select_all (EWebViewGtkHTML *web_view)
+{
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	gtk_html_command (GTK_HTML (web_view), "select-all");
+}
+
+void
+e_web_view_gtkhtml_unselect_all (EWebViewGtkHTML *web_view)
+{
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	gtk_html_command (GTK_HTML (web_view), "unselect-all");
+}
+
+void
+e_web_view_gtkhtml_zoom_100 (EWebViewGtkHTML *web_view)
+{
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	gtk_html_command (GTK_HTML (web_view), "zoom-reset");
+}
+
+void
+e_web_view_gtkhtml_zoom_in (EWebViewGtkHTML *web_view)
+{
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	gtk_html_command (GTK_HTML (web_view), "zoom-in");
+}
+
+void
+e_web_view_gtkhtml_zoom_out (EWebViewGtkHTML *web_view)
+{
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	gtk_html_command (GTK_HTML (web_view), "zoom-out");
+}
+
+GtkUIManager *
+e_web_view_gtkhtml_get_ui_manager (EWebViewGtkHTML *web_view)
+{
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), NULL);
+
+	return web_view->priv->ui_manager;
+}
+
+GtkWidget *
+e_web_view_gtkhtml_get_popup_menu (EWebViewGtkHTML *web_view)
+{
+	GtkUIManager *ui_manager;
+	GtkWidget *menu;
+
+	g_return_val_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view), NULL);
+
+	ui_manager = e_web_view_gtkhtml_get_ui_manager (web_view);
+	menu = gtk_ui_manager_get_widget (ui_manager, "/context");
+	g_return_val_if_fail (GTK_IS_MENU (menu), NULL);
+
+	return menu;
+}
+
+void
+e_web_view_gtkhtml_show_popup_menu (EWebViewGtkHTML *web_view,
+                            GdkEventButton *event,
+                            GtkMenuPositionFunc func,
+                            gpointer user_data)
+{
+	GtkWidget *menu;
+
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	e_web_view_gtkhtml_update_actions (web_view);
+
+	menu = e_web_view_gtkhtml_get_popup_menu (web_view);
+
+	if (event != NULL)
+		gtk_menu_popup (
+			GTK_MENU (menu), NULL, NULL, func,
+			user_data, event->button, event->time);
+	else
+		gtk_menu_popup (
+			GTK_MENU (menu), NULL, NULL, func,
+			user_data, 0, gtk_get_current_event_time ());
+}
+
+void
+e_web_view_gtkhtml_status_message (EWebViewGtkHTML *web_view,
+                           const gchar *status_message)
+{
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	g_signal_emit (web_view, signals[STATUS_MESSAGE], 0, status_message);
+}
+
+void
+e_web_view_gtkhtml_stop_loading (EWebViewGtkHTML *web_view)
+{
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	g_signal_emit (web_view, signals[STOP_LOADING], 0);
+}
+
+void
+e_web_view_gtkhtml_update_actions (EWebViewGtkHTML *web_view)
+{
+	g_return_if_fail (E_IS_WEB_VIEW_GTKHTML (web_view));
+
+	g_signal_emit (web_view, signals[UPDATE_ACTIONS], 0);
+}
diff --git a/widgets/misc/e-web-view-gtkhtml.h b/widgets/misc/e-web-view-gtkhtml.h
new file mode 100644
index 0000000..aab06e8
--- /dev/null
+++ b/widgets/misc/e-web-view-gtkhtml.h
@@ -0,0 +1,173 @@
+/*
+ * e-web-view-gtkhtml.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+/* This is intended to serve as a common base class for all HTML viewing
+ * needs in Evolution.  Currently based on GtkHTML, the idea is to wrap
+ * the GtkHTML API enough that we no longer have to make direct calls to
+ * it.  This should help smooth the transition to WebKit/GTK+.
+ *
+ * This class handles basic tasks like mouse hovers over links, clicked
+ * links, and servicing URI requests asynchronously via GIO. */
+
+#ifndef E_WEB_VIEW_GTKHTML_H
+#define E_WEB_VIEW_GTKHTML_H
+
+#include <gtkhtml/gtkhtml.h>
+
+/* Standard GObject macros */
+#define E_TYPE_WEB_VIEW_GTKHTML \
+	(e_web_view_gtkhtml_get_type ())
+#define E_WEB_VIEW_GTKHTML(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_WEB_VIEW_GTKHTML, EWebViewGtkHTML))
+#define E_WEB_VIEW_GTKHTML_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_WEB_VIEW_GTKHTML, EWebViewGtkHTMLClass))
+#define E_IS_WEB_VIEW_GTKHTML(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_WEB_VIEW_GTKHTML))
+#define E_IS_WEB_VIEW_GTKHTML_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_WEB_VIEW_GTKHTML))
+#define E_WEB_VIEW_GTKHTML_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_WEB_VIEW_GTKHTML, EWebViewGtkHTMLClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EWebViewGtkHTML EWebViewGtkHTML;
+typedef struct _EWebViewGtkHTMLClass EWebViewGtkHTMLClass;
+typedef struct _EWebViewGtkHTMLPrivate EWebViewGtkHTMLPrivate;
+
+struct _EWebViewGtkHTML {
+	GtkHTML parent;
+	EWebViewGtkHTMLPrivate *priv;
+};
+
+struct _EWebViewGtkHTMLClass {
+	GtkHTMLClass parent_class;
+
+	/* Methods */
+	gchar *		(*extract_uri)		(EWebViewGtkHTML *web_view,
+						 GdkEventButton *event,
+						 GtkHTML *frame);
+	void		(*hovering_over_link)	(EWebViewGtkHTML *web_view,
+						 const gchar *title,
+						 const gchar *uri);
+	void		(*link_clicked)		(EWebViewGtkHTML *web_view,
+						 const gchar *uri);
+	void		(*load_string)		(EWebViewGtkHTML *web_view,
+						 const gchar *load_string);
+
+	/* Signals */
+	void		(*copy_clipboard)	(EWebViewGtkHTML *web_view);
+	void		(*cut_clipboard)	(EWebViewGtkHTML *web_view);
+	void		(*paste_clipboard)	(EWebViewGtkHTML *web_view);
+	gboolean	(*popup_event)		(EWebViewGtkHTML *web_view,
+						 GdkEventButton *event,
+						 const gchar *uri);
+	void		(*status_message)	(EWebViewGtkHTML *web_view,
+						 const gchar *status_message);
+	void		(*stop_loading)		(EWebViewGtkHTML *web_view);
+	void		(*update_actions)	(EWebViewGtkHTML *web_view);
+	gboolean	(*process_mailto)	(EWebViewGtkHTML *web_view,
+						 const gchar *mailto_uri);
+};
+
+GType		e_web_view_gtkhtml_get_type		(void);
+GtkWidget *	e_web_view_gtkhtml_new			(void);
+void		e_web_view_gtkhtml_clear		(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_load_string		(EWebViewGtkHTML *web_view,
+							 const gchar *string);
+gboolean	e_web_view_gtkhtml_get_animate		(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_set_animate		(EWebViewGtkHTML *web_view,
+							 gboolean animate);
+gboolean	e_web_view_gtkhtml_get_caret_mode	(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_set_caret_mode	(EWebViewGtkHTML *web_view,
+							 gboolean caret_mode);
+GtkTargetList *	e_web_view_gtkhtml_get_copy_target_list	(EWebViewGtkHTML *web_view);
+gboolean	e_web_view_gtkhtml_get_disable_printing	(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_set_disable_printing	(EWebViewGtkHTML *web_view,
+							 gboolean disable_printing);
+gboolean	e_web_view_gtkhtml_get_disable_save_to_disk
+							(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_set_disable_save_to_disk
+							(EWebViewGtkHTML *web_view,
+							 gboolean disable_save_to_disk);
+gboolean	e_web_view_gtkhtml_get_editable		(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_set_editable		(EWebViewGtkHTML *web_view,
+							 gboolean editable);
+gboolean	e_web_view_gtkhtml_get_inline_spelling	(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_set_inline_spelling	(EWebViewGtkHTML *web_view,
+							 gboolean inline_spelling);
+gboolean	e_web_view_gtkhtml_get_magic_links	(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_set_magic_links	(EWebViewGtkHTML *web_view,
+							 gboolean magic_links);
+gboolean	e_web_view_gtkhtml_get_magic_smileys	(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_set_magic_smileys	(EWebViewGtkHTML *web_view,
+							 gboolean magic_smileys);
+const gchar *	e_web_view_gtkhtml_get_selected_uri	(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_set_selected_uri	(EWebViewGtkHTML *web_view,
+							 const gchar *selected_uri);
+GdkPixbufAnimation *
+		e_web_view_gtkhtml_get_cursor_image	(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_set_cursor_image	(EWebViewGtkHTML *web_view,
+							 GdkPixbufAnimation *animation);
+GtkAction *	e_web_view_gtkhtml_get_open_proxy	(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_set_open_proxy	(EWebViewGtkHTML *web_view,
+							 GtkAction *open_proxy);
+GtkTargetList *	e_web_view_gtkhtml_get_paste_target_list
+							(EWebViewGtkHTML *web_view);
+GtkAction *	e_web_view_gtkhtml_get_print_proxy	(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_set_print_proxy	(EWebViewGtkHTML *web_view,
+							 GtkAction *print_proxy);
+GtkAction *	e_web_view_gtkhtml_get_save_as_proxy	(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_set_save_as_proxy	(EWebViewGtkHTML *web_view,
+							 GtkAction *save_as_proxy);
+GtkAction *	e_web_view_gtkhtml_get_action		(EWebViewGtkHTML *web_view,
+							 const gchar *action_name);
+GtkActionGroup *e_web_view_gtkhtml_get_action_group	(EWebViewGtkHTML *web_view,
+							 const gchar *group_name);
+gchar *		e_web_view_gtkhtml_extract_uri		(EWebViewGtkHTML *web_view,
+							 GdkEventButton *event,
+							 GtkHTML *frame);
+void		e_web_view_gtkhtml_copy_clipboard	(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_cut_clipboard	(EWebViewGtkHTML *web_view);
+gboolean	e_web_view_gtkhtml_is_selection_active	(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_paste_clipboard	(EWebViewGtkHTML *web_view);
+gboolean	e_web_view_gtkhtml_scroll_forward	(EWebViewGtkHTML *web_view);
+gboolean	e_web_view_gtkhtml_scroll_backward	(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_select_all		(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_unselect_all		(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_zoom_100		(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_zoom_in		(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_zoom_out		(EWebViewGtkHTML *web_view);
+GtkUIManager *	e_web_view_gtkhtml_get_ui_manager	(EWebViewGtkHTML *web_view);
+GtkWidget *	e_web_view_gtkhtml_get_popup_menu	(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_show_popup_menu	(EWebViewGtkHTML *web_view,
+							 GdkEventButton *event,
+							 GtkMenuPositionFunc func,
+							 gpointer user_data);
+void		e_web_view_gtkhtml_status_message	(EWebViewGtkHTML *web_view,
+							const gchar *status_message);
+void		e_web_view_gtkhtml_stop_loading		(EWebViewGtkHTML *web_view);
+void		e_web_view_gtkhtml_update_actions	(EWebViewGtkHTML *web_view);
+
+G_END_DECLS
+
+#endif /* E_WEB_VIEW_GTKHTML_H */
diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c
index 26c9224..1fdc555 100644
--- a/widgets/misc/e-web-view.c
+++ b/widgets/misc/e-web-view.c
@@ -22,6 +22,10 @@
 
 #include "e-web-view.h"
 
+#include <math.h>
+
+#include <JavaScriptCore/JavaScript.h>
+
 #include <string.h>
 #include <glib/gi18n-lib.h>
 
@@ -33,8 +37,11 @@
 #include <libevolution-utils/e-alert-sink.h>
 #include <e-util/e-plugin-ui.h>
 
+#include <mail/e-mail-request.h>
+
 #include "e-popup-action.h"
 #include "e-selectable.h"
+#include <stdlib.h>
 
 #define E_WEB_VIEW_GET_PRIVATE(obj) \
 	(G_TYPE_INSTANCE_GET_PRIVATE \
@@ -49,51 +56,39 @@ struct _EWebViewPrivate {
 	GdkPixbufAnimation *cursor_image;
 	gchar *cursor_image_src;
 
+	GHashTable *js_callbacks;
+
+        GSList *highlights;
+
 	GtkAction *open_proxy;
 	GtkAction *print_proxy;
 	GtkAction *save_as_proxy;
 
-	GtkTargetList *copy_target_list;
-	GtkTargetList *paste_target_list;
-
 	/* Lockdown Options */
 	guint disable_printing     : 1;
 	guint disable_save_to_disk : 1;
-};
 
-struct _EWebViewRequest {
-	GFile *file;
-	EWebView *web_view;
-	GCancellable *cancellable;
-	GInputStream *input_stream;
-	GtkHTMLStream *output_stream;
-	gchar buffer[4096];
+	guint caret_mode : 1;
 };
 
 enum {
 	PROP_0,
-	PROP_ANIMATE,
 	PROP_CARET_MODE,
 	PROP_COPY_TARGET_LIST,
 	PROP_CURSOR_IMAGE,
 	PROP_CURSOR_IMAGE_SRC,
 	PROP_DISABLE_PRINTING,
 	PROP_DISABLE_SAVE_TO_DISK,
-	PROP_EDITABLE,
 	PROP_INLINE_SPELLING,
 	PROP_MAGIC_LINKS,
 	PROP_MAGIC_SMILEYS,
 	PROP_OPEN_PROXY,
-	PROP_PASTE_TARGET_LIST,
 	PROP_PRINT_PROXY,
 	PROP_SAVE_AS_PROXY,
 	PROP_SELECTED_URI
 };
 
 enum {
-	COPY_CLIPBOARD,
-	CUT_CLIPBOARD,
-	PASTE_CLIPBOARD,
 	POPUP_EVENT,
 	STATUS_MESSAGE,
 	STOP_LOADING,
@@ -125,6 +120,7 @@ static const gchar *ui =
 "    <placeholder name='custom-actions-3'/>"
 "    <separator/>"
 "    <menuitem action='select-all'/>"
+"    <placeholder name='inspect-menu' />"
 "  </popup>"
 "</ui>";
 
@@ -135,7 +131,7 @@ static void e_web_view_selectable_init (ESelectableInterface *interface);
 G_DEFINE_TYPE_WITH_CODE (
 	EWebView,
 	e_web_view,
-	GTK_TYPE_HTML,
+	WEBKIT_TYPE_WEB_VIEW,
 	G_IMPLEMENT_INTERFACE (
 		E_TYPE_EXTENSIBLE, NULL)
 	G_IMPLEMENT_INTERFACE (
@@ -145,141 +141,6 @@ G_DEFINE_TYPE_WITH_CODE (
 		E_TYPE_SELECTABLE,
 		e_web_view_selectable_init))
 
-static EWebViewRequest *
-web_view_request_new (EWebView *web_view,
-                      const gchar *uri,
-                      GtkHTMLStream *stream)
-{
-	EWebViewRequest *request;
-	GList *list;
-
-	request = g_slice_new (EWebViewRequest);
-
-	/* Try to detect file paths posing as URIs. */
-	if (*uri == '/')
-		request->file = g_file_new_for_path (uri);
-	else
-		request->file = g_file_new_for_uri (uri);
-
-	request->web_view = g_object_ref (web_view);
-	request->cancellable = g_cancellable_new ();
-	request->input_stream = NULL;
-	request->output_stream = stream;
-
-	list = request->web_view->priv->requests;
-	list = g_list_prepend (list, request);
-	request->web_view->priv->requests = list;
-
-	return request;
-}
-
-static void
-web_view_request_free (EWebViewRequest *request)
-{
-	GList *list;
-
-	list = request->web_view->priv->requests;
-	list = g_list_remove (list, request);
-	request->web_view->priv->requests = list;
-
-	g_object_unref (request->file);
-	g_object_unref (request->web_view);
-	g_object_unref (request->cancellable);
-
-	if (request->input_stream != NULL)
-		g_object_unref (request->input_stream);
-
-	g_slice_free (EWebViewRequest, request);
-}
-
-static void
-web_view_request_cancel (EWebViewRequest *request)
-{
-	g_cancellable_cancel (request->cancellable);
-}
-
-static gboolean
-web_view_request_check_for_error (EWebViewRequest *request,
-                                  GError *error)
-{
-	GtkHTML *html;
-	GtkHTMLStream *stream;
-
-	if (error == NULL)
-		return FALSE;
-
-	if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) {
-		/* use this error, but do not close the stream */
-		g_error_free (error);
-		return TRUE;
-	}
-
-	/* XXX Should we log errors that are not cancellations? */
-
-	html = GTK_HTML (request->web_view);
-	stream = request->output_stream;
-
-	gtk_html_end (html, stream, GTK_HTML_STREAM_ERROR);
-	web_view_request_free (request);
-	g_error_free (error);
-
-	return TRUE;
-}
-
-static void
-web_view_request_stream_read_cb (GInputStream *input_stream,
-                                 GAsyncResult *result,
-                                 EWebViewRequest *request)
-{
-	gssize bytes_read;
-	GError *error = NULL;
-
-	bytes_read = g_input_stream_read_finish (input_stream, result, &error);
-
-	if (web_view_request_check_for_error (request, error))
-		return;
-
-	if (bytes_read == 0) {
-		gtk_html_end (
-			GTK_HTML (request->web_view),
-			request->output_stream, GTK_HTML_STREAM_OK);
-		web_view_request_free (request);
-		return;
-	}
-
-	gtk_html_write (
-		GTK_HTML (request->web_view),
-		request->output_stream, request->buffer, bytes_read);
-
-	g_input_stream_read_async (
-		request->input_stream, request->buffer,
-		sizeof (request->buffer), G_PRIORITY_DEFAULT,
-		request->cancellable, (GAsyncReadyCallback)
-		web_view_request_stream_read_cb, request);
-}
-
-static void
-web_view_request_read_cb (GFile *file,
-                          GAsyncResult *result,
-                          EWebViewRequest *request)
-{
-	GFileInputStream *input_stream;
-	GError *error = NULL;
-
-	/* Input stream might be NULL, so don't use cast macro. */
-	input_stream = g_file_read_finish (file, result, &error);
-	request->input_stream = (GInputStream *) input_stream;
-
-	if (web_view_request_check_for_error (request, error))
-		return;
-
-	g_input_stream_read_async (
-		request->input_stream, request->buffer,
-		sizeof (request->buffer), G_PRIORITY_DEFAULT,
-		request->cancellable, (GAsyncReadyCallback)
-		web_view_request_stream_read_cb, request);
-}
-
 static void
 action_copy_clipboard_cb (GtkAction *action,
                           EWebView *web_view)
@@ -470,71 +331,149 @@ static GtkActionEntry standard_entries[] = {
 	  G_CALLBACK (action_select_all_cb) }
 };
 
-static gboolean
-web_view_button_press_event_cb (EWebView *web_view,
-                                GdkEventButton *event,
-                                GtkHTML *frame)
+static void
+web_view_menu_item_select_cb (EWebView *web_view,
+                              GtkWidget *widget)
 {
-	gboolean event_handled = FALSE;
-	gchar *uri = NULL;
+	GtkAction *action;
+	GtkActivatable *activatable;
+	const gchar *tooltip;
 
-	if (event) {
-		GdkPixbufAnimation *anim;
-		gchar *image_src;
+	activatable = GTK_ACTIVATABLE (widget);
+	action = gtk_activatable_get_related_action (activatable);
+	tooltip = gtk_action_get_tooltip (action);
 
-		if (frame == NULL)
-			frame = GTK_HTML (web_view);
+	if (tooltip == NULL)
+		return;
 
-		anim = gtk_html_get_image_at (frame, event->x, event->y);
-		e_web_view_set_cursor_image (web_view, anim);
-		if (anim != NULL)
-			g_object_unref (anim);
+	e_web_view_status_message (web_view, tooltip);
+}
 
-		image_src = gtk_html_get_image_src_at (
-			frame, event->x, event->y);
-		e_web_view_set_cursor_image_src (web_view, image_src);
-		g_free (image_src);
-	}
+static void
+replace_text (WebKitDOMNode *node,
+              const gchar *text,
+              WebKitDOMNode *replacement)
+{
+        /* NodeType 3 = TEXT_NODE */
+	if (webkit_dom_node_get_node_type (node) == 3) {
+
+		gint text_length = strlen (text);
+
+		while (node) {
+
+			WebKitDOMNode *current_node, *replacement_node;
+			const gchar *node_data, *offset;
+			goffset split_offset;
+			gint data_length;
+
+			current_node = node;
+
+                        /* Don't use the WEBKIT_DOM_CHARACTER_DATA macro for
+                         * casting. WebKit lies about type of the object and
+                         * GLib will throw runtime warning about node not being
+                         * WebKitDOMCharacterData, but the function will return
+                         * correct and valid data.
+                         * IMO it's bug in the Gtk bindings and WebKit internally
+                         * handles it by the nodeType so therefor it works
+                         * event for "invalid" objects. But really, who knows..?
+                         */
+			node_data = webkit_dom_character_data_get_data (
+					(WebKitDOMCharacterData *) node);
+
+			offset = strstr (node_data, text);
+			if (!offset) {
+				node = NULL;
+				continue;
+			}
+
+			split_offset = offset - node_data + text_length;
+			replacement_node =
+				webkit_dom_node_clone_node (replacement, TRUE);
+
+			data_length = webkit_dom_character_data_get_length (
+					(WebKitDOMCharacterData *) node);
+			if (split_offset < data_length) {
+
+				WebKitDOMNode *parent_node;
+
+				node = WEBKIT_DOM_NODE (
+					webkit_dom_text_split_text (
+						(WebKitDOMText *) node,
+						offset - node_data + text_length,
+						NULL));
+				parent_node = webkit_dom_node_get_parent_node (node);
+				webkit_dom_node_insert_before (
+					parent_node, replacement_node,
+					node, NULL);
+
+			} else {
+				WebKitDOMNode *parent_node;
+
+				parent_node = webkit_dom_node_get_parent_node (node);
+				webkit_dom_node_append_child (
+					parent_node,
+					replacement_node, NULL);
+			}
+
+			webkit_dom_character_data_delete_data (
+				(WebKitDOMCharacterData *) (current_node),
+				offset - node_data, text_length, NULL);
+		}
 
-	if (event != NULL && event->button != 3)
-		return FALSE;
+	} else {
 
-	/* Only extract a URI if no selection is active.  Selected text
-	 * implies the user is more likely to want to copy the selection
-	 * to the clipboard than open a link within the selection. */
-	if (!e_web_view_is_selection_active (web_view))
-		uri = e_web_view_extract_uri (web_view, event, frame);
+		WebKitDOMNode *child, *next_child;
 
-	if (uri != NULL && g_str_has_prefix (uri, "##")) {
-		g_free (uri);
-		return FALSE;
-	}
+                /* Iframe? Let's traverse inside! */
+		if (WEBKIT_DOM_IS_HTML_IFRAME_ELEMENT (node)) {
 
-	g_signal_emit (
-		web_view, signals[POPUP_EVENT], 0,
-		event, uri, &event_handled);
+			WebKitDOMDocument *frame_document;
 
-	g_free (uri);
+			frame_document =
+				webkit_dom_html_iframe_element_get_content_document (
+					WEBKIT_DOM_HTML_IFRAME_ELEMENT (node));
+			replace_text (WEBKIT_DOM_NODE (frame_document),
+				      text, replacement);
+
+		} else {
+
+			child = webkit_dom_node_get_first_child (node);
+			while (child) {
+				next_child = webkit_dom_node_get_next_sibling (child);
+				replace_text (child, text, replacement);
+				child = next_child;
+			}
+		}
+	}
 
-	return event_handled;
 }
 
 static void
-web_view_menu_item_select_cb (EWebView *web_view,
-                              GtkWidget *widget)
+web_view_update_document_highlights (EWebView *web_view)
 {
-	GtkAction *action;
-	GtkActivatable *activatable;
-	const gchar *tooltip;
+	WebKitDOMDocument *document;
+	GSList *iter;
 
-	activatable = GTK_ACTIVATABLE (widget);
-	action = gtk_activatable_get_related_action (activatable);
-	tooltip = gtk_action_get_tooltip (action);
+	document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (web_view));
 
-	if (tooltip == NULL)
-		return;
+	for (iter = web_view->priv->highlights; iter; iter = iter->next) {
 
-	e_web_view_status_message (web_view, tooltip);
+		WebKitDOMDocumentFragment *frag;
+		WebKitDOMElement *span;
+
+                span = webkit_dom_document_create_element (document, "span", NULL);
+		webkit_dom_html_element_set_class_name (
+                        WEBKIT_DOM_HTML_ELEMENT (span), "__evo-highlight");
+		webkit_dom_html_element_set_inner_text (
+			WEBKIT_DOM_HTML_ELEMENT (span), iter->data, NULL);
+
+		frag = webkit_dom_document_create_document_fragment (document);
+		webkit_dom_node_append_child (
+			WEBKIT_DOM_NODE (frag), WEBKIT_DOM_NODE (span), NULL);
+
+		replace_text (WEBKIT_DOM_NODE (document),
+			iter->data, WEBKIT_DOM_NODE (frag));
+	}
 }
 
 static void
@@ -560,6 +499,86 @@ web_view_connect_proxy_cb (EWebView *web_view,
 		G_CALLBACK (web_view_menu_item_deselect_cb), web_view);
 }
 
+static GtkWidget *
+web_view_create_plugin_widget_cb (EWebView *web_view,
+                                  const gchar *mime_type,
+                                  const gchar *uri,
+                                  GHashTable *param)
+{
+	EWebViewClass *class;
+
+	/* XXX WebKitWebView does not provide a class method for
+	 *     this signal, so we do so we can override the default
+	 *     behavior from subclasses for special URI types. */
+
+	class = E_WEB_VIEW_GET_CLASS (web_view);
+	g_return_val_if_fail (class->create_plugin_widget != NULL, NULL);
+
+	return class->create_plugin_widget (web_view, mime_type, uri, param);
+}
+
+static void
+web_view_hovering_over_link_cb (EWebView *web_view,
+                                const gchar *title,
+                                const gchar *uri)
+{
+	EWebViewClass *class;
+
+	/* XXX WebKitWebView does not provide a class method for
+	 *     this signal, so we do so we can override the default
+	 *     behavior from subclasses for special URI types. */
+
+	class = E_WEB_VIEW_GET_CLASS (web_view);
+	g_return_if_fail (class->hovering_over_link != NULL);
+
+	class->hovering_over_link (web_view, title, uri);
+}
+
+static gboolean
+web_view_navigation_policy_decision_requested_cb (EWebView *web_view,
+                                                  WebKitWebFrame *frame,
+                                                  WebKitNetworkRequest *request,
+                                                  WebKitWebNavigationAction *navigation_action,
+                                                  WebKitWebPolicyDecision *policy_decision)
+{
+	EWebViewClass *class;
+	WebKitWebNavigationReason reason;
+	const gchar *uri;
+
+	reason = webkit_web_navigation_action_get_reason (navigation_action);
+	if (reason != WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED)
+		return FALSE;
+
+	/* XXX WebKitWebView does not provide a class method for
+	 *     this signal, so we do so we can override the default
+	 *     behavior from subclasses for special URI types. */
+
+	class = E_WEB_VIEW_GET_CLASS (web_view);
+	g_return_val_if_fail (class->link_clicked != NULL, FALSE);
+
+	webkit_web_policy_decision_ignore (policy_decision);
+
+	uri = webkit_network_request_get_uri (request);
+
+	class->link_clicked (web_view, uri);
+
+	return TRUE;
+}
+
+static void
+web_view_load_status_changed_cb (WebKitWebView *web_view,
+                                 GParamSpec *pspec,
+                                 gpointer user_data)
+{
+	WebKitLoadStatus status;
+
+	status = webkit_web_view_get_load_status (web_view);
+	if (status != WEBKIT_LOAD_FINISHED)
+		return;
+
+	web_view_update_document_highlights (E_WEB_VIEW (web_view));
+}
+
 static void
 web_view_set_property (GObject *object,
                        guint property_id,
@@ -567,12 +586,6 @@ web_view_set_property (GObject *object,
                        GParamSpec *pspec)
 {
 	switch (property_id) {
-		case PROP_ANIMATE:
-			e_web_view_set_animate (
-				E_WEB_VIEW (object),
-				g_value_get_boolean (value));
-			return;
-
 		case PROP_CARET_MODE:
 			e_web_view_set_caret_mode (
 				E_WEB_VIEW (object),
@@ -603,12 +616,6 @@ web_view_set_property (GObject *object,
 				g_value_get_boolean (value));
 			return;
 
-		case PROP_EDITABLE:
-			e_web_view_set_editable (
-				E_WEB_VIEW (object),
-				g_value_get_boolean (value));
-			return;
-
 		case PROP_INLINE_SPELLING:
 			e_web_view_set_inline_spelling (
 				E_WEB_VIEW (object),
@@ -662,24 +669,12 @@ web_view_get_property (GObject *object,
                        GParamSpec *pspec)
 {
 	switch (property_id) {
-		case PROP_ANIMATE:
-			g_value_set_boolean (
-				value, e_web_view_get_animate (
-				E_WEB_VIEW (object)));
-			return;
-
 		case PROP_CARET_MODE:
 			g_value_set_boolean (
 				value, e_web_view_get_caret_mode (
 				E_WEB_VIEW (object)));
 			return;
 
-		case PROP_COPY_TARGET_LIST:
-			g_value_set_boxed (
-				value, e_web_view_get_copy_target_list (
-				E_WEB_VIEW (object)));
-			return;
-
 		case PROP_CURSOR_IMAGE:
 			g_value_set_object (
 				value, e_web_view_get_cursor_image (
@@ -704,12 +699,6 @@ web_view_get_property (GObject *object,
 				E_WEB_VIEW (object)));
 			return;
 
-		case PROP_EDITABLE:
-			g_value_set_boolean (
-				value, e_web_view_get_editable (
-				E_WEB_VIEW (object)));
-			return;
-
 		case PROP_INLINE_SPELLING:
 			g_value_set_boolean (
 				value, e_web_view_get_inline_spelling (
@@ -734,12 +723,6 @@ web_view_get_property (GObject *object,
 				E_WEB_VIEW (object)));
 			return;
 
-		case PROP_PASTE_TARGET_LIST:
-			g_value_set_boxed (
-				value, e_web_view_get_paste_target_list (
-				E_WEB_VIEW (object)));
-			return;
-
 		case PROP_PRINT_PROXY:
 			g_value_set_object (
 				value, e_web_view_get_print_proxy (
@@ -789,16 +772,6 @@ web_view_dispose (GObject *object)
 		priv->save_as_proxy = NULL;
 	}
 
-	if (priv->copy_target_list != NULL) {
-		gtk_target_list_unref (priv->copy_target_list);
-		priv->copy_target_list = NULL;
-	}
-
-	if (priv->paste_target_list != NULL) {
-		gtk_target_list_unref (priv->paste_target_list);
-		priv->paste_target_list = NULL;
-	}
-
 	if (priv->cursor_image != NULL) {
 		g_object_unref (priv->cursor_image);
 		priv->cursor_image = NULL;
@@ -809,6 +782,16 @@ web_view_dispose (GObject *object)
 		priv->cursor_image_src = NULL;
 	}
 
+	if (priv->js_callbacks != NULL) {
+		g_hash_table_destroy (priv->js_callbacks);
+		priv->js_callbacks = NULL;
+	}
+
+	if (priv->highlights != NULL) {
+		g_slist_free_full (priv->highlights, g_free);
+		priv->highlights = NULL;
+	}
+
 	/* Chain up to parent's dispose() method. */
 	G_OBJECT_CLASS (parent_class)->dispose (object);
 }
@@ -861,12 +844,103 @@ web_view_button_press_event (GtkWidget *widget,
 {
 	GtkWidgetClass *widget_class;
 	EWebView *web_view;
+	gboolean event_handled = FALSE;
+	gchar *uri;
 
 	web_view = E_WEB_VIEW (widget);
 
-	if (web_view_button_press_event_cb (web_view, event, NULL))
+	if (event) {
+		WebKitHitTestResult *test;
+		WebKitHitTestResultContext context;
+
+		if (web_view->priv->cursor_image) {
+			g_object_unref (web_view->priv->cursor_image);
+			web_view->priv->cursor_image = NULL;
+		}
+
+		if (web_view->priv->cursor_image_src) {
+			g_free (web_view->priv->cursor_image_src);
+			web_view->priv->cursor_image_src = NULL;
+		}
+
+		test = webkit_web_view_get_hit_test_result (WEBKIT_WEB_VIEW (web_view), event);
+
+		if (!test)
+			goto chainup;
+
+                g_object_get (G_OBJECT (test), "context", &context, NULL);
+		if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE) {
+			WebKitWebDataSource *data_source;
+			WebKitWebFrame *frame;
+			GList *subresources, *res;
+
+                        g_object_get (G_OBJECT (test), "image-uri", &uri, NULL);
+
+			if (!uri)
+				goto chainup;
+
+			if (web_view->priv->cursor_image_src)
+				g_free (web_view->priv->cursor_image_src);
+			web_view->priv->cursor_image_src = uri;
+
+                        /* Iterate through all resources of the loaded webpage and
+			   try to find resource with URI matching cursor_image_src */
+			frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
+			data_source = webkit_web_frame_get_data_source (frame);
+			subresources = webkit_web_data_source_get_subresources (data_source);
+			for (res = subresources; res; res = res->next) {
+				WebKitWebResource *src = res->data;
+				GdkPixbufLoader *loader;
+				GString *data;
+
+				if (g_strcmp0 (webkit_web_resource_get_uri (src),
+					web_view->priv->cursor_image_src) != 0)
+					continue;
+
+				data = webkit_web_resource_get_data (src);
+				if (!data)
+					break;
+
+				loader = gdk_pixbuf_loader_new ();
+				if (!gdk_pixbuf_loader_write (loader,
+					(guchar *) data->str, data->len, NULL)) {
+					g_object_unref (loader);
+					break;
+				}
+				gdk_pixbuf_loader_close (loader, NULL);
+
+				if (web_view->priv->cursor_image)
+					g_object_unref (web_view->priv->cursor_image);
+
+				web_view->priv->cursor_image =
+					g_object_ref (gdk_pixbuf_loader_get_animation (loader));
+
+				g_object_unref (loader);
+				break;
+			}
+		}
+	}
+
+	if (event != NULL && event->button != 3)
+		goto chainup;
+
+	uri = e_web_view_extract_uri (web_view, event);
+
+	if (uri != NULL && g_str_has_prefix (uri, "##")) {
+		g_free (uri);
+		goto chainup;
+	}
+
+	g_signal_emit (
+		web_view, signals[POPUP_EVENT], 0,
+		event, uri, &event_handled);
+
+	g_free (uri);
+
+	if (event_handled)
 		return TRUE;
 
+chainup:
 	/* Chain up to parent's button_press_event() method. */
 	widget_class = GTK_WIDGET_CLASS (parent_class);
 	return widget_class->button_press_event (widget, event);
@@ -879,10 +953,10 @@ web_view_scroll_event (GtkWidget *widget,
 	if (event->state & GDK_CONTROL_MASK) {
 		switch (event->direction) {
 			case GDK_SCROLL_UP:
-				gtk_html_zoom_in (GTK_HTML (widget));
+				e_web_view_zoom_in (E_WEB_VIEW (widget));
 				return TRUE;
 			case GDK_SCROLL_DOWN:
-				gtk_html_zoom_out (GTK_HTML (widget));
+				e_web_view_zoom_out (E_WEB_VIEW (widget));
 				return TRUE;
 			default:
 				break;
@@ -892,74 +966,71 @@ web_view_scroll_event (GtkWidget *widget,
 	return FALSE;
 }
 
-static void
-web_view_url_requested (GtkHTML *html,
-                        const gchar *uri,
-                        GtkHTMLStream *stream)
+static GtkWidget *
+web_view_create_plugin_widget (EWebView *web_view,
+                               const gchar *mime_type,
+                               const gchar *uri,
+                               GHashTable *param)
 {
-	EWebViewRequest *request;
+	GtkWidget *widget = NULL;
 
-	request = web_view_request_new (E_WEB_VIEW (html), uri, stream);
+	if (g_strcmp0 (mime_type, "image/x-themed-icon") == 0) {
+		GtkIconTheme *icon_theme;
+		GdkPixbuf *pixbuf;
+		gpointer data;
+		glong size = 0;
+		GError *error = NULL;
 
-	g_file_read_async (
-		request->file, G_PRIORITY_DEFAULT,
-		request->cancellable, (GAsyncReadyCallback)
-		web_view_request_read_cb, request);
-}
+		icon_theme = gtk_icon_theme_get_default ();
 
-static void
-web_view_gtkhtml_link_clicked (GtkHTML *html,
-                               const gchar *uri)
-{
-	EWebViewClass *class;
-	EWebView *web_view;
+		if (size == 0) {
+			data = g_hash_table_lookup (param, "width");
+			if (data != NULL)
+				size = MAX (size, strtol (data, NULL, 10));
+		}
 
-	web_view = E_WEB_VIEW (html);
+		if (size == 0) {
+			data = g_hash_table_lookup (param, "height");
+			if (data != NULL)
+				size = MAX (size, strtol (data, NULL, 10));
+		}
 
-	class = E_WEB_VIEW_GET_CLASS (web_view);
-	g_return_if_fail (class->link_clicked != NULL);
+		if (size == 0)
+			size = 32;  /* arbitrary default */
+
+		pixbuf = gtk_icon_theme_load_icon (
+			icon_theme, uri, size, 0, &error);
+		if (pixbuf != NULL) {
+			widget = gtk_image_new_from_pixbuf (pixbuf);
+			g_object_unref (pixbuf);
+		} else if (error != NULL) {
+			g_warning ("%s", error->message);
+			g_error_free (error);
+		}
+	}
 
-	class->link_clicked (web_view, uri);
+	return widget;
 }
 
-static void
-web_view_on_url (GtkHTML *html,
-                 const gchar *uri)
+static gchar *
+web_view_extract_uri (EWebView *web_view,
+                      GdkEventButton *event)
 {
-	EWebViewClass *class;
-	EWebView *web_view;
-
-	web_view = E_WEB_VIEW (html);
-
-	class = E_WEB_VIEW_GET_CLASS (web_view);
-	g_return_if_fail (class->hovering_over_link != NULL);
+	WebKitHitTestResult *result;
+	WebKitHitTestResultContext context;
+	gchar *uri = NULL;
 
-	/* XXX WebKit would supply a title here. */
-	class->hovering_over_link (web_view, NULL, uri);
-}
+	result = webkit_web_view_get_hit_test_result (
+		WEBKIT_WEB_VIEW (web_view), event);
 
-static void
-web_view_iframe_created (GtkHTML *html,
-                         GtkHTML *iframe)
-{
-	g_signal_connect_swapped (
-		iframe, "button-press-event",
-		G_CALLBACK (web_view_button_press_event_cb), html);
-}
+	g_object_get (result, "context", &context, "link-uri", &uri, NULL);
 
-static gchar *
-web_view_extract_uri (EWebView *web_view,
-                      GdkEventButton *event,
-                      GtkHTML *html)
-{
-	gchar *uri;
+	if (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK)
+		return uri;
 
-	if (event != NULL)
-		uri = gtk_html_get_url_at (html, event->x, event->y);
-	else
-		uri = gtk_html_get_cursor_url (html);
+	g_free (uri);
 
-	return uri;
+	return NULL;
 }
 
 static void
@@ -1030,30 +1101,62 @@ 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);
+	if (string == NULL)
+		string = "";
+
+	webkit_web_view_load_string (
+		WEBKIT_WEB_VIEW (web_view),
+		string, "text/html", "UTF-8", "file://");
 }
 
 static void
-web_view_copy_clipboard (EWebView *web_view)
+web_view_load_uri (EWebView *web_view,
+                   const gchar *uri)
 {
-	gtk_html_command (GTK_HTML (web_view), "copy");
+	if (uri == NULL)
+		uri = "about:blank";
+
+	webkit_web_view_load_uri (
+		WEBKIT_WEB_VIEW (web_view), uri);
 }
 
 static void
-web_view_cut_clipboard (EWebView *web_view)
+web_view_frame_load_string (EWebView *web_view,
+                            const gchar *frame_name,
+                            const gchar *string)
 {
-	if (e_web_view_get_editable (web_view))
-		gtk_html_command (GTK_HTML (web_view), "cut");
+	WebKitWebFrame *main_frame, *frame;
+
+	if (string == NULL)
+		string = "";
+
+	main_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
+	if (main_frame) {
+		frame = webkit_web_frame_find_frame (main_frame, frame_name);
+
+		if (frame)
+			webkit_web_frame_load_string (
+				frame, string, "text/html", "UTF-8", "file://");
+	}
 }
 
 static void
-web_view_paste_clipboard (EWebView *web_view)
+web_view_frame_load_uri (EWebView *web_view,
+                         const gchar *frame_name,
+                         const gchar *uri)
 {
-	if (e_web_view_get_editable (web_view))
-		gtk_html_command (GTK_HTML (web_view), "paste");
+	WebKitWebFrame *main_frame, *frame;
+
+	if (uri == NULL)
+		uri = "about:blank";
+
+	main_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
+	if (main_frame) {
+		frame = webkit_web_frame_find_frame (main_frame, frame_name);
+
+		if (frame)
+			webkit_web_frame_load_uri (frame, uri);
+	}
 }
 
 static gboolean
@@ -1070,11 +1173,7 @@ web_view_popup_event (EWebView *web_view,
 static void
 web_view_stop_loading (EWebView *web_view)
 {
-	g_list_foreach (
-		web_view->priv->requests, (GFunc)
-		web_view_request_cancel, NULL);
-
-	gtk_html_stop (GTK_HTML (web_view));
+	webkit_web_view_stop_loading (WEBKIT_WEB_VIEW (web_view));
 }
 
 static void
@@ -1267,48 +1366,27 @@ web_view_selectable_update_actions (ESelectable *selectable,
                                     GdkAtom *clipboard_targets,
                                     gint n_clipboard_targets)
 {
-	EWebView *web_view;
+	WebKitWebView *web_view;
 	GtkAction *action;
-	/*GtkTargetList *target_list;*/
-	gboolean can_paste = FALSE;
-	gboolean editable;
-	gboolean have_selection;
 	gboolean sensitive;
 	const gchar *tooltip;
-	/*gint ii;*/
-
-	web_view = E_WEB_VIEW (selectable);
-	editable = e_web_view_get_editable (web_view);
-	have_selection = e_web_view_is_selection_active (web_view);
 
-	/* XXX GtkHtml implements its own clipboard instead of using
-	 *     GDK_SELECTION_CLIPBOARD, so we don't get notifications
-	 *     when the clipboard contents change.  The logic below
-	 *     is what we would do if GtkHtml worked properly.
-	 *     Instead, we need to keep the Paste action sensitive so
-	 *     its accelerator overrides GtkHtml's key binding. */
-#if 0
-	target_list = e_selectable_get_paste_target_list (selectable);
-	for (ii = 0; ii < n_clipboard_targets && !can_paste; ii++)
-		can_paste = gtk_target_list_find (
-			target_list, clipboard_targets[ii], NULL);
-#endif
-	can_paste = TRUE;
+	web_view = WEBKIT_WEB_VIEW (selectable);
 
 	action = e_focus_tracker_get_cut_clipboard_action (focus_tracker);
-	sensitive = editable && have_selection;
+	sensitive = webkit_web_view_can_cut_clipboard (web_view);
 	tooltip = _("Cut the selection");
 	gtk_action_set_sensitive (action, sensitive);
 	gtk_action_set_tooltip (action, tooltip);
 
 	action = e_focus_tracker_get_copy_clipboard_action (focus_tracker);
-	sensitive = have_selection;
+	sensitive = webkit_web_view_can_copy_clipboard (web_view);
 	tooltip = _("Copy the selection");
 	gtk_action_set_sensitive (action, sensitive);
 	gtk_action_set_tooltip (action, tooltip);
 
 	action = e_focus_tracker_get_paste_clipboard_action (focus_tracker);
-	sensitive = editable && can_paste;
+	sensitive = webkit_web_view_can_paste_clipboard (web_view);
 	tooltip = _("Paste the clipboard");
 	gtk_action_set_sensitive (action, sensitive);
 	gtk_action_set_tooltip (action, tooltip);
@@ -1349,7 +1427,9 @@ e_web_view_class_init (EWebViewClass *class)
 {
 	GObjectClass *object_class;
 	GtkWidgetClass *widget_class;
+#if 0  /* WEBKIT */
 	GtkHTMLClass *html_class;
+#endif
 
 	parent_class = g_type_class_peek_parent (class);
 	g_type_class_add_private (class, sizeof (EWebViewPrivate));
@@ -1365,35 +1445,25 @@ e_web_view_class_init (EWebViewClass *class)
 	widget_class->button_press_event = web_view_button_press_event;
 	widget_class->scroll_event = web_view_scroll_event;
 
+#if 0  /* WEBKIT */
 	html_class = GTK_HTML_CLASS (class);
 	html_class->url_requested = web_view_url_requested;
-	html_class->link_clicked = web_view_gtkhtml_link_clicked;
-	html_class->on_url = web_view_on_url;
-	html_class->iframe_created = web_view_iframe_created;
+#endif
 
+	class->create_plugin_widget = web_view_create_plugin_widget;
 	class->extract_uri = web_view_extract_uri;
 	class->hovering_over_link = web_view_hovering_over_link;
 	class->link_clicked = web_view_link_clicked;
 	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;
+	class->load_uri = web_view_load_uri;
+	class->frame_load_string = web_view_frame_load_string;
+	class->frame_load_uri = web_view_frame_load_uri;
 	class->popup_event = web_view_popup_event;
 	class->stop_loading = web_view_stop_loading;
 	class->update_actions = web_view_update_actions;
 
 	g_object_class_install_property (
 		object_class,
-		PROP_ANIMATE,
-		g_param_spec_boolean (
-			"animate",
-			"Animate Images",
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	g_object_class_install_property (
-		object_class,
 		PROP_CARET_MODE,
 		g_param_spec_boolean (
 			"caret-mode",
@@ -1402,12 +1472,6 @@ e_web_view_class_init (EWebViewClass *class)
 			FALSE,
 			G_PARAM_READWRITE));
 
-	/* Inherited from ESelectableInterface */
-	g_object_class_override_property (
-		object_class,
-		PROP_COPY_TARGET_LIST,
-		"copy-target-list");
-
 	g_object_class_install_property (
 		object_class,
 		PROP_CURSOR_IMAGE,
@@ -1452,16 +1516,6 @@ e_web_view_class_init (EWebViewClass *class)
 
 	g_object_class_install_property (
 		object_class,
-		PROP_EDITABLE,
-		g_param_spec_boolean (
-			"editable",
-			"Editable",
-			NULL,
-			FALSE,
-			G_PARAM_READWRITE));
-
-	g_object_class_install_property (
-		object_class,
 		PROP_INLINE_SPELLING,
 		g_param_spec_boolean (
 			"inline-spelling",
@@ -1500,12 +1554,6 @@ e_web_view_class_init (EWebViewClass *class)
 			GTK_TYPE_ACTION,
 			G_PARAM_READWRITE));
 
-	/* Inherited from ESelectableInterface */
-	g_object_class_override_property (
-		object_class,
-		PROP_PASTE_TARGET_LIST,
-		"paste-target-list");
-
 	g_object_class_install_property (
 		object_class,
 		PROP_PRINT_PROXY,
@@ -1536,33 +1584,6 @@ e_web_view_class_init (EWebViewClass *class)
 			NULL,
 			G_PARAM_READWRITE));
 
-	signals[COPY_CLIPBOARD] = g_signal_new (
-		"copy-clipboard",
-		G_TYPE_FROM_CLASS (class),
-		G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-		G_STRUCT_OFFSET (EWebViewClass, copy_clipboard),
-		NULL, NULL,
-		g_cclosure_marshal_VOID__VOID,
-		G_TYPE_NONE, 0);
-
-	signals[CUT_CLIPBOARD] = g_signal_new (
-		"cut-clipboard",
-		G_TYPE_FROM_CLASS (class),
-		G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-		G_STRUCT_OFFSET (EWebViewClass, cut_clipboard),
-		NULL, NULL,
-		g_cclosure_marshal_VOID__VOID,
-		G_TYPE_NONE, 0);
-
-	signals[PASTE_CLIPBOARD] = g_signal_new (
-		"paste-clipboard",
-		G_TYPE_FROM_CLASS (class),
-		G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-		G_STRUCT_OFFSET (EWebViewClass, paste_clipboard),
-		NULL, NULL,
-		g_cclosure_marshal_VOID__VOID,
-		G_TYPE_NONE, 0);
-
 	signals[POPUP_EVENT] = g_signal_new (
 		"popup-event",
 		G_TYPE_FROM_CLASS (class),
@@ -1634,26 +1655,46 @@ e_web_view_init (EWebView *web_view)
 {
 	GtkUIManager *ui_manager;
 	GtkActionGroup *action_group;
-	GtkTargetList *target_list;
 	EPopupAction *popup_action;
+	WebKitWebSettings *web_settings;
 	const gchar *domain = GETTEXT_PACKAGE;
 	const gchar *id;
 	GError *error = NULL;
 
 	web_view->priv = E_WEB_VIEW_GET_PRIVATE (web_view);
 
+	web_view->priv->highlights = NULL;
+
+	g_signal_connect (
+		web_view, "create-plugin-widget",
+		G_CALLBACK (web_view_create_plugin_widget_cb), NULL);
+
+	g_signal_connect (
+		web_view, "hovering-over-link",
+		G_CALLBACK (web_view_hovering_over_link_cb), NULL);
+
+	g_signal_connect (
+		web_view, "navigation-policy-decision-requested",
+		G_CALLBACK (web_view_navigation_policy_decision_requested_cb),
+		NULL);
+
+	g_signal_connect (
+                web_view, "notify::load-status",
+		G_CALLBACK (web_view_load_status_changed_cb), NULL);
+
 	ui_manager = gtk_ui_manager_new ();
 	web_view->priv->ui_manager = ui_manager;
 
+	web_view->priv->js_callbacks = g_hash_table_new_full (g_str_hash, g_str_equal,
+		(GDestroyNotify) g_free, NULL);
+
 	g_signal_connect_swapped (
 		ui_manager, "connect-proxy",
 		G_CALLBACK (web_view_connect_proxy_cb), web_view);
 
-	target_list = gtk_target_list_new (NULL, 0);
-	web_view->priv->copy_target_list = target_list;
-
-	target_list = gtk_target_list_new (NULL, 0);
-	web_view->priv->paste_target_list = target_list;
+	web_settings = e_web_view_get_default_settings (GTK_WIDGET (web_view));
+	e_web_view_set_settings (web_view, web_settings);
+	g_object_unref (web_settings);
 
 	action_group = gtk_action_group_new ("uri");
 	gtk_action_group_set_translation_domain (action_group, domain);
@@ -1763,6 +1804,7 @@ e_web_view_init (EWebView *web_view)
 	e_plugin_ui_enable_manager (ui_manager, id);
 
 	e_extensible_load_extensions (E_EXTENSIBLE (web_view));
+
 }
 
 GtkWidget *
@@ -1776,7 +1818,7 @@ e_web_view_clear (EWebView *web_view)
 {
 	g_return_if_fail (E_IS_WEB_VIEW (web_view));
 
-	gtk_html_load_empty (GTK_HTML (web_view));
+	e_web_view_load_string (web_view, NULL);
 }
 
 void
@@ -1793,54 +1835,316 @@ e_web_view_load_string (EWebView *web_view,
 	class->load_string (web_view, string);
 }
 
-gboolean
-e_web_view_get_animate (EWebView *web_view)
+void
+e_web_view_load_uri (EWebView *web_view,
+                     const gchar *uri)
 {
-	/* XXX This is just here to maintain symmetry
-	 *     with e_web_view_set_animate(). */
+	EWebViewClass *class;
 
-	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
+	g_return_if_fail (E_IS_WEB_VIEW (web_view));
+
+	class = E_WEB_VIEW_GET_CLASS (web_view);
+	g_return_if_fail (class->load_uri != NULL);
 
-	return gtk_html_get_animate (GTK_HTML (web_view));
+	class->load_uri (web_view, uri);
 }
 
 void
-e_web_view_set_animate (EWebView *web_view,
-                        gboolean animate)
+e_web_view_reload (EWebView *web_view)
 {
-	/* XXX GtkHTML does not utilize GObject properties as well
-	 *     as it could.  This just wraps gtk_html_set_animate()
-	 *     so we can get a "notify::animate" signal. */
+	g_return_if_fail (E_IS_WEB_VIEW (web_view));
+
+	webkit_web_view_reload (WEBKIT_WEB_VIEW (web_view));
+}
+
+const gchar *
+e_web_view_get_uri (EWebView *web_view)
+{
+	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
+
+	return webkit_web_view_get_uri (WEBKIT_WEB_VIEW (web_view));
+}
+
+void
+e_web_view_frame_load_string (EWebView *web_view,
+                              const gchar *frame_name,
+                              const gchar *string)
+{
+	EWebViewClass *class;
+
+	g_return_if_fail (E_IS_WEB_VIEW (web_view));
+	g_return_if_fail (frame_name != NULL);
+
+	class = E_WEB_VIEW_GET_CLASS (web_view);
+	g_return_if_fail (class->frame_load_string != NULL);
+
+	class->frame_load_string (web_view, frame_name, string);
+}
+
+void
+e_web_view_frame_load_uri (EWebView *web_view,
+                           const gchar *frame_name,
+                           const gchar *uri)
+{
+	EWebViewClass *class;
+
+	g_return_if_fail (E_IS_WEB_VIEW (web_view));
+	g_return_if_fail (frame_name != NULL);
+
+	class = E_WEB_VIEW_GET_CLASS (web_view);
+	g_return_if_fail (class->frame_load_uri != NULL);
+
+	class->frame_load_uri (web_view, frame_name, uri);
+}
+
+const gchar *
+e_web_view_frame_get_uri (EWebView *web_view,
+                          const gchar *frame_name)
+{
+	WebKitWebFrame *main_frame, *frame;
+
+	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
+	g_return_val_if_fail (frame_name != NULL, NULL);
+
+	main_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
+	if (main_frame) {
+		frame = webkit_web_frame_find_frame (main_frame, frame_name);
+
+		if (frame)
+			return webkit_web_frame_get_uri (frame);
+	}
+
+	return NULL;
+}
+
+gchar *
+e_web_view_get_html (EWebView *web_view)
+{
+	GValue html = {0};
+
+	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
+
+	if (e_web_view_exec_script (web_view, "return document.documentElement.innerHTML;", &html) == G_TYPE_STRING)
+		return g_strdup (g_value_get_string (&html));
+	else
+		return NULL;
+}
+
+JSGlobalContextRef
+e_web_view_get_global_context (EWebView *web_view)
+{
+	WebKitWebFrame *main_frame;
+
+	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), 0);
+
+	main_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
+	return webkit_web_frame_get_global_context (main_frame);
+}
+
+GType
+e_web_view_exec_script (EWebView *web_view,
+                        const gchar *script,
+                        GValue *value)
+{
+	WebKitWebFrame *main_frame;
+
+	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), G_TYPE_INVALID);
+	g_return_val_if_fail (script != NULL, G_TYPE_INVALID);
+
+	main_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
+
+	return e_web_view_frame_exec_script (web_view,
+		webkit_web_frame_get_name (main_frame),
+		script, value);
+}
+
+GType
+e_web_view_frame_exec_script (EWebView *web_view,
+                              const gchar *frame_name,
+                              const gchar *script,
+                              GValue *value)
+{
+	WebKitWebFrame *main_frame, *frame;
+	JSGlobalContextRef context;
+	JSValueRef js_value, error = NULL;
+	JSType js_type;
+	JSStringRef js_script;
+	JSStringRef js_str;
+	size_t str_len;
+	gchar *str;
+
+	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), G_TYPE_INVALID);
+	g_return_val_if_fail (script != NULL, G_TYPE_INVALID);
+
+	main_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
+	frame = webkit_web_frame_find_frame (main_frame, frame_name);
+
+	context = webkit_web_frame_get_global_context (frame);
+
+	js_script = JSStringCreateWithUTF8CString (script);
+	js_value = JSEvaluateScript (context, js_script, NULL, NULL, 0, &error);
+	JSStringRelease (js_script);
+
+	if (error) {
+		gchar *msg;
+		js_str = JSValueToStringCopy (context, error, NULL);
+		str_len = JSStringGetLength (js_str);
+
+		msg = g_malloc (str_len + 1);
+		JSStringGetUTF8CString (js_str, msg, str_len + 1);
+		JSStringRelease (js_str);
+
+		g_message ("JavaScript Execution Failed: %s", msg);
+		g_free (msg);
+
+		return G_TYPE_INVALID;
+	}
+
+	if (!value)
+		return G_TYPE_NONE;
+
+	js_type = JSValueGetType (context, js_value);
+	switch (js_type) {
+		case kJSTypeBoolean:
+			g_value_init (value, G_TYPE_BOOLEAN);
+			g_value_set_boolean (value, JSValueToBoolean (context, js_value));
+			break;
+		case kJSTypeNumber:
+			g_value_init (value, G_TYPE_DOUBLE);
+			g_value_set_double (value, JSValueToNumber (context, js_value, NULL));
+			break;
+		case kJSTypeString:
+			js_str = JSValueToStringCopy (context, js_value, NULL);
+			str_len = JSStringGetLength (js_str);
+			str = g_malloc (str_len + 1);
+			JSStringGetUTF8CString (js_str, str, str_len + 1);
+			JSStringRelease (js_str);
+			g_value_init (value, G_TYPE_STRING);
+			g_value_set_string (value, str);
+			g_free (str);
+			break;
+		case kJSTypeObject:
+			g_value_init (value, G_TYPE_OBJECT);
+			g_value_set_object (value, JSValueToObject (context, js_value, NULL));
+			break;
+		case kJSTypeNull:
+			g_value_init (value, G_TYPE_POINTER);
+			g_value_set_pointer (value, NULL);
+			break;
+		case kJSTypeUndefined:
+			break;
+	}
+
+	return G_VALUE_TYPE (value);
+}
+
+static JSValueRef
+web_view_handle_js_callback (JSContextRef ctx,
+                             JSObjectRef function,
+                             JSObjectRef this_object,
+                             size_t argument_count,
+                             const JSValueRef arguments[],
+                             JSValueRef *exception)
+{
+	gpointer web_view;
+	gpointer user_data;
+	gchar *fnc_name;
+	size_t fnc_name_len;
+
+	EWebViewJSFunctionCallback callback;
+
+	JSStringRef js_webview_prop = JSStringCreateWithUTF8CString ("webview");
+	JSStringRef js_userdata_prop = JSStringCreateWithUTF8CString ("user-data");
+	JSStringRef js_fncname_prop = JSStringCreateWithUTF8CString ("fnc-name");
+	JSStringRef js_fncname_str;
+
+	JSValueRef js_webview = JSObjectGetProperty (ctx, function, js_webview_prop, NULL);
+	JSValueRef js_userdata = JSObjectGetProperty (ctx, function, js_userdata_prop, NULL);
+	JSValueRef js_fncname = JSObjectGetProperty (ctx, function, js_fncname_prop, NULL);
+
+	web_view = GINT_TO_POINTER ((gint) JSValueToNumber (ctx, js_webview, NULL));
+	user_data = GINT_TO_POINTER ((gint) JSValueToNumber (ctx, js_userdata, NULL));
+	js_fncname_str = JSValueToStringCopy (ctx, js_fncname, NULL);
+	fnc_name_len = JSStringGetLength (js_fncname_str);
+
+	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), 0);
+
+	/* Convert fncname to gchar* and lookup the callback in hashtable */
+	fnc_name = g_malloc (fnc_name_len + 1);
+	JSStringGetUTF8CString (js_fncname_str, fnc_name, fnc_name_len + 1);
+	callback = g_hash_table_lookup (E_WEB_VIEW (web_view)->priv->js_callbacks, fnc_name);
+
+	g_return_val_if_fail (callback != NULL, 0);
+
+	/* Call the callback function */
+	callback (E_WEB_VIEW (web_view), argument_count, arguments, user_data);
+
+	JSStringRelease (js_fncname_str);
+	JSStringRelease (js_fncname_prop);
+	JSStringRelease (js_webview_prop);
+	JSStringRelease (js_userdata_prop);
+
+	g_free (fnc_name);
+
+	return 0;
+}
+
+void
+e_web_view_install_js_callback (EWebView *web_view,
+                                const gchar *fnc_name,
+                                EWebViewJSFunctionCallback callback,
+                                gpointer user_data)
+{
+	WebKitWebFrame *frame;
+	JSGlobalContextRef ctx;
+	JSObjectRef global_obj, js_func;
+	JSStringRef js_fnc_name, js_webview_prop, js_userdata_prop, js_fncname_prop;
 
 	g_return_if_fail (E_IS_WEB_VIEW (web_view));
+	g_return_if_fail (fnc_name != NULL);
+	g_return_if_fail (callback != NULL);
+
+	frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
+	ctx = webkit_web_frame_get_global_context (frame);
+	global_obj = JSContextGetGlobalObject (ctx);
+	js_fnc_name = JSStringCreateWithUTF8CString (fnc_name);
+	js_func = JSObjectMakeFunctionWithCallback (ctx, NULL,
+		(JSObjectCallAsFunctionCallback) web_view_handle_js_callback);
+	js_webview_prop = JSStringCreateWithUTF8CString ("webview");
+	js_userdata_prop = JSStringCreateWithUTF8CString ("user-data");
+	js_fncname_prop = JSStringCreateWithUTF8CString ("fnc-name");
 
-	gtk_html_set_animate (GTK_HTML (web_view), animate);
+	/* Set some properties to the function */
+	JSObjectSetProperty (ctx, js_func, js_webview_prop, JSValueMakeNumber (ctx, GPOINTER_TO_INT (web_view)), 0, NULL);
+	JSObjectSetProperty (ctx, js_func, js_userdata_prop, JSValueMakeNumber (ctx, GPOINTER_TO_INT (user_data)), 0, NULL);
+	JSObjectSetProperty (ctx, js_func, js_fncname_prop, JSValueMakeString (ctx, js_fnc_name), 0, NULL);
 
-	g_object_notify (G_OBJECT (web_view), "animate");
+	/* Set the function as a property of global object */
+	JSObjectSetProperty (ctx, global_obj, js_fnc_name, js_func, 0, NULL);
+
+	JSStringRelease (js_fncname_prop);
+	JSStringRelease (js_userdata_prop);
+	JSStringRelease (js_webview_prop);
+	JSStringRelease (js_fnc_name);
+
+	g_hash_table_insert (web_view->priv->js_callbacks, g_strdup (fnc_name), callback);
 }
 
 gboolean
 e_web_view_get_caret_mode (EWebView *web_view)
 {
-	/* XXX This is just here to maintain symmetry
-	 *     with e_web_view_set_caret_mode(). */
-
 	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
 
-	return gtk_html_get_caret_mode (GTK_HTML (web_view));
+	return web_view->priv->caret_mode;
 }
 
 void
 e_web_view_set_caret_mode (EWebView *web_view,
                            gboolean caret_mode)
 {
-	/* XXX GtkHTML does not utilize GObject properties as well
-	 *     as it could.  This just wraps gtk_html_set_caret_mode()
-	 *     so we can get a "notify::caret-mode" signal. */
-
 	g_return_if_fail (E_IS_WEB_VIEW (web_view));
 
-	gtk_html_set_caret_mode (GTK_HTML (web_view), caret_mode);
+	web_view->priv->caret_mode = caret_mode;
 
 	g_object_notify (G_OBJECT (web_view), "caret-mode");
 }
@@ -1850,7 +2154,8 @@ e_web_view_get_copy_target_list (EWebView *web_view)
 {
 	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
 
-	return web_view->priv->copy_target_list;
+	return webkit_web_view_get_copy_target_list (
+		WEBKIT_WEB_VIEW (web_view));
 }
 
 gboolean
@@ -1892,46 +2197,74 @@ e_web_view_set_disable_save_to_disk (EWebView *web_view,
 }
 
 gboolean
-e_web_view_get_editable (EWebView *web_view)
+e_web_view_get_enable_frame_flattening (EWebView * web_view)
 {
-	/* XXX This is just here to maintain symmetry
-	 *     with e_web_view_set_editable(). */
+	WebKitWebSettings *settings;
+	gboolean flattening;
+
+        /* Return TRUE with fail since it's default value we set in _init(). */
+	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), TRUE);
+
+	settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (web_view));
+	g_return_val_if_fail (settings != NULL, TRUE);
+
+        g_object_get (G_OBJECT (settings), "enable-frame-flattening", &flattening, NULL);
+
+	return flattening;
+}
+
+void
+e_web_view_set_enable_frame_flattening (EWebView * web_view,
+                                        gboolean enable_frame_flattening)
+{
+	WebKitWebSettings *settings;
+
+	g_return_if_fail (E_IS_WEB_VIEW (web_view));
+
+	settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (web_view));
+	g_return_if_fail (settings != NULL);
+
+        g_object_set (G_OBJECT (settings), "enable-frame-flattening",
+		enable_frame_flattening, NULL);
+}
 
+gboolean
+e_web_view_get_editable (EWebView *web_view)
+{
 	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
 
-	return gtk_html_get_editable (GTK_HTML (web_view));
+	return webkit_web_view_get_editable (WEBKIT_WEB_VIEW (web_view));
 }
 
 void
 e_web_view_set_editable (EWebView *web_view,
                          gboolean editable)
 {
-	/* XXX GtkHTML does not utilize GObject properties as well
-	 *     as it could.  This just wraps gtk_html_set_editable()
-	 *     so we can get a "notify::editable" signal. */
-
 	g_return_if_fail (E_IS_WEB_VIEW (web_view));
 
-	gtk_html_set_editable (GTK_HTML (web_view), editable);
-
-	g_object_notify (G_OBJECT (web_view), "editable");
+	webkit_web_view_set_editable (WEBKIT_WEB_VIEW (web_view), editable);
 }
 
 gboolean
 e_web_view_get_inline_spelling (EWebView *web_view)
 {
+#if 0  /* WEBKIT - XXX No equivalent property? */
 	/* XXX This is just here to maintain symmetry
 	 *     with e_web_view_set_inline_spelling(). */
 
 	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
 
 	return gtk_html_get_inline_spelling (GTK_HTML (web_view));
+#endif
+
+	return FALSE;
 }
 
 void
 e_web_view_set_inline_spelling (EWebView *web_view,
                                 gboolean inline_spelling)
 {
+#if 0  /* WEBKIT - XXX No equivalent property? */
 	/* XXX GtkHTML does not utilize GObject properties as well
 	 *     as it could.  This just wraps gtk_html_set_inline_spelling()
 	 *     so we get a "notify::inline-spelling" signal. */
@@ -1941,23 +2274,29 @@ e_web_view_set_inline_spelling (EWebView *web_view,
 	gtk_html_set_inline_spelling (GTK_HTML (web_view), inline_spelling);
 
 	g_object_notify (G_OBJECT (web_view), "inline-spelling");
+#endif
 }
 
 gboolean
 e_web_view_get_magic_links (EWebView *web_view)
 {
+#if 0  /* WEBKIT - XXX No equivalent property? */
 	/* XXX This is just here to maintain symmetry
 	 *     with e_web_view_set_magic_links(). */
 
 	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
 
 	return gtk_html_get_magic_links (GTK_HTML (web_view));
+#endif
+
+	return FALSE;
 }
 
 void
 e_web_view_set_magic_links (EWebView *web_view,
                             gboolean magic_links)
 {
+#if 0  /* WEBKIT - XXX No equivalent property? */
 	/* XXX GtkHTML does not utilize GObject properties as well
 	 *     as it could.  This just wraps gtk_html_set_magic_links()
 	 *     so we can get a "notify::magic-links" signal. */
@@ -1967,23 +2306,29 @@ e_web_view_set_magic_links (EWebView *web_view,
 	gtk_html_set_magic_links (GTK_HTML (web_view), magic_links);
 
 	g_object_notify (G_OBJECT (web_view), "magic-links");
+#endif
 }
 
 gboolean
 e_web_view_get_magic_smileys (EWebView *web_view)
 {
+#if 0  /* WEBKIT - No equivalent property? */
 	/* XXX This is just here to maintain symmetry
 	 *     with e_web_view_set_magic_smileys(). */
 
 	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
 
 	return gtk_html_get_magic_smileys (GTK_HTML (web_view));
+#endif
+
+	return FALSE;
 }
 
 void
 e_web_view_set_magic_smileys (EWebView *web_view,
                               gboolean magic_smileys)
 {
+#if 0  /* WEBKIT - No equivalent property? */
 	/* XXX GtkHTML does not utilize GObject properties as well
 	 *     as it could.  This just wraps gtk_html_set_magic_smileys()
 	 *     so we can get a "notify::magic-smileys" signal. */
@@ -1993,6 +2338,7 @@ e_web_view_set_magic_smileys (EWebView *web_view,
 	gtk_html_set_magic_smileys (GTK_HTML (web_view), magic_smileys);
 
 	g_object_notify (G_OBJECT (web_view), "magic-smileys");
+#endif
 }
 
 const gchar *
@@ -2092,7 +2438,8 @@ e_web_view_get_paste_target_list (EWebView *web_view)
 {
 	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
 
-	return web_view->priv->paste_target_list;
+	return webkit_web_view_get_paste_target_list (
+		WEBKIT_WEB_VIEW (web_view));
 }
 
 GtkAction *
@@ -2149,6 +2496,40 @@ e_web_view_set_save_as_proxy (EWebView *web_view,
 	g_object_notify (G_OBJECT (web_view), "save-as-proxy");
 }
 
+GSList *
+e_web_view_get_highlights (EWebView *web_view)
+{
+	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
+
+	return web_view->priv->highlights;
+}
+
+void
+e_web_view_add_highlight (EWebView *web_view,
+                          const gchar *highlight)
+{
+	g_return_if_fail (E_IS_WEB_VIEW (web_view));
+	g_return_if_fail (highlight && *highlight);
+
+	web_view->priv->highlights =
+		g_slist_append (web_view->priv->highlights, g_strdup (highlight));
+
+	web_view_update_document_highlights (web_view);
+}
+
+void e_web_view_clear_highlights (EWebView *web_view)
+{
+	g_return_if_fail (E_IS_WEB_VIEW (web_view));
+
+	if (!web_view->priv->highlights)
+		return;
+
+	g_slist_free_full (web_view->priv->highlights, g_free);
+	web_view->priv->highlights = NULL;
+
+	web_view_update_document_highlights (web_view);
+}
+
 GtkAction *
 e_web_view_get_action (EWebView *web_view,
                        const gchar *action_name)
@@ -2179,20 +2560,16 @@ e_web_view_get_action_group (EWebView *web_view,
 
 gchar *
 e_web_view_extract_uri (EWebView *web_view,
-                        GdkEventButton *event,
-                        GtkHTML *frame)
+                        GdkEventButton *event)
 {
 	EWebViewClass *class;
 
 	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
 
-	if (frame == NULL)
-		frame = GTK_HTML (web_view);
-
 	class = E_WEB_VIEW_GET_CLASS (web_view);
 	g_return_val_if_fail (class->extract_uri != NULL, NULL);
 
-	return class->extract_uri (web_view, event, frame);
+	return class->extract_uri (web_view, event);
 }
 
 void
@@ -2200,7 +2577,7 @@ e_web_view_copy_clipboard (EWebView *web_view)
 {
 	g_return_if_fail (E_IS_WEB_VIEW (web_view));
 
-	g_signal_emit (web_view, signals[COPY_CLIPBOARD], 0);
+	webkit_web_view_copy_clipboard (WEBKIT_WEB_VIEW (web_view));
 }
 
 void
@@ -2208,7 +2585,7 @@ e_web_view_cut_clipboard (EWebView *web_view)
 {
 	g_return_if_fail (E_IS_WEB_VIEW (web_view));
 
-	g_signal_emit (web_view, signals[CUT_CLIPBOARD], 0);
+	webkit_web_view_cut_clipboard (WEBKIT_WEB_VIEW (web_view));
 }
 
 gboolean
@@ -2216,7 +2593,7 @@ e_web_view_is_selection_active (EWebView *web_view)
 {
 	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
 
-	return gtk_html_command (GTK_HTML (web_view), "is-selection-active");
+	return webkit_web_view_has_selection (WEBKIT_WEB_VIEW (web_view));
 }
 
 void
@@ -2224,7 +2601,7 @@ e_web_view_paste_clipboard (EWebView *web_view)
 {
 	g_return_if_fail (E_IS_WEB_VIEW (web_view));
 
-	g_signal_emit (web_view, signals[PASTE_CLIPBOARD], 0);
+	webkit_web_view_paste_clipboard (WEBKIT_WEB_VIEW (web_view));
 }
 
 gboolean
@@ -2232,7 +2609,10 @@ e_web_view_scroll_forward (EWebView *web_view)
 {
 	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
 
-	return gtk_html_command (GTK_HTML (web_view), "scroll-forward");
+	webkit_web_view_move_cursor (
+		WEBKIT_WEB_VIEW (web_view), GTK_MOVEMENT_PAGES, 1);
+
+	return TRUE;  /* XXX This means nothing. */
 }
 
 gboolean
@@ -2240,7 +2620,10 @@ e_web_view_scroll_backward (EWebView *web_view)
 {
 	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), FALSE);
 
-	return gtk_html_command (GTK_HTML (web_view), "scroll-backward");
+	webkit_web_view_move_cursor (
+		WEBKIT_WEB_VIEW (web_view), GTK_MOVEMENT_PAGES, -1);
+
+	return TRUE;  /* XXX This means nothing. */
 }
 
 void
@@ -2248,15 +2631,17 @@ e_web_view_select_all (EWebView *web_view)
 {
 	g_return_if_fail (E_IS_WEB_VIEW (web_view));
 
-	gtk_html_command (GTK_HTML (web_view), "select-all");
+	webkit_web_view_select_all (WEBKIT_WEB_VIEW (web_view));
 }
 
 void
 e_web_view_unselect_all (EWebView *web_view)
 {
+#if 0  /* WEBKIT */
 	g_return_if_fail (E_IS_WEB_VIEW (web_view));
 
 	gtk_html_command (GTK_HTML (web_view), "unselect-all");
+#endif
 }
 
 void
@@ -2264,7 +2649,7 @@ 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");
+	webkit_web_view_set_zoom_level (WEBKIT_WEB_VIEW (web_view), 1.0);
 }
 
 void
@@ -2272,7 +2657,7 @@ 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");
+	webkit_web_view_zoom_in (WEBKIT_WEB_VIEW (web_view));
 }
 
 void
@@ -2280,7 +2665,7 @@ 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");
+	webkit_web_view_zoom_out (WEBKIT_WEB_VIEW (web_view));
 }
 
 GtkUIManager *
@@ -2354,3 +2739,84 @@ e_web_view_update_actions (EWebView *web_view)
 
 	g_signal_emit (web_view, signals[UPDATE_ACTIONS], 0);
 }
+
+gchar *
+e_web_view_get_selection_html (EWebView *web_view)
+{
+	WebKitDOMDocument *document;
+	WebKitDOMDOMWindow *window;
+	WebKitDOMDOMSelection *selection;
+	WebKitDOMRange *range;
+	WebKitDOMDocumentFragment *fragment;
+	WebKitDOMHTMLElement *element;
+
+	g_return_val_if_fail (E_IS_WEB_VIEW (web_view), NULL);
+
+	if (!webkit_web_view_has_selection (WEBKIT_WEB_VIEW (web_view)))
+		return NULL;
+
+	document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (web_view));
+	window = webkit_dom_document_get_default_view (document);
+	selection = webkit_dom_dom_window_get_selection (window);
+	if (!selection)
+		return NULL;
+
+	range = webkit_dom_dom_selection_get_range_at (selection, 0, NULL);
+	if (!range)
+		return NULL;
+
+	fragment = webkit_dom_range_clone_contents (range, NULL);
+	if (!fragment)
+		return NULL;
+
+        element = WEBKIT_DOM_HTML_ELEMENT (webkit_dom_document_create_element (document, "div", NULL));
+	webkit_dom_node_append_child (WEBKIT_DOM_NODE (element),
+		WEBKIT_DOM_NODE (fragment), NULL);
+
+	return webkit_dom_html_element_get_inner_html (element);
+}
+
+void
+e_web_view_set_settings (EWebView *web_view,
+                         WebKitWebSettings *settings)
+{
+	g_return_if_fail (E_IS_WEB_VIEW (web_view));
+
+	if (settings == webkit_web_view_get_settings (WEBKIT_WEB_VIEW (web_view)))
+		return;
+
+	g_object_bind_property (settings, "enable-caret-browsing", web_view, "caret-mode",
+		G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+
+	webkit_web_view_set_settings (WEBKIT_WEB_VIEW (web_view), settings);
+}
+
+WebKitWebSettings *
+e_web_view_get_default_settings (GtkWidget *parent_widget)
+{
+	GtkStyleContext *context;
+	const PangoFontDescription *font;
+	WebKitWebSettings *settings;
+
+	g_return_val_if_fail (GTK_IS_WIDGET (parent_widget), NULL);
+
+	settings = webkit_web_settings_new ();
+
+	/* Use same font-size as rest of Evolution */
+	context = gtk_widget_get_style_context (parent_widget);
+	font = gtk_style_context_get_font (context, GTK_STATE_FLAG_NORMAL);
+
+	g_object_set (G_OBJECT (settings),
+                "default-font-size", (pango_font_description_get_size (font) / PANGO_SCALE),
+                "default-monospace-font-size", (pango_font_description_get_size (font) / PANGO_SCALE),
+                "enable-frame-flattening", TRUE, 
+                "enable-java-applet", FALSE,
+                "enable-html5-database", FALSE,
+                "enable-html5-local-storage", FALSE,
+                "enable-offline-web-application-cache", FALSE,
+                "enable-site-specific-quirks", TRUE,
+                "enable-scripts", FALSE,
+		NULL);
+
+	return settings;
+}
diff --git a/widgets/misc/e-web-view.h b/widgets/misc/e-web-view.h
index 1ca9915..d71cf04 100644
--- a/widgets/misc/e-web-view.h
+++ b/widgets/misc/e-web-view.h
@@ -27,7 +27,8 @@
 #ifndef E_WEB_VIEW_H
 #define E_WEB_VIEW_H
 
-#include <gtkhtml/gtkhtml.h>
+#include <webkit/webkit.h>
+#include <JavaScriptCore/JavaScript.h>
 
 /* Standard GObject macros */
 #define E_TYPE_WEB_VIEW \
@@ -55,17 +56,25 @@ typedef struct _EWebViewClass EWebViewClass;
 typedef struct _EWebViewPrivate EWebViewPrivate;
 
 struct _EWebView {
-	GtkHTML parent;
+	WebKitWebView parent;
 	EWebViewPrivate *priv;
 };
 
+typedef void (*EWebViewJSFunctionCallback)	(EWebView *web_view,
+						 size_t arg_count,
+						 const JSValueRef args[],
+						 gpointer user_data);
+
 struct _EWebViewClass {
-	GtkHTMLClass parent_class;
+	WebKitWebViewClass parent_class;
 
 	/* Methods */
+	GtkWidget *	(*create_plugin_widget)	(EWebView *web_view,
+						 const gchar *mime_type,
+						 const gchar *uri,
+						 GHashTable *param);
 	gchar *		(*extract_uri)		(EWebView *web_view,
-						 GdkEventButton *event,
-						 GtkHTML *frame);
+						 GdkEventButton *event);
 	void		(*hovering_over_link)	(EWebView *web_view,
 						 const gchar *title,
 						 const gchar *uri);
@@ -73,11 +82,15 @@ struct _EWebViewClass {
 						 const gchar *uri);
 	void		(*load_string)		(EWebView *web_view,
 						 const gchar *load_string);
-
+	void		(*load_uri)		(EWebView *web_view,
+						 const gchar *load_uri);
+	void		(*frame_load_string)	(EWebView *web_view,
+						 const gchar *frame_name,
+						 const gchar *string);
+	void		(*frame_load_uri)	(EWebView *web_view,
+						 const gchar *frame_name,
+						 const gchar *uri);
 	/* Signals */
-	void		(*copy_clipboard)	(EWebView *web_view);
-	void		(*cut_clipboard)	(EWebView *web_view);
-	void		(*paste_clipboard)	(EWebView *web_view);
 	gboolean	(*popup_event)		(EWebView *web_view,
 						 GdkEventButton *event,
 						 const gchar *uri);
@@ -94,9 +107,32 @@ GtkWidget *	e_web_view_new			(void);
 void		e_web_view_clear		(EWebView *web_view);
 void		e_web_view_load_string		(EWebView *web_view,
 						 const gchar *string);
-gboolean	e_web_view_get_animate		(EWebView *web_view);
-void		e_web_view_set_animate		(EWebView *web_view,
-						 gboolean animate);
+void		e_web_view_load_uri		(EWebView *web_view,
+						 const gchar *uri);
+const gchar *	e_web_view_get_uri		(EWebView *web_view);
+void		e_web_view_reload		(EWebView *web_view);
+void		e_web_view_frame_load_string	(EWebView *web_view,
+						 const gchar *frame_name,
+						 const gchar *string);
+void		e_web_view_frame_load_uri	(EWebView *web_view,
+						 const gchar *frame_name,
+						 const gchar *uri);
+const gchar *	e_web_view_frame_get_uri	(EWebView *web_view,
+						 const gchar *frame_name);
+JSGlobalContextRef
+		e_web_view_get_global_context	(EWebView *web_view);
+GType		e_web_view_exec_script		(EWebView *web_view,
+						 const gchar *script,
+						 GValue *value);
+GType		e_web_view_frame_exec_script	(EWebView *web_view,
+						 const gchar *frame_name,
+						 const gchar *script,
+						 GValue *value);
+void		e_web_view_install_js_callback  (EWebView *web_view,
+						 const gchar *fnc_name,
+						 EWebViewJSFunctionCallback callback,
+						 gpointer user_data);
+gchar *		e_web_view_get_html		(EWebView *web_view);
 gboolean	e_web_view_get_caret_mode	(EWebView *web_view);
 void		e_web_view_set_caret_mode	(EWebView *web_view,
 						 gboolean caret_mode);
@@ -109,6 +145,11 @@ gboolean	e_web_view_get_disable_save_to_disk
 void		e_web_view_set_disable_save_to_disk
 						(EWebView *web_view,
 						 gboolean disable_save_to_disk);
+gboolean        e_web_view_get_enable_frame_flattening
+                                                (EWebView *web_view);
+void            e_web_view_set_enable_frame_flattening
+                                                (EWebView *web_view,
+                                                 gboolean enable_frame_flattening);
 gboolean	e_web_view_get_editable		(EWebView *web_view);
 void		e_web_view_set_editable		(EWebView *web_view,
 						 gboolean editable);
@@ -142,13 +183,16 @@ void		e_web_view_set_print_proxy	(EWebView *web_view,
 GtkAction *	e_web_view_get_save_as_proxy	(EWebView *web_view);
 void		e_web_view_set_save_as_proxy	(EWebView *web_view,
 						 GtkAction *save_as_proxy);
+GSList *         e_web_view_get_highlights       (EWebView *web_view);
+void            e_web_view_add_highlight        (EWebView *web_view,
+                                                 const gchar *highlight);
+void            e_web_view_clear_highlights     (EWebView *web_view);
 GtkAction *	e_web_view_get_action		(EWebView *web_view,
 						 const gchar *action_name);
 GtkActionGroup *e_web_view_get_action_group	(EWebView *web_view,
 						 const gchar *group_name);
 gchar *		e_web_view_extract_uri		(EWebView *web_view,
-						 GdkEventButton *event,
-						 GtkHTML *frame);
+						 GdkEventButton *event);
 void		e_web_view_copy_clipboard	(EWebView *web_view);
 void		e_web_view_cut_clipboard	(EWebView *web_view);
 gboolean	e_web_view_is_selection_active	(EWebView *web_view);
@@ -171,6 +215,13 @@ void		e_web_view_status_message	(EWebView *web_view,
 void		e_web_view_stop_loading		(EWebView *web_view);
 void		e_web_view_update_actions	(EWebView *web_view);
 
+gchar *          e_web_view_get_selection_html   (EWebView *web_view);
+
+void		e_web_view_set_settings		(EWebView *web_view,
+						 WebKitWebSettings *settings);
+WebKitWebSettings *
+		e_web_view_get_default_settings ();
+
 G_END_DECLS
 
 #endif /* E_WEB_VIEW_H */



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