[evolution] Bug #680164 - Print Preview action should open preview immediatelly
- From: Dan VrÃtil <dvratil src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug #680164 - Print Preview action should open preview immediatelly
- Date: Thu, 19 Jul 2012 09:29:04 +0000 (UTC)
commit 75eae13cbc39577ab33b008c93707cb6ac66dc89
Author: Dan VrÃtil <dvratil redhat com>
Date: Thu Jul 19 11:27:05 2012 +0200
Bug #680164 - Print Preview action should open preview immediatelly
mail/e-mail-printer.c | 24 ++++++++++++------------
mail/e-mail-printer.h | 2 +-
mail/e-mail-reader-utils.c | 5 ++++-
mail/em-composer-utils.c | 3 ++-
mail/em-utils.c | 2 +-
5 files changed, 20 insertions(+), 16 deletions(-)
---
diff --git a/mail/e-mail-printer.c b/mail/e-mail-printer.c
index b9478f8..e6c9aa5 100644
--- a/mail/e-mail-printer.c
+++ b/mail/e-mail-printer.c
@@ -51,7 +51,6 @@ struct _EMailPrinterPrivate {
EMailFormatterPrint *formatter;
EMailPartList *parts_list;
- gboolean export_mode;
gchar *export_filename;
GtkListStore *headers;
@@ -62,6 +61,7 @@ struct _EMailPrinterPrivate {
GtkWidget *treeview;
GtkPrintOperation *operation;
+ GtkPrintOperationAction print_action;
};
G_DEFINE_TYPE (
@@ -167,20 +167,21 @@ emp_start_printing (GObject *object,
if (load_status != WEBKIT_LOAD_FINISHED)
return;
+ /* WebKit reloads the page once more right before starting to print, so
+ * disconnect this handler after the first time, so that we don't start
+ * another printing operation */
+ g_signal_handlers_disconnect_by_func (
+ object, emp_start_printing, user_data);
+
frame = webkit_web_view_get_main_frame (web_view);
- if (emp->priv->export_mode) {
+ if (emp->priv->print_action == GTK_PRINT_OPERATION_ACTION_EXPORT) {
gtk_print_operation_set_export_filename (
emp->priv->operation, emp->priv->export_filename);
- webkit_web_frame_print_full (
- frame, emp->priv->operation,
- GTK_PRINT_OPERATION_ACTION_EXPORT, NULL);
- } else {
- webkit_web_frame_print_full
- (frame, emp->priv->operation,
- GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL);
}
+ webkit_web_frame_print_full
+ (frame, emp->priv->operation, emp->priv->print_action, NULL);
}
static void
@@ -785,7 +786,7 @@ e_mail_printer_new (EMailPartList *source)
void
e_mail_printer_print (EMailPrinter *emp,
- gboolean export_mode,
+ GtkPrintOperationAction action,
GCancellable *cancellable)
{
g_return_if_fail (E_IS_MAIL_PRINTER (emp));
@@ -793,6 +794,7 @@ e_mail_printer_print (EMailPrinter *emp,
if (emp->priv->operation)
g_object_unref (emp->priv->operation);
emp->priv->operation = e_print_operation_new ();
+ emp->priv->print_action = action;
gtk_print_operation_set_unit (emp->priv->operation, GTK_UNIT_PIXEL);
gtk_print_operation_set_show_progress (emp->priv->operation, TRUE);
@@ -803,8 +805,6 @@ e_mail_printer_print (EMailPrinter *emp,
g_signal_connect (emp->priv->operation, "draw-page",
G_CALLBACK (emp_draw_footer), NULL);
- emp->priv->export_mode = export_mode;
-
if (cancellable)
g_signal_connect_swapped (cancellable, "cancelled",
G_CALLBACK (gtk_print_operation_cancel), emp->priv->operation);
diff --git a/mail/e-mail-printer.h b/mail/e-mail-printer.h
index a0721ea..c177bfe 100644
--- a/mail/e-mail-printer.h
+++ b/mail/e-mail-printer.h
@@ -66,7 +66,7 @@ GType e_mail_printer_get_type (void);
EMailPrinter * e_mail_printer_new (EMailPartList *source);
void e_mail_printer_print (EMailPrinter *printer,
- gboolean export,
+ GtkPrintOperationAction action,
GCancellable *cancellable);
void e_mail_printer_set_export_filename
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 3839973..3b0b065 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -913,6 +913,7 @@ struct _MessagePrintingContext {
EMailReader *reader;
CamelFolder *folder;
gchar *message_uid;
+ GtkPrintOperationAction action;
EActivity *activity;
};
@@ -954,7 +955,8 @@ mail_reader_do_print_message (GObject *object,
printer = e_mail_printer_new (part_list);
g_signal_connect (printer, "done",
G_CALLBACK (printing_done_cb), activity);
- e_mail_printer_print (printer, FALSE, cancellable);
+
+ e_mail_printer_print (printer, context->action, cancellable);
free_message_printing_context (context);
}
@@ -995,6 +997,7 @@ e_mail_reader_print (EMailReader *reader,
context->message_uid = g_strdup (message_list->cursor_uid);
context->folder = g_object_ref (e_mail_reader_get_folder (reader));
context->activity = e_mail_reader_new_activity (reader);
+ context->action = action;
g_return_if_fail (E_IS_MAIL_READER (reader));
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 33b24ae..b107745 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -982,7 +982,8 @@ em_utils_composer_print_cb (EMsgComposer *composer,
g_signal_connect (emp, "done",
G_CALLBACK (composer_print_done_cb), NULL);
- e_mail_printer_print (emp, FALSE, NULL);
+ e_mail_printer_print (
+ emp, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL);
g_object_unref (parts);
}
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 3c7cbac..3bfeaff 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -630,7 +630,7 @@ do_print_msg_to_file (GObject *source,
g_signal_connect_swapped (printer, "done",
G_CALLBACK (g_object_unref), printer);
- e_mail_printer_print (printer, TRUE, NULL);
+ e_mail_printer_print (printer, GTK_PRINT_OPERATION_ACTION_EXPORT, NULL);
g_object_unref (parser);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]