[gnome-builder] GbPreferencesWindow: hide sections with no search matches
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] GbPreferencesWindow: hide sections with no search matches
- Date: Fri, 12 Dec 2014 12:05:27 +0000 (UTC)
commit 8dbdae5575003152e591bfbe2749c54799ba1528
Author: Christian Hergert <christian hergert me>
Date: Fri Dec 12 03:58:29 2014 -0800
GbPreferencesWindow: hide sections with no search matches
src/preferences/gb-preferences-page.c | 8 ++++++--
src/preferences/gb-preferences-page.h | 2 +-
src/preferences/gb-preferences-window.c | 5 ++++-
3 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/src/preferences/gb-preferences-page.c b/src/preferences/gb-preferences-page.c
index 52e6253..dee8693 100644
--- a/src/preferences/gb-preferences-page.c
+++ b/src/preferences/gb-preferences-page.c
@@ -48,7 +48,7 @@ gb_preferences_page_match (const gchar *needle,
return !!strstr (haystack, needle);
}
-void
+guint
gb_preferences_page_set_keywords (GbPreferencesPage *page,
const gchar * const *keywords)
{
@@ -57,6 +57,7 @@ gb_preferences_page_set_keywords (GbPreferencesPage *page,
gpointer value;
gchar **needle;
gsize size;
+ guint count = 0;
guint i;
g_return_if_fail (GB_IS_PREFERENCES_PAGE (page));
@@ -64,7 +65,7 @@ gb_preferences_page_set_keywords (GbPreferencesPage *page,
if (!keywords || (g_strv_length ((gchar **)keywords) == 0))
{
g_hash_table_foreach (page->priv->widgets, (GHFunc)gtk_widget_show, NULL);
- return;
+ return G_MAXUINT;
}
size = g_strv_length ((gchar **)keywords) + 1;
@@ -88,6 +89,7 @@ gb_preferences_page_set_keywords (GbPreferencesPage *page,
{
if (gb_preferences_page_match (needle [i], haystack))
{
+ count++;
visible = TRUE;
break;
}
@@ -97,6 +99,8 @@ gb_preferences_page_set_keywords (GbPreferencesPage *page,
}
g_strfreev (needle);
+
+ return count;
}
void
diff --git a/src/preferences/gb-preferences-page.h b/src/preferences/gb-preferences-page.h
index 35a9ef7..e475859 100644
--- a/src/preferences/gb-preferences-page.h
+++ b/src/preferences/gb-preferences-page.h
@@ -49,7 +49,7 @@ struct _GbPreferencesPageClass
};
GType gb_preferences_page_get_type (void);
-void gb_preferences_page_set_keywords (GbPreferencesPage *page,
+guint gb_preferences_page_set_keywords (GbPreferencesPage *page,
const gchar * const *keywords);
void gb_preferences_page_set_keywords_for_widget (GbPreferencesPage *page,
const gchar *keywords,
diff --git a/src/preferences/gb-preferences-window.c b/src/preferences/gb-preferences-window.c
index 9008114..35d4427 100644
--- a/src/preferences/gb-preferences-window.c
+++ b/src/preferences/gb-preferences-window.c
@@ -107,7 +107,10 @@ gb_preferences_window_search_changed (GbPreferencesWindow *window,
{
GbPreferencesPage *page = GB_PREFERENCES_PAGE (iter->data);
- gb_preferences_page_set_keywords (page, (const gchar * const *)keywords);
+ if (0 == gb_preferences_page_set_keywords (page, (const gchar * const *)keywords))
+ gtk_widget_set_visible (GTK_WIDGET (page), FALSE);
+ else
+ gtk_widget_set_visible (GTK_WIDGET (page), TRUE);
}
g_list_free (pages);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]