From c3eb26e0dc3c7c4ae2dfd150d15ac2dfdda751b2 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Wed, 30 Jan 2008 04:04:24 +0000 Subject: [PATCH] 2008-01-29 Jim Evins * 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 | 6 ++++++ glabels2/src/print-op.c | 46 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index 0fe48b60..effd47fb 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,9 @@ +2008-01-29 Jim Evins + + * 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 * src/bc.c: diff --git a/glabels2/src/print-op.c b/glabels2/src/print-op.c index cdcf11fc..d3fd7ad0 100644 --- a/glabels2/src/print-op.c +++ b/glabels2/src/print-op.c @@ -32,6 +32,7 @@ #include #include +#include #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 */ /*--------------------------------------------------------------------------*/ -- 2.39.2