[gnome-builder] libide/tweaks: allow sections in subpages



commit dea7736a9e3f3c076a46afb2805e5def00d49047
Author: Christian Hergert <chergert redhat com>
Date:   Tue Aug 16 22:03:08 2022 -0700

    libide/tweaks: allow sections in subpages

 src/libide/tweaks/ide-tweaks-page.c       | 16 ++++++++++------
 src/libide/tweaks/ide-tweaks-panel-list.c | 13 ++++++++-----
 2 files changed, 18 insertions(+), 11 deletions(-)
---
diff --git a/src/libide/tweaks/ide-tweaks-page.c b/src/libide/tweaks/ide-tweaks-page.c
index 4d15d333b..c83a2e0fa 100644
--- a/src/libide/tweaks/ide-tweaks-page.c
+++ b/src/libide/tweaks/ide-tweaks-page.c
@@ -242,22 +242,26 @@ ide_tweaks_page_get_section (IdeTweaksPage *self)
 gboolean
 ide_tweaks_page_get_has_subpage (IdeTweaksPage *self)
 {
-  static GType page_type;
+  static GType types[] = { G_TYPE_INVALID, G_TYPE_INVALID };
 
   g_return_val_if_fail (IDE_IS_TWEAKS_PAGE (self), FALSE);
 
-  if G_UNLIKELY (page_type == G_TYPE_INVALID)
-    page_type = IDE_TYPE_TWEAKS_PAGE;
+  if G_UNLIKELY (types[0] == G_TYPE_INVALID)
+    {
+      types[0] = IDE_TYPE_TWEAKS_PAGE;
+      types[1] = IDE_TYPE_TWEAKS_SECTION;
+    }
 
   for (IdeTweaksItem *child = ide_tweaks_item_get_first_child (IDE_TWEAKS_ITEM (self));
        child != NULL;
        child = ide_tweaks_item_get_next_sibling (child))
     {
-      if (G_TYPE_CHECK_INSTANCE_TYPE (child, page_type))
-        return TRUE;
+      for (guint i = 0; i < G_N_ELEMENTS (types); i++)
+        if (G_TYPE_CHECK_INSTANCE_TYPE (child, types[i]))
+          return TRUE;
 
       if (IDE_IS_TWEAKS_FACTORY (child) &&
-          _ide_tweaks_factory_is_one_of (IDE_TWEAKS_FACTORY (child), &page_type, 1))
+          _ide_tweaks_factory_is_one_of (IDE_TWEAKS_FACTORY (child), types, G_N_ELEMENTS (types)))
         return TRUE;
     }
 
diff --git a/src/libide/tweaks/ide-tweaks-panel-list.c b/src/libide/tweaks/ide-tweaks-panel-list.c
index e53ee6706..cfa1d781e 100644
--- a/src/libide/tweaks/ide-tweaks-panel-list.c
+++ b/src/libide/tweaks/ide-tweaks-panel-list.c
@@ -62,14 +62,17 @@ static IdeTweaksItemVisitResult
 panel_list_visitor (IdeTweaksItem *item,
                     gpointer       user_data)
 {
-  static GType page_type;
+  static GType types[] = { G_TYPE_INVALID, G_TYPE_INVALID };
+
+  if G_UNLIKELY (types[0] == G_TYPE_INVALID)
+    {
+      types[0] = IDE_TYPE_TWEAKS_PAGE;
+      types[1] = IDE_TYPE_TWEAKS_SECTION;
+    }
 
   if (item == user_data)
     return IDE_TWEAKS_ITEM_VISIT_RECURSE;
 
-  if (!page_type)
-    page_type = IDE_TYPE_TWEAKS_PAGE;
-
   if (IDE_IS_TWEAKS_SECTION (item))
     return IDE_TWEAKS_ITEM_VISIT_RECURSE;
 
@@ -77,7 +80,7 @@ panel_list_visitor (IdeTweaksItem *item,
     return IDE_TWEAKS_ITEM_VISIT_ACCEPT_AND_CONTINUE;
 
   if (IDE_IS_TWEAKS_FACTORY (item) &&
-      _ide_tweaks_factory_is_one_of (IDE_TWEAKS_FACTORY (item), &page_type, 1))
+      _ide_tweaks_factory_is_one_of (IDE_TWEAKS_FACTORY (item), types, G_N_ELEMENTS (types)))
     return IDE_TWEAKS_ITEM_VISIT_RECURSE;
 
   return IDE_TWEAKS_ITEM_VISIT_CONTINUE;


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