[gtk/matthiasc/for-master] gtk-demo: Improve filtering
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master] gtk-demo: Improve filtering
- Date: Sun, 9 Aug 2020 14:55:31 +0000 (UTC)
commit c80a612af79dedccca76bcdfa66b431f212263b1
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Aug 9 10:53:48 2020 -0400
gtk-demo: Improve filtering
Show sidebar rows if any parent matches. This lets one
search for "lists" and get just the subtree with all the
listview demos.
demos/gtk-demo/main.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c
index 2b1c36f611..ad6043571f 100644
--- a/demos/gtk-demo/main.c
+++ b/demos/gtk-demo/main.c
@@ -766,6 +766,7 @@ demo_filter_by_name (GtkTreeListRow *row,
GListModel *children;
GtkDemo *demo;
guint i, n;
+ GtkTreeListRow *parent;
/* Show all items if search is empty */
if (!search_needle || !search_needle[0] || !*search_needle[0])
@@ -774,6 +775,17 @@ demo_filter_by_name (GtkTreeListRow *row,
g_assert (GTK_IS_TREE_LIST_ROW (row));
g_assert (GTK_IS_FILTER_LIST_MODEL (model));
+ /* Show a row if itself of any parent matches */
+ for (parent = row; parent; parent = gtk_tree_list_row_get_parent (parent))
+ {
+ demo = gtk_tree_list_row_get_item (parent);
+ g_assert (GTK_IS_DEMO (demo));
+
+ if (filter_demo (demo))
+ return TRUE;
+ }
+
+ /* Show a row if any child matches */
children = gtk_tree_list_row_get_children (row);
if (children)
{
@@ -792,10 +804,7 @@ demo_filter_by_name (GtkTreeListRow *row,
}
}
- demo = gtk_tree_list_row_get_item (row);
- g_assert (GTK_IS_DEMO (demo));
-
- return filter_demo (demo);
+ return FALSE;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]