]> git.sur5r.net Git - glabels/commitdiff
2008-08-17 Jim Evins <evins@snaught.com>
authorJim Evins <evins@snaught.com>
Sun, 17 Aug 2008 19:27:06 +0000 (19:27 +0000)
committerJim Evins <evins@snaught.com>
Sun, 17 Aug 2008 19:27:06 +0000 (19:27 +0000)
* 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/branches/glabels-2_2@778 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/ChangeLog
glabels2/data/dtd/glabels-2.2.dtd
glabels2/data/templates/paper-sizes.xml
glabels2/libglabels/db.c
glabels2/libglabels/paper.c
glabels2/libglabels/paper.h
glabels2/libglabels/xml-paper.c
glabels2/src/print-op.c

index 14857f7c27bb69a54245f33b02af2b7bb4d2fb73..5d6b145232df2a6367d43380c0ceed1b8f4aa7cd 100644 (file)
@@ -1,3 +1,16 @@
+2008-08-17  Jim Evins  <evins@snaught.com>
+
+       * 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  <evins@snaught.com>
 
        * src/object-editor-size-page.c: (size_reset_cb),
index 183df8b600e9d390048ce47c3a7c0796086222b7..b23519fcb595db0b90cf83c5af9ed2532062941f 100644 (file)
                  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
 >
index da61d75be9c70526b0c3efe1f413839a90bb9b73..17149aeb456bd24caa9814c2ad96cf73b69e44b9 100644 (file)
@@ -2,36 +2,36 @@
 <Glabels-paper-sizes>
 
   <!-- Most popular (at top of list) -->
-  <Paper-size id="US-Letter"    _name="US Letter"    width="8.5in" height="11in"/>
-  <Paper-size id="A4"           _name="A4"           width="210mm" height="297mm"/>
+  <Paper-size id="US-Letter"    _name="US Letter"    pwg_size="na_letter"    width="8.5in" height="11in"/>
+  <Paper-size id="A4"           _name="A4"           pwg_size="iso_a4"       width="210mm" height="297mm"/>
 
   <!-- Other US paper sizes -->
-  <Paper-size id="US-Legal"     _name="US Legal"     width="8.5in" height="14in"/>
-  <Paper-size id="US-Executive" _name="US Executive" width="7.25in" height="10.5in"/>
+  <Paper-size id="US-Legal"     _name="US Legal"     pwg_size="na_legal"     width="8.5in" height="14in"/>
+  <Paper-size id="US-Executive" _name="US Executive" pwg_size="na_executive" width="7.25in" height="10.5in"/>
 
   <!-- Other ISO A series sizes -->
-  <Paper-size id="A0"           _name="A0"           width="841mm" height="1189mm"/>
-  <Paper-size id="A1"           _name="A1"           width="594mm" height="841mm"/>
-  <Paper-size id="A2"           _name="A2"           width="420mm" height="594mm"/>
-  <Paper-size id="A3"           _name="A3"           width="297mm" height="420mm"/>
-  <Paper-size id="A5"           _name="A5"           width="148mm" height="210mm"/>
-  <Paper-size id="A6"           _name="A6"           width="105mm" height="148mm"/>
-  <Paper-size id="A7"           _name="A7"           width="74mm"  height="105mm"/>
-  <Paper-size id="A8"           _name="A8"           width="52mm"  height="74mm"/>
-  <Paper-size id="A9"           _name="A9"           width="37mm"  height="52mm"/>
-  <Paper-size id="A10"          _name="A10"          width="26mm"  height="37mm"/>
+  <Paper-size id="A0"           _name="A0"           pwg_size="iso_a0"       width="841mm" height="1189mm"/>
+  <Paper-size id="A1"           _name="A1"           pwg_size="iso_a1"       width="594mm" height="841mm"/>
+  <Paper-size id="A2"           _name="A2"           pwg_size="iso_a2"       width="420mm" height="594mm"/>
+  <Paper-size id="A3"           _name="A3"           pwg_size="iso_a3"       width="297mm" height="420mm"/>
+  <Paper-size id="A5"           _name="A5"           pwg_size="iso_a5"       width="148mm" height="210mm"/>
+  <Paper-size id="A6"           _name="A6"           pwg_size="iso_a6"       width="105mm" height="148mm"/>
+  <Paper-size id="A7"           _name="A7"           pwg_size="iso_a7"       width="74mm"  height="105mm"/>
+  <Paper-size id="A8"           _name="A8"           pwg_size="iso_a8"       width="52mm"  height="74mm"/>
+  <Paper-size id="A9"           _name="A9"           pwg_size="iso_a9"       width="37mm"  height="52mm"/>
+  <Paper-size id="A10"          _name="A10"          pwg_size="iso_a10"      width="26mm"  height="37mm"/>
 
   <!-- ISO B series sizes -->
