]> git.sur5r.net Git - glabels/commitdiff
2008-01-29 Jim Evins <evins@snaught.com>
authorJim Evins <evins@snaught.com>
Wed, 30 Jan 2008 04:04:24 +0000 (04:04 +0000)
committerJim Evins <evins@snaught.com>
Wed, 30 Jan 2008 04:04:24 +0000 (04:04 +0000)
* src/print-op.c: (gl_print_op_construct),
(gl_print_op_construct_batch), (set_page_size):
Explicitly set page size for "other" page sizes.

git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@734 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/ChangeLog
glabels2/src/print-op.c

index 0fe48b605f7dc3b448698246164bd1b30e493c0c..effd47fb1ae4e0f92e9bb554d4c45882b2cc73cf 100644 (file)
@@ -1,3 +1,9 @@
+2008-01-29  Jim Evins  <evins@snaught.com>
+
+       * src/print-op.c: (gl_print_op_construct),
+       (gl_print_op_construct_batch), (set_page_size):
+               Explicitly set page size for "other" page sizes.
+
 2008-01-25  Jim Evins  <evins@snaught.com>
 
        * src/bc.c:
index cdcf11fc340a2cf6ff8477d6bd05fb9cb8a66ee1..d3fd7ad097a302fb080a80ef169b813cd2763b35 100644 (file)
@@ -32,6 +32,7 @@
 #include <ctype.h>
 #include <gtk/gtktogglebutton.h>
 
+#include <libglabels/db.h>
 #include "print.h"
 #include "label.h"
 
@@ -120,6 +121,9 @@ static void     gl_print_op_construct_batch (glPrintOp          *op,
                                              gboolean            crop_marks_flag);
 
 
+static void     set_page_size                 (glPrintOp         *op,
+                                               glLabel           *label);
+
 static GObject *create_custom_widget_cb       (GtkPrintOperation *operation,
                                                gpointer           user_data);
 
@@ -227,6 +231,8 @@ gl_print_op_construct (glPrintOp      *op,
         op->priv->last               = lgl_template_frame_get_n_labels (frame);
         op->priv->n_copies           = 1;
 
+        set_page_size (op, label);
+
        gtk_print_operation_set_custom_tab_label ( GTK_PRINT_OPERATION (op),
                                                   _("Labels"));
 
@@ -349,7 +355,7 @@ gl_print_op_free_settings(glPrintOpSettings *settings)
 }
 
 /*--------------------------------------------------------------------------*/
-/* PRIVATE.  Construct op.                                              */
+/* PRIVATE.  Construct op.                                                  */
 /*--------------------------------------------------------------------------*/
 static void
 gl_print_op_construct_batch (glPrintOp      *op,
@@ -398,6 +404,8 @@ gl_print_op_construct_batch (glPrintOp      *op,
 
         }
 
+        set_page_size (op, label);
+
         gtk_print_operation_set_export_filename (GTK_PRINT_OPERATION (op),
                                                  filename);
 
@@ -408,6 +416,42 @@ gl_print_op_construct_batch (glPrintOp      *op,
                          G_CALLBACK (draw_page_cb), label);
 }
 
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  Set page size.                                                 */
+/*--------------------------------------------------------------------------*/
+static void
+set_page_size (glPrintOp  *op,
+               glLabel    *label)
+{
+        GtkPaperSize *psize;
+        GtkPageSetup *su;
+        gchar        *name;
+
+        name = lgl_db_lookup_paper_name_from_id (label->template->paper_id);
+
+        if (lgl_db_is_paper_id_other (label->template->paper_id))
+        {
+                psize = gtk_paper_size_new_custom (label->template->paper_id,
+                                                   name,
+                                                   label->template->page_width,
+                                                   label->template->page_height,
+                                                   GTK_UNIT_POINTS);
+        }
+        else
+        {
+                /* Use default size. */
+                return;
+        }
+        g_free (name);
+
+        su = gtk_page_setup_new ();
+        gtk_page_setup_set_paper_size (su, psize);
+        gtk_print_operation_set_default_page_setup (GTK_PRINT_OPERATION (op), su);
+        g_object_unref (su);
+
+        gtk_paper_size_free (psize);
+}
+
 /*--------------------------------------------------------------------------*/
 /* PRIVATE.  "Create custom widget" callback                                */
 /*--------------------------------------------------------------------------*/