From 6d2c382788a4042d53f49a080acd11b499aa52f6 Mon Sep 17 00:00:00 2001
From: Dan Vrátil <dvratil@redhat.com>
Date: Wed, 28 Mar 2012 18:38:11 +0200
Subject: WebKit port - port formatter and mail module

---
 mail/em-composer-utils.c | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

(limited to 'mail/em-composer-utils.c')

diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 745609fbc0..f4b8560f81 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -51,12 +51,14 @@
 #include <composer/e-composer-actions.h>
 #include <composer/e-composer-post-header.h>
 
+#include "e-mail-printer.h"
 #include "em-utils.h"
 #include "em-composer-utils.h"
 #include "em-folder-selector.h"
 #include "em-folder-tree.h"
 #include "em-format-html.h"
 #include "em-format-html-print.h"
+#include "em-format-html-display.h"
 #include "em-format-quote.h"
 #include "em-event.h"
 #include "mail-send-recv.h"
@@ -928,6 +930,17 @@ em_utils_composer_save_to_outbox_cb (EMsgComposer *composer,
 	camel_message_info_free (info);
 }
 
+static void
+composer_print_done_cb (EMailPrinter *emp,
+                        GtkPrintOperation *operation,
+                        GtkPrintOperationResult result,
+                        gpointer user_data)
+{
+	EMFormat *emf = user_data;
+	g_object_unref (emf);
+	g_object_unref (emp);
+}
+
 static void
 em_utils_composer_print_cb (EMsgComposer *composer,
                             GtkPrintOperationAction action,
@@ -935,11 +948,21 @@ em_utils_composer_print_cb (EMsgComposer *composer,
                             EActivity *activity,
                             EMailSession *session)
 {
-	EMFormatHTMLPrint *efhp;
+	EMailPrinter *emp;
+	EMFormatHTMLDisplay *efhd;
+
+	efhd = em_format_html_display_new ();
+	((EMFormat *) efhd)->message_uid = g_strdup (camel_mime_message_get_message_id (message));
+
+        /* Parse the message */
+	em_format_parse ((EMFormat *) efhd, message, NULL, NULL);
+
+        /* Use EMailPrinter and WebKit to print the message */
+	emp = e_mail_printer_new ((EMFormatHTML *) efhd);
+        g_signal_connect (emp, "done",
+		G_CALLBACK (composer_print_done_cb), efhd);
 
-	efhp = em_format_html_print_new (NULL, action);
-	em_format_html_print_message (efhp, message, NULL, NULL);
-	g_object_unref (efhp);
+	e_mail_printer_print (emp, FALSE, NULL);
 }
 
 /* Composing messages... */
-- 
cgit