[evolution/webkit: 16/196] Convert EMailDisplay to GtkScrolledWindow and change the way EMFormat is used.



commit bd65488068d7d6752bc748c6309cb622735a5658
Author: Dan VrÃtil <dvratil redhat com>
Date:   Fri Aug 26 16:29:38 2011 +0200

    Convert EMailDisplay to GtkScrolledWindow and change the way EMFormat is used.
    
    Because embedding widgets directly into WebKit is broken, I decided to
    split the email into multiple webview, thus allowing me to embbed
    GtkWidgets between the webviews directly to a parent container.
    
    The idea is to have EMailDisplay to implement most of the API of EWebView, thus
    making it to look like a single EWebView from the outside. The EMailDisplay
    would then work as a "proxy" resending the commands/signals/etc to all the
    EWebViews and widgets it would manage.
    
    This also requires completely another way of using EMFormat. Till now, it was
    EMFormat-per-EMailDisplay. Since now, it's EMFormat-per-mail. This way, displaying
    the same email in multiple views (the preview pane and EMailBrowser for example)
    requires the email to be parsed only once and then the write_func of the required
    mail parts are called. This can have positive impact on performance and user experience.
    
    FIXME: For now, all created EMFormat objects remain stored in SoupSession and are not
    removed even after the mail is not being displayed in any view. This is a big memleak
    that needs to be fixed definitely.

 mail/e-mail-browser.c                    |   61 ++---
 mail/e-mail-browser.h                    |    6 +-
 mail/e-mail-display.c                    |  436 ++++++++++++++++++++++++++----
 mail/e-mail-display.h                    |   51 +++-
 mail/e-mail-notebook-view.c              |   18 +-
 mail/e-mail-paned-view.c                 |   61 +++--
 mail/e-mail-paned-view.h                 |    1 +
 mail/e-mail-reader-utils.c               |   32 ++-
 mail/e-mail-reader.c                     |  215 +++++++--------
 mail/e-mail-reader.h                     |    6 +-
 mail/e-mail-request.c                    |  112 ++++++--
 mail/em-format-html-display.c            |   60 ++++-
 mail/em-format-html-print.c              |   46 +++-
 mail/em-format-html.c                    |    4 +-
 mail/em-utils.c                          |   17 +-
 modules/mail/e-mail-shell-backend.c      |    5 +-
 modules/mail/e-mail-shell-content.c      |   10 +-
 modules/mail/e-mail-shell-view-actions.c |   22 +-
 modules/mail/e-mail-shell-view-private.c |   41 ++--
 19 files changed, 839 insertions(+), 365 deletions(-)
