]> www.fi.muni.cz Git - evince.git/commitdiff
[printing] Set page orientation of each page when printing
authorAdrian Johnson <ajohnson@redneon.com>
Sat, 24 Oct 2009 08:14:02 +0000 (18:44 +1030)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Sun, 25 Oct 2009 12:16:27 +0000 (13:16 +0100)
so that documents with mixed portrait/landscape pages print correctly.
Fixes bgo#599470.

shell/ev-print-operation.c

index 60280b7ec3535eda01444c1a7b2f63e72374145f..92277d066c5eeb186f20d579859b43ebf685fb3b 100644 (file)
@@ -1642,6 +1642,23 @@ print_job_cancelled (EvJobPrint            *job,
        gtk_print_operation_cancel (print->op);
 }
 
+static void
+ev_print_operation_print_request_page_setup (EvPrintOperationPrint *print,
+                                            GtkPrintContext       *context,
+                                            gint                   page_nr,
+                                            GtkPageSetup          *setup)
+{
+       EvPrintOperation *op = EV_PRINT_OPERATION (print);
+       gdouble           width, height;
+
+       ev_document_get_page_size (op->document, page_nr,
+                                  &width, &height);
+       if (width > height)
+               gtk_page_setup_set_orientation (setup, GTK_PAGE_ORIENTATION_LANDSCAPE);
+       else
+               gtk_page_setup_set_orientation (setup, GTK_PAGE_ORIENTATION_PORTRAIT);
+}
+
 static void
 ev_print_operation_print_draw_page (EvPrintOperationPrint *print,
                                    GtkPrintContext       *context,
@@ -1730,6 +1747,9 @@ ev_print_operation_print_init (EvPrintOperationPrint *print)
        g_signal_connect_swapped (print->op, "status_changed",
                                  G_CALLBACK (ev_print_operation_print_status_changed),
                                  print);
+       g_signal_connect_swapped (print->op, "request_page_setup",
+                                 G_CALLBACK (ev_print_operation_print_request_page_setup),
+                                 print);
        gtk_print_operation_set_allow_async (print->op, TRUE);
 }