[gnome-builder] libide/tweaks: remove IdeTweaksSubpage



commit f33393530563cee9a9a69ed291c41dcac97688c4
Author: Christian Hergert <chergert redhat com>
Date:   Tue Aug 2 21:20:01 2022 -0700

    libide/tweaks: remove IdeTweaksSubpage
    
    We can just use IdeTweaksPage again, since walking the hierarchy gives us
    a good idea if there are parents.
    
    For the case in the UI code, we can use push/pop to maintain some sort of
    path to where we are and how to get back (for unrooted items).

 src/libide/tweaks/ide-tweaks-init.c                |   1 -
 src/libide/tweaks/ide-tweaks-page.c                |  16 +-
 src/libide/tweaks/ide-tweaks-panel-list.c          |   1 -
 src/libide/tweaks/ide-tweaks-panel.c               |  12 --
 src/libide/tweaks/ide-tweaks-subpage.c             | 179 ---------------------
 src/libide/tweaks/ide-tweaks-subpage.h             |  45 ------
 src/libide/tweaks/libide-tweaks.h                  |   1 -
 src/libide/tweaks/meson.build                      |   2 -
 src/libide/tweaks/tests/demo/040-code-languages.ui |   2 +-
 src/libide/tweaks/tests/test2/0.ui                 |   2 +-
 src/libide/tweaks/tests/test2/1.ui                 |   2 +-
 src/libide/tweaks/tests/test2/expected.xml         |   4 +-
 12 files changed, 14 insertions(+), 253 deletions(-)
---
diff --git a/src/libide/tweaks/ide-tweaks-init.c b/src/libide/tweaks/ide-tweaks-init.c
index 86a8e4685..b5a925140 100644
--- a/src/libide/tweaks/ide-tweaks-init.c
+++ b/src/libide/tweaks/ide-tweaks-init.c
@@ -39,7 +39,6 @@ _ide_tweaks_init (void)
   g_type_ensure (IDE_TYPE_TWEAKS_ITEM);
   g_type_ensure (IDE_TYPE_TWEAKS_PAGE);
   g_type_ensure (IDE_TYPE_TWEAKS_SECTION);
-  g_type_ensure (IDE_TYPE_TWEAKS_SUBPAGE);
   g_type_ensure (IDE_TYPE_TWEAKS_VARIABLE);
   g_type_ensure (IDE_TYPE_TWEAKS_WINDOW);
 }
diff --git a/src/libide/tweaks/ide-tweaks-page.c b/src/libide/tweaks/ide-tweaks-page.c
index 69fa75674..afa22236d 100644
--- a/src/libide/tweaks/ide-tweaks-page.c
+++ b/src/libide/tweaks/ide-tweaks-page.c
@@ -27,7 +27,6 @@
 #include "ide-tweaks-group.h"
 #include "ide-tweaks-page.h"
 #include "ide-tweaks-section.h"
-#include "ide-tweaks-subpage.h"
 
 struct _IdeTweaksPage
 {
@@ -59,7 +58,7 @@ static gboolean
 ide_tweaks_page_accepts (IdeTweaksItem *item,
                          IdeTweaksItem *child)
 {
-  return IDE_IS_TWEAKS_SUBPAGE (child) ||
+  return IDE_IS_TWEAKS_PAGE (child) ||
          IDE_IS_TWEAKS_FACTORY (child) ||
          IDE_IS_TWEAKS_GROUP (child);
 }
@@ -220,6 +219,9 @@ ide_tweaks_page_get_section (IdeTweaksPage *self)
 
   while ((item = ide_tweaks_item_get_parent (item)))
     {
+      if (IDE_IS_TWEAKS_PAGE (item))
+        break;
+
       if (IDE_IS_TWEAKS_SECTION (item))
         return item;
     }
@@ -238,22 +240,22 @@ ide_tweaks_page_get_section (IdeTweaksPage *self)
 gboolean
 ide_tweaks_page_get_has_subpage (IdeTweaksPage *self)
 {
-  static GType subpage_type;
+  static GType page_type;
 
   g_return_val_if_fail (IDE_IS_TWEAKS_PAGE (self), FALSE);
 
-  if G_UNLIKELY (subpage_type == G_TYPE_INVALID)
-    subpage_type = IDE_TYPE_TWEAKS_SUBPAGE;
+  if G_UNLIKELY (page_type == G_TYPE_INVALID)
+    page_type = IDE_TYPE_TWEAKS_PAGE;
 
   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, subpage_type))
