[gnome-builder] GbPreferencesWindow: trigger filtering when search text changes
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] GbPreferencesWindow: trigger filtering when search text changes
- Date: Fri, 12 Dec 2014 12:05:17 +0000 (UTC)
commit d39454726bc707f2840360c25efd4fb6ea4751cb
Author: Christian Hergert <christian hergert me>
Date: Fri Dec 12 03:44:09 2014 -0800
GbPreferencesWindow: trigger filtering when search text changes
src/preferences/gb-preferences-window.c | 37 +++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/src/preferences/gb-preferences-window.c b/src/preferences/gb-preferences-window.c
index 571edef..9008114 100644
--- a/src/preferences/gb-preferences-window.c
+++ b/src/preferences/gb-preferences-window.c
@@ -84,6 +84,37 @@ gb_preferences_window_close (GbPreferencesWindow *window)
}
static void
+gb_preferences_window_search_changed (GbPreferencesWindow *window,
+ GtkSearchEntry *entry)
+{
+ GList *pages;
+ GList *iter;
+ const gchar *text;
+ gchar **keywords;
+
+ g_return_if_fail (GB_IS_PREFERENCES_WINDOW (window));
+ g_return_if_fail (GTK_IS_ENTRY (entry));
+
+ text = gtk_entry_get_text (GTK_ENTRY (entry));
+ keywords = g_strsplit (text, " ", -1);
+
+ if (g_strv_length (keywords) == 0)
+ g_clear_pointer (&keywords, g_strfreev);
+
+ pages = gtk_container_get_children (GTK_CONTAINER (window->priv->stack));
+
+ for (iter = pages; iter; iter = iter->next)
+ {
+ GbPreferencesPage *page = GB_PREFERENCES_PAGE (iter->data);
+
+ gb_preferences_page_set_keywords (page, (const gchar * const *)keywords);
+ }
+
+ g_list_free (pages);
+ g_strfreev (keywords);
+}
+
+static void
gb_preferences_window_constructed (GObject *object)
{
GbPreferencesWindow *window = (GbPreferencesWindow *)object;
@@ -98,6 +129,12 @@ gb_preferences_window_constructed (GObject *object)
G_CALLBACK (gb_preferences_window_section_changed),
window);
gb_preferences_window_section_changed (window->priv->stack, NULL, window);
+
+ g_signal_connect_object (window->priv->search_entry,
+ "changed",
+ G_CALLBACK (gb_preferences_window_search_changed),
+ window,
+ G_CONNECT_SWAPPED);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]