X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=shell%2Fev-print-job.c;h=bb463f96108d33f57fd1e8522800350832bf18a8;hb=205c689a78e992d1ad3cf9223f7c95bf424dda94;hp=e7c1ce1b431d065a349d4f4aab539c98810656c1;hpb=3f3b7a054f3b5d704fc1389b4551a4bed49e63bc;p=evince.git diff --git a/shell/ev-print-job.c b/shell/ev-print-job.c index e7c1ce1b..bb463f96 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)) @@ -47,8 +48,8 @@ struct _EvPrintJob { double width; /* FIXME unused */ double height; /* FIXME unused */ gboolean duplex; /* FIXME unused */ - int copies; /* FIXME unused */ - int collate; /* FIXME unsued */ + int copies; + int collate; /* range printing */ int first_page; @@ -59,6 +60,7 @@ struct _EvPrintJob { guint idle_id; gboolean printing; int next_page; + int copies_done; }; struct _EvPrintJobClass { @@ -219,7 +221,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); + 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)); @@ -231,7 +233,7 @@ ev_print_job_use_print_dialog_settings (EvPrintJob *job, GnomePrintDialog *dialo gnome_print_config_get_boolean (print_config, (guchar *)GNOME_PRINT_KEY_DUPLEX, &job->duplex); - page_cache = ev_document_get_page_cache (job->document); + page_cache = ev_page_cache_get (job->document); /* get the printing ranges */ switch (gnome_print_dialog_get_range (dialog)) { @@ -257,9 +259,10 @@ idle_print_handler (EvPrintJob *job) { if (!job->printing) { ev_document_doc_mutex_lock (); - ev_ps_exporter_begin (EV_PS_EXPORTER (job->document), - job->temp_file, job->first_page, - job->last_page); + ev_ps_exporter_begin ( + EV_PS_EXPORTER (job->document), + job->temp_file, job->first_page, job->last_page, + job->width, job->height, job->duplex); ev_document_doc_mutex_unlock (); job->next_page = job->first_page; job->printing = TRUE; @@ -267,16 +270,37 @@ idle_print_handler (EvPrintJob *job) } if (job->next_page <= job->last_page) { + EvRenderContext *rc; #if 0 g_printerr ("Printing page %d\n", job->next_page); #endif + rc = ev_render_context_new (0, job->next_page, 1.0); + ev_document_doc_mutex_lock (); - ev_ps_exporter_do_page (EV_PS_EXPORTER (job->document), - job->next_page); + ev_ps_exporter_do_page (EV_PS_EXPORTER (job->document), rc); ev_document_doc_mutex_unlock (); - job->next_page++; + + g_object_unref (rc); + + if (job->collate) { + /* collate must repeat the same page */ + job->copies_done++; + if(job->copies == job->copies_done) { + job->next_page++; + job->copies_done = 0; + } + } else { + job->next_page++; + if (job->next_page > job->last_page){ + job->copies_done++; + if(job->copies_done < job->copies) { + /* more copies to go, restart to the first page */ + job->next_page = job->first_page; + } + } + } return TRUE; - } else { /* no more pages */ + } else { /* no more pages or copies */ ev_document_doc_mutex_lock (); ev_ps_exporter_end (EV_PS_EXPORTER (job->document)); ev_document_doc_mutex_unlock ();