Filtering a GtkTreeStore correctly
- From: Marcus von Appen <mva sysfault org>
- To: gtk-app-devel-list gnome org
- Subject: Filtering a GtkTreeStore correctly
- Date: Mon, 10 Jan 2005 14:54:41 +0100
Hi,
I wonder, how I can filter entries in a GtkTreeStore correctly.
The current stuff I use is a GtkTreeModelFilter with an own function
connected using gtk_tree_model_filter_set_visible_func.
The problem is that only the parent rows/iters are checked, but not
their children, what's - in my opinion - a wrong behaviour.
The connected function(s) should also operate on the children
automatically. Or do I something wrong?
Code excerpt:
[...]
model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (filter));
model = gtk_tree_model_filter_new (model, NULL);
/* connector */
gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (model),
filter_translation,
(gpointer) text, NULL);
[...]
filter function:
static gboolean
filter_translation (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
{
gchar *text = (gchar *) data;
gchar *value = NULL;
gboolean retval = FALSE;
gtk_tree_model_get (model, iter, EDIT_TRANS, &value, -1);
retval = (g_strrstr (value, text) != NULL);
g_free (value);
return retval;
}
If I have a model with data like this:
+- Test123
+--- Test
+--- Bar
+--- Foo
and want to filter on "Test", the expected result would be
+- Test123
+--- Test
Intstead I receive
- Test123
What would be the correct approach here (if any)?
Regards
Marcus
--
We don't understand the software, and sometimes we don't understand the
hardware, but we can *see* the blinking lights!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]