[devhelp] Settings lib: _dh_settings_new() static function



commit ed0fb8c9469011ab322e54e7d7750654776f71a9
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Mon Apr 2 07:59:29 2018 +0200

    Settings lib: _dh_settings_new() static function
    
    A first step to be able to customize in an app the GSettings paths.

 devhelp/dh-settings.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/devhelp/dh-settings.c b/devhelp/dh-settings.c
index b160937..a23ce4c 100644
--- a/devhelp/dh-settings.c
+++ b/devhelp/dh-settings.c
@@ -65,6 +65,14 @@ static void
 dh_settings_init (DhSettings *self)
 {
         self->priv = dh_settings_get_instance_private (self);
+}
+
+static DhSettings *
+_dh_settings_new (const gchar *contents_path)
+{
+        DhSettings *object;
+
+        object = g_object_new (DH_TYPE_SETTINGS, NULL);
 
         /* The GSettings schemas provided by the libdevhelp are relocatable.
          * Different major versions of libdevhelp must be parallel-installable,
@@ -76,16 +84,19 @@ dh_settings_init (DhSettings *self)
          * If a schema becomes incompatible, the compatible keys can be migrated
          * with dconf, with the DhDconfMigration utility class.
          */
-        self->priv->settings_contents = g_settings_new_with_path (SETTINGS_SCHEMA_ID_CONTENTS,
-                                                                  /* Must be compatible with Devhelp app 
version 3.28. */
-                                                                  "/org/gnome/devhelp/state/main/contents/");
+        object->priv->settings_contents = g_settings_new_with_path (SETTINGS_SCHEMA_ID_CONTENTS,
+                                                                    contents_path);
+
+        return object;
 }
 
 DhSettings *
 dh_settings_get_singleton (void)
 {
-        if (singleton == NULL)
-                singleton = g_object_new (DH_TYPE_SETTINGS, NULL);
+        if (singleton == NULL) {
+                singleton = _dh_settings_new (/* Must be compatible with Devhelp app version 3.28: */
+                                              "/org/gnome/devhelp/state/main/contents/");
+        }
 
         return singleton;
 }


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