* libglabels/db.h:
* libglabels/db.c:
Added lgl_db_does_template_name_exist().
In lgl_db_lookup_template_from_name() substitute brand/part of new template from
requested alias.
* src/prefs-model.c:
Proof read recent templates -- make sure they still exist.
* src/wdgt-media-select.c:
Default to "search all templates" tab if no recent templates found.
git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@696
f5e0f49d-192f-0410-a22d-
a8d8700d0965
+2007-11-29 Jim Evins <evins@snaught.com>
+
+ * libglabels/db.h:
+ * libglabels/db.c:
+ Added lgl_db_does_template_name_exist().
+ In lgl_db_lookup_template_from_name() substitute brand/part of new template from
+ requested alias.
+ * src/prefs-model.c:
+ Proof read recent templates -- make sure they still exist.
+ * src/wdgt-media-select.c:
+ Default to "search all templates" tab if no recent templates found.
+
2007-11-28 Jim Evins <evins@snaught.com>
* data/glade/wdgt-media-select.glade:
}
+/**
+ * lgl_db_does_template_name_exist:
+ * @name: name string
+ *
+ * This function test whether a template with the given name exists.
+ *
+ * Returns: TRUE if such a template exists in the database.
+ *
+ */
+gboolean
+lgl_db_does_template_name_exist (const gchar *name)
+{
+ GList *p_tmplt, *p_alias;
+ lglTemplate *template;
+ lglTemplateAlias *alias;
+ gchar *candidate_name;
+
+ if (!templates)
+ {
+ lgl_db_init ();
+ }
+
+ if (name == NULL)
+ {
+ return FALSE;
+ }
+
+ for (p_tmplt = templates; p_tmplt != NULL; p_tmplt = p_tmplt->next)
+ {
+ template = (lglTemplate *) p_tmplt->data;
+ for (p_alias = template->aliases; p_alias != NULL; p_alias = p_alias->next)
+ {
+ alias = (lglTemplateAlias *)p_alias->data;
+ candidate_name = g_strdup_printf ("%s %s", alias->brand, alias->part);
+
+ if ( UTF8_EQUAL (candidate_name, name) ) {
+ g_free (candidate_name);
+ return TRUE;
+ }
+ g_free (candidate_name);
+ }
+ }
+
+ return FALSE;
+}
+
+
/**
* lgl_db_get_template_name_list_unique:
* @brand: If non NULL, limit results to given brand
lglTemplate *template;
lglTemplateAlias *alias;
gchar *candidate_name;
+ lglTemplate *new_template;
if (!templates)
{
if ( UTF8_EQUAL (candidate_name, name) ) {
g_free (candidate_name);
- return lgl_template_dup (template);
+ new_template = lgl_template_dup (template);
+ new_template->brand = g_strdup (alias->brand);
+ new_template->part = g_strdup (alias->part);
+ return new_template;
}
g_free (candidate_name);
}
gboolean lgl_db_does_template_exist (const gchar *brand,
const gchar *part);
+gboolean lgl_db_does_template_name_exist (const gchar *name);
+
GList *lgl_db_get_template_name_list_unique (const gchar *brand,
const gchar *paper_id,
const gchar *category_id);
{
gchar *string;
lglPaper *paper;
- GSList *p;
+ GSList *p, *p_next;
gl_debug (DEBUG_PREFS, "START");
/* Proof read the default page size -- it must be a valid id. */
/* (For compatability with older versions.) */
- /* Note: paper module must be initialized for this to work. */
paper = lgl_db_lookup_paper_from_id (prefs_model->default_page_size);
if ( paper == NULL ) {
prefs_model->default_page_size = g_strdup (DEFAULT_PAGE_SIZE);
paper = NULL;
}
+ /* Proof read the recent templates list. Make sure the template names */
+ /* are valid. Remove from list if not. */
+ for (p=prefs_model->recent_templates; p != NULL; p=p_next)
+ {
+ p_next = p->next;
+
+ if ( !lgl_db_does_template_name_exist (p->data) )
+ {
+ g_free (p->data);
+ prefs_model->recent_templates = g_slist_delete_link (prefs_model->recent_templates, p);
+ }
+ }
+
gl_debug (DEBUG_PREFS, "max_recents = %d", prefs_model->max_recents);
g_free (page_size_name);
+ gtk_widget_show_all (GTK_WIDGET (media_select));
+ if ( gl_prefs->recent_templates )
+ {
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (media_select->priv->notebook),
+ media_select->priv->recent_page_num);
+ }
+ else
+ {
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (media_select->priv->notebook),
+ media_select->priv->search_all_page_num);
+ }
+
gl_debug (DEBUG_MEDIA_SELECT, "END");
}