From: Carlos Garcia Campos Date: Sat, 25 Aug 2007 15:55:07 +0000 (+0000) Subject: Adjust number of pages per row according to page orientation when printing X-Git-Tag: EVINCE_2_19_4~5 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=a50e3f1032fe4e868c92668477aea37bb86052d6;p=evince.git Adjust number of pages per row according to page orientation when printing 2007-08-25 Carlos Garcia Campos * backend/pdf/ev-poppler.cc: (pdf_document_file_exporter_begin): * libdocument/ev-file-exporter.[ch]: (ev_file_exporter_get_capabilities): * shell/ev-jobs.[ch]: (ev_job_print_new), (ev_job_print_run): * shell/ev-window.c: (ev_window_print_dialog_response_cb): Adjust number of pages per row according to page orientation when printing 2 or 6 pages per sheet. svn path=/trunk/; revision=2641 --- diff --git a/ChangeLog b/ChangeLog index da0444ac..d95b6e17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-08-25 Carlos Garcia Campos + + * backend/pdf/ev-poppler.cc: (pdf_document_file_exporter_begin): + * libdocument/ev-file-exporter.[ch]: + (ev_file_exporter_get_capabilities): + * shell/ev-jobs.[ch]: (ev_job_print_new), (ev_job_print_run): + * shell/ev-window.c: (ev_window_print_dialog_response_cb): + + Adjust number of pages per row according to page orientation when + printing 2 or 6 pages per sheet. + 2007-08-25 Carlos Garcia Campos * shell/ev-window.c: (ev_window_print_send): diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc index 8af07fd4..cc6137b1 100644 --- a/backend/pdf/ev-poppler.cc +++ b/backend/pdf/ev-poppler.cc @@ -1579,7 +1579,7 @@ pdf_document_file_exporter_begin (EvFileExporter *exporter, PdfDocument *pdf_document = PDF_DOCUMENT (exporter); PdfPrintContext *ctx; gdouble width, height; - gboolean change_orient = FALSE; + gboolean landscape, change_orient = FALSE; #ifdef HAVE_CAIRO_PRINT cairo_surface_t *surface = NULL; #endif @@ -1591,6 +1591,8 @@ pdf_document_file_exporter_begin (EvFileExporter *exporter, ctx->format = fc->format; ctx->pages_per_sheet = fc->pages_per_sheet; + landscape = (fc->orientation == EV_FILE_EXPORTER_LANDSCAPE); + switch (fc->pages_per_sheet) { default: case 1: @@ -1599,8 +1601,9 @@ pdf_document_file_exporter_begin (EvFileExporter *exporter, break; case 2: change_orient = TRUE; - ctx->pages_x = 2; - ctx->pages_y = 1; + landscape = !landscape; + ctx->pages_x = 1; + ctx->pages_y = 2; break; case 4: ctx->pages_x = 2; @@ -1608,8 +1611,9 @@ pdf_document_file_exporter_begin (EvFileExporter *exporter, break; case 6: change_orient = TRUE; - ctx->pages_x = 3; - ctx->pages_y = 2; + landscape = !landscape; + ctx->pages_x = 2; + ctx->pages_y = 3; break; case 9: ctx->pages_x = 3; @@ -1628,7 +1632,15 @@ pdf_document_file_exporter_begin (EvFileExporter *exporter, width = fc->paper_width; height = fc->paper_height; } + + if (landscape) { + gint tmp; + tmp = ctx->pages_x; + ctx->pages_x = ctx->pages_y; + ctx->pages_y = tmp; + } + ctx->page_width = width / ctx->pages_x; ctx->page_height = height / ctx->pages_y; diff --git a/libdocument/ev-file-exporter.c b/libdocument/ev-file-exporter.c index d65abec1..1b942a25 100644 --- a/libdocument/ev-file-exporter.c +++ b/libdocument/ev-file-exporter.c @@ -74,5 +74,5 @@ ev_file_exporter_get_capabilities (EvFileExporter *exporter) { EvFileExporterIface *iface = EV_FILE_EXPORTER_GET_IFACE (exporter); - iface->get_capabilities (exporter); + return iface->get_capabilities (exporter); } diff --git a/libdocument/ev-file-exporter.h b/libdocument/ev-file-exporter.h index c05ea27d..ab1daee4 100644 --- a/libdocument/ev-file-exporter.h +++ b/libdocument/ev-file-exporter.h @@ -47,15 +47,21 @@ typedef enum { EV_FILE_EXPORTER_CAN_NUMBER_UP = 1 << 8 } EvFileExporterCapabilities; +typedef enum { + EV_FILE_EXPORTER_PORTRAIT, + EV_FILE_EXPORTER_LANDSCAPE +} EvFileExporterOrientation; + typedef struct { - EvFileExporterFormat format; - const gchar *filename; - gint first_page; - gint last_page; - gdouble paper_width; - gdouble paper_height; - gboolean duplex; - gint pages_per_sheet; + EvFileExporterFormat format; + const gchar *filename; + gint first_page; + gint last_page; + gdouble paper_width; + gdouble paper_height; + EvFileExporterOrientation orientation; + gboolean duplex; + gint pages_per_sheet; } EvFileExporterContext; #define EV_TYPE_FILE_EXPORTER (ev_file_exporter_get_type ()) diff --git a/shell/ev-jobs.c b/shell/ev-jobs.c index 1218cd06..c78b28cb 100644 --- a/shell/ev-jobs.c +++ b/shell/ev-jobs.c @@ -10,8 +10,6 @@ #include "ev-document-fonts.h" #include "ev-selection.h" #include "ev-async-renderer.h" -#include "ev-file-exporter.h" -#include "ev-window.h" #include #include @@ -564,6 +562,7 @@ ev_job_print_new (EvDocument *document, const gchar *format, gdouble width, gdouble height, + EvFileExporterOrientation orientation, EvPrintRange *ranges, gint n_ranges, EvPrintPageSet page_set, @@ -585,6 +584,7 @@ ev_job_print_new (EvDocument *document, job->width = width; job->height = height; + job->orientation = orientation; job->ranges = ranges; job->n_ranges = n_ranges; @@ -718,6 +718,7 @@ ev_job_print_run (EvJobPrint *job) fc.last_page = MAX (first_page, last_page); fc.paper_width = job->width; fc.paper_height = job->height; + fc.orientation = job->orientation; fc.duplex = FALSE; fc.pages_per_sheet = job->pages_per_sheet; diff --git a/shell/ev-jobs.h b/shell/ev-jobs.h index 1f348d81..b15f260f 100644 --- a/shell/ev-jobs.h +++ b/shell/ev-jobs.h @@ -23,6 +23,7 @@ #include #include "ev-document.h" #include "ev-window.h" +#include "ev-file-exporter.h" G_BEGIN_DECLS @@ -204,6 +205,7 @@ struct _EvJobPrint gboolean reverse; gdouble width; gdouble height; + EvFileExporterOrientation orientation; }; struct _EvJobPrintClass @@ -262,6 +264,7 @@ EvJob *ev_job_print_new (EvDocument *document, const gchar *format, gdouble width, gdouble height, + EvFileExporterOrientation orientation, EvPrintRange *ranges, gint n_ranges, EvPrintPageSet page_set, diff --git a/shell/ev-window.c b/shell/ev-window.c index b3906443..97007467 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -2332,6 +2332,7 @@ ev_window_print_dialog_response_cb (GtkDialog *dialog, gdouble width; gdouble height; GtkPrintPages print_pages; + EvFileExporterOrientation orientation; const gchar *file_format; if (response == GTK_RESPONSE_CANCEL) { @@ -2410,6 +2411,17 @@ ev_window_print_dialog_response_cb (GtkDialog *dialog, GTK_UNIT_PIXEL); height = gtk_page_setup_get_paper_height (window->priv->print_page_setup, GTK_UNIT_PIXEL); + + switch (gtk_page_setup_get_orientation (window->priv->print_page_setup)) { + case GTK_PAGE_ORIENTATION_PORTRAIT: + case GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT: + orientation = EV_FILE_EXPORTER_PORTRAIT; + break; + case GTK_PAGE_ORIENTATION_LANDSCAPE: + case GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE: + orientation = EV_FILE_EXPORTER_LANDSCAPE; + break; + } if (scale != 1.0) { width *= scale; @@ -2425,6 +2437,7 @@ ev_window_print_dialog_response_cb (GtkDialog *dialog, window->priv->print_job = ev_job_print_new (window->priv->document, file_format ? file_format : "ps", width, height, + orientation, ranges, n_ranges, page_set, pages_per_sheet,