[evince] print-operation: Fix orientation of auto-rotate option



commit e7840f9488734358a1d0357891563ffa0109aa91
Author: Jason Crain <jcrain src gnome org>
Date:   Tue Jan 9 12:24:14 2018 -0600

    print-operation: Fix orientation of auto-rotate option
    
    When printing a landscape document, if both the "Auto Rotate and Center"
    and "Select page size using document page size" options are enabled,
    evince will choose the wrong orientation.  This will also occur with any
    document if you use a custom paper size which is wider than it is tall
    and enable the auto rotate option, but do not enable the "Select page
    size" option.
    
    Fix this by having the auto rotate option pick landscape orientation if
    and only if the document's orientation does not match the paper's
    unrotated orientation.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=792394

 libview/ev-print-operation.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/libview/ev-print-operation.c b/libview/ev-print-operation.c
index b267c54..ede4201 100644
--- a/libview/ev-print-operation.c
+++ b/libview/ev-print-operation.c
@@ -1802,7 +1802,17 @@ ev_print_operation_print_request_page_setup (EvPrintOperationPrint *print,
        }
 
        if (print->autorotate) {
-               if (width > height)
+               gdouble paper_width, paper_height;
+               gboolean page_is_landscape, paper_is_landscape;
+
+               GtkPaperSize *psize = gtk_page_setup_get_paper_size (setup);
+               paper_width = gtk_paper_size_get_width (psize, GTK_UNIT_POINTS);
+               paper_height = gtk_paper_size_get_height (psize, GTK_UNIT_POINTS);
+
+               paper_is_landscape = paper_width > paper_height;
+               page_is_landscape = width > height;
+
+               if (page_is_landscape != paper_is_landscape)
                        gtk_page_setup_set_orientation (setup, GTK_PAGE_ORIENTATION_LANDSCAPE);
                else
                        gtk_page_setup_set_orientation (setup, GTK_PAGE_ORIENTATION_PORTRAIT);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]