[gtk/prop-list: 2/3] inspector: Use search instead of filtering for properties
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/prop-list: 2/3] inspector: Use search instead of filtering for properties
- Date: Wed, 25 Dec 2019 06:11:46 +0000 (UTC)
commit 682dbe1c9c85a40c2672c3830443ee73e5745061
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Dec 24 15:34:04 2019 -0500
inspector: Use search instead of filtering for properties
This is mainly to test the search support.
gtk/inspector/prop-list.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
---
diff --git a/gtk/inspector/prop-list.c b/gtk/inspector/prop-list.c
index 9ba203258f..ac97ef5c9d 100644
--- a/gtk/inspector/prop-list.c
+++ b/gtk/inspector/prop-list.c
@@ -42,7 +42,6 @@
#include "gtklistbox.h"
#include "gtksizegroup.h"
#include "gtkroot.h"
-#include "gtkgestureclick.h"
#include "gtkstylecontext.h"
#include "prop-holder.h"
@@ -229,6 +228,18 @@ update_filter (GtkInspectorPropList *pl,
gtk_string_filter_set_search (GTK_STRING_FILTER (pl->priv->filter), text);
}
+static void
+next_match (GtkInspectorPropList *pl)
+{
+ gtk_column_view_select_next_match (GTK_COLUMN_VIEW (pl->priv->list), TRUE);
+}
+
+static void
+previous_match (GtkInspectorPropList *pl)
+{
+ gtk_column_view_select_next_match (GTK_COLUMN_VIEW (pl->priv->list), FALSE);
+}
+
static void
constructed (GObject *object)
{
@@ -243,6 +254,10 @@ constructed (GObject *object)
G_CALLBACK (show_search_entry), pl);
g_signal_connect_swapped (pl->priv->search_entry, "search-changed",
G_CALLBACK (update_filter), pl);
+ g_signal_connect_swapped (pl->priv->search_entry, "next-match",
+ G_CALLBACK (next_match), pl);
+ g_signal_connect_swapped (pl->priv->search_entry, "previous-match",
+ G_CALLBACK (previous_match), pl);
}
static void
@@ -579,8 +594,6 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
guint num_properties;
guint i;
GListStore *store;
- GListModel *list;
- GListModel *filtered;
GtkSortListModel *sorted;
if (!object)
@@ -618,19 +631,15 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
if (GTK_IS_WIDGET (object))
g_signal_connect_object (object, "destroy", G_CALLBACK (cleanup_object), pl, G_CONNECT_SWAPPED);
- filtered = G_LIST_MODEL (gtk_filter_list_model_new (G_LIST_MODEL (store), pl->priv->filter));
- sorted = gtk_sort_list_model_new (filtered, NULL);
- list = G_LIST_MODEL (gtk_no_selection_new (G_LIST_MODEL (sorted)));
+ sorted = gtk_sort_list_model_new (G_LIST_MODEL (store), gtk_column_view_get_sorter (GTK_COLUMN_VIEW
(pl->priv->list)));
- gtk_column_view_set_model (GTK_COLUMN_VIEW (pl->priv->list), list);
- gtk_sort_list_model_set_sorter (sorted, gtk_column_view_get_sorter (GTK_COLUMN_VIEW (pl->priv->list)));
+ gtk_column_view_set_search_filter (GTK_COLUMN_VIEW (pl->priv->list), pl->priv->filter);
+ gtk_column_view_set_model (GTK_COLUMN_VIEW (pl->priv->list), G_LIST_MODEL (sorted));
gtk_column_view_sort_by_column (GTK_COLUMN_VIEW (pl->priv->list), pl->priv->name, GTK_SORT_ASCENDING);
gtk_widget_show (GTK_WIDGET (pl));
- g_object_unref (list);
g_object_unref (sorted);
- g_object_unref (filtered);
g_object_unref (store);
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]