+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),
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
>
<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>
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);
}
/**
* 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.
*
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;
}
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;
}
g_free (paper->name);
paper->name = NULL;
+ g_free (paper->pwg_size);
+ paper->pwg_size = NULL;
+
g_free (paper);
}
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 */
};
lglPaper *lgl_paper_new (gchar *id,
gchar *name,
gdouble width,
- gdouble height);
+ gdouble height,
+ gchar *pwg_size);
lglPaper *lgl_paper_dup (const lglPaper *orig);
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;
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;
}
{
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);
g_object_unref (su);
gtk_paper_size_free (psize);
+
+ gl_debug (DEBUG_PRINT, "end");
}
/*--------------------------------------------------------------------------*/