]> www.fi.muni.cz Git - evince.git/commitdiff
Support printing page range, based on patch by Amaury Jacquot
authorJuerg Billeter <j@bitron.ch>
Tue, 10 May 2005 09:21:02 +0000 (09:21 +0000)
committerMartin Kretzschmar <martink@src.gnome.org>
Tue, 10 May 2005 09:21:02 +0000 (09:21 +0000)
2005-05-10  Juerg Billeter  <j@bitron.ch>

* shell/ev-print-job.c: (ev_print_job_use_print_dialog_settings),
(idle_print_handler)
* shell/ev-window.c: (ev_window_print):

Support printing page range, based on patch by Amaury Jacquot

ChangeLog
shell/ev-print-job.c
shell/ev-window.c

index 79dfafd29dece10a6ecc88e3b023fb6db6eba64a..4858053a437c0f44ac8218342af3b8484b971d77 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2005-05-10  Juerg Billeter  <j@bitron.ch>
+
+       * shell/ev-print-job.c: (ev_print_job_use_print_dialog_settings),
+       (idle_print_handler)
+       * shell/ev-window.c: (ev_window_print):
+
+       Support printing page range, based on patch by Amaury Jacquot
+
 2005-05-10  Marco Pesenti Gritti  <mpg@redhat.com>
 
        * data/evince-toolbar.xml:
index 70f92fd53bfa9e6d859d8510fa20209637595bdf..8363639861105632257be2e7f1de722c252e4608 100644 (file)
@@ -50,6 +50,10 @@ struct _EvPrintJob {
        int copies; /* FIXME unused */
        int collate; /* FIXME unsued */
 
+       /* range printing */
+       int first_page;
+       int last_page;
+
        int fd;
        char *temp_file;
        guint idle_id;
@@ -215,6 +219,7 @@ void
 ev_print_job_use_print_dialog_settings (EvPrintJob *job, GnomePrintDialog *dialog)
 {
        GnomePrintConfig *print_config;
+       EvPageCache *page_cache = ev_document_get_page_cache (job->document);
 
        g_return_if_fail (EV_IS_PRINT_JOB (job));
        g_return_if_fail (GNOME_IS_PRINT_DIALOG (dialog));
@@ -225,26 +230,42 @@ ev_print_job_use_print_dialog_settings (EvPrintJob *job, GnomePrintDialog *dialo
                                          &job->width, &job->height);
        gnome_print_config_get_boolean (print_config,
                                        (guchar *)GNOME_PRINT_KEY_DUPLEX, &job->duplex);
+
+       page_cache = ev_document_get_page_cache (job->document);
+
+       /* get the printing ranges */
+       switch (gnome_print_dialog_get_range (dialog)) {
+       case GNOME_PRINT_RANGE_ALL:
+               job->first_page = 0;
+               job->last_page = ev_page_cache_get_n_pages (page_cache) - 1;
+               break;
+       case GNOME_PRINT_RANGE_RANGE:
+               gnome_print_dialog_get_range_page (dialog, &job->first_page, &job->last_page);
+               /* convert 1-based user interface to 0-based internal numbers */
+               job->first_page--;
+               job->last_page--;
+               break;
+       default:
+               g_assert_not_reached ();
+       }
+
        gnome_print_config_unref (print_config);
 }
 
 static gboolean
 idle_print_handler (EvPrintJob *job)
 {
-       EvPageCache *page_cache;
-
        if (!job->printing) {
                ev_document_doc_mutex_lock ();
                ev_ps_exporter_begin (EV_PS_EXPORTER (job->document),
                                      job->temp_file);
                ev_document_doc_mutex_unlock ();
-               job->next_page = 0;
+               job->next_page = job->first_page;
                job->printing = TRUE;
                return TRUE;
        }
 
-       page_cache = ev_document_get_page_cache (job->document);
-       if (job->next_page < ev_page_cache_get_n_pages (page_cache)) {
+       if (job->next_page <= job->last_page) {
 #if 0
                g_printerr ("Printing page %d\n", job->next_page);
 #endif
index 8a0ec4efc49b536c0630c4142aca51d13895b4f9..489c1cc01b9b3f8efae60077f683041a55e26e82 100644 (file)
@@ -1065,6 +1065,8 @@ ev_window_print (EvWindow *ev_window)
        GnomePrintConfig *config;
        GnomePrintJob *job;
        GtkWidget *print_dialog;
+       EvPageCache *page_cache;
+       gchar *pages_label;
        EvPrintJob *print_job = NULL;
 
         g_return_if_fail (EV_IS_WINDOW (ev_window));
@@ -1073,9 +1075,21 @@ ev_window_print (EvWindow *ev_window)
        config = gnome_print_config_default ();
        job = gnome_print_job_new (config);
 
+       page_cache = ev_document_get_page_cache (ev_window->priv->document);
+
        print_dialog = gnome_print_dialog_new (job, (guchar *) _("Print"),
                                               (GNOME_PRINT_DIALOG_RANGE |
                                                GNOME_PRINT_DIALOG_COPIES));
+
+       pages_label = g_strconcat (_("Pages"), " ", NULL);
+       gnome_print_dialog_construct_range_page (GNOME_PRINT_DIALOG (print_dialog),
+                                                GNOME_PRINT_RANGE_ALL |
+                                                GNOME_PRINT_RANGE_RANGE,
+                                                1,
+                                                ev_page_cache_get_n_pages (page_cache),
+                                                NULL, (const guchar *)pages_label);
+       g_free (pages_label);
+                                                
        gtk_dialog_set_response_sensitive (GTK_DIALOG (print_dialog),
                                           GNOME_PRINT_DIALOG_RESPONSE_PREVIEW,
                                           FALSE);