[evolution/webkit: 70/182] Port EMsgComposer to the EMailPrinter
- From: Dan VrÃtil <dvratil src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit: 70/182] Port EMsgComposer to the EMailPrinter
- Date: Tue, 6 Mar 2012 16:14:35 +0000 (UTC)
commit a995e6f6a6c51f725c7cca5de50a45dbbe3ab1b4
Author: Dan VrÃtil <dvratil redhat com>
Date: Wed Nov 30 17:25:16 2011 +0100
Port EMsgComposer to the EMailPrinter
This works perfectly, but could use some polishing. On the other hand it's just
a temporary solution until the composer is ported to WebKit as well...
em-format/em-format.c | 7 ++++++-
mail/e-mail-printer.c | 3 +++
mail/em-composer-utils.c | 43 +++++++++++++++++++++++++++++++++++++++----
3 files changed, 48 insertions(+), 5 deletions(-)
---
diff --git a/em-format/em-format.c b/em-format/em-format.c
index ca55849..8a67c41 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -2348,15 +2348,20 @@ em_format_build_mail_uri (CamelFolder *folder,
gchar *uri, *tmp;
va_list ap;
const gchar *name;
+ const gchar *service_uid;
char separator;
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
g_return_val_if_fail (message_uid && *message_uid, NULL);
store = camel_folder_get_parent_store (folder);
+ if (store)
+ service_uid = camel_service_get_uid (CAMEL_SERVICE (store));
+ else
+ service_uid = "generic";
tmp = g_strdup_printf ("mail://%s/%s/%s",
- camel_service_get_uid (CAMEL_SERVICE (store)),
+ service_uid,
camel_folder_get_full_name (folder),
message_uid);
diff --git a/mail/e-mail-printer.c b/mail/e-mail-printer.c
index 45ed25f..b732fa3 100644
--- a/mail/e-mail-printer.c
+++ b/mail/e-mail-printer.c
@@ -531,6 +531,9 @@ emp_set_formatter (EMailPrinter *emp,
G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_INT);
headers = camel_medium_get_headers (CAMEL_MEDIUM (emf->message));
+ if (!headers)
+ return;
+
for (i = 0; i < headers->len; i++) {
GtkTreeIter iter;
GList *found_header;
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 2c29628..58ac8a0 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"
@@ -929,17 +931,50 @@ em_utils_composer_save_to_outbox_cb (EMsgComposer *composer,
}
static void
+composer_print_done_cb (EMailPrinter *emp,
+ GtkPrintOperation *operation,
+ GtkPrintOperationResult result,
+ gpointer user_data)
+{
+ EMFormat *emf = user_data;
+
+ g_object_unref (emf->folder);
+ g_object_unref (emf);
+
+ g_object_unref (emp);
+
+}
+
+static void
em_utils_composer_print_cb (EMsgComposer *composer,
GtkPrintOperationAction action,
CamelMimeMessage *message,
EActivity *activity,
EMailSession *session)
{
- EMFormatHTMLPrint *efhp;
+ EMailPrinter *emp;
+ EMFormatHTMLDisplay *efhd;
+ CamelFolder *folder;
+
+ /* Create a virtual temporary camel folder */
+ /* FIXME WEBKIT This throws a warning about null parent-store.
+ * Find a better way. */
+ folder = g_object_new (CAMEL_TYPE_OFFLINE_FOLDER,
+ "full-name", "composer",
+ "parent-store", NULL, NULL);
+
+ efhd = g_object_new (EM_TYPE_FORMAT_HTML_DISPLAY, NULL);
+ ((EMFormat *) efhd)->message_uid = g_strdup (camel_mime_message_get_message_id (message));
+
+ /* Parse the message */
+ em_format_parse ((EMFormat *) efhd, message, folder, NULL);
+
+ /* Use EMailPrinter and WebKit to print the message */
+ emp = e_mail_printer_new ((EMFormatHTML *) efhd, action);
+ 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, NULL);
}
/* Composing messages... */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]