X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=inline;f=shell%2Fev-print-job.c;h=d042ab680214ce67824d87ecf30d45e3f15b1bee;hb=4f6105d3df2cbf07bccd7de156693aab7e71bc31;hp=b9aded8b539f7f3e01dac17cc612724a7db1fc3f;hpb=96ab01a78dafd62f121b11010a9857cbd9a7922c;p=evince.git diff --git a/shell/ev-print-job.c b/shell/ev-print-job.c index b9aded8b..d042ab68 100644 --- a/shell/ev-print-job.c +++ b/shell/ev-print-job.c @@ -32,7 +32,7 @@ #define GNOME_PRINT_UNSTABLE_API #include -#include "ev-ps-exporter.h" +#include "ev-file-exporter.h" #include "ev-print-job.h" #include "ev-page-cache.h" @@ -45,21 +45,17 @@ struct _EvPrintJob { EvDocument *document; GnomePrintJob *gnome_print_job; - double width; /* FIXME unused */ - double height; /* FIXME unused */ - gboolean duplex; /* FIXME unused */ - int copies; /* FIXME unused */ - int collate; /* FIXME unsued */ - - /* range printing */ - int first_page; - int last_page; + EvFileExporterContext fc; + int copies; + int collate; int fd; char *temp_file; guint idle_id; gboolean printing; int next_page; + int copies_done; + int shift; }; struct _EvPrintJobClass { @@ -221,6 +217,7 @@ ev_print_job_use_print_dialog_settings (EvPrintJob *job, GnomePrintDialog *dialo { GnomePrintConfig *print_config; EvPageCache *page_cache = ev_page_cache_get (job->document); + gint first_page, last_page; g_return_if_fail (EV_IS_PRINT_JOB (job)); g_return_if_fail (GNOME_IS_PRINT_DIALOG (dialog)); @@ -228,28 +225,31 @@ ev_print_job_use_print_dialog_settings (EvPrintJob *job, GnomePrintDialog *dialo print_config = gnome_print_dialog_get_config (dialog); gnome_print_dialog_get_copies (dialog, &job->copies, &job->collate); gnome_print_config_get_page_size (print_config, - &job->width, &job->height); + &job->fc.paper_width, &job->fc.paper_height); gnome_print_config_get_boolean (print_config, - (guchar *)GNOME_PRINT_KEY_DUPLEX, &job->duplex); + (guchar *)GNOME_PRINT_KEY_DUPLEX, &job->fc.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; + first_page = 0; + 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); + gnome_print_dialog_get_range_page (dialog, &first_page, &last_page); /* convert 1-based user interface to 0-based internal numbers */ - job->first_page--; - job->last_page--; + first_page--; + last_page--; break; default: g_assert_not_reached (); } + job->fc.first_page = MIN (first_page, last_page); + job->fc.last_page = MAX (first_page, last_page); + gnome_print_config_unref (print_config); } @@ -258,35 +258,49 @@ 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, - job->width, job->height, job->duplex); + ev_file_exporter_begin (EV_FILE_EXPORTER (job->document), + &(job->fc)); ev_document_doc_mutex_unlock (); - job->next_page = job->first_page; + job->next_page = job->fc.first_page; + job->shift = (job->fc.first_page > job->fc.last_page) ? -1 : 1; job->printing = TRUE; return TRUE; } - - if (job->next_page <= job->last_page) { + + if ((job->next_page - job->fc.last_page) * job->shift <= 0) { EvRenderContext *rc; #if 0 g_printerr ("Printing page %d\n", job->next_page); #endif - rc = ev_render_context_new (EV_ORIENTATION_PORTRAIT, - job->next_page, 1.0); + 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), rc); + ev_file_exporter_do_page (EV_FILE_EXPORTER (job->document), rc); ev_document_doc_mutex_unlock (); g_object_unref (rc); - job->next_page++; + if (job->collate) { + /* collate must repeat the same page */ + job->copies_done++; + if(job->copies == job->copies_done) { + job->next_page += job->shift; + job->copies_done = 0; + } + } else { + job->next_page += job->shift; + if ((job->next_page - job->fc.last_page) * job->shift > 0){ + job->copies_done++; + if(job->copies_done < job->copies) { + /* more copies to go, restart to the first page */ + job->next_page = job->fc.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_file_exporter_end (EV_FILE_EXPORTER (job->document)); ev_document_doc_mutex_unlock (); close (job->fd); @@ -320,7 +334,7 @@ ev_print_job_print (EvPrintJob *job, GtkWindow *parent) g_return_if_fail (EV_IS_PRINT_JOB (job)); g_return_if_fail (job->document != NULL); - g_return_if_fail (EV_IS_PS_EXPORTER (job->document)); + g_return_if_fail (EV_IS_FILE_EXPORTER (job->document)); #if 0 g_printerr ("Printing...\n"); #endif @@ -329,6 +343,8 @@ ev_print_job_print (EvPrintJob *job, GtkWindow *parent) if (job->fd <= -1) return; /* FIXME use GError */ + job->fc.format = EV_FILE_FORMAT_PS; + job->fc.filename = job->temp_file; gnome_print_job_set_file (job->gnome_print_job, job->temp_file); g_object_ref (job);