[evolution/webkit: 96/96] Port 'drop&drop to PDF' to EMailPrinter
- From: Dan VrÃtil <dvratil src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit: 96/96] Port 'drop&drop to PDF' to EMailPrinter
- Date: Wed, 4 Jan 2012 14:04:42 +0000 (UTC)
commit 15f3078842c84a8e68cc2d0adcc12de80569dc61
Author: Dan VrÃtil <dvratil redhat com>
Date: Wed Jan 4 14:53:15 2012 +0100
Port 'drop&drop to PDF' to EMailPrinter
This adds ability to run GTK_PRINT_OPERATION_ACTION_EXPORT via EMailPrinter
mail/e-mail-printer.c | 26 ++++++++++++++++++++++++++
mail/e-mail-printer.h | 8 ++++++++
mail/em-composer-utils.c | 2 +-
mail/em-utils.c | 40 ++++++++++++++++++++++++++++++----------
4 files changed, 65 insertions(+), 11 deletions(-)
---
diff --git a/mail/e-mail-printer.c b/mail/e-mail-printer.c
index b67936e..dc2f5f7 100644
--- a/mail/e-mail-printer.c
+++ b/mail/e-mail-printer.c
@@ -778,6 +778,32 @@ e_mail_printer_print (EMailPrinter *emp,
emp_run_print_operation (emp, export);
}
+const gchar*
+e_mail_printer_get_export_filename (EMailPrinter * printer)
+{
+ g_return_val_if_fail (E_IS_MAIL_PRINTER (printer), NULL);
+
+ if (!printer->priv->efhp)
+ return NULL;
+
+ return printer->priv->efhp->export_filename;
+}
+
+void
+e_mail_printer_set_export_filename (EMailPrinter * printer,
+ const gchar * filename)
+{
+ g_return_if_fail (E_IS_MAIL_PRINTER (printer));
+ g_return_if_fail (printer->priv->efhp != NULL);
+
+ if (printer->priv->efhp->export_filename && *printer->priv->efhp->export_filename)
+ g_free (printer->priv->efhp->export_filename);
+
+ printer->priv->efhp->export_filename = g_strdup (filename);
+}
+
+
+
EMFormatHTMLPrint*
e_mail_printer_get_print_formatter (EMailPrinter *emp)
{
diff --git a/mail/e-mail-printer.h b/mail/e-mail-printer.h
index 95d38a3..f0ebb0a 100644
--- a/mail/e-mail-printer.h
+++ b/mail/e-mail-printer.h
@@ -69,6 +69,14 @@ void e_mail_printer_print (EMailPrinter *printer,
gboolean export,
GCancellable *cancellable);
+void e_mail_printer_set_export_filename
+ (EMailPrinter *printer,
+ const gchar *filename);
+
+const gchar* e_mail_printer_get_export_filename
+ (EMailPrinter *printer);
+
+
EMFormatHTMLPrint *
e_mail_printer_get_print_formatter
(EMailPrinter *printer);
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 4fcbad6..ccc42e7 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -935,7 +935,7 @@ em_utils_composer_print_cb (EMsgComposer *composer,
EMailPrinter *emp;
EMFormatHTMLDisplay *efhd;
- efhd = g_object_new (EM_TYPE_FORMAT_HTML_DISPLAY, NULL);
+ efhd = em_format_html_display_new ();
((EMFormat *) efhd)->message_uid = g_strdup (camel_mime_message_get_message_id (message));
/* Parse the message */
diff --git a/mail/em-utils.c b/mail/em-utils.c
index c1a7bb4..8aba34a 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -69,8 +69,10 @@
#include "em-utils.h"
#include "em-composer-utils.h"
+#include "em-format-html-display.h"
#include "em-format-html-print.h"
#include "e-mail-folder-utils.h"
+#include "e-mail-printer.h"
#include "e-mail-session.h"
#include "em-format/em-format-quote.h"
@@ -614,26 +616,44 @@ em_utils_write_messages_to_stream (CamelFolder *folder,
return res;
}
+static void
+do_print_msg_to_file (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+
+ EMFormatHTML *efh = EM_FORMAT_HTML (source);
+ gchar *filename = user_data;
+
+ EMailPrinter *printer;
+
+ printer = e_mail_printer_new (efh);
+ e_mail_printer_set_export_filename (printer, filename);
+ g_signal_connect_swapped (printer, "done",
+ G_CALLBACK (g_object_unref), printer);
+
+ e_mail_printer_print (printer, TRUE, NULL);
+
+ g_object_unref (efh);
+}
+
static gboolean
-em_utils_print_messages_to_file (CamelFolder *folder,
- const gchar * uid,
+em_utils_print_messages_to_file (CamelFolder *folder,
+ const gchar * uid,
const gchar *filename)
{
- EMFormatHTMLPrint *efhp;
+ EMFormatHTMLDisplay *efhd;
CamelMimeMessage *message;
message = camel_folder_get_message_sync (folder, uid, NULL, NULL);
if (message == NULL)
return FALSE;
- efhp = em_format_html_print_new (NULL);
- efhp->export_filename = g_strdup (filename);
- efhp->async = FALSE;
-
- em_format_html_print_message (efhp, message, folder, uid);
+ efhd = em_format_html_display_new ();
+ ((EMFormat *) efhd)->message_uid = g_strdup (uid);
- g_object_unref (efhp);
- g_object_unref (message);
+ em_format_parse_async ((EMFormat *) efhd, message, folder, NULL,
+ (GAsyncReadyCallback) do_print_msg_to_file, g_strdup (filename));
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]