[gnome-builder] libide/tweaks: add bind helper to bind object to settings



commit 7e627128bc65cac647ec277cb50548dd1d397ede
Author: Christian Hergert <chergert redhat com>
Date:   Fri Aug 12 16:59:45 2022 -0700

    libide/tweaks: add bind helper to bind object to settings

 src/libide/tweaks/ide-tweaks-settings.c | 24 ++++++++++++++++++++++++
 src/libide/tweaks/ide-tweaks-settings.h | 28 +++++++++++++++++-----------
 2 files changed, 41 insertions(+), 11 deletions(-)
---
diff --git a/src/libide/tweaks/ide-tweaks-settings.c b/src/libide/tweaks/ide-tweaks-settings.c
index 045ec20c2..8135bec41 100644
--- a/src/libide/tweaks/ide-tweaks-settings.c
+++ b/src/libide/tweaks/ide-tweaks-settings.c
@@ -22,6 +22,7 @@
 
 #include "config.h"
 
+#include "ide-tweaks.h"
 #include "ide-tweaks-settings.h"
 
 struct _IdeTweaksSettings
@@ -268,3 +269,26 @@ ide_tweaks_settings_create_action_group (IdeTweaksSettings *self,
 
   return G_ACTION_GROUP (settings);
 }
+
+void
+ide_tweaks_settings_bind (IdeTweaksSettings  *self,
+                          const char         *key,
+                          gpointer            instance,
+                          const char         *property,
+                          GSettingsBindFlags  bind_flags)
+{
+  g_autoptr(IdeSettings) settings = NULL;
+  const char *project_id = NULL;
+  IdeTweaksItem *root;
+
+  g_return_if_fail (IDE_IS_TWEAKS_SETTINGS (self));
+  g_return_if_fail (key != NULL);
+  g_return_if_fail (G_IS_OBJECT (instance));
+  g_return_if_fail (property != NULL);
+
+  if ((root = ide_tweaks_item_get_root (IDE_TWEAKS_ITEM (self))) && IDE_IS_TWEAKS (root))
+    project_id = ide_tweaks_get_project_id (IDE_TWEAKS (root));
+
+  settings = IDE_SETTINGS (ide_tweaks_settings_create_action_group (self, project_id));
+  ide_settings_bind (settings, key, instance, property, bind_flags);
+}
diff --git a/src/libide/tweaks/ide-tweaks-settings.h b/src/libide/tweaks/ide-tweaks-settings.h
index 4995e01ed..12737ae2f 100644
--- a/src/libide/tweaks/ide-tweaks-settings.h
+++ b/src/libide/tweaks/ide-tweaks-settings.h
@@ -32,22 +32,28 @@ G_DECLARE_FINAL_TYPE (IdeTweaksSettings, ide_tweaks_settings, IDE, TWEAKS_SETTIN
 IDE_AVAILABLE_IN_ALL
 IdeTweaksSettings *ide_tweaks_settings_new                  (void);
 IDE_AVAILABLE_IN_ALL
-const char        *ide_tweaks_settings_get_schema_id        (IdeTweaksSettings *self);
+const char        *ide_tweaks_settings_get_schema_id        (IdeTweaksSettings  *self);
 IDE_AVAILABLE_IN_ALL
-void               ide_tweaks_settings_set_schema_id        (IdeTweaksSettings *self,
-                                                             const char        *schema_id);
+void               ide_tweaks_settings_set_schema_id        (IdeTweaksSettings  *self,
+                                                             const char         *schema_id);
 IDE_AVAILABLE_IN_ALL
-const char        *ide_tweaks_settings_get_schema_path      (IdeTweaksSettings *self);
+const char        *ide_tweaks_settings_get_schema_path      (IdeTweaksSettings  *self);
 IDE_AVAILABLE_IN_ALL
-void               ide_tweaks_settings_set_schema_path      (IdeTweaksSettings *self,
-                                                             const char        *schema_path);
+void               ide_tweaks_settings_set_schema_path      (IdeTweaksSettings  *self,
+                                                             const char         *schema_path);
 IDE_AVAILABLE_IN_ALL
-gboolean           ide_tweaks_settings_get_application_only (IdeTweaksSettings *self);
+gboolean           ide_tweaks_settings_get_application_only (IdeTweaksSettings  *self);
 IDE_AVAILABLE_IN_ALL
-void               ide_tweaks_settings_set_application_only (IdeTweaksSettings *self,
-                                                             gboolean           application_only);
+void               ide_tweaks_settings_set_application_only (IdeTweaksSettings  *self,
+                                                             gboolean            application_only);
 IDE_AVAILABLE_IN_ALL
-GActionGroup      *ide_tweaks_settings_create_action_group  (IdeTweaksSettings *self,
-                                                             const char        *project_id);
+GActionGroup      *ide_tweaks_settings_create_action_group  (IdeTweaksSettings  *self,
+                                                             const char         *project_id);
+IDE_AVAILABLE_IN_ALL
+void               ide_tweaks_settings_bind                 (IdeTweaksSettings  *self,
+                                                             const char         *key,
+                                                             gpointer            instance,
+                                                             const char         *property,
+                                                             GSettingsBindFlags  bind_flags);
 
 G_END_DECLS


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