* 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
+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):
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) {
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);
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;
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),
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);
{
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);
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);
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;
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;
}
-
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