[gnumeric] Provide an information dialog for print preview. [#662056]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Provide an information dialog for print preview. [#662056]
- Date: Tue, 18 Oct 2011 22:07:44 +0000 (UTC)
commit b1e3297e553649386d2cc315d0d668e334d67471
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Tue Oct 18 16:07:26 2011 -0600
Provide an information dialog for print preview. [#662056]
2011-10-18 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/print.c (PrintingInstance): add fields
(printing_instance_new): initialize new fields
(printing_instance_delete): destroy progress report
(cb_progress_response): new
(cb_progress_delete): new
(gnm_begin_print_cb): create progress dialog
(gnm_draw_page_cb): update progress dialog
(gnm_print_sheet): tell gtk not to create their buggy
progress report
ChangeLog | 12 +++++++++++
NEWS | 1 +
src/print.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 72 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b358384..c0ebabc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2011-10-18 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * src/print.c (PrintingInstance): add fields
+ (printing_instance_new): initialize new fields
+ (printing_instance_delete): destroy progress report
+ (cb_progress_response): new
+ (cb_progress_delete): new
+ (gnm_begin_print_cb): create progress dialog
+ (gnm_draw_page_cb): update progress dialog
+ (gnm_print_sheet): tell gtk not to create their buggy
+ progress report
+
+2011-10-18 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* src/print.c (gnm_print_sheet): avoid double free
2011-10-18 Andreas J. Guelzow <aguelzow pyrshep ca>
diff --git a/NEWS b/NEWS
index b3f8870..c25441f 100644
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,7 @@ Andreas:
* Fix border import from 1C generated xls files. [#660605]
* Fix cell extent caclulation for xlsx export. [#661958]
* Speed up printing of few pages of large sheets. [#662056]
+ * Provide an information dialog for print preview. [#662056]
Jean:
* Make things build against gtk+-3.0.
diff --git a/src/print.c b/src/print.c
index 6dca597..0538ce8 100644
--- a/src/print.c
+++ b/src/print.c
@@ -76,6 +76,8 @@ typedef struct {
gboolean ignore_pb;
guint last_pagination;
HFRenderInfo *hfi;
+ GtkWidget *progress;
+ gboolean cancel;
} PrintingInstance;
typedef struct {
@@ -111,6 +113,8 @@ printing_instance_new (void)
{
PrintingInstance * pi = g_new0 (PrintingInstance,1);
pi->hfi = hf_render_info_new ();
+ pi->cancel = FALSE;
+ pi->hfi->pages = -1;
return pi;
}
@@ -130,6 +134,9 @@ printing_instance_delete (PrintingInstance *pi)
{
go_list_free_custom (pi->gnmSheets, sheet_print_info_free);
hf_render_info_destroy (pi->hfi);
+ if (pi->progress) {
+ gtk_widget_destroy (pi->progress);
+ }
g_free (pi);
}
@@ -1182,6 +1189,23 @@ gnm_paginate_cb (GtkPrintOperation *operation,
return FALSE;
}
+static void
+cb_progress_response (G_GNUC_UNUSED GtkDialog *dialog,
+ G_GNUC_UNUSED gint response_id,
+ PrintingInstance *pi)
+{
+ pi->cancel = TRUE;
+}
+
+static gboolean
+cb_progress_delete (G_GNUC_UNUSED GtkWidget *widget,
+ G_GNUC_UNUSED GdkEvent *event,
+ PrintingInstance *pi)
+{
+ pi->cancel = TRUE;
+ return TRUE;
+}
+
static void
gnm_begin_print_cb (GtkPrintOperation *operation,
G_GNUC_UNUSED GtkPrintContext *context,
@@ -1220,6 +1244,20 @@ gnm_begin_print_cb (GtkPrintOperation *operation,
pr = pi->pr;
}
+ if (NULL != pi->wbc && IS_WBC_GTK(pi->wbc)) {
+ pi->progress = gtk_message_dialog_new (wbcg_toplevel (WBC_GTK (pi->wbc)),
+ GTK_DIALOG_MODAL |
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_CANCEL,
+ _("Preparing to print"));
+ g_signal_connect (G_OBJECT (pi->progress), "response",
+ G_CALLBACK (cb_progress_response), pi);
+ g_signal_connect (G_OBJECT (pi->progress), "delete-event",
+ G_CALLBACK (cb_progress_delete), pi);
+ gtk_widget_show_all (pi->progress);
+ }
+
compute_pages (operation, pi, pr, from, to);
}
@@ -1283,8 +1321,26 @@ gnm_draw_page_cb (GtkPrintOperation *operation,
{
PrintingInstance * pi = (PrintingInstance *) user_data;
- SheetPageRange * gsr = print_get_sheet_page_range (pi, page_nr);
+ SheetPageRange * gsr;
+
+ if (pi->cancel) {
+ gtk_print_operation_cancel (operation);
+ return;
+ }
+
+ gsr = print_get_sheet_page_range (pi, page_nr);
if (gsr) {
+ if (pi->progress) {
+ char *text;
+
+ if (pi->hfi->pages == -1)
+ text = g_strdup_printf (_("Printing page %.3d"), page_nr);
+ else
+ text = g_strdup_printf (_("Printing page %.3d of %.3d pages"),
+ page_nr, pi->hfi->pages);
+ g_object_set (G_OBJECT (pi->progress), "text", text, NULL);
+ g_free (text);
+ }
pi->hfi->page = page_nr + 1;
pi->hfi->sheet = gsr->sheet;
pi->hfi->page_area = gsr->range;
@@ -1702,12 +1758,12 @@ gnm_print_sheet (WorkbookControl *wbc, Sheet *sheet,
action = GTK_PRINT_OPERATION_ACTION_EXPORT;
gtk_print_operation_set_export_filename (print, tmp_file_name);
- gtk_print_operation_set_show_progress (print, preview_via_pdf);
+ gtk_print_operation_set_show_progress (print, FALSE);
} else {
action = preview
? GTK_PRINT_OPERATION_ACTION_PREVIEW
: GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG;
- gtk_print_operation_set_show_progress (print, TRUE);
+ gtk_print_operation_set_show_progress (print, FALSE);
gtk_print_operation_set_custom_tab_label (print, _("Gnumeric Print Range"));
g_signal_connect (print, "create-custom-widget", G_CALLBACK (gnm_create_widget_cb), pi);
g_signal_connect (print, "custom-widget-apply", G_CALLBACK (gnm_custom_widget_apply_cb), pi);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]