[glabels] Added test for duplicate templates
- From: Jim Evins <jimevins src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glabels] Added test for duplicate templates
- Date: Thu, 22 Apr 2010 02:41:11 +0000 (UTC)
commit 7381cfd88fa386dc1fc3a7cce0d0aaac9c4dce45
Author: Jim Evins <evins snaught com>
Date: Wed Apr 21 22:37:57 2010 -0400
Added test for duplicate templates
Added test for duplicate pre-defined templates. Removed duplicate
template in pearl-iso-templates.xml. Also added lgl_template_print() for
debugging purposes.
libglabels/db.c | 13 ++++++++++---
libglabels/template.c | 33 +++++++++++++++++++++++++++++++++
libglabels/template.h | 6 ++++++
templates/pearl-iso-templates.xml | 15 +--------------
4 files changed, 50 insertions(+), 17 deletions(-)
---
diff --git a/libglabels/db.c b/libglabels/db.c
index 3370b03..ba01850 100644
--- a/libglabels/db.c
+++ b/libglabels/db.c
@@ -1437,9 +1437,16 @@ _lgl_db_register_template_internal (const lglTemplate *template)
{
lglTemplate *template_copy;
- template_copy = lgl_template_dup (template);
- model->templates = g_list_append (model->templates, template_copy);
- add_to_template_cache (template_copy);
+ if (!lgl_db_does_template_exist (template->brand, template->part))
+ {
+ template_copy = lgl_template_dup (template);
+ model->templates = g_list_append (model->templates, template_copy);
+ add_to_template_cache (template_copy);
+ }
+ else
+ {
+ g_message ("Duplicate template: %s %s.", template->brand, template->part);
+ }
}
diff --git a/libglabels/template.c b/libglabels/template.c
index 50271fb..50ba454 100644
--- a/libglabels/template.c
+++ b/libglabels/template.c
@@ -1474,6 +1474,39 @@ compare_origins (gconstpointer a,
}
+/**
+ * lgl_template_print:
+ * @template: template
+ *
+ * Print template details (for debugging purposes).
+ *
+ */
+void
+lgl_template_print (const lglTemplate *template)
+{
+ GList *p;
+ lglTemplateAlias *alias;
+
+ g_print ("---- %s( TEMPLATE=%p ) ----\n", __FUNCTION__, template);
+
+ g_print("brand=\"%s\", part=\"%s\", description=\"%s\"\n",
+ template->brand, template->part, template->description);
+
+ g_print("paper_id=\"%s\", page_width=%g, page_height=%g\n",
+ template->paper_id, template->page_width, template->page_height);
+
+ for (p=template->aliases; p!=NULL; p=p->next)
+ {
+ alias = (lglTemplateAlias *)p->data;
+ g_print("Alias: brand=\"%s\", part=\"%s\"\n", alias->brand, alias->part);
+
+ }
+
+ g_print ("\n");
+
+}
+
+
/*
* Local Variables: -- emacs
diff --git a/libglabels/template.h b/libglabels/template.h
index a3c0111..a7f43fc 100644
--- a/libglabels/template.h
+++ b/libglabels/template.h
@@ -426,6 +426,12 @@ lglTemplateMarkup *lgl_template_markup_dup (const lglTemplateMarkup
void lgl_template_markup_free (lglTemplateMarkup *markup);
+/*
+ * Debugging functions.
+ */
+void lgl_template_print (const lglTemplate *template);
+
+
G_END_DECLS
#endif /* __LGL_TEMPLATE_H__ */
diff --git a/templates/pearl-iso-templates.xml b/templates/pearl-iso-templates.xml
index d772425..c499ce3 100644
--- a/templates/pearl-iso-templates.xml
+++ b/templates/pearl-iso-templates.xml
@@ -34,7 +34,7 @@
<!-- =================================================================== -->
<!-- PEARL: Adress Labels, 48.8mm x 25.4mm, 40 per sheet -->
<!-- =================================================================== -->
- <Template brand="PEARL" part="PE 8008, PE 8018" size="A4" description="Adressetiketten">
+ <Template brand="PEARL" part="PE-8008, PE-8018" size="A4" description="Adressetiketten">
<Meta category="label"/>
<Meta category="rectangle-label"/>
<Meta product_url="http://www.pearl.de/a-PE8008-2204.shtml"/>
@@ -45,19 +45,6 @@
</Template>
<!-- =================================================================== -->
- <!-- PEARL: Adress Labels, 70mm x 36mm, 24 per sheet -->
- <!-- =================================================================== -->
- <Template brand="PEARL" part="PE-8004, PE-8014" size="A4" description="Adress-Etiketten">
- <Meta category="label"/>
- <Meta category="rectangle-label"/>
- <Meta product_url="http://www.pearl.de/a-PE8004-2204.shtml"/>
- <Label-rectangle id="0" width="70mm" height="36mm" round="0mm" x_waste="0mm" y_waste="0mm">
- <Markup-margin size="3.2mm"/>
- <Layout nx="3" ny="8" x0="0mm" y0="4.8mm" dx="70mm" dy="36mm"/>
- </Label-rectangle>
- </Template>
-
- <!-- =================================================================== -->
<!-- PEARL: Labels, 210mm x 297mm, 1 per sheet -->
<!-- =================================================================== -->
<Template brand="PEARL" part="PE-8007, PE-8017" size="A4" description="Etiketten A4">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]