[evince] [printing] Show print progress information when using GtkPrintOperation
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evince] [printing] Show print progress information when using GtkPrintOperation
- Date: Sat, 8 Aug 2009 14:19:01 +0000 (UTC)
commit a0f9ec3d4c28ed79363aaeb32395c3e026d1cb18
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Sat Aug 8 16:16:13 2009 +0200
[printing] Show print progress information when using GtkPrintOperation
configure.ac | 1 +
shell/ev-print-operation.c | 30 ++++++++++++++++++++++++++----
2 files changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 821c52b..eee407e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -191,6 +191,7 @@ dnl ===== Check special functions
evince_save_LIBS=$LIBS
LIBS="$LIBS $BACKEND_LIBS"
AC_CHECK_FUNCS(cairo_format_stride_for_width)
+AC_CHECK_FUNCS(gtk_print_operation_get_n_pages_to_print)
LIBS=$evince_save_LIBS
# ******************
diff --git a/shell/ev-print-operation.c b/shell/ev-print-operation.c
index 4e78c3f..a6f8d53 100644
--- a/shell/ev-print-operation.c
+++ b/shell/ev-print-operation.c
@@ -1472,6 +1472,8 @@ struct _EvPrintOperationPrint {
EvPrintOperation parent;
GtkPrintOperation *op;
+ gint n_pages_to_print;
+ gint total;
EvJob *job_print;
gchar *job_name;
};
@@ -1589,8 +1591,6 @@ ev_print_operation_print_begin_print (EvPrintOperationPrint *print,
n_pages = ev_page_cache_get_n_pages (ev_page_cache_get (op->document));
gtk_print_operation_set_n_pages (print->op, n_pages);
-
- /* FIXME: gtk_print should provide the progress */
ev_print_operation_update_status (op, -1, n_pages, 0);
g_signal_emit (op, signals[BEGIN_PRINT], 0);
@@ -1602,17 +1602,36 @@ ev_print_operation_print_done (EvPrintOperationPrint *print,
{
EvPrintOperation *op = EV_PRINT_OPERATION (print);
- /* FIXME: gtk_print should provide the progress */
- ev_print_operation_update_status (op, 0, 1, 1.0);
+ ev_print_operation_update_status (op, 0, print->n_pages_to_print, 1.0);
g_signal_emit (op, signals[DONE], 0, result);
}
static void
+ev_print_operation_print_status_changed (EvPrintOperationPrint *print)
+{
+#ifdef HAVE_GTK_PRINT_OPERATION_GET_N_PAGES_TO_PRINT
+ GtkPrintStatus status;
+
+ status = gtk_print_operation_get_status (print->op);
+ if (status == GTK_PRINT_STATUS_GENERATING_DATA)
+ print->n_pages_to_print = gtk_print_operation_get_n_pages_to_print (print->op);
+#endif
+}
+
+static void
print_job_finished (EvJobPrint *job,
EvPrintOperationPrint *print)
{
+ EvPrintOperation *op = EV_PRINT_OPERATION (print);
+
gtk_print_operation_draw_page_finish (print->op);
+#ifdef HAVE_GTK_PRINT_OPERATION_GET_N_PAGES_TO_PRINT
+ print->total++;
+ ev_print_operation_update_status (op, print->total,
+ print->n_pages_to_print,
+ print->total / (gdouble)print->n_pages_to_print);
+#endif
ev_job_print_set_cairo (job, NULL);
}
@@ -1703,6 +1722,9 @@ ev_print_operation_print_init (EvPrintOperationPrint *print)
g_signal_connect_swapped (print->op, "draw_page",
G_CALLBACK (ev_print_operation_print_draw_page),
print);
+ g_signal_connect_swapped (print->op, "status_changed",
+ G_CALLBACK (ev_print_operation_print_status_changed),
+ print);
gtk_print_operation_set_allow_async (print->op, TRUE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]