[gnome-builder] libide/tweaks: handle widget without group somewhat gracefully



commit e5f6e9243c0a4371e9cd9c85af2a02450995a101
Author: Christian Hergert <chergert redhat com>
Date:   Thu Aug 4 15:58:45 2022 -0700

    libide/tweaks: handle widget without group somewhat gracefully

 src/libide/tweaks/ide-tweaks-panel.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/src/libide/tweaks/ide-tweaks-panel.c b/src/libide/tweaks/ide-tweaks-panel.c
index f86b48c42..8a2a20ff4 100644
--- a/src/libide/tweaks/ide-tweaks-panel.c
+++ b/src/libide/tweaks/ide-tweaks-panel.c
@@ -73,13 +73,22 @@ ide_tweaks_panel_visitor_cb (IdeTweaksItem *item,
       GtkWidget *child = _ide_tweaks_widget_inflate (IDE_TWEAKS_WIDGET (item));
 
       if (child == NULL)
-        g_critical ("Failed to create widget from #%s",
-                    ide_tweaks_item_get_id (item));
-      else if (self->current_group)
-        g_critical ("Attempt to add #%s without a group!",
-                    ide_tweaks_item_get_id (item));
+        {
+          g_critical ("Failed to create widget from #%s",
+                      ide_tweaks_item_get_id (item));
+        }
+      else if (self->current_group == NULL)
+        {
+          g_critical ("Attempt to add #%s without a group, this is discouraged",
+                      ide_tweaks_item_get_id (item));
+          self->current_group = g_object_new (ADW_TYPE_PREFERENCES_GROUP, NULL);
+          adw_preferences_page_add (self->prefs_page, self->current_group);
+          adw_preferences_group_add (self->current_group, child);
+        }
       else
-        adw_preferences_group_add (self->current_group, child);
+        {
+          adw_preferences_group_add (self->current_group, child);
+        }
     }
 
   return IDE_TWEAKS_ITEM_VISIT_CONTINUE;


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