From ac41c67c4089c1303453fee8efe5c5e97acbc1bd Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Mon, 19 Nov 2007 03:19:50 +0000 Subject: [PATCH] 2007-11-18 Jim Evins * data/glade/template-designer.glade: * src/template-designer.c: Don't advance past name page, if brand and part match an existing template. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@691 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/ChangeLog | 6 +++ glabels2/data/glade/template-designer.glade | 42 +++++++++++++++++---- glabels2/src/template-designer.c | 33 +++++++++++----- 3 files changed, 65 insertions(+), 16 deletions(-) diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index cd93db28..b4199448 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,9 @@ +2007-11-18 Jim Evins + + * data/glade/template-designer.glade: + * src/template-designer.c: + Don't advance past name page, if brand and part match an existing template. + 2007-11-18 Jim Evins * libglabels/db.c: (lgl_db_register_template), (read_templates): diff --git a/glabels2/data/glade/template-designer.glade b/glabels2/data/glade/template-designer.glade index 6b84fbab..f148a742 100644 --- a/glabels2/data/glade/template-designer.glade +++ b/glabels2/data/glade/template-designer.glade @@ -115,7 +115,7 @@ This dialog will assist you in the creation of a custom gLabels template. True - 4 + 6 2 False 12 @@ -318,8 +318,8 @@ This dialog will assist you in the creation of a custom gLabels template. 0 1 - 2 - 3 + 4 + 5 fill @@ -340,8 +340,8 @@ This dialog will assist you in the creation of a custom gLabels template. 1 2 - 2 - 3 + 4 + 5 @@ -367,8 +367,36 @@ This dialog will assist you in the creation of a custom gLabels template. 1 2 - 3 - 4 + 5 + 6 + fill + + + + + + + True + + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 2 + 3 fill diff --git a/glabels2/src/template-designer.c b/glabels2/src/template-designer.c index 097083b3..1cc8cc5c 100644 --- a/glabels2/src/template-designer.c +++ b/glabels2/src/template-designer.c @@ -92,6 +92,7 @@ struct _glTemplateDesignerPrivate /* Name page controls */ GtkWidget *brand_entry; GtkWidget *part_num_entry; + GtkWidget *name_warning_label; GtkWidget *description_entry; /* Page size page controls */ @@ -443,10 +444,11 @@ construct_name_page (glTemplateDesigner *dialog, return; } - dialog->priv->name_page = glade_xml_get_widget (gui, "name_page"); - dialog->priv->brand_entry = glade_xml_get_widget (gui, "brand_entry"); - dialog->priv->part_num_entry = glade_xml_get_widget (gui, "part_num_entry"); - dialog->priv->description_entry = glade_xml_get_widget (gui, "description_entry"); + dialog->priv->name_page = glade_xml_get_widget (gui, "name_page"); + dialog->priv->brand_entry = glade_xml_get_widget (gui, "brand_entry"); + dialog->priv->part_num_entry = glade_xml_get_widget (gui, "part_num_entry"); + dialog->priv->name_warning_label = glade_xml_get_widget (gui, "name_warning_label"); + dialog->priv->description_entry = glade_xml_get_widget (gui, "description_entry"); g_object_unref (gui); @@ -1235,11 +1237,24 @@ name_page_changed_cb (glTemplateDesigner *dialog) { gchar *brand, *part_num, *desc; - brand = gtk_editable_get_chars (GTK_EDITABLE(dialog->priv->brand_entry), 0, -1); - part_num = gtk_editable_get_chars (GTK_EDITABLE(dialog->priv->part_num_entry), 0, -1); + brand = g_strstrip (gtk_editable_get_chars (GTK_EDITABLE(dialog->priv->brand_entry), 0, -1)); + part_num = g_strstrip (gtk_editable_get_chars (GTK_EDITABLE(dialog->priv->part_num_entry), 0, -1)); desc = gtk_editable_get_chars (GTK_EDITABLE(dialog->priv->description_entry), 0, -1); - if (brand && brand[0] && part_num && part_num[0] && desc && desc[0]) + + if (brand && brand[0] && part_num && part_num[0] && + lgl_db_does_template_exist (brand, part_num)) + { + gtk_label_set_markup (GTK_LABEL (dialog->priv->name_warning_label), + _("Brand and part# match an existing template!")); + } + else + { + gtk_label_set_text (GTK_LABEL (dialog->priv->name_warning_label), ""); + } + + if (brand && brand[0] && part_num && part_num[0] && desc && desc[0] && + !lgl_db_does_template_exist (brand, part_num)) { gtk_assistant_set_page_complete (GTK_ASSISTANT (dialog), @@ -1614,8 +1629,8 @@ build_template (glTemplateDesigner *dialog) upp = dialog->priv->units_per_point; - brand = gtk_editable_get_chars (GTK_EDITABLE(dialog->priv->brand_entry), 0, -1); - part_num = gtk_editable_get_chars (GTK_EDITABLE(dialog->priv->part_num_entry), 0, -1); + brand = g_strstrip (gtk_editable_get_chars (GTK_EDITABLE(dialog->priv->brand_entry), 0, -1)); + part_num = g_strstrip (gtk_editable_get_chars (GTK_EDITABLE(dialog->priv->part_num_entry), 0, -1)); desc = gtk_editable_get_chars (GTK_EDITABLE(dialog->priv->description_entry), 0, -1); page_size_name = -- 2.39.5