]> www.fi.muni.cz Git - evince.git/commitdiff
Adjust number of pages per row according to page orientation when printing
authorCarlos Garcia Campos <carlosgc@gnome.org>
Sat, 25 Aug 2007 15:55:07 +0000 (15:55 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Sat, 25 Aug 2007 15:55:07 +0000 (15:55 +0000)
2007-08-25  Carlos Garcia Campos  <carlosgc@gnome.org>
* 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

ChangeLog
backend/pdf/ev-poppler.cc
libdocument/ev-file-exporter.c
libdocument/ev-file-exporter.h
shell/ev-jobs.c
shell/ev-jobs.h
shell/ev-window.c

index da0444acf292a7f2ba335f164187b520daa1be32..d95b6e176cb586ac774324fba3988c22a90738f8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-08-25  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * 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  <carlosgc@gnome.org>
 
        * shell/ev-window.c: (ev_window_print_send):
index 8af07fd4fdb8f3a4a63c8850a7f74323334ecffd..cc6137b11be2d0bef8271aa4fec08084f47de800 100644 (file)
@@ -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;
 
index d65abec168535249355ff5bfc8e67316f2cf7635..1b942a25cad7f667366e305898fb5fa6db8d6a69 100644 (file)
@@ -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);
 }
index c05ea27d966e3edbdb38378899b750f28c23ce2b..ab1daee416cfc822243640dd5486ed49d8306ef8 100644 (file)
@@ -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 ())
index 1218cd063314451300fc05f90a9622c76a93b9cc..c78b28cbf358193b18798bd40058ec632e9d7f18 100644 (file)
@@ -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 <glib/gstdio.h>
 #include <unistd.h>
@@ -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;
 
index 1f348d81ee0372a1726898db8544baccb27bc459..b15f260f5fc0a672a52e348e85b9330037334988 100644 (file)
@@ -23,6 +23,7 @@
 #include <gtk/gtk.h>
 #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,
index b3906443af3dccac0b2e08bf4ef3317d62088130..970074677e0bbf5e7e2a619e9f12256c4c2d0fa0 100644 (file)
@@ -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,