gui: Configure page setup when printing in the GUI.
authorBen Pfaff <blp@cs.stanford.edu>
Thu, 13 May 2010 04:58:40 +0000 (21:58 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Thu, 13 May 2010 04:59:57 +0000 (21:59 -0700)
The page setup has to be passed down to the Cairo output driver or it
doesn't know how to paginate the output properly.

src/ui/gui/psppire-output-window.c

index b78ef8d3344290064af9c1ba267b1903904b6c8d..2e02b4e5ec33503f8ffc08d63676bc64e6d8d30b 100644 (file)
@@ -621,8 +621,33 @@ static void
 create_xr_print_driver (GtkPrintContext *context, PsppireOutputWindow *window)
 {
   struct string_map options;
+  GtkPageSetup *page_setup;
+  double width, height;
+  double left_margin;
+  double right_margin;
+  double top_margin;
+  double bottom_margin;
+
+  page_setup = gtk_print_context_get_page_setup (context);
+  width = gtk_page_setup_get_paper_width (page_setup, GTK_UNIT_MM);
+  height = gtk_page_setup_get_paper_height (page_setup, GTK_UNIT_MM);
+  left_margin = gtk_page_setup_get_left_margin (page_setup, GTK_UNIT_MM);
+  right_margin = gtk_page_setup_get_right_margin (page_setup, GTK_UNIT_MM);
+  top_margin = gtk_page_setup_get_top_margin (page_setup, GTK_UNIT_MM);
+  bottom_margin = gtk_page_setup_get_bottom_margin (page_setup, GTK_UNIT_MM);
 
   string_map_init (&options);
+  string_map_insert_nocopy (&options, xstrdup ("paper-size"),
+                            xasprintf("%.2fx%.2fmm", width, height));
+  string_map_insert_nocopy (&options, xstrdup ("left-margin"),
+                            xasprintf ("%.2fmm", left_margin));
+  string_map_insert_nocopy (&options, xstrdup ("right-margin"),
+                            xasprintf ("%.2fmm", right_margin));
+  string_map_insert_nocopy (&options, xstrdup ("top-margin"),
+                            xasprintf ("%.2fmm", top_margin));
+  string_map_insert_nocopy (&options, xstrdup ("bottom-margin"),
+                            xasprintf ("%.2fmm", bottom_margin));
+
   window->print_xrd =
     xr_driver_create (gtk_print_context_get_cairo_context (context), &options);