[gnome-builder] gsettings: move some settings to org.gnome.builder.debug



commit 57c722c15480745242e574d7ee70379a12194c97
Author: Christian Hergert <chergert redhat com>
Date:   Tue Jul 26 18:41:08 2022 -0700

    gsettings: move some settings to org.gnome.builder.debug
    
    The goal here is to have overrides in the project and also just make this
    all easier to display/bind practically to the user.

 data/gsettings/meson.build                         |  1 +
 data/gsettings/org.gnome.builder.build.gschema.xml |  5 --
 data/gsettings/org.gnome.builder.debug.gschema.xml | 19 ++++++
 src/libide/debugger/ide-debug-manager.c            | 76 ++++++++--------------
 src/libide/gui/ide-workbench.c                     |  1 -
 src/plugins/gdb/gbp-gdb-debugger.c                 | 16 +++--
 6 files changed, 56 insertions(+), 62 deletions(-)
---
diff --git a/data/gsettings/meson.build b/data/gsettings/meson.build
index e8fcb81b8..f65649e5f 100644
--- a/data/gsettings/meson.build
+++ b/data/gsettings/meson.build
@@ -28,6 +28,7 @@ schema_files += [configure_file(
 
 schemas = [
   'org.gnome.builder.build.gschema.xml',
+  'org.gnome.builder.debug.gschema.xml',
   'org.gnome.builder.editor.gschema.xml',
   'org.gnome.builder.editor.language.gschema.xml',
   'org.gnome.builder.extension-type.gschema.xml',
diff --git a/data/gsettings/org.gnome.builder.build.gschema.xml 
b/data/gsettings/org.gnome.builder.build.gschema.xml
index f5f3d4aa1..0c04ca8e9 100644
--- a/data/gsettings/org.gnome.builder.build.gschema.xml
+++ b/data/gsettings/org.gnome.builder.build.gschema.xml
@@ -16,10 +16,5 @@
       <summary>Allow network when metered</summary>
       <description>Enable automated transfers upon building such as SDK downloads and dependencies when 
connection is metered.</description>
     </key>
-    <key name="debugger-breakpoint-on-main" type="b">
-      <default>false</default>
-      <summary>Debugger Breakpoint on Main</summary>
-      <description>Debugger should automatically insert breakpoint on main function.</description>
-    </key>
   </schema>
 </schemalist>
diff --git a/data/gsettings/org.gnome.builder.debug.gschema.xml 
b/data/gsettings/org.gnome.builder.debug.gschema.xml
new file mode 100644
index 000000000..a26a6ff79
--- /dev/null
+++ b/data/gsettings/org.gnome.builder.debug.gschema.xml
@@ -0,0 +1,19 @@
+<schemalist>
+  <schema id="org.gnome.builder.debug" path="/org/gnome/builder/debug/" gettext-domain="gnome-builder">
+    <key name="insert-breakpoint-at-main" type="b">
+      <default>false</default>
+      <summary>Debugger Breakpoint at Main</summary>
+      <description>Debugger should automatically insert breakpoint at main() function.</description>
+    </key>
+    <key name="insert-breakpoint-at-criticals" type="b">
+      <default>false</default>
+      <summary>Debugger Breakpoint at g_critical()</summary>
+      <description>Debugger should automatically insert breakpoint at g_critical() function.</description>
+    </key>
+    <key name="insert-breakpoint-at-warnings" type="b">
+      <default>false</default>
+      <summary>Debugger Breakpoint at g_warning()</summary>
+      <description>Debugger should automatically insert breakpoint at g_warning() function.</description>
+    </key>
+  </schema>
+</schemalist>
diff --git a/src/libide/debugger/ide-debug-manager.c b/src/libide/debugger/ide-debug-manager.c
index f80be75c3..267aa22f0 100644
--- a/src/libide/debugger/ide-debug-manager.c
+++ b/src/libide/debugger/ide-debug-manager.c
@@ -49,8 +49,6 @@ struct _IdeDebugManager
   GPtrArray      *supported_languages;
 
   guint           active : 1;
-  guint           stop_at_criticals : 1;
-  guint           stop_at_warnings : 1;
 };
 
 typedef struct
@@ -76,22 +74,10 @@ enum {
   N_SIGNALS
 };
 
-static void ide_debug_manager_actions_stop_at_criticals (IdeDebugManager *self,
-                                                         GVariant        *param);
-static void ide_debug_manager_actions_stop_at_warnings  (IdeDebugManager *self,
-                                                         GVariant        *param);
-
-
 static GParamSpec *properties [N_PROPS];
 static guint signals [N_SIGNALS];
 
-IDE_DEFINE_ACTION_GROUP (IdeDebugManager, ide_debug_manager, {
-  { "stop-at-criticals", ide_debug_manager_actions_stop_at_criticals, NULL, "false" },
-  { "stop-at-warnings", ide_debug_manager_actions_stop_at_warnings, NULL, "false" },
-})
-
-G_DEFINE_FINAL_TYPE_WITH_CODE (IdeDebugManager, ide_debug_manager, IDE_TYPE_OBJECT,
-                               G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_GROUP, 
ide_debug_manager_init_action_group))
+G_DEFINE_FINAL_TYPE (IdeDebugManager, ide_debug_manager, IDE_TYPE_OBJECT)
 
 static gint
 compare_language_id (gconstpointer a,
@@ -557,6 +543,22 @@ ide_debug_manager_dispose (GObject *object)
   G_OBJECT_CLASS (ide_debug_manager_parent_class)->dispose (object);
 }
 
+static void
+ide_debug_manager_parent_set (IdeObject *object,
+                              IdeObject *parent)
+{
+  g_autoptr(IdeContext) context = NULL;
+
+  g_assert (IDE_IS_OBJECT (object));
+  g_assert (!parent || IDE_IS_OBJECT (parent));
+
+  if (!parent)
+    return;
+
+  context = ide_object_ref_context (object);
+  ide_context_register_settings (context, "org.gnome.builder.debug");
+}
+
 static void
 ide_debug_manager_finalize (GObject *object)
 {
@@ -596,11 +598,14 @@ static void
 ide_debug_manager_class_init (IdeDebugManagerClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  IdeObjectClass *i_object_class = IDE_OBJECT_CLASS (klass);
 
   object_class->dispose = ide_debug_manager_dispose;
   object_class->finalize = ide_debug_manager_finalize;
   object_class->get_property = ide_debug_manager_get_property;
 
+  i_object_class->parent_set = ide_debug_manager_parent_set;
+
   /**
    * IdeDebugManager:active:
    *
@@ -951,6 +956,8 @@ _ide_debug_manager_prepare (IdeDebugManager  *self,
                             GError          **error)
 {
   g_autoptr(IdeDebugger) debugger = NULL;
+  g_autoptr(IdeSettings) settings = NULL;
+  IdeContext *context;
 
   IDE_ENTRY;
 
@@ -959,6 +966,9 @@ _ide_debug_manager_prepare (IdeDebugManager  *self,
   g_return_val_if_fail (IDE_IS_RUN_CONTEXT (run_context), FALSE);
   g_return_val_if_fail (self->debugger == NULL, FALSE);
 
+  context = ide_object_get_context (IDE_OBJECT (self));
+  settings = ide_context_ref_settings (context, "org.gnome.builder.debug");
+
   if (!(debugger = ide_debug_manager_find_debugger (self, pipeline, run_command)))
     {
       g_set_error_literal (error,
@@ -970,9 +980,9 @@ _ide_debug_manager_prepare (IdeDebugManager  *self,
 
   ide_debugger_prepare_for_run (debugger, pipeline, run_context);
 
-  if (self->stop_at_criticals)
+  if (ide_settings_get_boolean (settings, "insert-breakpoint-at-criticals"))
     ide_run_context_setenv (run_context, "G_DEBUG", "fatal-criticals");
-  else if (self->stop_at_warnings)
+  else if (ide_settings_get_boolean (settings, "insert-breakpoint-at-warnings"))
     ide_run_context_setenv (run_context, "G_DEBUG", "fatal-warnings");
 
   if (g_set_object (&self->debugger, debugger))
@@ -1157,35 +1167,3 @@ ide_debug_manager_from_context (IdeContext *context)
 
   return ret;
 }
-
-static void
-ide_debug_manager_actions_stop_at_criticals (IdeDebugManager *self,
-                                             GVariant        *param)
-{
-  IDE_ENTRY;
-
-  g_assert (IDE_IS_DEBUG_MANAGER (self));
-
-  self->stop_at_criticals = !self->stop_at_criticals;
-  ide_debug_manager_set_action_state (self,
-                                      "stop-at-criticals",
-                                      g_variant_new_boolean (self->stop_at_criticals));
-
-  IDE_EXIT;
-}
-
-static void
-ide_debug_manager_actions_stop_at_warnings (IdeDebugManager *self,
-                                            GVariant        *param)
-{
-  IDE_ENTRY;
-
-  g_assert (IDE_IS_DEBUG_MANAGER (self));
-
-  self->stop_at_warnings = !self->stop_at_warnings;
-  ide_debug_manager_set_action_state (self,
-                                      "stop-at-warnings",
-                                      g_variant_new_boolean (self->stop_at_warnings));
-
-  IDE_EXIT;
-}
diff --git a/src/libide/gui/ide-workbench.c b/src/libide/gui/ide-workbench.c
index 66903b141..5afb8ab5a 100644
--- a/src/libide/gui/ide-workbench.c
+++ b/src/libide/gui/ide-workbench.c
@@ -736,7 +736,6 @@ add_remove_foundry_action_groups (IdeWorkbench *self,
   } groups[] = {
     { "config-manager", IDE_TYPE_CONFIG_MANAGER },
     { "build-manager", IDE_TYPE_BUILD_MANAGER },
-    { "debug-manager", IDE_TYPE_DEBUG_MANAGER },
     { "device-manager", IDE_TYPE_DEVICE_MANAGER },
     { "run-manager", IDE_TYPE_RUN_MANAGER },
     { "test-manager", IDE_TYPE_TEST_MANAGER },
diff --git a/src/plugins/gdb/gbp-gdb-debugger.c b/src/plugins/gdb/gbp-gdb-debugger.c
index 256344892..0cef71a1f 100644
--- a/src/plugins/gdb/gbp-gdb-debugger.c
+++ b/src/plugins/gdb/gbp-gdb-debugger.c
@@ -39,8 +39,6 @@ struct _GbpGdbDebugger
   GFile                    *builddir;
   IdeRuntime               *current_runtime;
 
-  GSettings                *settings;
-
   struct gdbwire_mi_parser *parser;
 
   GQueue                    writequeue;
@@ -1453,7 +1451,7 @@ gbp_gdb_debugger_move_async (IdeDebugger         *debugger,
 {
   GbpGdbDebugger *self = (GbpGdbDebugger *)debugger;
   g_autoptr(IdeTask) task = NULL;
-  const gchar *command = NULL;
+  const char *command = NULL;
 
   g_assert (GBP_IS_GDB_DEBUGGER (self));
   g_assert (IDE_IS_DEBUGGER_MOVEMENT (movement));
@@ -1463,14 +1461,20 @@ gbp_gdb_debugger_move_async (IdeDebugger         *debugger,
   ide_task_set_priority (task, G_PRIORITY_LOW);
   ide_task_set_source_tag (task, gbp_gdb_debugger_move_async);
 
+
   switch (movement)
     {
-    case IDE_DEBUGGER_MOVEMENT_START:
-      if (g_settings_get_boolean (self->settings, "debugger-breakpoint-on-main"))
+    case IDE_DEBUGGER_MOVEMENT_START: {
+      IdeContext *context = ide_object_get_context (IDE_OBJECT (self));
+      g_autoptr(IdeSettings) settings = ide_context_ref_settings (context, "org.gnome.builder.debug");
+
+      if (ide_settings_get_boolean (settings, "insert-breakpoint-at-main"))
         command = "-exec-run --all --start";
       else
         command = "-exec-run --all";
+
       break;
+    }
 
     case IDE_DEBUGGER_MOVEMENT_CONTINUE:
       command = "-exec-continue";
@@ -2575,7 +2579,6 @@ gbp_gdb_debugger_finalize (GObject *object)
   /* Ensure no tasks were queued after dispose call */
   g_assert (self->cmdqueue.length == 0);
 
-  g_clear_object (&self->settings);
   g_clear_object (&self->io_stream);
   g_clear_object (&self->read_cancellable);
   g_clear_pointer (&self->parser, gdbwire_mi_parser_destroy);
@@ -2635,7 +2638,6 @@ gbp_gdb_debugger_init (GbpGdbDebugger *self)
     self, gbp_gdb_debugger_output_callback
   };
 
-  self->settings = g_settings_new ("org.gnome.builder.build");
   self->parser = gdbwire_mi_parser_create (callbacks);
   self->read_cancellable = g_cancellable_new ();
   self->read_buffer = g_malloc (READ_BUFFER_LEN);


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