From 7b353782309c9627b471bd5928d836e4ed380e9b Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sun, 17 Aug 2008 19:10:04 +0000 Subject: [PATCH] 2008-08-17 Jim Evins * data/dtd/glabels-2.2.dtd: * data/templates/paper-sizes.xml: * libglabels/db.c: (lgl_db_init): * libglabels/paper.c: (lgl_paper_new), (lgl_paper_dup), (lgl_paper_free): * libglabels/paper.h: * libglabels/xml-paper.c: (lgl_xml_paper_parse_paper_node): * src/print-op.c: (set_page_size): Bug #2049431. Always explicitely set page size. Added pwg_size field (PWG 5101.1-2002 size specification) to the libglabels paper database to allow the page size to be communicated to GtkPrintOp un-ambiguously. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@777 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/ChangeLog | 13 +++++++ glabels2/data/dtd/glabels-2.2.dtd | 1 + glabels2/data/templates/paper-sizes.xml | 50 ++++++++++++------------- glabels2/libglabels/db.c | 2 +- glabels2/libglabels/paper.c | 38 +++++++++++-------- glabels2/libglabels/paper.h | 12 +++--- glabels2/libglabels/xml-paper.c | 7 +++- glabels2/src/print-op.c | 33 ++++++++++++---- 8 files changed, 100 insertions(+), 56 deletions(-) diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index 01dec999..a3a757e8 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,16 @@ +2008-08-17 Jim Evins + + * data/dtd/glabels-2.2.dtd: + * data/templates/paper-sizes.xml: + * libglabels/db.c: (lgl_db_init): + * libglabels/paper.c: (lgl_paper_new), (lgl_paper_dup), (lgl_paper_free): + * libglabels/paper.h: + * libglabels/xml-paper.c: (lgl_xml_paper_parse_paper_node): + * src/print-op.c: (set_page_size): + Bug #2049431. Always explicitely set page size. Added pwg_size field (PWG 5101.1-2002 + size specification) to the libglabels paper database to allow the page size to be + communicated to GtkPrintOp un-ambiguously. + 2008-07-25 Jim Evins * src/object-editor-size-page.c: (size_reset_cb), diff --git a/glabels2/data/dtd/glabels-2.2.dtd b/glabels2/data/dtd/glabels-2.2.dtd index 183df8b6..b23519fc 100644 --- a/glabels2/data/dtd/glabels-2.2.dtd +++ b/glabels2/data/dtd/glabels-2.2.dtd @@ -101,6 +101,7 @@ id %STRING_TYPE; #REQUIRED name %STRING_TYPE; #IMPLIED _name %STRING_TYPE; #IMPLIED + pwg_size %STRING_TYPE; #REQUIRED width %LENGTH_TYPE; #REQUIRED height %LENGTH_TYPE; #REQUIRED > diff --git a/glabels2/data/templates/paper-sizes.xml b/glabels2/data/templates/paper-sizes.xml index da61d75b..17149aeb 100644 --- a/glabels2/data/templates/paper-sizes.xml +++ b/glabels2/data/templates/paper-sizes.xml @@ -2,36 +2,36 @@ - - + + - - + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + diff --git a/glabels2/libglabels/db.c b/glabels2/libglabels/db.c index 2ca3f83b..28f227c5 100644 --- a/glabels2/libglabels/db.c +++ b/glabels2/libglabels/db.c @@ -115,7 +115,7 @@ lgl_db_init (void) papers = read_papers (); /* Create and append an "Other" entry. */ - paper_other = lgl_paper_new ("Other", _("Other"), 0.0, 0.0); + paper_other = lgl_paper_new ("Other", _("Other"), 0.0, 0.0, NULL); papers = g_list_append (papers, paper_other); } diff --git a/glabels2/libglabels/paper.c b/glabels2/libglabels/paper.c index e4d266a6..98826c9b 100644 --- a/glabels2/libglabels/paper.c +++ b/glabels2/libglabels/paper.c @@ -55,11 +55,12 @@ /** * lgl_paper_new: - * @id: Id of paper definition. (E.g. US-Letter, A4, etc.) Should be - * unique. - * @name: Localized name of paper. - * @width: Width of paper in points. - * @height: Height of paper in points. + * @id: Id of paper definition. (E.g. US-Letter, A4, etc.) Should be + * unique. + * @name: Localized name of paper. + * @width: Width of paper in points. + * @height: Height of paper in points. + * @pwg_size: PWG 5101.1-2002 size name. * * Allocates and constructs a new #lglPaper structure. * @@ -70,15 +71,18 @@ lglPaper * lgl_paper_new (gchar *id, gchar *name, gdouble width, - gdouble height) + gdouble height, + gchar *pwg_size) { lglPaper *paper; - paper = g_new0 (lglPaper,1); - paper->id = g_strdup (id); - paper->name = g_strdup (name); - paper->width = width; - paper->height = height; + paper = g_new0 (lglPaper,1); + + paper->id = g_strdup (id); + paper->name = g_strdup (name); + paper->width = width; + paper->height = height; + paper->pwg_size = g_strdup (pwg_size); return paper; } @@ -101,10 +105,11 @@ lglPaper *lgl_paper_dup (const lglPaper *orig) paper = g_new0 (lglPaper,1); - paper->id = g_strdup (orig->id); - paper->name = g_strdup (orig->name); - paper->width = orig->width; - paper->height = orig->height; + paper->id = g_strdup (orig->id); + paper->name = g_strdup (orig->name); + paper->width = orig->width; + paper->height = orig->height; + paper->pwg_size = g_strdup (orig->pwg_size); return paper; } @@ -128,6 +133,9 @@ void lgl_paper_free (lglPaper *paper) g_free (paper->name); paper->name = NULL; + g_free (paper->pwg_size); + paper->pwg_size = NULL; + g_free (paper); } diff --git a/glabels2/libglabels/paper.h b/glabels2/libglabels/paper.h index 12fe978f..0fb42388 100644 --- a/glabels2/libglabels/paper.h +++ b/glabels2/libglabels/paper.h @@ -38,10 +38,11 @@ G_BEGIN_DECLS typedef struct _lglPaper lglPaper; struct _lglPaper { - gchar *id; /* Unique ID of paper definition */ - gchar *name; /* Localized name of paper */ - gdouble width; /* Width (in points) */ - gdouble height; /* Height (in points) */ + gchar *id; /* Unique ID of paper definition */ + gchar *name; /* Localized name of paper */ + gdouble width; /* Width (in points) */ + gdouble height; /* Height (in points) */ + gchar *pwg_size; /* PWG 5101.1-2002 size name */ }; @@ -51,7 +52,8 @@ struct _lglPaper { lglPaper *lgl_paper_new (gchar *id, gchar *name, gdouble width, - gdouble height); + gdouble height, + gchar *pwg_size); lglPaper *lgl_paper_dup (const lglPaper *orig); diff --git a/glabels2/libglabels/xml-paper.c b/glabels2/libglabels/xml-paper.c index 0eda5a39..fc6f07fa 100644 --- a/glabels2/libglabels/xml-paper.c +++ b/glabels2/libglabels/xml-paper.c @@ -151,7 +151,7 @@ lglPaper * lgl_xml_paper_parse_paper_node (xmlNodePtr paper_node) { lglPaper *paper; - gchar *id, *name; + gchar *id, *name, *pwg_size; gdouble width, height; LIBXML_TEST_VERSION; @@ -163,10 +163,13 @@ lgl_xml_paper_parse_paper_node (xmlNodePtr paper_node) width = lgl_xml_get_prop_length (paper_node, "width", 0); height = lgl_xml_get_prop_length (paper_node, "height", 0); - paper = lgl_paper_new (id, name, width, height); + pwg_size = lgl_xml_get_prop_string (paper_node, "pwg_size", NULL); + + paper = lgl_paper_new (id, name, width, height, pwg_size); g_free (id); g_free (name); + g_free (pwg_size); return paper; } diff --git a/glabels2/src/print-op.c b/glabels2/src/print-op.c index d3fd7ad0..2b2cd4a7 100644 --- a/glabels2/src/print-op.c +++ b/glabels2/src/print-op.c @@ -425,24 +425,39 @@ set_page_size (glPrintOp *op, { GtkPaperSize *psize; GtkPageSetup *su; - gchar *name; + lglPaper *paper; - name = lgl_db_lookup_paper_name_from_id (label->template->paper_id); + gl_debug (DEBUG_PRINT, "begin"); - if (lgl_db_is_paper_id_other (label->template->paper_id)) + paper = lgl_db_lookup_paper_from_id (label->template->paper_id); + + if (!paper) { - psize = gtk_paper_size_new_custom (label->template->paper_id, - name, + const gchar *name; + + name = gtk_paper_size_get_default (); + psize = gtk_paper_size_new (name); + + gl_debug (DEBUG_PRINT, "Using default size = \"%s\"", name); + } + else if (lgl_db_is_paper_id_other (paper->id)) + { + psize = gtk_paper_size_new_custom (paper->id, + paper->name, label->template->page_width, label->template->page_height, GTK_UNIT_POINTS); + gl_debug (DEBUG_PRINT, "Using custom size = %g x %g points", + label->template->page_width, + label->template->page_height); + } else { - /* Use default size. */ - return; + psize = gtk_paper_size_new (paper->pwg_size); + gl_debug (DEBUG_PRINT, "Using PWG size \"%s\"", paper->pwg_size); } - g_free (name); + lgl_paper_free (paper); su = gtk_page_setup_new (); gtk_page_setup_set_paper_size (su, psize); @@ -450,6 +465,8 @@ set_page_size (glPrintOp *op, g_object_unref (su); gtk_paper_size_free (psize); + + gl_debug (DEBUG_PRINT, "end"); } /*--------------------------------------------------------------------------*/ -- 2.39.5