summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2011-09-19 15:45:24 +0200
committerBenjamin Otte <otte@redhat.com>2011-09-19 22:11:06 +0200
commit6d8010d3d409bfab85eccab6af9fb25a643954aa (patch)
tree00b626e03bd1a77675aac1c2ffd1c73e98ac42f5 /gtk
parentd88b7a6d6b9005db0159cf78f09aed7a9249c92f (diff)
downloadgtk+-6d8010d3d409bfab85eccab6af9fb25a643954aa.tar.gz
fontchooser: Move the filter func to the visibility func
... instead of rereading all the fonts every time. With this change, the liststore now contains every font face known to GTK, so we can actually walk it for matching fonts.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkfontchooserwidget.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c
index 9ea47b1376..1bd14055c1 100644
--- a/gtk/gtkfontchooserwidget.c
+++ b/gtk/gtkfontchooserwidget.c
@@ -752,10 +752,6 @@ populate_list (GtkFontChooserWidget *fontchooser,
const gchar *face_name;
gchar *font_desc;
- if (priv->filter_func != NULL &&
- !priv->filter_func (families[i], faces[j], priv->filter_data))
- continue;
-
pango_desc = pango_font_face_describe (faces[j]);
face_name = pango_font_face_get_face_name (faces[j]);
font_desc = pango_font_description_to_string (pango_desc);
@@ -831,6 +827,25 @@ visible_func (GtkTreeModel *model,
gchar *font_name, *font_name_casefold, *term_casefold;
guint i;
+ if (priv->filter_func != NULL)
+ {
+ PangoFontFamily *family;
+ PangoFontFace *face;
+
+ gtk_tree_model_get (model, iter,
+ FAMILY_COLUMN, &family,
+ FACE_COLUMN, &face,
+ -1);
+
+ result = priv->filter_func (family, face, priv->filter_data);
+
+ g_object_unref (family);
+ g_object_unref (face);
+
+ if (!result)
+ return FALSE;
+ }
+
/* If there's no filter string we show the item */
search_text = gtk_entry_get_text (GTK_ENTRY (priv->search_entry));
if (strlen (search_text) == 0)
@@ -1190,9 +1205,7 @@ gtk_font_chooser_widget_set_filter_func (GtkFontChooser *chooser,
priv->filter_data = data;
priv->filter_data_destroy = destroy;
- populate_list (fontchooser,
- GTK_TREE_VIEW (priv->family_face_list),
- priv->model);
+ gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter_model));
}
static void