]> git.sur5r.net Git - glabels/commitdiff
2007-11-29 Jim Evins <evins@snaught.com>
authorJim Evins <evins@snaught.com>
Fri, 30 Nov 2007 02:13:51 +0000 (02:13 +0000)
committerJim Evins <evins@snaught.com>
Fri, 30 Nov 2007 02:13:51 +0000 (02:13 +0000)
* 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

glabels2/ChangeLog
glabels2/libglabels/db.c
glabels2/libglabels/db.h
glabels2/src/prefs-model.c
glabels2/src/wdgt-media-select.c

index 232975f6fe9ad7b5a60e2d7d3ee43b386f0a2726..cc133c0c6313fc3115864c6ef3a97a6b031aed7e 100644 (file)
@@ -1,3 +1,15 @@
+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:
index 1411408c032a28f58dd7632fdb682081394c7f91..b9cb9ad6a695c6f9a59eb6abf8e569270e1f13d8 100644 (file)
@@ -1146,6 +1146,53 @@ lgl_db_does_template_exist (const gchar *brand,
 }
 
 
+/**
+ * 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
@@ -1291,6 +1338,7 @@ lgl_db_lookup_template_from_name (const gchar *name)
        lglTemplate      *template;
         lglTemplateAlias *alias;
         gchar            *candidate_name;
+       lglTemplate      *new_template;
 
        if (!templates)
         {
@@ -1313,7 +1361,10 @@ lgl_db_lookup_template_from_name (const gchar *name)
 
                        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);
                }
index fe0c85e405b0459d0efe3888a700719ba1b7b260..c6b6f7ef2bc868e36d994f4e2577ead3d1d110ae 100644 (file)
@@ -115,6 +115,8 @@ lglDbRegStatus lgl_db_register_template              (const lglTemplate   *templ
 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);
index c49c155eac9e093282d894d7e0c593a31d011520..b67f92f4835dd4f721fb675946a1eab823b2dea5 100644 (file)
@@ -385,7 +385,7 @@ gl_prefs_model_load_settings (glPrefsModel *prefs_model)
 {
        gchar    *string;
        lglPaper *paper;
-        GSList   *p;
+        GSList   *p, *p_next;
 
        gl_debug (DEBUG_PREFS, "START");
        
@@ -538,7 +538,6 @@ gl_prefs_model_load_settings (glPrefsModel *prefs_model)
 
        /* 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);
@@ -547,6 +546,19 @@ gl_prefs_model_load_settings (glPrefsModel *prefs_model)
                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);
 
 
index 6906646d5e3abae336dd9f2d44b03434705363b5..0c4b476465f7800939b9fcc42dccc8bc364be2fe 100644 (file)
@@ -353,6 +353,18 @@ gl_wdgt_media_select_construct (glWdgtMediaSelect *media_select)
 
         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");
 }