X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fev-print-job.c;h=f79c1fc3a1a9d3297b0165e10a8bc15ae384e169;hb=848665b157185945d190a7a746d054d7f5d5e6e0;hp=70f92fd53bfa9e6d859d8510fa20209637595bdf;hpb=bf325e9279324f02bcadc0145cd553ed94c23d2d;p=evince.git diff --git a/shell/ev-print-job.c b/shell/ev-print-job.c index 70f92fd5..f79c1fc3 100644 --- a/shell/ev-print-job.c +++ b/shell/ev-print-job.c @@ -34,6 +34,7 @@ #include "ev-ps-exporter.h" #include "ev-print-job.h" +#include "ev-page-cache.h" #define EV_PRINT_JOB_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), EV_PRINT_JOB, EvPrintJobClass)) #define EV_IS_PRINT_JOB_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EV_PRINT_JOB)) @@ -50,6 +51,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 +220,7 @@ void ev_print_job_use_print_dialog_settings (EvPrintJob *job, GnomePrintDialog *dialog) { GnomePrintConfig *print_config; + EvPageCache *page_cache = ev_page_cache_get (job->document); g_return_if_fail (EV_IS_PRINT_JOB (job)); g_return_if_fail (GNOME_IS_PRINT_DIALOG (dialog)); @@ -225,26 +231,43 @@ 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_page_cache_get (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); + job->temp_file, job->first_page, + job->last_page); 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