summaryrefslogtreecommitdiff
path: root/gtk/gtkfontchooserwidget.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2015-05-04 13:25:27 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2015-05-05 11:22:53 +0100
commitc6df17577ab3ee8ffebec049ddf580f486f356c8 (patch)
treed9524be85561547b1287aca5f4aac056baf460bd /gtk/gtkfontchooserwidget.c
parent4c06d08e2d6cf4790af38fb2c40be36e65535f77 (diff)
downloadgtk+-c6df17577ab3ee8ffebec049ddf580f486f356c8.tar.gz
fontchooser: Use gtk-fontconfig-timestamp setting
We can use the GtkSettings:gtk-fontconfig-timestamp property to decide whether or not we should reload fonts on style and screen changes. This should avoid doing a lot of work with large font collections when only the theme has changed. https://bugzilla.gnome.org/show_bug.cgi?id=748782
Diffstat (limited to 'gtk/gtkfontchooserwidget.c')
-rw-r--r--gtk/gtkfontchooserwidget.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c
index 5fc82b264a..9e22fbc277 100644
--- a/gtk/gtkfontchooserwidget.c
+++ b/gtk/gtkfontchooserwidget.c
@@ -95,6 +95,8 @@ struct _GtkFontChooserWidgetPrivate
GtkFontFilterFunc filter_func;
gpointer filter_data;
GDestroyNotify filter_data_destroy;
+
+ guint last_fontconfig_timestamp;
};
/* This is the initial fixed height and the top padding of the preview entry */
@@ -633,6 +635,21 @@ gtk_font_chooser_widget_load_fonts (GtkFontChooserWidget *fontchooser)
gint n_families, i;
PangoFontFamily **families;
gchar *family_and_face;
+ guint fontconfig_timestamp;
+
+ g_object_get (gtk_widget_get_settings (GTK_WIDGET (fontchooser)),
+ "gtk-fontconfig-timestamp", &fontconfig_timestamp,
+ NULL);
+
+ /* The fontconfig timestamp is only set on systems with fontconfig; every
+ * other platform will set it to 0. For those systems, we fall back to
+ * reloading the fonts every time.
+ */
+ if (fontconfig_timestamp != 0 &&
+ priv->last_fontconfig_timestamp == fontconfig_timestamp)
+ return;
+
+ priv->last_fontconfig_timestamp = fontconfig_timestamp;
list_store = GTK_LIST_STORE (priv->model);