]> git.sur5r.net Git - glabels/commitdiff
2008-10-23 Jim Evins <evins@snaught.com>
authorJim Evins <evins@snaught.com>
Fri, 24 Oct 2008 03:30:36 +0000 (03:30 +0000)
committerJim Evins <evins@snaught.com>
Fri, 24 Oct 2008 03:30:36 +0000 (03:30 +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/trunk@788 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 69519f680597e5b467bdbd60b2c451b3d0d14eb2..5a7943bf3a63ea24184db831da1a70d7d76f5a5c 100644 (file)
@@ -1,3 +1,21 @@
+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-10-19  Jim Evins  <evins@snaught.com>
 
        * data/builder/object-editor.glade:
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 79f130513043e579207ddbac8d0445cfc23e69c8..57b37dae75cb44cfe2072fbc1fb552693cd9443f 100644 (file)
@@ -103,7 +103,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);
@@ -223,26 +222,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 a578e9ff5713fc1d77ba8bbdb59822759cc6a955..e5f79d3d98062f985e9611bd1b9999bb4ef4f4b8 100644 (file)
@@ -346,7 +346,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),
@@ -526,7 +525,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 98d233051be4e67e3f30134838baaade10589509..2cfca42fc2b91fc46cfba6e1bdeaa543166c8643 100644 (file)
@@ -336,7 +336,6 @@ gl_ui_property_bar_construct (glUIPropertyBar   *this)
         {
                gtk_combo_box_set_active (GTK_COMBO_BOX (this->priv->font_family_combo), 0);
        }
-       gl_util_font_family_list_free (family_names);
 
        g_signal_connect (G_OBJECT (this->priv->font_family_combo),
                          "changed", G_CALLBACK (font_family_changed_cb), this);
@@ -435,7 +434,6 @@ reset_to_default_properties (glView *view,
        gl_util_combo_box_set_active_text (GTK_COMBO_BOX (this->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(this->priv->font_size_spin),
                                   view->default_font_size);
index 161f2bfcab414c3f7264db8b4943c3bda66c3461..92e31107d77b7e17f65ba2153fce20bd3a64cc8d 100644 (file)
@@ -306,13 +306,14 @@ gl_util_combo_box_add_text_model (GtkComboBox       *combo)
 }
 
 
+
 /****************************************************************************/
 /* 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;
@@ -320,39 +321,27 @@ 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 267b0ef24efae4b1a112ecf8ef0ea7cc00f57e8e..5629cbace2740903444038b63a680a87878bfeda 100644 (file)
@@ -52,7 +52,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);
 
 GdkPixbuf *gl_util_cairo_convert_to_pixbuf (cairo_surface_t *surface);