---
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c
index 7b7ee2d..f53f0aa 100644
--- a/mail/e-mail-browser.c
+++ b/mail/e-mail-browser.c
@@ -55,7 +55,7 @@ struct _EMailBrowserPrivate {
 	EMailBackend *backend;
 	GtkUIManager *ui_manager;
 	EFocusTracker *focus_tracker;
-	EMFormatHTMLDisplay *formatter;
+	EMailDisplay *display;
 
 	GtkWidget *main_menu;
 	GtkWidget *main_toolbar;
@@ -260,11 +260,10 @@ static void
 mail_browser_message_selected_cb (EMailBrowser *browser,
                                   const gchar *uid)
 {
-	EMFormatHTML *formatter;
 	CamelMessageInfo *info;
 	CamelFolder *folder;
 	EMailReader *reader;
-	EWebView *web_view;
+	EMailDisplay *display;
 	const gchar *title;
 	guint32 state;
 
@@ -276,8 +275,7 @@ mail_browser_message_selected_cb (EMailBrowser *browser,
 		return;
 
 	folder = e_mail_reader_get_folder (reader);
-	formatter = e_mail_reader_get_formatter (reader);
-	web_view = em_format_html_get_web_view (formatter);
+	display = e_mail_reader_get_mail_display (reader);
 
 	info = camel_folder_get_message_info (folder, uid);
 
@@ -289,7 +287,7 @@ mail_browser_message_selected_cb (EMailBrowser *browser,
 		title = _("(No Subject)");
 
 	gtk_window_set_title (GTK_WINDOW (browser), title);
-	gtk_widget_grab_focus (GTK_WIDGET (web_view));
+	gtk_widget_grab_focus (GTK_WIDGET (display));
 
 	camel_message_info_set_flags (
 		info, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
@@ -319,7 +317,7 @@ mail_browser_popup_event_cb (EMailBrowser *browser,
                              GdkEventButton *event,
                              const gchar *uri)
 {
-	EMFormatHTML *formatter;
+	EMailDisplay *display;
 	EMailReader *reader;
 	EWebView *web_view;
 	GtkMenu *menu;
@@ -329,8 +327,8 @@ mail_browser_popup_event_cb (EMailBrowser *browser,
 		return FALSE;
 
 	reader = E_MAIL_READER (browser);
-	formatter = e_mail_reader_get_formatter (reader);
-	web_view = em_format_html_get_web_view (formatter);
+	display = e_mail_reader_get_mail_display (reader);
+	web_view = e_mail_display_get_current_web_view (display);
 
 	if (e_web_view_get_cursor_image (web_view) != NULL)
 		return FALSE;
@@ -495,11 +493,6 @@ mail_browser_dispose (GObject *object)
 		priv->focus_tracker = NULL;
 	}
 
-	if (priv->formatter != NULL) {
-		g_object_unref (priv->formatter);
-		priv->formatter = NULL;
-	}
-
 	if (priv->main_menu != NULL) {
 		g_object_unref (priv->main_menu);
 		priv->main_menu = NULL;
@@ -533,8 +526,8 @@ mail_browser_dispose (GObject *object)
 static void
 mail_browser_constructed (GObject *object)
 {
+	EMailBrowserPrivate *priv;
 	EMailBrowser *browser;
-	EMFormatHTML *formatter;
 	EMailReader *reader;
 	EMailBackend *backend;
 	EMailSession *session;
@@ -549,7 +542,6 @@ mail_browser_constructed (GObject *object)
 	GtkUIManager *ui_manager;
 	GtkWidget *container;
 	GtkWidget *widget;
-	EWebView *web_view;
 	const gchar *domain;
 	const gchar *id;
 	guint merge_id;
@@ -558,6 +550,7 @@ mail_browser_constructed (GObject *object)
 	G_OBJECT_CLASS (parent_class)->constructed (object);
 
 	browser = E_MAIL_BROWSER (object);
+	priv = E_MAIL_BROWSER_GET_PRIVATE (browser);
 
 	reader = E_MAIL_READER (object);
 	backend = e_mail_reader_get_backend (reader);
@@ -575,8 +568,7 @@ mail_browser_constructed (GObject *object)
 	gtk_application_add_window (
 		GTK_APPLICATION (shell), GTK_WINDOW (object));
 
-	formatter = e_mail_reader_get_formatter (reader);
-	web_view = em_format_html_get_web_view (formatter);
+	priv->display = e_mail_reader_get_mail_display (reader);
 
 	/* The message list is a widget, but it is not shown in the browser.
 	 * Unfortunately, the widget is inseparable from its model, and the
@@ -593,11 +585,11 @@ mail_browser_constructed (GObject *object)
 		G_CALLBACK (mail_browser_message_list_built_cb), object);
 
 	g_signal_connect_swapped (
-		web_view, "popup-event",
+		priv->display, "popup-event",
 		G_CALLBACK (mail_browser_popup_event_cb), object);
 
 	g_signal_connect_swapped (
-		web_view, "status-message",
+		priv->display, "status-message",
 		G_CALLBACK (mail_browser_status_message_cb), object);
 
 	/* Add action groups before initializing the reader interface. */
@@ -684,19 +676,19 @@ mail_browser_constructed (GObject *object)
 		gtk_widget_get_style_context (widget),
 		GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
 
-	gtk_widget_show (GTK_WIDGET (web_view));
+	gtk_widget_show (GTK_WIDGET (priv->display));
 
-	widget = e_preview_pane_new (web_view);
+	widget = GTK_WIDGET (priv->display);
 	gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
 	browser->priv->preview_pane = g_object_ref (widget);
 	gtk_widget_show (widget);
 
-	search_bar = e_preview_pane_get_search_bar (E_PREVIEW_PANE (widget));
+	search_bar = e_mail_display_get_search_bar (priv->display);
 
 	g_signal_connect_swapped (
 		search_bar, "changed",
-		G_CALLBACK (e_web_view_reload),
-		web_view);
+		G_CALLBACK (e_mail_display_reload),
+		priv->display);
 
 	/* Bind GObject properties to GSettings keys. */
 
@@ -772,14 +764,14 @@ mail_browser_get_hide_deleted (EMailReader *reader)
 	return !e_mail_browser_get_show_deleted (browser);
 }
 
-static EMFormatHTML *
-mail_browser_get_formatter (EMailReader *reader)
+static EMailDisplay *
+mail_browser_get_mail_display (EMailReader *reader)
 {
-	EMailBrowser *browser;
+	EMailBrowserPrivate *priv;
 
-	browser = E_MAIL_BROWSER (reader);
+	priv = E_MAIL_BROWSER_GET_PRIVATE (E_MAIL_BROWSER (reader));
 
-	return EM_FORMAT_HTML (browser->priv->formatter);
+	return priv->display;
 }
 
 static GtkWidget *
@@ -923,7 +915,7 @@ e_mail_browser_reader_init (EMailReaderInterface *interface)
 {
 	interface->get_action_group = mail_browser_get_action_group;
 	interface->get_backend = mail_browser_get_backend;
-	interface->get_formatter = mail_browser_get_formatter;
+	interface->get_mail_display = mail_browser_get_mail_display;
 	interface->get_hide_deleted = mail_browser_get_hide_deleted;
 	interface->get_message_list = mail_browser_get_message_list;
 	interface->get_popup_menu = mail_browser_get_popup_menu;
@@ -936,7 +928,7 @@ static void
 e_mail_browser_init (EMailBrowser *browser)
 {
 	browser->priv = E_MAIL_BROWSER_GET_PRIVATE (browser);
-	browser->priv->formatter = em_format_html_display_new ();
+	browser->priv->display = g_object_new (E_TYPE_MAIL_DISPLAY, NULL);
 
 	gtk_window_set_title (GTK_WINDOW (browser), _("Evolution"));
 	gtk_window_set_default_size (GTK_WINDOW (browser), 600, 400);
@@ -948,7 +940,10 @@ e_mail_browser_init (EMailBrowser *browser)
 }
 
 GtkWidget *
-e_mail_browser_new (EMailBackend *backend)
+e_mail_browser_new (EMailBackend *backend,
+		    CamelFolder *folder,
+		    const gchar *msg_uid,
+		    EMailDisplayMode mode)
 {
 	g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
 
diff --git a/mail/e-mail-browser.h b/mail/e-mail-browser.h
index c09c85b..90ea53a 100644
--- a/mail/e-mail-browser.h
+++ b/mail/e-mail-browser.h
@@ -24,6 +24,7 @@
 
 #include <mail/e-mail-backend.h>
 #include <misc/e-focus-tracker.h>
+#include <mail/e-mail-display.h>
 
 /* Standard GObject macros */
 #define E_TYPE_MAIL_BROWSER \
@@ -60,7 +61,10 @@ struct _EMailBrowserClass {
 };
 
 GType		e_mail_browser_get_type		(void);
-GtkWidget *	e_mail_browser_new		(EMailBackend *backend);
+GtkWidget *	e_mail_browser_new		(EMailBackend *backend,
+						 CamelFolder *folder,
+						 const gchar *message_uid,
+						 EMailDisplayMode mode);
 void		e_mail_browser_close		(EMailBrowser *browser);
 gboolean	e_mail_browser_get_show_deleted	(EMailBrowser *browser);
 void		e_mail_browser_set_show_deleted (EMailBrowser *browser,
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index f7a5a33..8494c93 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -34,6 +34,8 @@
 #include "mail/em-composer-utils.h"
 #include "mail/em-utils.h"
 #include "mail/e-mail-request.h"
+#include "mail/em-format-html-display.h"
+#include "mail/e-mail-attachment-bar.h"
 
 #include <libsoup/soup.h>
 #include <libsoup/soup-requester.h>
@@ -43,14 +45,24 @@
 	((obj), E_TYPE_MAIL_DISPLAY, EMailDisplayPrivate))
 
 struct _EMailDisplayPrivate {
+	GtkWidget *vbox;
+
+	ESearchBar *searchbar;
 	EMFormatHTML *formatter;
+
+	EMailDisplayMode display_mode;
 };
 
 enum {
 	PROP_0,
-	PROP_FORMATTER
+	PROP_FORMATTER,
+	PROP_DISPLAY_MODE
 };
 
+static gpointer parent_class;
+
+typedef void (*WebViewActionFunc) (EWebView *web_view);
+
 static const gchar *ui =
 "<ui>"
 "  <popup name='context'>"
@@ -64,6 +76,7 @@ static const gchar *ui =
 "        <menuitem action='search-folder-sender'/>"
 "      </menu>"
 "    </placeholder>"
+"    <placeholder name='inspect' />"
 "  </popup>"
 "</ui>";
 
@@ -107,8 +120,6 @@ static GtkActionEntry mailto_entries[] = {
 	  NULL }
 };
 
-G_DEFINE_TYPE (EMailDisplay, e_mail_display, E_TYPE_WEB_VIEW)
-
 static void
 mail_display_update_formatter_colors (EMailDisplay *display)
 {
@@ -121,6 +132,9 @@ mail_display_update_formatter_colors (EMailDisplay *display)
 	state = gtk_widget_get_state (GTK_WIDGET (display));
 	formatter = display->priv->formatter;
 
+	if (!display->priv->formatter)
+		return;
+
 	style = gtk_widget_get_style (GTK_WIDGET (display));
 	if (style == NULL)
 		return;
@@ -162,6 +176,11 @@ mail_display_set_property (GObject *object,
 				E_MAIL_DISPLAY (object),
 				g_value_get_object (value));
 			return;
+		case PROP_DISPLAY_MODE:
+			e_mail_display_set_mode (
+				E_MAIL_DISPLAY (object),
+				g_value_get_int (value));
+			return;
 	}
 
 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -179,6 +198,11 @@ mail_display_get_property (GObject *object,
 				value, e_mail_display_get_formatter (
 				E_MAIL_DISPLAY (object)));
 			return;
+		case PROP_DISPLAY_MODE:
+			g_value_set_int (
+				value, e_mail_display_get_mode (
+				E_MAIL_DISPLAY (object)));
+			return;
 	}
 
 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -196,15 +220,20 @@ mail_display_dispose (GObject *object)
 		priv->formatter = NULL;
 	}
 
+	if (priv->searchbar) {
+		g_object_unref (priv->searchbar);
+		priv->searchbar = NULL;
+	}
+
 	/* Chain up to parent's dispose() method. */
-	G_OBJECT_CLASS (e_mail_display_parent_class)->dispose (object);
+	G_OBJECT_CLASS (parent_class)->dispose (object);
 }
 
 static void
 mail_display_realize (GtkWidget *widget)
 {
 	/* Chain up to parent's realize() method. */
-	GTK_WIDGET_CLASS (e_mail_display_parent_class)->realize (widget);
+	GTK_WIDGET_CLASS (parent_class)->realize (widget);
 
 	mail_display_update_formatter_colors (E_MAIL_DISPLAY (widget));
 }
@@ -213,22 +242,26 @@ static void
 mail_display_style_set (GtkWidget *widget,
                         GtkStyle *previous_style)
 {
+	EMailDisplay *display = E_MAIL_DISPLAY (widget);
+
 	/* Chain up to parent's style_set() method. */
-	GTK_WIDGET_CLASS (e_mail_display_parent_class)->
-		style_set (widget, previous_style);
+	GTK_WIDGET_CLASS (parent_class)->style_set (widget, previous_style);
 
-	mail_display_update_formatter_colors (E_MAIL_DISPLAY (widget));
+	mail_display_update_formatter_colors (display);
 
-	e_web_view_reload (E_WEB_VIEW (widget));
+	e_mail_display_reload (display);
 }
 
 static gboolean
 mail_display_process_mailto (EWebView *web_view,
-                             const gchar *mailto_uri)
+                             const gchar *mailto_uri,
+                             gpointer user_data)
 {
+	EMailDisplay *display = user_data;
+
 	g_return_val_if_fail (web_view != NULL, FALSE);
 	g_return_val_if_fail (mailto_uri != NULL, FALSE);
-	g_return_val_if_fail (E_IS_MAIL_DISPLAY (web_view), FALSE);
+	g_return_val_if_fail (E_IS_MAIL_DISPLAY (display), FALSE);
 
 	if (g_ascii_strncasecmp (mailto_uri, "mailto:";, 7) == 0) {
 		EMailDisplayPrivate *priv;
@@ -269,7 +302,7 @@ mail_display_link_clicked (WebKitWebView *web_view,
 	priv = E_MAIL_DISPLAY_GET_PRIVATE (display);
 	g_return_val_if_fail (priv->formatter != NULL, FALSE);
 
-	if (mail_display_process_mailto (E_WEB_VIEW (display), uri)) {
+	if (mail_display_process_mailto (E_WEB_VIEW (web_view), uri, display)) {
 		/* do nothing, function handled the "mailto:"; uri already */
 		webkit_web_policy_decision_ignore (policy_decision);
 		return TRUE;
@@ -294,17 +327,17 @@ static void
 mail_display_resource_requested (WebKitWebView *web_view,
 				 WebKitWebFrame *frame,
 				 WebKitWebResource *resource,
-                        	 WebKitNetworkRequest *request,
-                        	 WebKitNetworkResponse *response,
-                        	 gpointer user_data)
+				 WebKitNetworkRequest *request,
+				 WebKitNetworkResponse *response,
+				 gpointer user_data)
 {
-	EMFormatHTML *formatter = E_MAIL_DISPLAY (web_view)->priv->formatter;
+	EMailDisplay *display = user_data;
+	EMFormatHTML *formatter = display->priv->formatter;
 	const gchar *uri = webkit_network_request_get_uri (request);
 
         /* Redirect cid:part_id to mail://mail_id/cid:part_id */
         if (g_str_has_prefix (uri, "cid:")) {
-		gchar *new_uri = em_format_build_mail_uri (EM_FORMAT (formatter)->folder,
-			EM_FORMAT (formatter)->uid, uri, EM_FORMAT (formatter));
+		gchar *new_uri = em_format_build_mail_uri (EM_FORMAT (formatter)->folder, EM_FORMAT (formatter)->message_uid, uri);
 
                 webkit_network_request_set_uri (request, new_uri);
 
@@ -341,7 +374,7 @@ mail_display_resource_requested (WebKitWebView *web_view,
                 g_free (path);
         }
 
-       	g_signal_stop_emission_by_name (web_view, "resource-request-starting");
+       	//g_signal_stop_emission_by_name (web_view, "resource-request-starting");
 }
 
 static void
@@ -350,7 +383,8 @@ mail_display_headers_collapsed_state_changed (EWebView *web_view,
 					      const JSValueRef args[],
 					      gpointer user_data)
 {
-	EMFormatHTML *formatter = E_MAIL_DISPLAY (web_view)->priv->formatter;
+	EMailDisplay *display = user_data;
+	EMFormatHTML *formatter = display->priv->formatter;
 	JSGlobalContextRef ctx = e_web_view_get_global_context (web_view);
 
 	gboolean collapsed = JSValueToBoolean (ctx, args[0]);
@@ -376,14 +410,54 @@ mail_display_install_js_callbacks (WebKitWebView *web_view,
 		(EWebViewJSFunctionCallback) mail_display_headers_collapsed_state_changed, user_data);
 }
 
+static EWebView*
+mail_display_setup_webview (EMailDisplay *display)
+{
+	EWebView *web_view;
+	GtkUIManager *ui_manager;
+	GtkActionGroup *action_group;
+	GError *error = NULL;
+
+	web_view = E_WEB_VIEW (e_web_view_new ());
+
+	g_signal_connect (web_view, "navigation-policy-decision-requested",
+		G_CALLBACK (mail_display_link_clicked), display);
+	g_signal_connect (web_view, "window-object-cleared",
+		G_CALLBACK (mail_display_install_js_callbacks), display);
+	g_signal_connect (web_view, "resource-request-starting",
+		G_CALLBACK (mail_display_resource_requested), display);
+	g_signal_connect (web_view, "process-mailto",
+		G_CALLBACK (mail_display_process_mailto), display);
+
+	/* EWebView's action groups are added during its instance
+	 * initialization function (like what we're in now), so it
+	 * is safe to fetch them this early in construction. */
+	action_group = e_web_view_get_action_group (web_view, "mailto");
+
+	/* We don't actually handle the actions we're adding.
+	 * EMailReader handles them.  How devious is that? */
+	gtk_action_group_add_actions (
+		action_group, mailto_entries,
+		G_N_ELEMENTS (mailto_entries), display);
+
+	/* 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. */
+	ui_manager = e_web_view_get_ui_manager (web_view);
+	gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
+	if (error != NULL)
+		g_error ("%s", error->message);
+
+	return web_view;
+}
 
 static void
 e_mail_display_class_init (EMailDisplayClass *class)
 {
 	GObjectClass *object_class;
 	GtkWidgetClass *widget_class;
-	EWebViewClass *web_view_class;
 
+	parent_class = g_type_class_peek_parent (class);
 	g_type_class_add_private (class, sizeof (EMailDisplayPrivate));
 
 	object_class = G_OBJECT_CLASS (class);
@@ -395,9 +469,6 @@ e_mail_display_class_init (EMailDisplayClass *class)
 	widget_class->realize = mail_display_realize;
 	widget_class->style_set = mail_display_style_set;
 
-	web_view_class = E_WEB_VIEW_CLASS (class);
-	web_view_class->process_mailto = mail_display_process_mailto;
-
 	g_object_class_install_property (
 		object_class,
 		PROP_FORMATTER,
@@ -407,50 +478,45 @@ e_mail_display_class_init (EMailDisplayClass *class)
 			NULL,
 			EM_TYPE_FORMAT_HTML,
 			G_PARAM_READWRITE));
+
+	g_object_class_install_property (
+		object_class,
+		PROP_DISPLAY_MODE,
+		g_param_spec_int (
+			"display-mode",
+			"Display Mode",
+			NULL,
+			E_MAIL_DISPLAY_MODE_NORMAL,
+			E_MAIL_DISPLAY_MODE_SOURCE,
+			E_MAIL_DISPLAY_MODE_NORMAL,
+			G_PARAM_READWRITE));
 }
 
 static void
 e_mail_display_init (EMailDisplay *display)
 {
-	GtkUIManager *ui_manager;
-	GtkActionGroup *action_group;
-	GError *error = NULL;
-	EWebView *web_view;
+	GtkScrolledWindow *scrolled_window;
 	SoupSession *session;
 	SoupSessionFeature *feature;
-
-	web_view = E_WEB_VIEW (display);
+	GValue margin = {0};
 
 	display->priv = E_MAIL_DISPLAY_GET_PRIVATE (display);
 
-	g_signal_connect (web_view, "navigation-policy-decision-requested",
-		G_CALLBACK (mail_display_link_clicked), display);
-	g_signal_connect (web_view, "resource-request-starting",
-		G_CALLBACK (mail_display_resource_requested), display);
-	g_signal_connect (web_view, "window-object-cleared",
-		G_CALLBACK (mail_display_install_js_callbacks), display);
+	scrolled_window = GTK_SCROLLED_WINDOW (display);
+	gtk_scrolled_window_set_policy (scrolled_window, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+	gtk_scrolled_window_set_shadow_type (scrolled_window, GTK_SHADOW_NONE);
 
-	/* EWebView's action groups are added during its instance
-	 * initialization function (like what we're in now), so it
-	 * is safe to fetch them this early in construction. */
-	action_group = e_web_view_get_action_group (web_view, "mailto");
+	display->priv->vbox = gtk_vbox_new (FALSE, 0);
+	gtk_scrolled_window_add_with_viewport (scrolled_window, display->priv->vbox);
+	g_value_init (&margin, G_TYPE_INT);
+	g_value_set_int (&margin, 10);
+	g_object_set_property (G_OBJECT (display->priv->vbox), "margin", &margin);
 
-	/* We don't actually handle the actions we're adding.
-	 * EMailReader handles them.  How devious is that? */
-	gtk_action_group_add_actions (
-		action_group, mailto_entries,
-		G_N_ELEMENTS (mailto_entries), display);
 
-	/* 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. */
-	ui_manager = e_web_view_get_ui_manager (web_view);
-	gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error);
-	if (error != NULL)
-		g_error ("%s", error->message);
+	/* WEBKIT TODO: ESearchBar */
 
 
-	/* Register our own handler for mail:// protocol */
+	/* Register our own handler for our own mail:// protocol */
 	session = webkit_get_default_session ();
 	feature = SOUP_SESSION_FEATURE (soup_requester_new ());
 	soup_session_feature_add_feature (feature, E_TYPE_MAIL_REQUEST);
@@ -458,6 +524,32 @@ e_mail_display_init (EMailDisplay *display)
 	g_object_unref (feature);
 }
 
+GType
+e_mail_display_get_type (void)
+{
+	static GType type = 0;
+
+	if (G_UNLIKELY (type == 0)) {
+		static const GTypeInfo type_info = {
+			sizeof (EMailDisplayClass),
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) e_mail_display_class_init,
+			(GClassFinalizeFunc) NULL,
+			NULL,  /* class_data */
+			sizeof (EMailDisplay),
+			0,     /* n_preallocs */
+			(GInstanceInitFunc) e_mail_display_init,
+			NULL   /* value_table */
+		};
+
+		type = g_type_register_static (
+			GTK_TYPE_SCROLLED_WINDOW, "EMailDisplay", &type_info, 0);
+	}
+
+	return type;
+}
+
 EMFormatHTML *
 e_mail_display_get_formatter (EMailDisplay *display)
 {
@@ -482,3 +574,241 @@ e_mail_display_set_formatter (EMailDisplay *display,
 
 	g_object_notify (G_OBJECT (display), "formatter");
 }
+
+EMailDisplayMode
+e_mail_display_get_mode (EMailDisplay *display)
+{
+	g_return_val_if_fail (E_IS_MAIL_DISPLAY (display),
+			E_MAIL_DISPLAY_MODE_NORMAL);
+
+	return display->priv->display_mode;
+}
+
+void
+e_mail_display_set_mode (EMailDisplay *display,
+			 EMailDisplayMode mode)
+{
+	g_return_if_fail (E_IS_MAIL_DISPLAY (display));
+
+	if (display->priv->display_mode == mode)
+		return;
+
+	display->priv->display_mode = mode;
+	e_mail_display_reload (display);
+
+	g_object_notify (G_OBJECT (display), "display-mode");
+}
+
+void
+e_mail_display_load (EMailDisplay *display,
+		     const gchar *msg_uri)
+{
+	EWebView *web_view;
+	EMFormatPURI *puri;
+	EMFormat *emf = (EMFormat *) display->priv->formatter;
+	gchar *uri;
+	GList *iter;
+	GtkBox *box;
+
+	g_return_if_fail (E_IS_MAIL_DISPLAY (display));
+
+	/* First remove all widgets left after previous message */
+	e_mail_display_clear (display);
+
+	box = GTK_BOX (display->priv->vbox);
+
+	/* Headers webview */
+	web_view = mail_display_setup_webview (display);
+	display->widgets = g_list_append (display->widgets, GTK_WIDGET (web_view));
+	gtk_box_pack_start (box, GTK_WIDGET (web_view),
+			TRUE, TRUE, 0);
+	uri = em_format_build_mail_uri (emf->folder, emf->message_uid, "headers");
+	e_web_view_load_uri (web_view, uri);
+	g_free (uri);
+
+	/* Attachment bar */
+	puri = g_hash_table_lookup (emf->mail_part_table, "attachment-bar:");
+	if (puri && puri->widget_func) {
+		GtkWidget *widget = puri->widget_func (emf, puri, NULL);
+		display->widgets = g_list_append (display->widgets, widget);
+		gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
+	}
+
+	for (iter = emf->mail_part_list; iter; iter = iter->next) {
+		puri = iter->data;
+		uri = em_format_build_mail_uri (emf->folder, emf->message_uid, puri->uri);
+
+		if (puri->widget_func && strcmp (puri->uri, "attachment-bar:") != 0) {
+			GtkWidget *widget;
+
+			widget = puri->widget_func (emf, puri, NULL);
+			if (!widget) {
+				g_message ("Part %s didn't provide a valid widget, skipping!", puri->uri);
+				continue;
+			}
+			display->widgets = g_list_append (display->widgets, widget);
+			gtk_box_pack_start (box, widget,
+					TRUE, TRUE, 0);
+
+		} else if (puri->write_func) {
+			web_view = mail_display_setup_webview (display);
+			display->widgets = g_list_append (display->widgets, GTK_WIDGET (web_view));
+			gtk_box_pack_start (box, GTK_WIDGET (web_view),
+					TRUE, TRUE, 0);
+			e_web_view_load_uri (web_view, uri);
+		}
+
+		g_free (uri);
+	}
+
+	gtk_widget_show_all (display->priv->vbox);
+}
+
+void
+e_mail_display_reload (EMailDisplay *display)
+{
+	GList *iter;
+
+	g_return_if_fail (E_IS_MAIL_DISPLAY (display));
+
+	for (iter = display->widgets; iter; iter = iter->next) {
+		if (E_IS_WEB_VIEW (iter->data))
+			e_web_view_reload (E_WEB_VIEW (iter->data));
+	}
+}
+
+EWebView*
+e_mail_display_get_current_web_view (EMailDisplay *display)
+{
+	GtkWidget *widget;
+
+	g_return_val_if_fail (E_IS_MAIL_DISPLAY (display), NULL);
+
+	widget = gtk_container_get_focus_child (GTK_CONTAINER (display));
+
+	if (E_IS_WEB_VIEW (widget))
+		return E_WEB_VIEW (widget);
+	else
+		return NULL;
+}
+
+void
+e_mail_display_set_status (EMailDisplay *display,
+			   const gchar *status)
+{
+	GtkWidget *label;
+
+	g_return_if_fail (E_IS_MAIL_DISPLAY (display));
+
+	e_mail_display_clear (display);
+
+	label = gtk_label_new (status);
+	gtk_box_pack_start (GTK_BOX (display->priv->vbox), label, TRUE, TRUE, 0);
+	gtk_widget_show_all (display->priv->vbox);
+
+	display->widgets = g_list_append (display->widgets, label);
+}
+
+void
+e_mail_display_clear (EMailDisplay *display)
+{
+	g_return_if_fail (E_IS_MAIL_DISPLAY (display));
+
+	gtk_widget_hide (display->priv->vbox);
+
+	g_list_free_full (display->widgets,
+			(GDestroyNotify) gtk_widget_destroy);
+	display->widgets = NULL;
+}
+
+ESearchBar*
+e_mail_display_get_search_bar (EMailDisplay *display)
+{
+	g_return_val_if_fail (E_IS_MAIL_DISPLAY (display), NULL);
+
+	return display->priv->searchbar;
+}
+
+gboolean
+e_mail_display_is_selection_active (EMailDisplay *display)
+{
+	EWebView *web_view;
+
+	g_return_val_if_fail (E_IS_MAIL_DISPLAY (display), FALSE);
+
+	web_view = e_mail_display_get_current_web_view (display);
+	if (!web_view)
+		return FALSE;
+	else
+		return e_web_view_is_selection_active (web_view);
+}
+
+gchar*
+e_mail_display_get_selection_plain_text (EMailDisplay *display,
+					 gint *len)
+{
+	EWebView *web_view;
+	WebKitWebFrame *frame;
+	const gchar *frame_name;
+	GValue value = {0};
+	GType type;
+	const gchar *str;
+
+	g_return_val_if_fail (E_IS_MAIL_DISPLAY (display), NULL);
+
+	web_view = e_mail_display_get_current_web_view (display);
+	if (!web_view)
+		return NULL;
+
+	frame = webkit_web_view_get_focused_frame (WEBKIT_WEB_VIEW (web_view));
+	frame_name = webkit_web_frame_get_name (frame);
+
+	type = e_web_view_frame_exec_script (web_view, frame_name, "window.getSelection().toString()", &value);
+	g_return_val_if_fail (type == G_TYPE_STRING, NULL);
+
+	str = g_value_get_string (&value);
+
+	if (len)
+		*len = strlen (str);
+
+	return g_strdup (str);
+}
+
+static void
+webview_action (GtkWidget *widget, WebViewActionFunc func)
+{
+	/*
+	 * It's not a critical error to pass other then EWebView
+	 * widgets.
+	 */
+	if (E_IS_WEB_VIEW (widget)) {
+		func (E_WEB_VIEW (widget));
+	}
+}
+
+void
+e_mail_display_zoom_100 (EMailDisplay *display)
+{
+	g_return_if_fail (E_IS_MAIL_DISPLAY (display));
+
+	gtk_container_foreach (GTK_CONTAINER (display),
+			(GtkCallback) webview_action, e_web_view_zoom_100);
+}
+
+void
+e_mail_display_zoom_in (EMailDisplay *display)
+{
+	g_return_if_fail (E_IS_MAIL_DISPLAY (display));
+
+	gtk_container_foreach (GTK_CONTAINER (display),
+			(GtkCallback) webview_action, e_web_view_zoom_in);
+}
+
+void
+e_mail_display_zoom_out (EMailDisplay *display)
+{
+	g_return_if_fail (E_IS_MAIL_DISPLAY (display));
+
+	gtk_container_foreach (GTK_CONTAINER (display),
+			(GtkCallback) webview_action, e_web_view_zoom_out);
+}
diff --git a/mail/e-mail-display.h b/mail/e-mail-display.h
index fb3f29d..d81dd1b 100644
--- a/mail/e-mail-display.h
+++ b/mail/e-mail-display.h
@@ -23,6 +23,7 @@
 #define E_MAIL_DISPLAY_H
 
 #include <widgets/misc/e-web-view.h>
+#include <widgets/misc/e-search-bar.h>
 #include "em-format-html.h"
 
 /* Standard GObject macros */
@@ -50,19 +51,57 @@ typedef struct _EMailDisplay EMailDisplay;
 typedef struct _EMailDisplayClass EMailDisplayClass;
 typedef struct _EMailDisplayPrivate EMailDisplayPrivate;
 
+typedef enum {
+	E_MAIL_DISPLAY_MODE_NORMAL,
+	E_MAIL_DISPLAY_MODE_ALL_HEADERS,
+	E_MAIL_DISPLAY_MODE_SOURCE
+} EMailDisplayMode;
+
 struct _EMailDisplay {
-	EWebView parent;
+	GtkScrolledWindow parent;
 	EMailDisplayPrivate *priv;
+
+	GtkWidget *headers;	/* EWebView */
+	GList *widgets;
 };
 
 struct _EMailDisplayClass {
-	EWebViewClass parent_class;
+	GtkScrolledWindowClass parent_class;
+
+	/* TODO WEBKIT: popup-event signal */
+	/* TODO WEBKIT: status-message signal */
 };
 
-GType		e_mail_display_get_type		(void);
-EMFormatHTML *	e_mail_display_get_formatter	(EMailDisplay *display);
-void		e_mail_display_set_formatter	(EMailDisplay *display,
-						 EMFormatHTML *formatter);
+GType			e_mail_display_get_type			(void);
+EMFormatHTML *		e_mail_display_get_formatter	(EMailDisplay *display);
+void			e_mail_display_set_formatter	(EMailDisplay *display,
+						 	 EMFormatHTML *formatter);
+void			e_mail_display_set_mode		(EMailDisplay *display,
+							 EMailDisplayMode mode);
+EMailDisplayMode	e_mail_display_get_mode		(EMailDisplay *display);
+void			e_mail_display_load		(EMailDisplay *display,
+						 	 const gchar *msg_uri);
+void			e_mail_display_reload		(EMailDisplay *display);
+
+EWebView *		e_mail_display_get_current_web_view
+							(EMailDisplay *display);
+
+void			e_mail_display_set_status	(EMailDisplay *display,
+							 const gchar *status);
+void			e_mail_display_clear		(EMailDisplay *display);
+
+ESearchBar*		e_mail_display_get_search_bar	(EMailDisplay *display);
+
+gboolean		e_mail_display_is_selection_active
+							(EMailDisplay *display);
+
+gchar*			e_mail_display_get_selection_plain_text
+							(EMailDisplay *display, gint *len);
+
+
+void			e_mail_display_zoom_100		(EMailDisplay *display);
+void			e_mail_display_zoom_in		(EMailDisplay *display);
+void			e_mail_display_zoom_out		(EMailDisplay *display);
 
 G_END_DECLS
 
diff --git a/mail/e-mail-notebook-view.c b/mail/e-mail-notebook-view.c
index 64995bc..86b47f6 100644
--- a/mail/e-mail-notebook-view.c
+++ b/mail/e-mail-notebook-view.c
@@ -900,21 +900,17 @@ mail_notebook_view_get_backend (EMailReader *reader)
 	return E_MAIL_BACKEND (shell_backend);
 }
 
-static EMFormatHTML *
-mail_notebook_view_get_formatter (EMailReader *reader)
+static EMailDisplay *
+mail_notebook_view_get_mail_display (EMailReader *reader)
 {
-	EMailNotebookView *notebook_view;
-	EMailView *current_view;
+	EMailNotebookViewPrivate *priv;
 
-	notebook_view = E_MAIL_NOTEBOOK_VIEW (reader);
-	current_view = notebook_view->priv->current_view;
+	priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv;
 
-	if (current_view == NULL)
+	if (priv->current_view == NULL)
 		return NULL;
 
-	reader = E_MAIL_READER (current_view);
-
-	return e_mail_reader_get_formatter (reader);
+	return e_mail_reader_get_mail_display (E_MAIL_READER (priv->current_view));
 }
 
 static gboolean
@@ -1458,7 +1454,7 @@ e_mail_notebook_view_reader_init (EMailReaderInterface *interface)
 	interface->get_action_group = mail_notebook_view_get_action_group;
 	interface->get_alert_sink = mail_notebook_view_get_alert_sink;
 	interface->get_backend = mail_notebook_view_get_backend;
-	interface->get_formatter = mail_notebook_view_get_formatter;
+	interface->get_mail_display = mail_notebook_view_get_mail_display;
 	interface->get_hide_deleted = mail_notebook_view_get_hide_deleted;
 	interface->get_message_list = mail_notebook_view_get_message_list;
 	interface->get_popup_menu = mail_notebook_view_get_popup_menu;
diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c
index 710048e..f17bef8 100644
--- a/mail/e-mail-paned-view.c
+++ b/mail/e-mail-paned-view.c
@@ -59,8 +59,9 @@ struct _EMailPanedViewPrivate {
 	GtkWidget *scrolled_window;
 	GtkWidget *message_list;
 	GtkWidget *preview_pane;
+	GtkWidget *search_bar;
 
-	EMFormatHTMLDisplay *formatter;
+	EMailDisplay *display;
 	GalViewInstance *view_instance;
 
 	/* ETable scrolling hack */
@@ -358,9 +359,9 @@ mail_paned_view_dispose (GObject *object)
 		priv->preview_pane = NULL;
 	}
 
-	if (priv->formatter != NULL) {
-		g_object_unref (priv->formatter);
-		priv->formatter = NULL;
+	if (priv->display != NULL) {
+		g_object_unref (priv->display);
+		priv->display = NULL;
 	}
 
 	if (priv->view_instance != NULL) {
@@ -427,14 +428,14 @@ mail_paned_view_get_backend (EMailReader *reader)
 	return E_MAIL_BACKEND (shell_backend);
 }
 
-static EMFormatHTML *
-mail_paned_view_get_formatter (EMailReader *reader)
+static EMailDisplay *
+mail_paned_view_get_mail_display (EMailReader *reader)
 {
-	EMailPanedView *paned_view;
+	EMailPanedViewPrivate *priv;
 
-	paned_view = E_MAIL_PANED_VIEW (reader);
+	priv = E_MAIL_PANED_VIEW (reader)->priv;
 
-	return EM_FORMAT_HTML (paned_view->priv->formatter);
+	return priv->display;
 }
 
 static gboolean
@@ -620,8 +621,6 @@ mail_paned_view_constructed (GObject *object)
 	EShellBackend *shell_backend;
 	EShellWindow *shell_window;
 	EShellView *shell_view;
-	EShell *shell;
-	EShellSettings *shell_settings;
 	ESearchBar *search_bar;
 	EMailReader *reader;
 	EMailBackend *backend;
@@ -630,32 +629,28 @@ mail_paned_view_constructed (GObject *object)
 	GtkWidget *message_list;
 	GtkWidget *container;
 	GtkWidget *widget;
-	EWebView *web_view;
 
 	priv = E_MAIL_PANED_VIEW_GET_PRIVATE (object);
-	priv->formatter = em_format_html_display_new ();
+
+	priv->display = g_object_new (E_TYPE_MAIL_DISPLAY, NULL);
 
 	view = E_MAIL_VIEW (object);
 	shell_view = e_mail_view_get_shell_view (view);
 	shell_window = e_shell_view_get_shell_window (shell_view);
 	shell_backend = e_shell_view_get_shell_backend (shell_view);
-	shell = e_shell_window_get_shell (shell_window);
-	shell_settings = e_shell_get_shell_settings (shell);
 
 	backend = E_MAIL_BACKEND (shell_backend);
 	session = e_mail_backend_get_session (backend);
 
 	/* Make headers collapsable and store state of headers in config file */
-	em_format_html_set_headers_collapsable (
-		EM_FORMAT_HTML (priv->formatter), TRUE);
+	/* FIXME WEBKIT */
+	/*em_format_html_set_headers_collapsable (EM_FORMAT_HTML (priv->formatter), TRUE);
 	g_object_bind_property (
 		shell_settings, "paned-view-headers-state",
 		priv->formatter, "headers-state",
 		G_BINDING_BIDIRECTIONAL |
 		G_BINDING_SYNC_CREATE);
-
-	web_view = em_format_html_get_web_view (
-		EM_FORMAT_HTML (priv->formatter));
+	*/
 
 	/* Build content widgets. */
 
@@ -692,9 +687,9 @@ mail_paned_view_constructed (GObject *object)
 
 	container = priv->paned;
 
-	gtk_widget_show (GTK_WIDGET (web_view));
+	gtk_widget_show (GTK_WIDGET (priv->display));
 
-	widget = e_preview_pane_new (web_view);
+	widget = GTK_WIDGET (priv->display);
 	gtk_paned_pack2 (GTK_PANED (container), widget, FALSE, FALSE);
 	priv->preview_pane = g_object_ref (widget);
 	gtk_widget_show (widget);
@@ -704,11 +699,15 @@ mail_paned_view_constructed (GObject *object)
 		widget, "visible",
 		G_BINDING_SYNC_CREATE);
 
-	search_bar = e_preview_pane_get_search_bar (E_PREVIEW_PANE (widget));
+	/* FIXME WEBKIT: Searchbar!!! */
+	search_bar = e_mail_display_get_search_bar (priv->display);
+	if (search_bar) {
+		priv->search_bar = g_object_ref (search_bar);
 
-	g_signal_connect_swapped (
-		search_bar, "changed",
-		G_CALLBACK (e_web_view_reload), web_view);
+		g_signal_connect_swapped (
+				search_bar, "changed",
+				G_CALLBACK (e_mail_display_reload), priv->display);
+	}
 
 	/* Load the view instance. */
 
@@ -1048,7 +1047,7 @@ e_mail_paned_view_reader_init (EMailReaderInterface *interface)
 	interface->get_action_group = mail_paned_view_get_action_group;
 	interface->get_alert_sink = mail_paned_view_get_alert_sink;
 	interface->get_backend = mail_paned_view_get_backend;
-	interface->get_formatter = mail_paned_view_get_formatter;
+	interface->get_mail_display = mail_paned_view_get_mail_display;
 	interface->get_hide_deleted = mail_paned_view_get_hide_deleted;
 	interface->get_message_list = mail_paned_view_get_message_list;
 	interface->get_popup_menu = mail_paned_view_get_popup_menu;
@@ -1093,6 +1092,14 @@ e_mail_paned_view_hide_message_list_pane (EMailPanedView *view,
 		gtk_widget_hide (view->priv->scrolled_window);
 }
 
+GtkWidget *
+e_mail_paned_view_get_preview (EMailPanedView *view)
+{
+	g_return_val_if_fail (E_IS_MAIL_PANED_VIEW (view), NULL);
+
+	return GTK_WIDGET (mail_paned_view_get_mail_display (E_MAIL_READER (view)));
+}
+
 void
 e_mail_paned_view_set_enable_show_folder (EMailPanedView *view,
                                           gboolean set)
diff --git a/mail/e-mail-paned-view.h b/mail/e-mail-paned-view.h
index 3226b39..5e6879a 100644
--- a/mail/e-mail-paned-view.h
+++ b/mail/e-mail-paned-view.h
@@ -71,6 +71,7 @@ GtkWidget *	e_mail_paned_view_new		(EShellView *shell_view);
 void		e_mail_paned_view_hide_message_list_pane
 						(EMailPanedView *view,
 						 gboolean visible);
+GtkWidget *	e_mail_paned_view_get_preview	(EMailPanedView *view);
 void		e_mail_paned_view_set_enable_show_folder
 						(EMailPanedView *view,
 						 gboolean set);
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 8a0fed2..a32a4d0 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -412,7 +412,8 @@ e_mail_reader_open_selected (EMailReader *reader)
 		const gchar *uid = views->pdata[ii];
 		GtkWidget *browser;
 
-		browser = e_mail_browser_new (backend);
+		browser = e_mail_browser_new (backend, folder, uid,
+				E_MAIL_DISPLAY_MODE_NORMAL);
 		e_mail_reader_set_folder (E_MAIL_READER (browser), folder);
 		e_mail_reader_set_message (E_MAIL_READER (browser), uid);
 		copy_tree_state (reader, E_MAIL_READER (browser));
@@ -438,6 +439,7 @@ mail_reader_print_cb (CamelFolder *folder,
 {
 	EAlertSink *alert_sink;
 	CamelMimeMessage *message;
+	EMailDisplay *display;
 	EMFormatHTML *formatter;
 	EMFormatHTMLPrint *html_print;
 	GError *error = NULL;
@@ -464,12 +466,15 @@ mail_reader_print_cb (CamelFolder *folder,
 
 	g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message));
 
-	formatter = e_mail_reader_get_formatter (context->reader);
+	display = e_mail_reader_get_mail_display (context->reader);
+	formatter = e_mail_display_get_formatter (display);
 
 	html_print = em_format_html_print_new (
 		formatter, context->print_action);
+	/* FIXME WEBKIT
 	em_format_merge_handler (
 		EM_FORMAT (html_print), EM_FORMAT (formatter));
+	*/
 	em_format_html_print_message (
 		html_print, message, folder, context->message_uid);
 	g_object_unref (html_print);
@@ -763,6 +768,7 @@ mail_reader_get_message_ready_cb (CamelFolder *folder,
 	EMailBackend *backend;
 	EAlertSink *alert_sink;
 	EMFormatHTML *formatter;
+	EMailDisplay *display;
 	CamelMimeMessage *message;
 	GError *error = NULL;
 
@@ -791,7 +797,8 @@ mail_reader_get_message_ready_cb (CamelFolder *folder,
 	backend = e_mail_reader_get_backend (context->reader);
 	shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
 
-	formatter = e_mail_reader_get_formatter (context->reader);
+	display = e_mail_reader_get_mail_display (context->reader);
+	formatter = e_mail_display_get_formatter (display);
 
 	em_utils_reply_to_message (
 		shell, message,
@@ -814,6 +821,7 @@ e_mail_reader_reply_to_message (EMailReader *reader,
 	EShell *shell;
 	EMailBackend *backend;
 	EShellBackend *shell_backend;
+	EMailDisplay *display;
 	EMFormatHTML *formatter;
 	GtkWidget *message_list;
 	CamelMimeMessage *new_message;
@@ -834,14 +842,15 @@ e_mail_reader_reply_to_message (EMailReader *reader,
 
 	backend = e_mail_reader_get_backend (reader);
 	folder = e_mail_reader_get_folder (reader);
-	formatter = e_mail_reader_get_formatter (reader);
+	display = e_mail_reader_get_mail_display (reader);
+	formatter = e_mail_display_get_formatter (display);
 	message_list = e_mail_reader_get_message_list (reader);
 	reply_style = e_mail_reader_get_reply_style (reader);
 
 	shell_backend = E_SHELL_BACKEND (backend);
 	shell = e_shell_backend_get_shell (shell_backend);
 
-	web_view = em_format_html_get_web_view (formatter);
+	web_view = e_mail_display_get_current_web_view (display);
 
 	if (reply_type == E_MAIL_REPLY_TO_RECIPIENT) {
 		const gchar *uri;
@@ -1399,18 +1408,23 @@ headers_changed_cb (GConfClient *client,
                     GConfEntry *entry,
                     EMailReader *reader)
 {
+	EMailDisplay *display;
 	EMFormatHTML *formatter;
-	EWebView *web_view;
 	GSList *header_config_list, *p;
 
 	g_return_if_fail (client != NULL);
 	g_return_if_fail (reader != NULL);
 
-	formatter = e_mail_reader_get_formatter (reader);
+	display = e_mail_reader_get_mail_display (reader);
+	formatter = e_mail_display_get_formatter (display);
+
+	if (!formatter)
+		return;
 
 	header_config_list = gconf_client_get_list (
 		client, "/apps/evolution/mail/display/headers",
 		GCONF_VALUE_STRING, NULL);
+	/* FIXME WEBKIT
 	em_format_clear_headers (EM_FORMAT (formatter));
 	for (p = header_config_list; p; p = g_slist_next (p)) {
 		EMailReaderHeader *h;
@@ -1430,11 +1444,11 @@ headers_changed_cb (GConfClient *client,
 
 	g_slist_foreach (header_config_list, (GFunc) g_free, NULL);
 	g_slist_free (header_config_list);
+	*/
 
 	/* force a redraw */
 	if (EM_FORMAT (formatter)->message) {
-		web_view = em_format_html_get_web_view (formatter);
-		e_web_view_reload (web_view);
+		e_mail_display_reload (display);
 	}
 }
 
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 944ab2b..5799167 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -48,13 +48,13 @@
 
 #include "mail/e-mail-backend.h"
 #include "mail/e-mail-browser.h"
-#include "mail/e-mail-display.h"
 #include "mail/e-mail-reader-utils.h"
 #include "mail/e-mail-view.h"
 #include "mail/em-composer-utils.h"
 #include "mail/em-event.h"
 #include "mail/em-folder-selector.h"
 #include "mail/em-folder-tree.h"
+#include "mail/em-format-html-display.h"
 #include "mail/em-utils.h"
 #include "mail/mail-autofilter.h"
 #include "mail/mail-vfolder-ui.h"
@@ -201,9 +201,9 @@ action_add_to_address_book_cb (GtkAction *action,
 	EShell *shell;
 	EMailBackend *backend;
 	EShellBackend *shell_backend;
-	EMFormatHTML *formatter;
+	EMailDisplay *display;
 	CamelInternetAddress *cia;
-	EWebView *web_view;
+	GtkWidget *web_view;
 	CamelURL *curl;
 	const gchar *uri;
 	gchar *email;
@@ -211,11 +211,13 @@ action_add_to_address_book_cb (GtkAction *action,
 	/* This action is defined in EMailDisplay. */
 
 	backend = e_mail_reader_get_backend (reader);
-	formatter = e_mail_reader_get_formatter (reader);
+	display = e_mail_reader_get_mail_display (reader);
 
-	web_view = em_format_html_get_web_view (formatter);
+	web_view = gtk_container_get_focus_child (GTK_CONTAINER  (display));
+	if (!E_IS_WEB_VIEW (web_view))
+		return;
 
-	uri = e_web_view_get_selected_uri (web_view);
+	uri = e_web_view_get_selected_uri (E_WEB_VIEW (web_view));
 	g_return_if_fail (uri != NULL);
 
 	curl = camel_url_new (uri, NULL);
@@ -251,17 +253,20 @@ action_mail_charset_cb (GtkRadioAction *action,
                         GtkRadioAction *current,
                         EMailReader *reader)
 {
+	EMailDisplay *display;
 	EMFormatHTML *formatter;
 	const gchar *charset;
 
 	if (action != current)
 		return;
 
-	formatter = e_mail_reader_get_formatter (reader);
+	display = e_mail_reader_get_mail_display (reader);
+	formatter = e_mail_display_get_formatter (display);
 	charset = g_object_get_data (G_OBJECT (action), "charset");
 
 	/* Charset for "Default" action will be NULL. */
-	em_format_set_charset (EM_FORMAT (formatter), charset);
+	if (formatter)
+		em_format_set_charset (EM_FORMAT (formatter), charset);
 }
 
 static void
@@ -438,42 +443,38 @@ static void
 action_mail_flag_clear_cb (GtkAction *action,
                            EMailReader *reader)
 {
-	EMFormatHTML *formatter;
-	EWebView *web_view;
+	EMailDisplay *display;
 	CamelFolder *folder;
 	GtkWindow *window;
 	GPtrArray *uids;
 
 	folder = e_mail_reader_get_folder (reader);
-	formatter = e_mail_reader_get_formatter (reader);
-	web_view = em_format_html_get_web_view (formatter);
+	display = e_mail_reader_get_mail_display (reader);
 	uids = e_mail_reader_get_selected_uids (reader);
 	window = e_mail_reader_get_window (reader);
 
 	em_utils_flag_for_followup_clear (window, folder, uids);
 
-	e_web_view_reload (web_view);
+	e_mail_display_reload (display);
 }
 
 static void
 action_mail_flag_completed_cb (GtkAction *action,
                                EMailReader *reader)
 {
-	EMFormatHTML *formatter;
-	EWebView *web_view;
+	EMailDisplay *display;
 	CamelFolder *folder;
 	GtkWindow *window;
 	GPtrArray *uids;
 
 	folder = e_mail_reader_get_folder (reader);
-	formatter = e_mail_reader_get_formatter (reader);
-	web_view = em_format_html_get_web_view (formatter);
+	display = e_mail_reader_get_mail_display (reader);
 	uids = e_mail_reader_get_selected_uids (reader);
 	window = e_mail_reader_get_window (reader);
 
 	em_utils_flag_for_followup_completed (window, folder, uids);
 
-	e_web_view_reload (web_view);
+	e_mail_display_reload (display);
 }
 
 static void
@@ -667,9 +668,11 @@ static void
 action_mail_load_images_cb (GtkAction *action,
                             EMailReader *reader)
 {
+	EMailDisplay *display;
 	EMFormatHTML *formatter;
 
-	formatter = e_mail_reader_get_formatter (reader);
+	display = e_mail_reader_get_mail_display (reader);
+	formatter = e_mail_display_get_formatter (display);
 
 	em_format_html_load_images (formatter);
 }
@@ -1580,20 +1583,14 @@ static void
 action_mail_show_all_headers_cb (GtkToggleAction *action,
                                  EMailReader *reader)
 {
-	EMFormatHTML *formatter;
-	EMFormatMode mode;
+	EMailDisplay *display;
 
-	formatter = e_mail_reader_get_formatter (reader);
-
-	if (!formatter)
-		return;
+	display = e_mail_reader_get_mail_display (reader);
 
 	if (gtk_toggle_action_get_active (action))
-		mode = EM_FORMAT_MODE_ALLHEADERS;
+		e_mail_display_set_mode (display, E_MAIL_DISPLAY_MODE_ALL_HEADERS);
 	else
-		mode = EM_FORMAT_MODE_NORMAL;
-
-	em_format_set_mode (EM_FORMAT (formatter), mode);
+		e_mail_display_set_mode (display, E_MAIL_DISPLAY_MODE_NORMAL);
 }
 
 static void
@@ -1601,7 +1598,7 @@ action_mail_show_source_cb (GtkAction *action,
                             EMailReader *reader)
 {
 	EMailBackend *backend;
-	EMFormatHTML *formatter;
+	EMailDisplay *display;
 	CamelFolder *folder;
 	GtkWidget *browser;
 	GPtrArray *uids;
@@ -1609,21 +1606,15 @@ action_mail_show_source_cb (GtkAction *action,
 
 	backend = e_mail_reader_get_backend (reader);
 	folder = e_mail_reader_get_folder (reader);
+	display = e_mail_reader_get_mail_display (reader);
 
 	uids = e_mail_reader_get_selected_uids (reader);
 	g_return_if_fail (uids != NULL && uids->len == 1);
 	message_uid = g_ptr_array_index (uids, 0);
 
-	browser = e_mail_browser_new (backend);
-	reader = E_MAIL_READER (browser);
-	formatter = e_mail_reader_get_formatter (reader);
-
-	if (formatter != NULL)
-		em_format_set_mode (
-			EM_FORMAT (formatter), EM_FORMAT_MODE_SOURCE);
+	browser = e_mail_browser_new (backend, folder, message_uid,
+			E_MAIL_DISPLAY_MODE_SOURCE);
 
-	e_mail_reader_set_folder (reader, folder);
-	e_mail_reader_set_message (reader, message_uid);
 	gtk_widget_show (browser);
 
 	em_utils_uids_free (uids);
@@ -1675,39 +1666,33 @@ static void
 action_mail_zoom_100_cb (GtkAction *action,
                          EMailReader *reader)
 {
-	EMFormatHTML *formatter;
-	EWebView *web_view;
+	EMailDisplay *display;
 
-	formatter = e_mail_reader_get_formatter (reader);
-	web_view = em_format_html_get_web_view (formatter);
+	display = e_mail_reader_get_mail_display (reader);
 
-	e_web_view_zoom_100 (web_view);
+	e_mail_display_zoom_100 (display);
 }
 
 static void
 action_mail_zoom_in_cb (GtkAction *action,
                         EMailReader *reader)
 {
-	EMFormatHTML *formatter;
-	EWebView *web_view;
+	EMailDisplay *display;
 
-	formatter = e_mail_reader_get_formatter (reader);
-	web_view = em_format_html_get_web_view (formatter);
+	display = e_mail_reader_get_mail_display (reader);
 
-	e_web_view_zoom_in (web_view);
+	e_mail_display_zoom_in (display);
 }
 
 static void
 action_mail_zoom_out_cb (GtkAction *action,
                          EMailReader *reader)
 {
-	EMFormatHTML *formatter;
-	EWebView *web_view;
+	EMailDisplay *display;
 
-	formatter = e_mail_reader_get_formatter (reader);
-	web_view = em_format_html_get_web_view (formatter);
+	display = e_mail_reader_get_mail_display (reader);
 
-	e_web_view_zoom_out (web_view);
+	e_mail_display_zoom_out (display);
 }
 
 static void
@@ -1716,7 +1701,7 @@ action_search_folder_recipient_cb (GtkAction *action,
 {
 	EMailBackend *backend;
 	EMailSession *session;
-	EMFormatHTML *formatter;
+	EMailDisplay *display;
 	EWebView *web_view;
 	CamelFolder *folder;
 	CamelURL *curl;
@@ -1725,9 +1710,8 @@ action_search_folder_recipient_cb (GtkAction *action,
 	/* This action is defined in EMailDisplay. */
 
 	folder = e_mail_reader_get_folder (reader);
-	formatter = e_mail_reader_get_formatter (reader);
-
-	web_view = em_format_html_get_web_view (formatter);
+	display = e_mail_reader_get_mail_display (reader);
+	web_view = e_mail_display_get_current_web_view (display);
 
 	uri = e_web_view_get_selected_uri (web_view);
 	g_return_if_fail (uri != NULL);
@@ -1757,7 +1741,7 @@ action_search_folder_sender_cb (GtkAction *action,
 {
 	EMailBackend *backend;
 	EMailSession *session;
-	EMFormatHTML *formatter;
+	EMailDisplay *display;
 	EWebView *web_view;
 	CamelFolder *folder;
 	CamelURL *curl;
@@ -1766,9 +1750,8 @@ action_search_folder_sender_cb (GtkAction *action,
 	/* This action is defined in EMailDisplay. */
 
 	folder = e_mail_reader_get_folder (reader);
-	formatter = e_mail_reader_get_formatter (reader);
-
-	web_view = em_format_html_get_web_view (formatter);
+	display = e_mail_reader_get_mail_display (reader);
+	web_view = e_mail_display_get_current_web_view (display);
 
 	uri = e_web_view_get_selected_uri (web_view);
 	g_return_if_fail (uri != NULL);
@@ -2498,6 +2481,7 @@ mail_reader_message_seen_cb (EMailReaderClosure *closure)
 	EMailReader *reader;
 	GtkWidget *message_list;
 	EMFormatHTML *formatter;
+	EMailDisplay *display;
 	CamelMimeMessage *message;
 	const gchar *current_uid;
 	const gchar *message_uid;
@@ -2506,13 +2490,14 @@ mail_reader_message_seen_cb (EMailReaderClosure *closure)
 	reader = closure->reader;
 	message_uid = closure->message_uid;
 
-	formatter = e_mail_reader_get_formatter (reader);
+
+	display = e_mail_reader_get_mail_display (reader);
+	formatter = e_mail_display_get_formatter (display);
 	message_list = e_mail_reader_get_message_list (reader);
 
 	if (e_tree_is_dragging (E_TREE (message_list)))
 		return FALSE;
 
-	current_uid = EM_FORMAT (formatter)->uid;
 	uid_is_current &= (g_strcmp0 (current_uid, message_uid) == 0);
 
 	current_uid = MESSAGE_LIST (message_list)->cursor_uid;
@@ -2673,10 +2658,9 @@ static gboolean
 mail_reader_message_selected_timeout_cb (EMailReader *reader)
 {
 	EMailReaderPrivate *priv;
-	EMFormatHTML *formatter;
+	EMailDisplay *display;
 	GtkWidget *message_list;
 	EPreviewPane *preview_pane;
-	EWebView *web_view;
 	CamelFolder *folder;
 	const gchar *cursor_uid;
 	const gchar *format_uid;
@@ -2685,49 +2669,36 @@ mail_reader_message_selected_timeout_cb (EMailReader *reader)
 
 	folder = e_mail_reader_get_folder (reader);
 
-	formatter = e_mail_reader_get_formatter (reader);
 	message_list = e_mail_reader_get_message_list (reader);
-	preview_pane = e_mail_reader_get_preview_pane (reader);
-	web_view = e_preview_pane_get_web_view (preview_pane);
+	display = e_mail_reader_get_mail_display (reader);
 
 	cursor_uid = MESSAGE_LIST (message_list)->cursor_uid;
-	format_uid = EM_FORMAT (formatter)->uid;
-
-	e_preview_pane_clear_alerts (preview_pane);
+	//format_uid = EM_FORMAT (formatter)->message_uid;
 
 	if (MESSAGE_LIST (message_list)->last_sel_single) {
+		GtkWidget *widget;
 		gboolean preview_visible;
+		gboolean display_visible;
 		gboolean selected_uid_changed;
 
 		/* Decide whether to download the full message now. */
+		widget = GTK_WIDGET (display);
+
+		display_visible = gtk_widget_get_mapped (widget);
 
-		preview_visible =
-			gtk_widget_get_mapped (GTK_WIDGET (preview_pane));
-		selected_uid_changed = g_strcmp0 (cursor_uid, format_uid);
+		/* FIXME WEBKIT */
+		//selected_uid_changed = g_strcmp0 (cursor_uid, format_uid);
 
-		if (preview_visible && selected_uid_changed) {
+		//if (display_visible && selected_uid_changed) {
+		if (display_visible) {
 			EMailReaderClosure *closure;
 			GCancellable *cancellable;
 			EActivity *activity;
-			gchar *string, *html;
+			gchar *string;
 
-			string = g_strdup_printf (
-				_("Retrieving message '%s'"), cursor_uid);
-
-			html = g_strdup_printf ("<html><head></head><body>"
-						"<table width=\"100%%\" height=\"100%%\"><tr>"
-						"<td valign=\"middle\" align=\"center\"><h5>%s</h5></td>"
-						"</tr></table>"
-						"</body></html>",
-						string);
-#if HAVE_CLUTTER
-			if (!e_shell_get_express_mode (e_shell_get_default ()))
-				e_web_view_load_string (web_view, html);
-#else
-			e_web_view_load_string (web_view, html);
-#endif
+			string = g_strdup_printf (_("Retrieving message '%s'"), cursor_uid);
+			e_mail_display_set_status (display, string);
 			g_free (string);
-			g_free (html);
 
 			activity = e_mail_reader_new_activity (reader);
 			cancellable = e_activity_get_cancellable (activity);
@@ -2747,8 +2718,6 @@ mail_reader_message_selected_timeout_cb (EMailReader *reader)
 			priv->retrieving_message = g_object_ref (cancellable);
 		}
 	} else {
-		e_web_view_load_string (web_view, "");
-
 		priv->restoring_message_selection = FALSE;
 	}
 
@@ -2879,8 +2848,7 @@ mail_reader_set_folder (EMailReader *reader,
                         CamelFolder *folder)
 {
 	EMailReaderPrivate *priv;
-	EMFormatHTML *formatter;
-	EWebView *web_view;
+	EMailDisplay *display;
 	CamelFolder *previous_folder;
 	GtkWidget *message_list;
 	EMailBackend *backend;
@@ -2890,8 +2858,7 @@ mail_reader_set_folder (EMailReader *reader,
 	priv = E_MAIL_READER_GET_PRIVATE (reader);
 
 	backend = e_mail_reader_get_backend (reader);
-	formatter = e_mail_reader_get_formatter (reader);
-	web_view = em_format_html_get_web_view (formatter);
+	display = e_mail_reader_get_mail_display (reader);
 	message_list = e_mail_reader_get_message_list (reader);
 
 	previous_folder = e_mail_reader_get_folder (reader);
@@ -2911,7 +2878,7 @@ mail_reader_set_folder (EMailReader *reader,
 		em_utils_folder_is_outbox (folder) ||
 		em_utils_folder_is_sent (folder));
 
-	e_web_view_load_string (web_view, "");
+	e_mail_display_clear (display);
 
 	priv->folder_was_just_selected = (folder != NULL);
 
@@ -2952,6 +2919,7 @@ mail_reader_message_loaded (EMailReader *reader,
 	GtkWidget *message_list;
 	EMailBackend *backend;
 	CamelFolder *folder;
+	EMailDisplay *display;
 	EWebView *web_view;
 	EPreviewPane *preview_pane;
 	EShellBackend *shell_backend;
@@ -2960,20 +2928,22 @@ mail_reader_message_loaded (EMailReader *reader,
 	EMEventTargetMessage *target;
 	GError *error = NULL;
 	gchar *mail_uri;
+	SoupSession *session;
+	GHashTable *formattters;
+	GCancellable *cancellable;
 
 	priv = E_MAIL_READER_GET_PRIVATE (reader);
 
 	folder = e_mail_reader_get_folder (reader);
 	backend = e_mail_reader_get_backend (reader);
-	formatter = e_mail_reader_get_formatter (reader);
+	display = e_mail_reader_get_mail_display (reader);
 	message_list = e_mail_reader_get_message_list (reader);
 	preview_pane = e_mail_reader_get_preview_pane (reader);
+	formatter = e_mail_display_get_formatter (display);
 
 	shell_backend = E_SHELL_BACKEND (backend);
 	shell = e_shell_backend_get_shell (shell_backend);
 
-	web_view = e_preview_pane_get_web_view (preview_pane);
-
 	/** @Event: message.reading
 	 * @Title: Viewing a message
 	 * @Target: EMEventTargetMessage
@@ -2987,13 +2957,19 @@ mail_reader_message_loaded (EMailReader *reader,
 		(EEvent *) event, "message.reading",
 		(EEventTarget *) target);
 
-	/* Initialize formatter */
-	em_format_format_clone (EM_FORMAT (formatter), folder, 
-	                        message_uid, message, NULL, NULL);
 
-	/* Start formatting */
-	mail_uri = em_format_build_mail_uri (folder, message_uid, NULL, EM_FORMAT (formatter));
-	e_web_view_load_uri (web_view, mail_uri);
+	mail_uri = em_format_build_mail_uri (folder, message_uid, NULL);
+
+	session = webkit_get_default_session ();
+	if ((formatter = g_object_get_data (G_OBJECT (session), mail_uri)) == NULL) {
+		formatter = em_format_html_display_new ();
+		EM_FORMAT (formatter)->message_uid = g_strdup (message_uid);
+		em_format_parse (EM_FORMAT (formatter), message, folder, NULL);
+		g_object_set_data (G_OBJECT (session), mail_uri, formatter);
+	}
+
+	e_mail_display_set_formatter (display, EM_FORMAT_HTML (formatter));
+	e_mail_display_load (display, mail_uri);
 	g_free (mail_uri);
 
 	/* Reset the shell view icon. */
@@ -3613,9 +3589,7 @@ e_mail_reader_init (EMailReader *reader,
                     gboolean init_actions,
                     gboolean connect_signals)
 {
-	EMFormatHTML *formatter;
 	EMenuToolAction *menu_tool_action;
-	EWebView *web_view;
 	GtkActionGroup *action_group;
 	GtkWidget *message_list;
 	GtkAction *action;
@@ -3628,11 +3602,8 @@ e_mail_reader_init (EMailReader *reader,
 
 	g_return_if_fail (E_IS_MAIL_READER (reader));
 
-	formatter = e_mail_reader_get_formatter (reader);
 	message_list = e_mail_reader_get_message_list (reader);
 
-	web_view = em_format_html_get_web_view (formatter);
-
 	if (!init_actions)
 		goto connect_signals;
 
@@ -3771,6 +3742,7 @@ e_mail_reader_init (EMailReader *reader,
 	gtk_action_set_is_important (action, TRUE);
 	gtk_action_set_short_label (action, _("Reply"));
 
+	/* FIXME WEBKIT
 	action_name = "add-to-address-book";
 	action = e_web_view_get_action (web_view, action_name);
 	g_signal_connect (
@@ -3794,7 +3766,7 @@ e_mail_reader_init (EMailReader *reader,
 	g_signal_connect (
 		action, "activate",
 		G_CALLBACK (action_search_folder_sender_cb), reader);
-
+	*/
 #ifndef G_OS_WIN32
 	/* Lockdown integration. */
 
@@ -3835,21 +3807,24 @@ e_mail_reader_init (EMailReader *reader,
 	action_name = "mail-caret-mode";
 	action = e_mail_reader_get_action (reader, action_name);
 
+	/* FIXME WEBKIT
 	g_object_bind_property (
 		action, "active",
 		web_view, "caret-mode",
 		G_BINDING_BIDIRECTIONAL |
 		G_BINDING_SYNC_CREATE);
-
+	*/
 connect_signals:
 
 	if (!connect_signals)
 		goto init_private;
 
 	/* Connect signals. */
+	/* WEBKIT FIXME
 	g_signal_connect_swapped (
 		web_view, "key-press-event",
 		G_CALLBACK (mail_reader_key_press_event_cb), reader);
+	 */
 
 	g_signal_connect_swapped (
 		message_list, "message-selected",
@@ -4173,17 +4148,17 @@ e_mail_reader_get_backend (EMailReader *reader)
 	return interface->get_backend (reader);
 }
 
-EMFormatHTML *
-e_mail_reader_get_formatter (EMailReader *reader)
+EMailDisplay *
+e_mail_reader_get_mail_display (EMailReader *reader)
 {
 	EMailReaderInterface *interface;
 
 	g_return_val_if_fail (E_IS_MAIL_READER (reader), NULL);
 
 	interface = E_MAIL_READER_GET_INTERFACE (reader);
-	g_return_val_if_fail (interface->get_formatter != NULL, NULL);
+	g_return_val_if_fail (interface->get_mail_display != NULL, NULL);
 
-	return interface->get_formatter (reader);
+	return interface->get_mail_display (reader);
 }
 
 gboolean
diff --git a/mail/e-mail-reader.h b/mail/e-mail-reader.h
index 233e52b..6f03fc0 100644
--- a/mail/e-mail-reader.h
+++ b/mail/e-mail-reader.h
@@ -31,7 +31,7 @@
 #include <camel/camel.h>
 #include <libevolution-utils/e-alert-sink.h>
 #include <mail/e-mail-backend.h>
-#include <mail/em-format-html.h>
+#include <mail/e-mail-display.h>
 #include <misc/e-preview-pane.h>
 
 /* Standard GObject macros */
@@ -96,7 +96,7 @@ struct _EMailReaderInterface {
 						 EMailReaderActionGroup group);
 	EAlertSink *	(*get_alert_sink)	(EMailReader *reader);
 	EMailBackend *	(*get_backend)		(EMailReader *reader);
-	EMFormatHTML *	(*get_formatter)	(EMailReader *reader);
+	EMailDisplay *	(*get_mail_display)	(EMailReader *reader);
 	gboolean	(*get_hide_deleted)	(EMailReader *reader);
 	GtkWidget *	(*get_message_list)	(EMailReader *reader);
 	GtkMenu *	(*get_popup_menu)	(EMailReader *reader);
@@ -141,7 +141,7 @@ GtkActionGroup *
 						 EMailReaderActionGroup group);
 EAlertSink *	e_mail_reader_get_alert_sink	(EMailReader *reader);
 EMailBackend *	e_mail_reader_get_backend	(EMailReader *reader);
-EMFormatHTML *	e_mail_reader_get_formatter	(EMailReader *reader);
+EMailDisplay *	e_mail_reader_get_mail_display	(EMailReader *reader);
 gboolean	e_mail_reader_get_hide_deleted	(EMailReader *reader);
 GtkWidget *	e_mail_reader_get_message_list	(EMailReader *reader);
 guint		e_mail_reader_open_selected_mail
diff --git a/mail/e-mail-request.c b/mail/e-mail-request.c
index eb7c694..b4f7576 100644
--- a/mail/e-mail-request.c
+++ b/mail/e-mail-request.c
@@ -7,6 +7,7 @@
 
 #include "em-format-html.h"
 
+#define d(x)
 
 G_DEFINE_TYPE (EMailRequest, e_mail_request, SOUP_TYPE_REQUEST)
 
@@ -16,11 +17,22 @@ struct _EMailRequestPrivate {
 
 	CamelStream *output_stream;
 
-	gchar *content_type;
+	CamelContentType *content_type;
+	gchar *mime_type;
 
 	GHashTable *uri_query;
 };
 
+static void
+mail_request_set_content_type (EMailRequest *emr,
+			       CamelContentType *ct)
+{
+	if (emr->priv->content_type)
+		camel_content_type_unref (emr->priv->content_type);
+
+	emr->priv->content_type = ct;
+	camel_content_type_ref (emr->priv->content_type);
+}
 
 static void
 start_mail_formatting (GSimpleAsyncResult *res,
@@ -45,25 +57,23 @@ start_mail_formatting (GSimpleAsyncResult *res,
 	part_id = g_hash_table_lookup (request->priv->uri_query, "part_id");
 
 	if (part_id) {
-		CamelContentType *ct;
-		EMFormatPURI *puri;
-
-		puri = em_format_find_puri (emf, part_id);
-		if (puri) {
-			request->priv->part = puri->part;
-			ct = camel_mime_part_get_content_type (request->priv->part);
-			if (ct) {
-				request->priv->content_type = camel_content_type_format (ct);
-			camel_content_type_unref (ct);
+		gboolean all_headers = GPOINTER_TO_INT (g_hash_table_lookup (
+				request->priv->uri_query, "all-headers"));
+
+		if (strcmp (part_id, "headers") == 0) {
+			em_format_html_format_headers (efh, request->priv->output_stream,
+				CAMEL_MEDIUM (emf->message), all_headers, cancellable);
+		} else {
+			EMFormatPURI *puri = g_hash_table_lookup (emf->mail_part_table, part_id);
+			if (puri) {
+				em_format_puri_write (puri, request->priv->output_stream, NULL);
 			} else {
-				request->priv->content_type = g_strdup ("text/html");
+				g_warning ("Failed to lookup requested part '%s' - this should not happen!", part_id);
 			}
-			em_format_html_format_message_part (efh, part_id, request->priv->output_stream, cancellable);
+
+			mail_request_set_content_type (request,
+					camel_mime_part_get_content_type (puri->part));
 		}
-	} else {
-		request->priv->content_type = g_strdup ("text/html");
-		request->priv->part = g_object_ref (CAMEL_MIME_PART (emf->message));
-		em_format_html_format_message (efh, request->priv->output_stream, cancellable);
 	}
 
 	/* Convert the GString to GInputStream and send it back to WebKit */
@@ -96,7 +106,12 @@ get_image_content (GSimpleAsyncResult *res,
 	uri = soup_request_get_uri (SOUP_REQUEST (request));
 
 	if (g_file_get_contents (uri->path, &contents, &length, NULL)) {
-		request->priv->content_type = g_content_type_guess (uri->path, NULL, 0, NULL);
+		CamelContentType *ct;
+		gchar *mime_type = g_content_type_guess (uri->path, NULL, 0, NULL);
+		ct = camel_content_type_decode (mime_type);
+		mail_request_set_content_type (request, ct);
+		camel_content_type_unref (ct);
+
 		stream = g_memory_input_stream_new_from_data (contents, length, NULL);
 		g_simple_async_result_set_op_res_gpointer (res, stream, NULL);
 	}
@@ -125,10 +140,15 @@ mail_request_finalize (GObject *object)
 	}
 
 	if (request->priv->content_type) {
-		g_free (request->priv->content_type);
+		camel_content_type_unref (request->priv->content_type);
 		request->priv->content_type = NULL;
 	}
 
+	if (request->priv->mime_type) {
+		g_free (request->priv->mime_type);
+		request->priv->mime_type = NULL;
+	}
+
 	if (request->priv->uri_query) {
 		g_hash_table_destroy (request->priv->uri_query);
 		request->priv->uri_query = NULL;
@@ -152,26 +172,34 @@ mail_request_send_async (SoupRequest *request,
 			 GAsyncReadyCallback callback,
 			 gpointer	user_data)
 {
+	SoupSession *session;
 	EMailRequest *emr = E_MAIL_REQUEST (request);
 	GSimpleAsyncResult *result;
 	SoupURI *uri;
 
+	session = soup_request_get_session (request);
 	uri = soup_request_get_uri (request);
-
 	if (g_strcmp0 (uri->scheme, "mail") == 0) {
-		gchar *formatter;
-		emr->priv->uri_query = soup_form_decode (uri->query);
+		gchar *uri_str;
+
+		if (!uri->query) {
+			g_warning ("No query in URI %s", soup_uri_to_string (uri, FALSE));
+			g_return_if_fail (uri->query);
+		}
 
-		formatter = g_hash_table_lookup (emr->priv->uri_query, "formatter");
+		/* SoupURI has no API to get URI without queries */
+		uri_str = g_strdup_printf ("%s://%s%s", uri->scheme, uri->host, uri->path);
 
-		emr->priv->efh = GINT_TO_POINTER (atoi (formatter));
-		g_return_if_fail (EM_IS_FORMAT (emr->priv->efh));
+		emr->priv->efh = g_object_get_data (G_OBJECT (session), uri_str);
+		g_free (uri_str);
+		g_return_if_fail (emr->priv->efh);
 
+		emr->priv->uri_query = soup_form_decode (uri->query);
 		result = g_simple_async_result_new (G_OBJECT (request), callback, user_data, mail_request_send_async);
 		g_simple_async_result_run_in_thread (result, start_mail_formatting, G_PRIORITY_DEFAULT, cancellable);
 	} else if (g_strcmp0 (uri->scheme, "evo-file") == 0) {
 		/* WebKit won't allow us to load data through local file:// protocol, when using "remote" mail://
-		   protocol. evo-file:// behaves as file:// */
+		   protocol, so we have evo-file:// which WebKit thinks it's remote, but in fact it behaves like file:// */
 		result = g_simple_async_result_new (G_OBJECT (request), callback, user_data, mail_request_send_async);
 		g_simple_async_result_run_in_thread (result, get_image_content, G_PRIORITY_DEFAULT, cancellable);
 	}
@@ -195,15 +223,17 @@ mail_request_get_content_length (SoupRequest *request)
 {
 	EMailRequest *emr = E_MAIL_REQUEST (request);
 	GByteArray *ba;
+	gint content_length = 0;
 
 	if (emr->priv->output_stream) {
 		ba = camel_stream_mem_get_byte_array (CAMEL_STREAM_MEM (emr->priv->output_stream));
 		if (ba) {
-			return ba->len;
+			content_length = ba->len;
 		}
 	}
 
-	return 0;
+	d(printf("Content-Length: %d bytes", content_length));
+	return content_length;
 }
 
 static const gchar*
@@ -211,7 +241,31 @@ mail_request_get_content_type (SoupRequest *request)
 {
 	EMailRequest *emr = E_MAIL_REQUEST (request);
 
-	return emr->priv->content_type;
+	if (emr->priv->mime_type)
+		g_free (emr->priv->mime_type);
+
+	if (emr->priv->content_type == NULL) {
+		emr->priv->mime_type = g_strdup ("text/html");
+
+	/* For text/html return native content type, since it can contain
+	 * informations about charset
+	 */
+	} else if (camel_content_type_is (emr->priv->content_type, "text", "html")) {
+		emr->priv->mime_type = camel_content_type_format (emr->priv->content_type);
+
+	/* For any other text/* content type, return text/html, because we
+	 * have converted it from whatever type it was to HTML */
+	} else if (camel_content_type_is (emr->priv->content_type, "text", "*")) {
+		emr->priv->mime_type = g_strdup ("text/html");
+
+	/* For any other format return it's native format, because then it is
+	 * most probably image or something similar	 */
+	} else {
+		emr->priv->mime_type = camel_content_type_format (emr->priv->content_type);
+	}
+
+	d(printf("Content-Type: %s\n", emr->priv->mime_type));
+	return emr->priv->mime_type;
 }
 
 static const char *data_schemes[] = { "mail", "evo-file", NULL };
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index 6095e7f..b7fb9ec 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -114,10 +114,7 @@ static void efhd_message_prefix (EMFormat *emf, CamelMimePart *part, GString *pa
 
 static void efhd_builtin_init (EMFormatHTMLDisplayClass *efhc);
 
-G_DEFINE_TYPE (
-	EMFormatHTMLDisplay,
-	em_format_html_display,
-	EM_TYPE_FORMAT_HTML)
+static gpointer parent_class;
 
 static void
 efhd_xpkcs7mime_free (EMFormatPURI *puri)
@@ -391,7 +388,7 @@ static void
 efhd_parse (EMFormat *emf,
 	    CamelMimeMessage *msg,
 	    CamelFolder *folder,
-	    Cancellable *cancellable)
+	    GCancellable *cancellable)
 {
 	EMFormatHTMLDisplay *efhd;
 
@@ -407,8 +404,7 @@ efhd_parse (EMFormat *emf,
 	 */
 
 	/* Chain up to parent's format_clone() method. */
-	EM_FORMAT_CLASS (em_format_html_display_parent_class)->
-		parse (emf, msg, folder, cancellable);
+	EM_FORMAT_CLASS (parent_class)->parse (emf, msg, folder, cancellable);
 }
 
 static void
@@ -582,10 +578,12 @@ attachment_load_finish (EAttachment *attachment,
 	g_object_unref (file);
 }
 
+
 static void
 action_image_save_cb (GtkAction *action,
                       EMFormatHTMLDisplay *efhd)
 {
+#if 0 /* FIXME WEBKIT */
 	EWebView *web_view;
 	EMFormat *emf;
 	const gchar *image_src;
@@ -661,6 +659,7 @@ action_image_save_cb (GtkAction *action,
 		attachment_load_finish, file);
 
 	g_object_unref (part);
+#endif
 }
 
 static void
@@ -726,17 +725,17 @@ efhd_finalize (GObject *object)
 	}
 
 	/* Chain up to parent's finalize() method. */
-	G_OBJECT_CLASS (em_format_html_display_parent_class)->
-		finalize (object);
+	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
 static void
-em_format_html_display_class_init (EMFormatHTMLDisplayClass *class)
+efhd_class_init (EMFormatHTMLDisplayClass *class)
 {
 	GObjectClass *object_class;
 	EMFormatClass *format_class;
 	EMFormatHTMLClass *format_html_class;
 
+	parent_class = g_type_class_peek_parent (class);
 	g_type_class_add_private (class, sizeof (EMFormatHTMLDisplayPrivate));
 
 	object_class = G_OBJECT_CLASS (class);
@@ -755,8 +754,13 @@ em_format_html_display_class_init (EMFormatHTMLDisplayClass *class)
 }
 
 static void
-em_format_html_display_init (EMFormatHTMLDisplay *efhd)
+efhd_init (EMFormatHTMLDisplay *efhd)
 {
+	EWebView *web_view;
+	GtkActionGroup *image_actions;
+	GtkUIManager *ui_manager;
+	GError *error = NULL;
+
 	efhd->priv = EM_FORMAT_HTML_DISPLAY_GET_PRIVATE (efhd);
 	efhd->priv->attachment_views = g_hash_table_new_full (
 		g_str_hash, g_str_equal, g_free, NULL);
@@ -766,16 +770,18 @@ em_format_html_display_init (EMFormatHTMLDisplay *efhd)
 		CAMEL_MIME_FILTER_TOHTML_CONVERT_URLS |
 		CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES;
 
+/* FIXME WEBKIT There's no way how to get web_view from EFHD for now...
 	image_actions = e_web_view_get_action_group (web_view, "image");
 	g_return_if_fail (image_actions != NULL);
 
 	gtk_action_group_add_actions (
 		image_actions, image_entries,
 		G_N_ELEMENTS (image_entries), efhd);
-
+*/
 	/* 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. */
+/* FIXME WEBKIT There's no way how to get web_view from EFHD for now...
 	ui_manager = e_web_view_get_ui_manager (web_view);
 	gtk_ui_manager_add_ui_from_string (ui_manager, image_ui, -1, &error);
 	if (error != NULL)
@@ -784,6 +790,34 @@ em_format_html_display_init (EMFormatHTMLDisplay *efhd)
 	g_signal_connect (
 		web_view, "update-actions",
 		G_CALLBACK (efhd_web_view_update_actions_cb), efhd);
+*/
+}
+
+GType
+em_format_html_display_get_type (void)
+{
+	static GType type = 0;
+
+	if (G_UNLIKELY (type == 0)) {
+		static const GTypeInfo type_info = {
+			sizeof (EMFormatHTMLDisplayClass),
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) efhd_class_init,
+			(GClassFinalizeFunc) NULL,
+			NULL,  /* class_data */
+			sizeof (EMFormatHTMLDisplay),
+			0,     /* n_preallocs */
+			(GInstanceInitFunc) efhd_init,
+			NULL   /* value_table */
+		};
+
+		type = g_type_register_static (
+			EM_TYPE_FORMAT_HTML, "EMFormatHTMLDisplay",
+			&type_info, 0);
+	}
+
+	return type;
 }
 
 EMFormatHTMLDisplay *
@@ -929,7 +963,7 @@ efhd_attachment_button (EMFormat *emf,
 	if (emf->folder && emf->folder->summary && emf->message_uid) {
 		CamelMessageInfo *mi;
 
-		mi = camel_folder_summary_get (emf->folder->summary, emf->uid);
+		mi = camel_folder_summary_get (emf->folder->summary, emf->message_uid);
 		if (mi) {
 			const CamelMessageContentInfo *ci;
 
diff --git a/mail/em-format-html-print.c b/mail/em-format-html-print.c
index dbfef3c..72769c2 100644
--- a/mail/em-format-html-print.c
+++ b/mail/em-format-html-print.c
@@ -37,10 +37,7 @@
 
 #include "em-format-html-print.h"
 
-G_DEFINE_TYPE (
-	EMFormatHTMLPrint,
-	em_format_html_print,
-	EM_TYPE_FORMAT_HTML)
+static gpointer parent_class = NULL;
 
 static void
 efhp_finalize (GObject *object)
@@ -54,7 +51,7 @@ efhp_finalize (GObject *object)
 		g_object_unref (efhp->source);
 
 	/* Chain up to parent's finalize() method. */
-	G_OBJECT_CLASS (em_format_html_print_parent_class)->finalize (object);
+	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
 static gboolean
@@ -68,11 +65,13 @@ efhp_is_inline (EMFormat *emf,
 }
 
 static void
-em_format_html_print_class_init (EMFormatHTMLPrintClass *class)
+efhp_class_init (EMFormatHTMLPrintClass *class)
 {
 	GObjectClass *object_class;
 	EMFormatClass *format_class;
 
+	parent_class = g_type_class_peek_parent (class);
+
 	object_class = G_OBJECT_CLASS (class);
 	object_class->finalize = efhp_finalize;
 
@@ -81,15 +80,17 @@ em_format_html_print_class_init (EMFormatHTMLPrintClass *class)
 }
 
 static void
-em_format_html_print_init (EMFormatHTMLPrint *efhp)
+efhp_init (EMFormatHTMLPrint *efhp)
 {
 	EWebView *web_view;
 
 	/* FIXME WEBKIT: this ain't gonna work
 	web_view = em_format_html_get_web_view (EM_FORMAT_HTML (efhp));
+	*/
 
 	/* gtk widgets don't like to be realized outside top level widget
 	 * so we put new html widget into gtk window */
+	/* FIXME WEBKIT: this ain't gonna work
 	efhp->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 	gtk_container_add (GTK_CONTAINER (efhp->window), GTK_WIDGET (web_view));
 	gtk_widget_realize (GTK_WIDGET (web_view));
@@ -103,6 +104,32 @@ em_format_html_print_init (EMFormatHTMLPrint *efhp)
 	efhp->async = TRUE;
 }
 
+GType
+em_format_html_print_get_type (void)
+{
+	static GType type = 0;
+
+	if (G_UNLIKELY (type == 0)) {
+		static const GTypeInfo type_info = {
+			sizeof (EMFormatHTMLPrintClass),
+			(GBaseInitFunc) NULL,
+			(GBaseFinalizeFunc) NULL,
+			(GClassInitFunc) efhp_class_init,
+			(GClassFinalizeFunc) NULL,
+			NULL,  /* class_data */
+			sizeof (EMFormatHTMLPrint),
+			0,     /* n_preallocs */
+			(GInstanceInitFunc) efhp_init
+		};
+
+		type = g_type_register_static (
+			EM_TYPE_FORMAT_HTML, "EMFormatHTMLPrint",
+			&type_info, 0);
+	}
+
+	return type;
+}
+
 EMFormatHTMLPrint *
 em_format_html_print_new (EMFormatHTML *source,
                           GtkPrintOperationAction action)
@@ -227,8 +254,5 @@ em_format_html_print_message (EMFormatHTMLPrint *efhp,
 		efhp, "complete", G_CALLBACK (emfhp_complete), efhp);
 
 	/* FIXME Not passing a GCancellable here. */
-	em_format_parse (EM_FORMAT (efhp), message, folder, NULL);
-		(EMFormat *) efhp,
-		folder, message_uid, message,
-		(EMFormat *) efhp->source, NULL);
+	em_format_parse ((EMFormat *) efhp, message, folder, NULL);
 }
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 9f1ca64..2d0d5ca 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -2409,10 +2409,12 @@ em_format_html_get_cached_image (EMFormatHTML *efh,
 	g_return_val_if_fail (efh != NULL, NULL);
 	g_return_val_if_fail (image_uri != NULL, NULL);
 
+	/* FIXME WEBKIT This has not been ported yet
 	if (!emfh_http_cache)
 		return NULL;
 
 	return camel_data_cache_get (
 		emfh_http_cache, EMFH_HTTP_CACHE_PATH, image_uri, NULL);
+	*/
+	return NULL;
 }
-
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 2e79bd2..e88c68a 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -380,8 +380,7 @@ em_utils_flag_for_followup (EMailReader *reader,
 	EMailBackend *backend;
 	EShellSettings *shell_settings;
 	EShellBackend *shell_backend;
-	EMFormatHTML *formatter;
-	EWebView *web_view;
+	EMailDisplay *display;
 	GtkWidget *editor;
 	GtkWindow *window;
 	CamelTag *tags;
@@ -471,9 +470,8 @@ em_utils_flag_for_followup (EMailReader *reader,
 	camel_folder_thaw (folder);
 	camel_tag_list_free (&tags);
 
-	formatter = e_mail_reader_get_formatter (reader);
-	web_view = em_format_html_get_web_view (formatter);
-	e_web_view_reload (web_view);
+	display = e_mail_reader_get_mail_display (reader);
+	e_mail_display_reload (display);
 
 exit:
 	/* XXX We shouldn't be freeing this. */
@@ -1175,7 +1173,7 @@ em_utils_message_to_html (CamelMimeMessage *message,
 	camel_stream_mem_set_byte_array (CAMEL_STREAM_MEM (mem), buf);
 
 	emfq = em_format_quote_new (credits, mem, flags);
-	((EMFormat *) emfq)->composer = TRUE;
+	em_format_set_composer ((EMFormat *) emfq, TRUE);
 
 	if (!source) {
 		GSettings *settings;
@@ -1191,11 +1189,12 @@ em_utils_message_to_html (CamelMimeMessage *message,
 	}
 
 	/* FIXME Not passing a GCancellable here. */
-	em_format_format_clone (
-		EM_FORMAT (emfq), NULL, NULL, message, source, NULL);
+	em_format_parse (EM_FORMAT (emfq), message, NULL, NULL);
+	/* FIXME WEBKIT The validity is now per-part, not global :(
 	if (validity_found)
-		*validity_found = ((EMFormat *)emfq)->validity_found;
+		*validity_found = ((EMFormat *)emfq)->validity_type;
 	g_object_unref (emfq);
+	*/
 
 	if (append && *append)
 		camel_stream_write_string (mem, append, NULL, NULL);
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index 25902f3..1c3ff19 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -846,11 +846,12 @@ mbox_create_preview_cb (GObject *preview,
 	g_return_if_fail (preview != NULL);
 	g_return_if_fail (preview_widget != NULL);
 
+	/* FIXME WEBKIT
 	format = em_format_html_display_new ();
 	g_object_set_data_full (
 		preview, "mbox-imp-formatter", format, g_object_unref);
 	web_view = em_format_html_get_web_view (EM_FORMAT_HTML (format));
-
+*/
 	*preview_widget = GTK_WIDGET (web_view);
 }
 
@@ -867,5 +868,7 @@ mbox_fill_preview_cb (GObject *preview,
 	g_return_if_fail (format != NULL);
 
 	/* FIXME Not passing a GCancellable here. */
+	/* FIXME WEBKIT
 	em_format_format (EM_FORMAT (format), NULL, NULL, msg, NULL);
+	*/
 }
diff --git a/modules/mail/e-mail-shell-content.c b/modules/mail/e-mail-shell-content.c
index 5bb60e3..9643926 100644
--- a/modules/mail/e-mail-shell-content.c
+++ b/modules/mail/e-mail-shell-content.c
@@ -307,18 +307,18 @@ mail_shell_content_get_backend (EMailReader *reader)
 	return e_mail_reader_get_backend (reader);
 }
 
-static EMFormatHTML *
-mail_shell_content_get_formatter (EMailReader *reader)
+static EMailDisplay *
+mail_shell_content_get_mail_display(EMailReader *reader)
 {
 	EMailShellContent *mail_shell_content;
+	EMailDisplay *display;
 
 	mail_shell_content = E_MAIL_SHELL_CONTENT (reader);
 
 	/* Forward this to our internal EMailView, which
 	 * also implements the EMailReader interface. */
 	reader = E_MAIL_READER (mail_shell_content->priv->mail_view);
-
-	return e_mail_reader_get_formatter (reader);
+	return e_mail_reader_get_mail_display (reader);
 }
 
 static gboolean
@@ -464,7 +464,7 @@ e_mail_shell_content_reader_init (EMailReaderInterface *interface)
 {
 	interface->get_action_group = mail_shell_content_get_action_group;
 	interface->get_backend = mail_shell_content_get_backend;
-	interface->get_formatter = mail_shell_content_get_formatter;
+	interface->get_mail_display = mail_shell_content_get_mail_display;
 	interface->get_hide_deleted = mail_shell_content_get_hide_deleted;
 	interface->get_message_list = mail_shell_content_get_message_list;
 	interface->get_popup_menu = mail_shell_content_get_popup_menu;
diff --git a/modules/mail/e-mail-shell-view-actions.c b/modules/mail/e-mail-shell-view-actions.c
index b39d22d..7621fa5 100644
--- a/modules/mail/e-mail-shell-view-actions.c
+++ b/modules/mail/e-mail-shell-view-actions.c
@@ -891,12 +891,11 @@ action_mail_smart_backward_cb (GtkAction *action,
 	EMailShellContent *mail_shell_content;
 	EMailShellSidebar *mail_shell_sidebar;
 	EMFolderTree *folder_tree;
-	EMFormatHTML *formatter;
 	EMailReader *reader;
 	EMailView *mail_view;
 	GtkWidget *message_list;
 	GtkToggleAction *toggle_action;
-	EWebView *web_view;
+	EMailDisplay *display;
 	gboolean caret_mode;
 	gboolean magic_spacebar;
 
@@ -914,7 +913,7 @@ action_mail_smart_backward_cb (GtkAction *action,
 	folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
 
 	reader = E_MAIL_READER (mail_view);
-	formatter = e_mail_reader_get_formatter (reader);
+	display = e_mail_reader_get_mail_display (reader);
 	message_list = e_mail_reader_get_message_list (reader);
 
 	magic_spacebar = e_shell_settings_get_boolean (
@@ -923,10 +922,9 @@ action_mail_smart_backward_cb (GtkAction *action,
 	toggle_action = GTK_TOGGLE_ACTION (ACTION (MAIL_CARET_MODE));
 	caret_mode = gtk_toggle_action_get_active (toggle_action);
 
-	web_view = em_format_html_get_web_view (formatter);
-
-	if (e_web_view_scroll_backward (web_view))
-		return;
+	/* FIXME WEBKIT FUCKING IMPLEMENT
+	gtk_scrolled_window_scroll (display, GTK_MOVEMENT_PAGES, -1);
+	*/
 
 	if (caret_mode || !magic_spacebar)
 		return;
@@ -967,7 +965,7 @@ action_mail_smart_forward_cb (GtkAction *action,
 	EMailView *mail_view;
 	GtkWidget *message_list;
 	GtkToggleAction *toggle_action;
-	EWebView *web_view;
+	EMailDisplay *display;
 	gboolean caret_mode;
 	gboolean magic_spacebar;
 
@@ -985,7 +983,7 @@ action_mail_smart_forward_cb (GtkAction *action,
 	folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar);
 
 	reader = E_MAIL_READER (mail_view);
-	formatter = e_mail_reader_get_formatter (reader);
+	display = e_mail_reader_get_mail_display (reader);
 	message_list = e_mail_reader_get_message_list (reader);
 
 	magic_spacebar = e_shell_settings_get_boolean (
@@ -994,10 +992,10 @@ action_mail_smart_forward_cb (GtkAction *action,
 	toggle_action = GTK_TOGGLE_ACTION (ACTION (MAIL_CARET_MODE));
 	caret_mode = gtk_toggle_action_get_active (toggle_action);
 
-	web_view = em_format_html_get_web_view (formatter);
+	/* FIXME WEBKIT: Fucking implement
+	gtk_scolled_window_scroll (display, GTK_MOVEMENT_PAGES, 1);
+	*/
 
-	if (e_web_view_scroll_forward (web_view))
-		return;
 
 	if (caret_mode || !magic_spacebar)
 		return;
diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c
index 8838f1a..9519df3 100644
--- a/modules/mail/e-mail-shell-view-private.c
+++ b/modules/mail/e-mail-shell-view-private.c
@@ -331,7 +331,7 @@ mail_shell_view_popup_event_cb (EMailShellView *mail_shell_view,
                                 const gchar *uri)
 {
 	EMailShellContent *mail_shell_content;
-	EMFormatHTML *formatter;
+	EMailDisplay *display;
 	EShellView *shell_view;
 	EMailReader *reader;
 	EMailView *mail_view;
@@ -344,9 +344,10 @@ mail_shell_view_popup_event_cb (EMailShellView *mail_shell_view,
 	mail_shell_content = mail_shell_view->priv->mail_shell_content;
 	mail_view = e_mail_shell_content_get_mail_view (mail_shell_content);
 
+	/* FIXME WEBKIT: Probably does not do what we want it to */
 	reader = E_MAIL_READER (mail_view);
-	formatter = e_mail_reader_get_formatter (reader);
-	web_view = em_format_html_get_web_view (formatter);
+	display = e_mail_reader_get_mail_display (reader);
+	web_view = e_mail_display_get_current_web_view (display);
 
 	if (e_web_view_get_cursor_image (web_view) != NULL)
 		return FALSE;
@@ -427,17 +428,15 @@ mail_shell_view_reader_changed_cb (EMailShellView *mail_shell_view,
                                    EMailReader *reader)
 {
 	GtkWidget *message_list;
-	EMFormatHTML *formatter;
-	EWebView *web_view;
+	EMailDisplay *display;
 	EShellView *shell_view;
 	EShellTaskbar *shell_taskbar;
 
 	shell_view = E_SHELL_VIEW (mail_shell_view);
 	shell_taskbar = e_shell_view_get_shell_taskbar (shell_view);
 
-	formatter = e_mail_reader_get_formatter (reader);
+	display = e_mail_reader_get_mail_display (reader);
 	message_list = e_mail_reader_get_message_list (reader);
-	web_view = em_format_html_get_web_view (formatter);
 
 	e_shell_view_update_actions (E_SHELL_VIEW (mail_shell_view));
 	e_mail_shell_view_update_sidebar (mail_shell_view);
@@ -463,26 +462,28 @@ mail_shell_view_reader_changed_cb (EMailShellView *mail_shell_view,
 		G_CALLBACK (mail_shell_view_message_list_right_click_cb),
 		mail_shell_view, G_CONNECT_SWAPPED);
 
+	/* FIXME WEBKIT EMailDisplay does not have these signals (yet)
 	g_signal_connect_object (
-		web_view, "key-press-event",
+		display, "key-press-event",
 		G_CALLBACK (mail_shell_view_key_press_event_cb),
 		mail_shell_view, G_CONNECT_SWAPPED);
 
 	g_signal_connect_object (
-		web_view, "popup-event",
+		display, "popup-event",
 		G_CALLBACK (mail_shell_view_popup_event_cb),
 		mail_shell_view, G_CONNECT_SWAPPED);
 
 	g_signal_connect_object (
-		web_view, "scroll",
+		display, "scroll",
 		G_CALLBACK (mail_shell_view_scroll_cb),
 		mail_shell_view,
 		G_CONNECT_AFTER | G_CONNECT_SWAPPED);
 
 	g_signal_connect_object (
-		web_view, "status-message",
+		display, "status-message",
 		G_CALLBACK (e_shell_taskbar_set_message),
 		shell_taskbar, G_CONNECT_SWAPPED);
+	*/
 }
 
 static void
@@ -634,7 +635,6 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view)
 	EShellTaskbar *shell_taskbar;
 	EShellWindow *shell_window;
 	EShellSearchbar *searchbar;
-	EMFormatHTML *formatter;
 	EMFolderTree *folder_tree;
 	EActionComboBox *combo_box;
 	ERuleContext *context;
@@ -647,7 +647,7 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view)
 	EMailSession *session;
 	EMailReader *reader;
 	EMailView *mail_view;
-	EWebView *web_view;
+	EMailDisplay *display;
 	const gchar *source;
 	guint merge_id;
 	gint ii = 0;
@@ -691,7 +691,7 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view)
 	combo_box = e_shell_searchbar_get_scope_combo_box (searchbar);
 
 	reader = E_MAIL_READER (shell_content);
-	formatter = e_mail_reader_get_formatter (reader);
+	display = e_mail_reader_get_mail_display (reader);
 	message_list = e_mail_reader_get_message_list (reader);
 
 	em_folder_tree_set_selectable_widget (folder_tree, message_list);
@@ -710,8 +710,6 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view)
 		G_CALLBACK (mail_shell_view_search_filter_changed_cb),
 		mail_shell_view, G_CONNECT_SWAPPED);
 
-	web_view = em_format_html_get_web_view (formatter);
-
 	g_signal_connect_object (
 		folder_tree, "folder-selected",
 		G_CALLBACK (mail_shell_view_folder_tree_selected_cb),
@@ -783,27 +781,28 @@ e_mail_shell_view_private_constructed (EMailShellView *mail_shell_view)
 		G_CALLBACK (e_mail_shell_view_update_search_filter),
 		mail_shell_view, G_CONNECT_SWAPPED);
 
+	/* FIXME WEBKIT: EMailDisplay does no have these signals (for now)
 	g_signal_connect_object (
-		web_view, "key-press-event",
+		display, "key-press-event",
 		G_CALLBACK (mail_shell_view_key_press_event_cb),
 		mail_shell_view, G_CONNECT_SWAPPED);
 
 	g_signal_connect_object (
-		web_view, "popup-event",
+		display, "popup-event",
 		G_CALLBACK (mail_shell_view_popup_event_cb),
 		mail_shell_view, G_CONNECT_SWAPPED);
 
 	g_signal_connect_object (
-		web_view, "scroll",
+		display, "scroll",
 		G_CALLBACK (mail_shell_view_scroll_cb),
 		mail_shell_view,
 		G_CONNECT_AFTER | G_CONNECT_SWAPPED);
 
 	g_signal_connect_object (
-		web_view, "status-message",
+		display, "status-message",
 		G_CALLBACK (e_shell_taskbar_set_message),
 		shell_taskbar, G_CONNECT_SWAPPED);
-
+	*/
 	g_signal_connect_object (
 		mail_shell_view, "toggled",
 		G_CALLBACK (e_mail_shell_view_update_send_receive_menus),



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