-  <Paper-size id="B0"           _name="B0"           width="1000mm" height="1414mm"/>
-  <Paper-size id="B1"           _name="B1"           width="707mm"  height="1000mm"/>
-  <Paper-size id="B2"           _name="B2"           width="500mm"  height="707mm"/>
-  <Paper-size id="B3"           _name="B3"           width="353mm"  height="500mm"/>
-  <Paper-size id="B4"           _name="B4"           width="250mm"  height="353mm"/>
-  <Paper-size id="B5"           _name="B5"           width="176mm"  height="250mm"/>
-  <Paper-size id="B6"           _name="B6"           width="125mm"  height="176mm"/>
-  <Paper-size id="B7"           _name="B7"           width="88mm"   height="125mm"/>
-  <Paper-size id="B8"           _name="B8"           width="62mm"   height="88mm"/>
-  <Paper-size id="B9"           _name="B9"           width="44mm"   height="62mm"/>
-  <Paper-size id="B10"          _name="B10"          width="31mm"   height="44mm"/>
+  <Paper-size id="B0"           _name="B0"           pwg_size="iso_b0"       width="1000mm" height="1414mm"/>
+  <Paper-size id="B1"           _name="B1"           pwg_size="iso_b1"       width="707mm"  height="1000mm"/>
+  <Paper-size id="B2"           _name="B2"           pwg_size="iso_b2"       width="500mm"  height="707mm"/>
+  <Paper-size id="B3"           _name="B3"           pwg_size="iso_b3"       width="353mm"  height="500mm"/>
+  <Paper-size id="B4"           _name="B4"           pwg_size="iso_b4"       width="250mm"  height="353mm"/>
+  <Paper-size id="B5"           _name="B5"           pwg_size="iso_b5"       width="176mm"  height="250mm"/>
+  <Paper-size id="B6"           _name="B6"           pwg_size="iso_b6"       width="125mm"  height="176mm"/>
+  <Paper-size id="B7"           _name="B7"           pwg_size="iso_b7"       width="88mm"   height="125mm"/>
+  <Paper-size id="B8"           _name="B8"           pwg_size="iso_b8"       width="62mm"   height="88mm"/>
+  <Paper-size id="B9"           _name="B9"           pwg_size="iso_b9"       width="44mm"   height="62mm"/>
+  <Paper-size id="B10"          _name="B10"          pwg_size="iso_b10"      width="31mm"   height="44mm"/>
 
 </Glabels-paper-sizes>
index 2ca3f83b3fa79d56407cc1e660a3281a2d56369a..28f227c5fa6e89bd66dec26c6e95b42f25e0a6c0 100644 (file)
@@ -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);
 
        }
index e4d266a610ebc91df11f4b534d2f13c3a371c183..98826c9b213fb792f2f0895859a91888d21c6cab 100644 (file)
 
 /**
  * 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);
        }
 
index 12fe978f59e5aff1128db5cea07b69f6a8a020f0..0fb4238816dbf48386e43dd80de481c4dddad01f 100644 (file)
@@ -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);
 
index 0eda5a39edfd8e89a18f5902b799ad5117200d69..fc6f07fa49f38eddd93b88d4f7e4b7904feb3660 100644 (file)
@@ -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;
 }
index d3fd7ad097a302fb080a80ef169b813cd2763b35..2b2cd4a7c838bc7904e40dad0674a653638951d9 100644 (file)
@@ -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");
 }
 
 /*--------------------------------------------------------------------------*/