[gnome-builder] libide/tweaks: allow hiding icons from rows



commit aeb0a76584638abb20b1f56d4226ec846a7ac7ef
Author: Christian Hergert <chergert redhat com>
Date:   Wed Aug 17 10:38:49 2022 -0700

    libide/tweaks: allow hiding icons from rows

 src/libide/tweaks/ide-tweaks-page.c            | 39 ++++++++++++++++++++++++++
 src/libide/tweaks/ide-tweaks-page.h            |  5 ++++
 src/libide/tweaks/ide-tweaks-panel-list-row.ui |  5 ++++
 3 files changed, 49 insertions(+)
---
diff --git a/src/libide/tweaks/ide-tweaks-page.c b/src/libide/tweaks/ide-tweaks-page.c
index c83a2e0fa..a86be71ba 100644
--- a/src/libide/tweaks/ide-tweaks-page.c
+++ b/src/libide/tweaks/ide-tweaks-page.c
@@ -34,6 +34,7 @@ struct _IdeTweaksPage
   IdeTweaksItem parent_instance;
   char *icon_name;
   char *title;
+  guint show_icon : 1;
 };
 
 G_DEFINE_FINAL_TYPE (IdeTweaksPage, ide_tweaks_page, IDE_TYPE_TWEAKS_ITEM)
@@ -43,6 +44,7 @@ enum {
   PROP_HAS_SUBPAGE,
   PROP_ICON_NAME,
   PROP_SECTION,
+  PROP_SHOW_ICON,
   PROP_TITLE,
   N_PROPS
 };
@@ -98,6 +100,10 @@ ide_tweaks_page_get_property (GObject    *object,
       g_value_set_object (value, ide_tweaks_page_get_section (self));
       break;
 
+    case PROP_SHOW_ICON:
+      g_value_set_boolean (value, ide_tweaks_page_get_show_icon (self));
+      break;
+
     case PROP_TITLE:
       g_value_set_string (value, ide_tweaks_page_get_title (self));
       break;
@@ -121,6 +127,10 @@ ide_tweaks_page_set_property (GObject      *object,
       ide_tweaks_page_set_icon_name (self, g_value_get_string (value));
       break;
 
+    case PROP_SHOW_ICON:
+      ide_tweaks_page_set_show_icon (self, g_value_get_boolean (value));
+      break;
+
     case PROP_TITLE:
       ide_tweaks_page_set_title (self, g_value_get_string (value));
       break;
@@ -156,6 +166,11 @@ ide_tweaks_page_class_init (IdeTweaksPageClass *klass)
                          IDE_TYPE_TWEAKS_SECTION,
                          (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
 
+  properties[PROP_SHOW_ICON] =
+    g_param_spec_boolean ("show-icon", NULL, NULL,
+                          TRUE,
+                          (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));
@@ -166,6 +181,7 @@ ide_tweaks_page_class_init (IdeTweaksPageClass *klass)
 static void
 ide_tweaks_page_init (IdeTweaksPage *self)
 {
+  self->show_icon = TRUE;
 }
 
 const char *
@@ -186,6 +202,29 @@ ide_tweaks_page_set_icon_name (IdeTweaksPage *self,
     g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_ICON_NAME]);
 }
 
+gboolean
+ide_tweaks_page_get_show_icon (IdeTweaksPage *self)
+{
+  g_return_val_if_fail (IDE_IS_TWEAKS_PAGE (self), FALSE);
+
+  return self->show_icon;
+}
+
+void
+ide_tweaks_page_set_show_icon (IdeTweaksPage *self,
+                               gboolean       show_icon)
+{
+  g_return_if_fail (IDE_IS_TWEAKS_PAGE (self));
+
+  show_icon = !!show_icon;
+
+  if (show_icon != self->show_icon)
+    {
+      self->show_icon = show_icon;
+      g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_SHOW_ICON]);
+    }
+}
+
 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 5723cbdd2..d0c008acb 100644
--- a/src/libide/tweaks/ide-tweaks-page.h
+++ b/src/libide/tweaks/ide-tweaks-page.h
@@ -45,6 +45,11 @@ IDE_AVAILABLE_IN_ALL
 void           ide_tweaks_page_set_title       (IdeTweaksPage *self,
                                                 const char    *title);
 IDE_AVAILABLE_IN_ALL
+gboolean       ide_tweaks_page_get_show_icon   (IdeTweaksPage *self);
+IDE_AVAILABLE_IN_ALL
+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);
 
 G_END_DECLS
diff --git a/src/libide/tweaks/ide-tweaks-panel-list-row.ui b/src/libide/tweaks/ide-tweaks-panel-list-row.ui
index 6bc59e988..afdd15d13 100644
--- a/src/libide/tweaks/ide-tweaks-panel-list-row.ui
+++ b/src/libide/tweaks/ide-tweaks-panel-list-row.ui
@@ -16,6 +16,11 @@
                 <lookup name="item">IdeTweaksPanelListRow</lookup>
               </lookup>
             </binding>
+            <binding name="visible">
+              <lookup name="show-icon" type="IdeTweaksPage">
+                <lookup name="item">IdeTweaksPanelListRow</lookup>
+              </lookup>
+            </binding>
           </object>
         </child>
         <child>


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