[gnome-builder] libide/tweaks: only show search on pages that request it



commit 8544a17098f0e95c364b888850d206279a78fefb
Author: Christian Hergert <chergert redhat com>
Date:   Mon Aug 22 21:05:34 2022 -0700

    libide/tweaks: only show search on pages that request it

 src/libide/tweaks/ide-tweaks-page.c   | 38 +++++++++++++++++++++++++++++++++++
 src/libide/tweaks/ide-tweaks-page.h   |  5 +++++
 src/libide/tweaks/ide-tweaks-window.c |  3 ++-
 3 files changed, 45 insertions(+), 1 deletion(-)
---
diff --git a/src/libide/tweaks/ide-tweaks-page.c b/src/libide/tweaks/ide-tweaks-page.c
index 91026cd63..deb9d671d 100644
--- a/src/libide/tweaks/ide-tweaks-page.c
+++ b/src/libide/tweaks/ide-tweaks-page.c
@@ -35,6 +35,7 @@ struct _IdeTweaksPage
   char *icon_name;
   char *title;
   guint show_icon : 1;
+  guint show_search : 1;
 };
 
 G_DEFINE_FINAL_TYPE (IdeTweaksPage, ide_tweaks_page, IDE_TYPE_TWEAKS_ITEM)
@@ -45,6 +46,7 @@ enum {
   PROP_ICON_NAME,
   PROP_SECTION,
   PROP_SHOW_ICON,
+  PROP_SHOW_SEARCH,
   PROP_TITLE,
   N_PROPS
 };
@@ -115,6 +117,10 @@ ide_tweaks_page_get_property (GObject    *object,
       g_value_set_boolean (value, ide_tweaks_page_get_show_icon (self));
       break;
 
+    case PROP_SHOW_SEARCH:
+      g_value_set_boolean (value, ide_tweaks_page_get_show_search (self));
+      break;
+
     case PROP_TITLE:
       g_value_set_string (value, ide_tweaks_page_get_title (self));
       break;
@@ -142,6 +148,10 @@ ide_tweaks_page_set_property (GObject      *object,
       ide_tweaks_page_set_show_icon (self, g_value_get_boolean (value));
       break;
 
+    case PROP_SHOW_SEARCH:
+      ide_tweaks_page_set_show_search (self, g_value_get_boolean (value));
+      break;
+
     case PROP_TITLE:
       ide_tweaks_page_set_title (self, g_value_get_string (value));
       break;
@@ -183,6 +193,11 @@ ide_tweaks_page_class_init (IdeTweaksPageClass *klass)
                           TRUE,
                           (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
 
+  properties[PROP_SHOW_SEARCH] =
+    g_param_spec_boolean ("show-search", NULL, NULL,
+                          FALSE,
+                          (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
+
   properties [PROP_TITLE] =
     g_param_spec_string ("title", NULL, NULL, NULL,
                          (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
@@ -237,6 +252,29 @@ ide_tweaks_page_set_show_icon (IdeTweaksPage *self,
     }
 }
 
+gboolean
+ide_tweaks_page_get_show_search (IdeTweaksPage *self)
+{
+  g_return_val_if_fail (IDE_IS_TWEAKS_PAGE (self), FALSE);
+
+  return self->show_search;
+}
+
+void
+ide_tweaks_page_set_show_search (IdeTweaksPage *self,
+                                 gboolean       show_search)
+{
+  g_return_if_fail (IDE_IS_TWEAKS_PAGE (self));
+
+  show_search = !!show_search;
+
+  if (show_search != self->show_search)
+    {
+      self->show_search = show_search;
+      g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_SHOW_SEARCH]);
+    }
+}
+
 const char *
 ide_tweaks_page_get_title (IdeTweaksPage *self)
 {
diff --git a/src/libide/tweaks/ide-tweaks-page.h b/src/libide/tweaks/ide-tweaks-page.h
index d0c008acb..8645ba672 100644
--- a/src/libide/tweaks/ide-tweaks-page.h
+++ b/src/libide/tweaks/ide-tweaks-page.h
@@ -51,5 +51,10 @@ void           ide_tweaks_page_set_show_icon   (IdeTweaksPage *self,
                                                 gboolean       show_icon);
 IDE_AVAILABLE_IN_ALL
 gboolean       ide_tweaks_page_get_has_subpage (IdeTweaksPage *self);
+IDE_AVAILABLE_IN_ALL
+gboolean       ide_tweaks_page_get_show_search (IdeTweaksPage *self);
+IDE_AVAILABLE_IN_ALL
+void           ide_tweaks_page_set_show_search (IdeTweaksPage *self,
+                                                gboolean       show_search);
 
 G_END_DECLS
diff --git a/src/libide/tweaks/ide-tweaks-window.c b/src/libide/tweaks/ide-tweaks-window.c
index 282ae6a51..c5d1046a2 100644
--- a/src/libide/tweaks/ide-tweaks-window.c
+++ b/src/libide/tweaks/ide-tweaks-window.c
@@ -182,7 +182,8 @@ ide_tweaks_window_page_activated_cb (IdeTweaksWindow    *self,
                            sublist,
                            ide_tweaks_item_get_id (IDE_TWEAKS_ITEM (page)));
       gtk_stack_set_visible_child (self->panel_list_stack, sublist);
-      ide_tweaks_panel_list_set_search_mode (IDE_TWEAKS_PANEL_LIST (sublist), TRUE);
+      ide_tweaks_panel_list_set_search_mode (IDE_TWEAKS_PANEL_LIST (sublist),
+                                             ide_tweaks_page_get_show_search (page));
 
       if (self->folded)
         ide_tweaks_panel_list_set_selection_mode (IDE_TWEAKS_PANEL_LIST (sublist),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]