]> git.sur5r.net Git - glabels/commitdiff
2008-10-23 Jim Evins <evins@snaught.com>
authorJim Evins <evins@snaught.com>
Fri, 24 Oct 2008 03:17:46 +0000 (03:17 +0000)
committerJim Evins <evins@snaught.com>
Fri, 24 Oct 2008 03:17:46 +0000 (03:17 +0000)
* src/label-text.c: (set_font_family):
* src/object-editor-text-page.c:
(gl_object_editor_prepare_text_page),
(gl_object_editor_set_font_family):
* src/prefs-dialog.c: (construct_object_page),
(update_object_page_from_prefs):
* src/ui-property-bar.c: (gl_ui_property_bar_construct),
(reset_to_default_properties):
* src/util.c: (gl_util_get_font_family_list):
* src/util.h:
Bug #1902275 and Bug #2186214.  Cache font list so that it is not re-created everytime
the list is requested.
* src/object-editor-text-page.c: (gl_object_editor_set_font_family):
Don't change font-family if it hasn't actually changed.

git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/branches/glabels-2_2@787 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/ChangeLog
glabels2/src/label-text.c
glabels2/src/object-editor-text-page.c
glabels2/src/prefs-dialog.c
glabels2/src/ui-property-bar.c
glabels2/src/util.c
glabels2/src/util.h

index 4d2351dac5257a79ec17100d9ac772ff5abceca9..77b9aef769be64545918832960f3581856d0bdf5 100644 (file)
@@ -1,3 +1,20 @@
+2008-10-23  Jim Evins  <evins@snaught.com>
+
+       * src/label-text.c: (set_font_family):
+       * src/object-editor-text-page.c:
+       (gl_object_editor_prepare_text_page),
+       (gl_object_editor_set_font_family):
+       * src/prefs-dialog.c: (construct_object_page),
+       (update_object_page_from_prefs):
+       * src/ui-property-bar.c: (gl_ui_property_bar_construct),
+       (reset_to_default_properties):
+       * src/util.c: (gl_util_get_font_family_list):
+       * src/util.h:
+               Bug #1902275 and Bug #2186214.  Cache font list so that it is not re-created everytime
+               the list is requested.
+       * src/object-editor-text-page.c: (gl_object_editor_set_font_family):
+               Don't change font-family if it hasn't actually changed.
+
 2008-08-29  Jim Evins  <evins@snaught.com>
 
        * src/file.c: (gl_file_open), (gl_file_save_as):
index 6139d5e79f2d3879a188fc0976a56e5a5e453e0f..9a4d59a16581ae643774d587c8c7cca4407201e0 100644 (file)
@@ -450,7 +450,6 @@ set_font_family (glLabelObject *object,
                        good_font_family = g_strdup (font_family);
                }
        }
