[glib] Add g_settings_new_full() taking GSettingsSchema



commit 1e700720657aa75b0ac4d2457b2ee2f216477c87
Author: Ryan Lortie <desrt desrt ca>
Date:   Tue Nov 15 12:38:01 2011 +0000

    Add g_settings_new_full() taking GSettingsSchema

 gio/gio.symbols |    1 +
 gio/gsettings.c |   37 +++++++++++++++++++++++++++++++++++++
 gio/gsettings.h |    4 ++++
 3 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/gio/gio.symbols b/gio/gio.symbols
index a370a6e..ed9d87c 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -1125,6 +1125,7 @@ g_settings_new
 g_settings_new_with_backend
 g_settings_new_with_backend_and_path
 g_settings_new_with_path
+g_settings_new_full
 g_settings_revert
 g_settings_reset
 g_settings_set
diff --git a/gio/gsettings.c b/gio/gsettings.c
index f8be1b4..72e49d5 100644
--- a/gio/gsettings.c
+++ b/gio/gsettings.c
@@ -937,6 +937,43 @@ g_settings_new_with_backend_and_path (const gchar      *schema,
                        NULL);
 }
 
+/**
+ * g_settings_new_full:
+ * @schema: a #GSettingsSchema
+ * @backend: a #GSettingsBackend
+ * @path: the path to use
+ * @returns: a new #GSettings object
+ *
+ * Creates a new #GSettings object with a given schema, backend and
+ * path.
+ *
+ * It should be extremely rare that you ever want to use this function.
+ * It is made available for advanced use-cases (such as plugin systems
+ * that want to provide access to schemas loaded from custom locations,
+ * etc).
+ *
+ * At the most basic level, a #GSettings object is a pure composition of
+ * 4 things: a #GSettingsSchema, a #GSettingsBackend, a path within that
+ * backend, and a #GMainContext to which signals are dispatched.
+ *
+ * This constructor therefore gives you full control over constructing
+ * #GSettings instances.  The first 4 parameters are given directly as
+ * @schema, @backend and @path, and the main context is taken from the
+ * thread-default (as per g_settings_new()).
+ *
+ * Since: 2.32
+ */
+GSettings *
+g_settings_new_full (GSettingsSchema  *schema,
+                     GSettingsBackend *backend,
+                     const gchar      *path)
+{
+  return g_object_new (G_TYPE_SETTINGS,
+                       "settings-schema", schema,
+                       "backend", backend,
+                       "path", path);
+}
+
 /* Internal read/write utilities {{{1 */
 static gboolean
 g_settings_write_to_backend (GSettings          *settings,
diff --git a/gio/gsettings.h b/gio/gsettings.h
index 8db2f75..d06a60e 100644
--- a/gio/gsettings.h
+++ b/gio/gsettings.h
@@ -26,6 +26,7 @@
 #ifndef __G_SETTINGS_H__
 #define __G_SETTINGS_H__
 
+#include <gio/gsettingsschema.h>
 #include <gio/giotypes.h>
 
 G_BEGIN_DECLS
@@ -80,6 +81,9 @@ GSettings *             g_settings_new_with_backend                     (const g
 GSettings *             g_settings_new_with_backend_and_path            (const gchar        *schema,
                                                                          GSettingsBackend   *backend,
                                                                          const gchar        *path);
+GSettings *             g_settings_new_full                             (GSettingsSchema    *schema,
+                                                                         GSettingsBackend   *backend,
+                                                                         const gchar        *path);
 gchar **                g_settings_list_children                        (GSettings          *settings);
 gchar **                g_settings_list_keys                            (GSettings          *settings);
 GVariant *              g_settings_get_range                            (GSettings          *settings,



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