+      if (G_TYPE_CHECK_INSTANCE_TYPE (child, page_type))
         return TRUE;
 
       if (IDE_IS_TWEAKS_FACTORY (child) &&
-          _ide_tweaks_factory_is_one_of (IDE_TWEAKS_FACTORY (child), &subpage_type, 1))
+          _ide_tweaks_factory_is_one_of (IDE_TWEAKS_FACTORY (child), &page_type, 1))
         return TRUE;
     }
 
diff --git a/src/libide/tweaks/ide-tweaks-panel-list.c b/src/libide/tweaks/ide-tweaks-panel-list.c
index 290c3abe9..d0a72fa37 100644
--- a/src/libide/tweaks/ide-tweaks-panel-list.c
+++ b/src/libide/tweaks/ide-tweaks-panel-list.c
@@ -28,7 +28,6 @@
 #include "ide-tweaks-panel-list-private.h"
 #include "ide-tweaks-panel-list-row-private.h"
 #include "ide-tweaks-section.h"
-#include "ide-tweaks-subpage.h"
 
 struct _IdeTweaksPanelList
 {
diff --git a/src/libide/tweaks/ide-tweaks-panel.c b/src/libide/tweaks/ide-tweaks-panel.c
index 810fbe4d8..c40406024 100644
--- a/src/libide/tweaks/ide-tweaks-panel.c
+++ b/src/libide/tweaks/ide-tweaks-panel.c
@@ -24,7 +24,6 @@
 
 #include "ide-tweaks-page.h"
 #include "ide-tweaks-panel-private.h"
-#include "ide-tweaks-subpage.h"
 
 typedef struct
 {
@@ -81,15 +80,6 @@ ide_tweaks_panel_load_page (IdeTweaksPanel *self,
   ide_tweaks_panel_page_notify_title_cb (self, NULL, page);
 }
 
-static void
-ide_tweaks_panel_load_subpage (IdeTweaksPanel   *self,
-                               IdeTweaksSubpage *subpage)
-{
-  g_assert (IDE_IS_TWEAKS_PANEL (self));
-  g_assert (IDE_IS_TWEAKS_SUBPAGE (subpage));
-
-}
-
 static void
 ide_tweaks_panel_set_item (IdeTweaksPanel *self,
                            IdeTweaksItem  *item)
@@ -103,8 +93,6 @@ ide_tweaks_panel_set_item (IdeTweaksPanel *self,
     {
       if (IDE_IS_TWEAKS_PAGE (item))
         ide_tweaks_panel_load_page (self, IDE_TWEAKS_PAGE (item));
-      else if (IDE_IS_TWEAKS_SUBPAGE (item))
-        ide_tweaks_panel_load_subpage (self, IDE_TWEAKS_SUBPAGE (item));
     }
 }
 
diff --git a/src/libide/tweaks/libide-tweaks.h b/src/libide/tweaks/libide-tweaks.h
index 23d3bcd72..7dc81a173 100644
--- a/src/libide/tweaks/libide-tweaks.h
+++ b/src/libide/tweaks/libide-tweaks.h
@@ -28,7 +28,6 @@
 # include "ide-tweaks-item.h"
 # include "ide-tweaks-page.h"
 # include "ide-tweaks-section.h"
-# include "ide-tweaks-subpage.h"
 # include "ide-tweaks-variable.h"
 # include "ide-tweaks-window.h"
 #undef IDE_TWEAKS_INSIDE
diff --git a/src/libide/tweaks/meson.build b/src/libide/tweaks/meson.build
index 43df28eb0..fd836b724 100644
--- a/src/libide/tweaks/meson.build
+++ b/src/libide/tweaks/meson.build
@@ -15,7 +15,6 @@ libide_tweaks_public_headers = [
   'ide-tweaks-item.h',
   'ide-tweaks-page.h',
   'ide-tweaks-section.h',
-  'ide-tweaks-subpage.h',
   'ide-tweaks-variable.h',
   'ide-tweaks-window.h',
 ]
@@ -34,7 +33,6 @@ libide_tweaks_public_sources = [
   'ide-tweaks-group.c',
   'ide-tweaks-page.c',
   'ide-tweaks-section.c',
-  'ide-tweaks-subpage.c',
   'ide-tweaks-variable.c',
   'ide-tweaks-window.c',
 ]
diff --git a/src/libide/tweaks/tests/demo/040-code-languages.ui 
b/src/libide/tweaks/tests/demo/040-code-languages.ui
index 28715133b..88d244e52 100644
--- a/src/libide/tweaks/tests/demo/040-code-languages.ui
+++ b/src/libide/tweaks/tests/demo/040-code-languages.ui
@@ -11,7 +11,7 @@
               <object class="IdeTweaksFactory" id="language_page_factory">
                 <property name="model">GtkSourceLanguages</property>
                 <child>
-                  <object class="IdeTweaksSubpage" id="language_page">
+                  <object class="IdeTweaksPage" id="language_page">
                   </object>
                 </child>
               </object>
diff --git a/src/libide/tweaks/tests/test2/0.ui b/src/libide/tweaks/tests/test2/0.ui
index 3411ef4e6..024a1979a 100644
--- a/src/libide/tweaks/tests/test2/0.ui
+++ b/src/libide/tweaks/tests/test2/0.ui
@@ -8,7 +8,7 @@
               <object class="IdeTweaksFactory" id="language_subpage_factory">
                 <property name="model">GtkSourceLanguages</property>
                 <child>
-                  <object class="IdeTweaksSubpage" id="language_subpage">
+                  <object class="IdeTweaksPage" id="language_subpage">
                     <child>
                       <object class="IdeTweaksGroup" id="language_general_group">
                         <property name="title" translatable="yes">General</property>
diff --git a/src/libide/tweaks/tests/test2/1.ui b/src/libide/tweaks/tests/test2/1.ui
index 04cc1e8a3..6f5ea66b6 100644
--- a/src/libide/tweaks/tests/test2/1.ui
+++ b/src/libide/tweaks/tests/test2/1.ui
@@ -9,7 +9,7 @@
             <child internal-child="language_subpage_factory">
               <object class="IdeTweaksFactory">
                 <child internal-child="language_subpage">
-                  <object class="IdeTweaksSubpage">
+                  <object class="IdeTweaksPage">
                     <binding name="title">
                       <lookup name="title" type="IdeTweaksPage">
                         <lookup name="item">language_subpage_factory</lookup>
diff --git a/src/libide/tweaks/tests/test2/expected.xml b/src/libide/tweaks/tests/test2/expected.xml
index b67257c68..eb28bbeda 100644
--- a/src/libide/tweaks/tests/test2/expected.xml
+++ b/src/libide/tweaks/tests/test2/expected.xml
@@ -2,9 +2,9 @@
   <IdeTweaksSection id="programming_section" sort-key="">
     <IdeTweaksPage id="languages_page" has-subpage="TRUE" 
icon-name="preferences-desktop-appearance-symbolic" section="#programming_section" sort-key="" 
title="Appearance">
       <IdeTweaksFactory id="language_subpage_factory" model="GListStore<GtkSourceLanguage>" sort-key="">
-        <IdeTweaksSubpage id="language_subpage" icon-name="" sort-key="" title="">
+        <IdeTweaksPage id="language_subpage" has-subpage="FALSE" icon-name="" sort-key="" title="">
           <IdeTweaksGroup id="language_general_group" sort-key="test-key" title="General"/>
-        </IdeTweaksSubpage>
+        </IdeTweaksPage>
       </IdeTweaksFactory>
     </IdeTweaksPage>
   </IdeTweaksSection>


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