-       gl_util_font_family_list_free (family_names);
 
        if (ltext->priv->font_family) {
                if (g_strcasecmp (ltext->priv->font_family, good_font_family) == 0) {
index 93aad0a47c0e8c6d1e79c2926054460b14920998..e8a463da2f6526378f3d292eb895f75b03cc6444 100644 (file)
@@ -108,7 +108,6 @@ gl_object_editor_prepare_text_page (glObjectEditor       *editor)
        family_names = gl_util_get_font_family_list ();
        gl_util_combo_box_set_strings (GTK_COMBO_BOX(editor->priv->text_family_combo),
                                       family_names);
-       gl_util_font_family_list_free (family_names);
 
        /* Modify widgets */
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->text_color_radio), TRUE);
@@ -228,26 +227,34 @@ gl_object_editor_set_font_family (glObjectEditor      *editor,
                                  const gchar         *font_family)
 {
         GList    *family_names;
+       gchar    *old_font_family;
        gchar    *good_font_family;
 
        gl_debug (DEBUG_EDITOR, "START");
 
         editor->priv->stop_signals = TRUE;
 
-        /* Make sure we have a valid font family.  if not provide a good default. */
-        family_names = gl_util_get_font_family_list ();
-        if (g_list_find_custom (family_names, font_family, (GCompareFunc)g_utf8_collate)) {
-                good_font_family = g_strdup (font_family);
-        } else {
-                if (family_names != NULL) {
-                        good_font_family = g_strdup (family_names->data); /* 1st entry */
+       old_font_family = gtk_combo_box_get_active_text (GTK_COMBO_BOX (editor->priv->text_family_combo));
+
+        if ( !old_font_family || g_utf8_collate( old_font_family, font_family ) )
+        {
+
+                /* Make sure we have a valid font family.  if not provide a good default. */
+                family_names = gl_util_get_font_family_list ();
+                if (g_list_find_custom (family_names, font_family, (GCompareFunc)g_utf8_collate)) {
+                        good_font_family = g_strdup (font_family);
                 } else {
-                        good_font_family = NULL;
+                        if (family_names != NULL) {
+                                good_font_family = g_strdup (family_names->data); /* 1st entry */
+                        } else {
+                                good_font_family = NULL;
+                        }
                 }
+                gl_util_combo_box_set_active_text (GTK_COMBO_BOX (editor->priv->text_family_combo), good_font_family);
+                g_free (good_font_family);
         }
-        gl_util_font_family_list_free (family_names);
-        gl_util_combo_box_set_active_text (GTK_COMBO_BOX (editor->priv->text_family_combo), good_font_family);
-        g_free (good_font_family);
+
+        g_free (old_font_family);
 
         editor->priv->stop_signals = FALSE;
 
index 683926fb906d22ed9ae4663f0ad7c6a1da30701f..0a09523178ef6a4dca10ef9c0d0e24d20bc6f4ad 100644 (file)
@@ -341,7 +341,6 @@ construct_object_page (glPrefsDialog *dialog)
         family_names = gl_util_get_font_family_list ();
        gl_util_combo_box_set_strings (GTK_COMBO_BOX (dialog->priv->text_family_combo),
                                       family_names);
-        gl_util_font_family_list_free (family_names);
                                                                                 
 
        g_signal_connect_swapped (G_OBJECT(dialog->priv->text_family_combo),
@@ -522,7 +521,6 @@ update_object_page_from_prefs (glPrefsDialog *dialog)
                         good_font_family = NULL;
                 }
         }
-        gl_util_font_family_list_free (family_names);
        gl_util_combo_box_set_active_text (GTK_COMBO_BOX (dialog->priv->text_family_combo),
                                           good_font_family);
         g_free (good_font_family);
index ea2d10a497417e166db9a8b96e4823762ddf4fbf..d128682c3c8512c136a6604cf4166431f9dcc3bd 100644 (file)
@@ -301,7 +301,6 @@ gl_ui_property_bar_construct (glUIPropertyBar   *property_bar)
         {
                gtk_combo_box_set_active (GTK_COMBO_BOX (property_bar->priv->font_family_combo), 0);
        }
-       gl_util_font_family_list_free (family_names);
 
        g_signal_connect (G_OBJECT (property_bar->priv->font_family_combo),
                          "changed", G_CALLBACK (font_family_changed_cb), property_bar);
@@ -406,7 +405,6 @@ reset_to_default_properties (glView *view,
        gl_util_combo_box_set_active_text (GTK_COMBO_BOX (property_bar->priv->font_family_combo),
                                           good_font_family);
        g_free (good_font_family);
-       gl_util_font_family_list_free (family_names);
 
        gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->priv->font_size_spin),
                                   view->default_font_size);
index ee9151bff7667be2545c7fc59e52fb71b0bf82ae..1e852ecac316558034a667be0fcba501b84837d4 100644 (file)
@@ -305,13 +305,14 @@ gl_util_combo_box_add_text_model (GtkComboBox       *combo)
                                        NULL);
 }
 
+
 /****************************************************************************/
 /* Get list of available font families.                                     */
 /****************************************************************************/
 GList  *
 gl_util_get_font_family_list (void)
 {
-       GList                *list = NULL;
+       static GList         *list = NULL;
        PangoFontMap         *fontmap;
        PangoContext         *context;
        PangoFontFamily     **families;
@@ -319,39 +320,26 @@ gl_util_get_font_family_list (void)
        gint                  i;
        gchar                *name;
 
-       fontmap = pango_cairo_font_map_new ();
-       context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fontmap));
-
-       pango_context_list_families (context, &families, &n);
-
-       for ( i=0; i<n; i++ )
-       {
-               name = g_strdup (pango_font_family_get_name (families[i]));
-               list = g_list_insert_sorted (list, name,
-                                             (GCompareFunc)lgl_str_utf8_casecmp);
-       }
-
-       g_free (families);
+        if ( !list )
+        {
+                fontmap = pango_cairo_font_map_new ();
+                context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fontmap));
 
-       g_object_unref (context);
-       g_object_unref (fontmap);
+                pango_context_list_families (context, &families, &n);
 
-       return list;
-}
+                for ( i=0; i<n; i++ )
+                {
+                        name = g_strdup (pango_font_family_get_name (families[i]));
+                        list = g_list_insert_sorted (list, name,
+                                                     (GCompareFunc)lgl_str_utf8_casecmp);
+                }
 
-/****************************************************************************/
-/* Free previosly allocated list of font families.                          */
-/****************************************************************************/
-void    gl_util_font_family_list_free (GList *list)
-{
-        GList *p;
+                g_free (families);
 
-        for (p = list; p != NULL; p = p->next) {
-                g_free (p->data);
-                p->data = NULL;
+                g_object_unref (context);
+                g_object_unref (fontmap);
         }
 
-        g_list_free (list);
+       return list;
 }
 
-
index aa0ff25e57b0c47b3633b5a245aceaf1b3c04b2d..bed0112fd80cead7882c787e367aaadef3c03626 100644 (file)
@@ -51,7 +51,6 @@ void gl_util_combo_box_set_active_text (GtkComboBox       *combo,
 void gl_util_combo_box_add_text_model  (GtkComboBox       *combo);
 
 GList  *gl_util_get_font_family_list (void);
-void    gl_util_font_family_list_free (GList *list);
 
 G_END_DECLS