[glib/gsettings] add main GSettings class



commit 8d581aae151b56a319e5ecbc2055a5a489dd7b75
Author: Ryan Lortie <desrt desrt ca>
Date:   Tue Sep 1 18:48:10 2009 -0400

    add main GSettings class

 gio/Makefile.am |    2 +
 gio/gio.symbols |   21 ++
 gio/gsettings.c |  627 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gio/gsettings.h |   97 +++++++++
 4 files changed, 747 insertions(+), 0 deletions(-)
---
diff --git a/gio/Makefile.am b/gio/Makefile.am
index 883aa5f..91d3007 100644
--- a/gio/Makefile.am
+++ b/gio/Makefile.am
@@ -240,6 +240,7 @@ libgio_2_0_la_SOURCES =		\
 	gsettingsbackend.c	\
 	gsettingsdelayedbackend.c \
 	gsettingsschema.c	\
+	gsettings.c		\
 	gsimpleasyncresult.c 	\
 	gsocket.c		\
 	gsocketaddress.c	\
@@ -371,6 +372,7 @@ gio_headers =			\
 	gsettingsbackend.h	\
 	gsettingsdelayedbackend.h \
 	gsettingsschema.h	\
+	gsettings.h		\
 	gsimpleasyncresult.h 	\
 	gsocket.h		\
 	gsocketaddress.h	\
diff --git a/gio/gio.symbols b/gio/gio.symbols
index feacfa2..d7b663a 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -1296,3 +1296,24 @@ g_settings_delayed_backend_revert
 g_settings_delayed_backend_get_has_unapplied
 #endif
 #endif
+
+#if IN_HEADER(_gsettings_h_)
+#if IN_FILE(_gsettings_c_)
+g_settings_apply
+g_settings_changes
+g_settings_destroy
+g_settings_get
+g_settings_get_delay_apply
+g_settings_get_has_unapplied
+g_settings_get_settings
+g_settings_get_type
+g_settings_get_value
+g_settings_is_writable
+g_settings_new
+g_settings_new_from_path
+g_settings_revert
+g_settings_set
+g_settings_set_delay_apply
+g_settings_set_value
+#endif
+#endif
diff --git a/gio/gsettings.c b/gio/gsettings.c
new file mode 100644
index 0000000..d621506
--- /dev/null
+++ b/gio/gsettings.c
@@ -0,0 +1,627 @@
+/*
+ * Copyright © 2009 Codethink Limited
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of version 3 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * See the included COPYING file for more information.
+ */
+
+#include "gsettings.h"
+
+#include "gsettingsdelayedbackend.h"
+#include "gio-marshal.h"
+#include "gsettingsschema.h"
+
+#include <string.h>
+
+#include "gioalias.h"
+
+struct _GSettingsPrivate {
+  GSettingsBackend *backend;
+  gchar *base_path;
+
+  GSettingsSchema *schema;
+  gchar *schema_name;
+
+  guint handler_id;
+  guint unapplied_handler;
+  gboolean locked;
+  gboolean delayed;
+};
+
+enum
+{
+  PROP_0,
+  PROP_SCHEMA_NAME,
+  PROP_SCHEMA,
+  PROP_DELAY_APPLY,
+  PROP_STORAGE,
+  PROP_BASE_PATH,
+  PROP_HAS_UNAPPLIED,
+};
+
+enum
+{
+  SIGNAL_CHANGES,
+  SIGNAL_CHANGED,
+  SIGNAL_DESTROYED,
+  N_SIGNALS
+};
+
+static guint g_settings_signals[N_SIGNALS];
+
+G_DEFINE_TYPE (GSettings, g_settings, G_TYPE_OBJECT)
+
+static void
+g_settings_storage_changed (GSettingsBackend    *backend,
+                            const gchar         *prefix,
+                            gchar const * const *names,
+                            gint                 n_names,
+                            gpointer             origin_tag,
+                            gpointer             user_data)
+{
+  GSettings *settings = G_SETTINGS (user_data);
+  gchar **changes;
+  GQuark *quarks;
+  gint i, c;
+
+  g_assert (settings->priv->backend == backend);
+
+  /* slow and stupid. */
+  changes = g_new (gchar *, n_names);
+  quarks = g_new (GQuark, n_names);
+  for (i = 0; i < n_names; i++)
+    changes[i] = g_strconcat (prefix, names[i], NULL);
+
+  /* check which are for us */
+  c = 0;
+  for (i = 0; i < n_names; i++)
+    if (g_str_has_prefix (changes[i], settings->priv->base_path))
+      {
+        const gchar *rel = changes[i] + strlen (settings->priv->base_path);
+
+        if (strchr (rel, '/') == NULL)
+          /* XXX also check schema to ensure it's really a key */
+          quarks[c++] = g_quark_from_string (rel);
+      }
+
+  g_settings_changes (settings, quarks, c);
+
+  for (i = 0; i < n_names; i++)
+    g_free (changes[i]);
+  g_free (changes);
+  g_free (quarks);
+}
+
+/**
+ * g_settings_changes:
+ * @settings: a #GSettings object
+ * @keys: an array of #GQuark key names
+ * @n_keys: the length of @keys
+ *
+ * Emits the "changes" signal on a #GSettings object.
+ *
+ * It is an error to call this function with a quark in @keys that is
+ * not a valid key for @settings (according to its schema).
+ **/
+void
+g_settings_changes (GSettings    *settings,
+                    const GQuark *keys,
+                    gint          n_keys)
+{
+  g_return_if_fail (settings != NULL);
+
+  if (n_keys == 0)
+    return;
+
+  g_return_if_fail (keys != NULL);
+  g_return_if_fail (n_keys > 0);
+
+  g_signal_emit (settings,
+                 g_settings_signals[SIGNAL_CHANGES], 0,
+                 keys, n_keys);
+}
+
+static void
+g_settings_real_changes (GSettings    *settings,
+                         const GQuark *keys,
+                         gint          n_keys)
+{
+  gint i;
+
+  for (i = 0; i < n_keys; i++)
+    g_signal_emit (settings,
+                   g_settings_signals[SIGNAL_CHANGED],
+                   keys[i], g_quark_to_string (keys[i]));
+}
+
+static void
+g_settings_init (GSettings *settings)
+{
+  settings->priv = G_TYPE_INSTANCE_GET_PRIVATE (settings,
+                                                G_TYPE_SETTINGS,
+                                                GSettingsPrivate);
+}
+
+static void
+g_settings_notify_unapplied (GSettings *settings)
+{
+  g_object_notify (G_OBJECT (settings), "has-unapplied");
+}
+
+void
+g_settings_set_delay_apply (GSettings *settings,
+                            gboolean   delayed)
+{
+  delayed = !!delayed;
+
+  if (delayed != settings->priv->delayed)
+    {
+      GSettingsBackend *backend;
+
+      if G_UNLIKELY (settings->priv->locked)
+        g_error ("Can only set delayed-apply attribute on "
+                 "freshly-created GSettings instances");
+
+      g_assert (delayed);
+
+      backend = g_settings_delayed_backend_new (settings->priv->backend,
+                                                settings->priv->base_path);
+      g_settings_backend_subscribe (backend, "");
+      g_settings_backend_unsubscribe (settings->priv->backend,
+                                      settings->priv->base_path);
+      g_signal_handler_disconnect (settings->priv->backend,
+                                   settings->priv->handler_id);
+      g_object_unref (settings->priv->backend);
+
+      settings->priv->backend = backend;
+      settings->priv->unapplied_handler = 
+        g_signal_connect_swapped (backend, "notify::has-unapplied",
+                                  G_CALLBACK (g_settings_notify_unapplied),
+                                  settings);
+      settings->priv->handler_id =
+        g_signal_connect (settings->priv->backend, "changed",
+                          G_CALLBACK (g_settings_storage_changed),
+                          settings);
+
+      g_free (settings->priv->base_path);
+      settings->priv->base_path = g_strdup ("");
+
+      settings->priv->delayed = TRUE;
+      settings->priv->locked = TRUE;
+    }
+}
+
+gboolean
+g_settings_get_delay_apply (GSettings *settings)
+{
+  return settings->priv->delayed;
+}
+
+/**
+ * g_settings_apply:
+ * @settings: a #GSettings instance
+ *
+ * Applies any changes that have been made to the settings.  This
+ * function does nothing unless @settings is in 'delay-apply' mode;
+ * see g_settings_set_delay_apply().  In the normal case settings are
+ * always applied immediately.
+ **/
+void
+g_settings_apply (GSettings *settings)
+{
+  if (settings->priv->delayed)
+    {
+      GSettingsDelayedBackend *delayed;
+
+      delayed = G_SETTINGS_DELAYED_BACKEND (settings->priv->backend);
+      g_settings_delayed_backend_apply (delayed);
+    }
+}
+
+/**
+ * g_settings_revert:
+ * @settings: a #GSettings instance
+ *
+ * Reverts all non-applied changes to the settings.  This function
+ * does nothing unless @settings is in 'delay-apply' mode; see
+ * g_settings_set_delay_apply().  In the normal case settings are
+ * always applied immediately.
+ *
+ * Change notifications will be emitted for affected keys.
+ **/
+void
+g_settings_revert (GSettings *settings)
+{
+  if (settings->priv->delayed)
+    {
+      GSettingsDelayedBackend *delayed;
+
+      delayed = G_SETTINGS_DELAYED_BACKEND (settings->priv->backend);
+      g_settings_delayed_backend_revert (delayed);
+    }
+}
+
+static void
+g_settings_set_property (GObject *object, guint prop_id,
+                         const GValue *value, GParamSpec *pspec)
+{
+  GSettings *settings = G_SETTINGS (object);
+
+  switch (prop_id)
+    {
+     case PROP_SCHEMA_NAME:
+      g_assert (settings->priv->schema_name == NULL);
+      settings->priv->schema_name = g_value_dup_string (value);
+      break;
+
+     case PROP_SCHEMA:
+      g_assert (settings->priv->schema == NULL);
+      settings->priv->schema = g_value_dup_object (value);
+      break;
+
+     case PROP_DELAY_APPLY:
+      g_settings_set_delay_apply (settings, g_value_get_boolean (value));
+      break;
+
+     case PROP_BASE_PATH:
+      settings->priv->base_path = g_value_dup_string (value);
+      break;
+
+     case PROP_STORAGE:
+      settings->priv->backend = g_value_dup_object (value);
+      break;
+
+     default:
+      g_assert_not_reached ();
+    }
+}
+
+gboolean
+g_settings_get_has_unapplied (GSettings *settings)
+{
+  return settings->priv->delayed &&
+         g_settings_delayed_backend_get_has_unapplied (
+           G_SETTINGS_DELAYED_BACKEND (settings->priv->backend));
+}
+
+static void
+g_settings_get_property (GObject *object, guint prop_id,
+                         GValue *value, GParamSpec *pspec)
+{
+  GSettings *settings = G_SETTINGS (object);
+
+  switch (prop_id)
+    {
+     case PROP_SCHEMA:
+      g_value_set_object (value, settings->priv->schema);
+      break;
+
+     case PROP_HAS_UNAPPLIED:
+      g_value_set_boolean (value, g_settings_get_has_unapplied (settings));
+      break;
+
+     default:
+      g_assert_not_reached ();
+    }
+}
+
+static void
+g_settings_finalize (GObject *object)
+{
+  GSettings *settings = G_SETTINGS (object);
+
+  g_signal_handler_disconnect (settings->priv->backend, settings->priv->handler_id);
+  g_object_unref (settings->priv->backend);
+  g_object_unref (settings->priv->schema);
+  g_free (settings->priv->schema_name);
+  g_free (settings->priv->base_path);
+}
+
+static void
+g_settings_constructed (GObject *object)
+{
+  GSettings *settings = G_SETTINGS (object);
+
+  if (settings->priv->backend == NULL)
+    settings->priv->backend = g_settings_backend_get_default ();
+
+  settings->priv->handler_id =
+    g_signal_connect (settings->priv->backend, "changed",
+                      G_CALLBACK (g_settings_backend_changed),
+                      settings);
+
+  if (settings->priv->schema != NULL && settings->priv->schema_name != NULL)
+    g_error ("Schema and schema name specified");
+
+  if (settings->priv->schema == NULL && settings->priv->schema_name != NULL)
+    settings->priv->schema = g_settings_schema_new (settings->priv->schema_name);
+
+  if (settings->priv->schema == NULL)
+    settings->priv->schema = g_settings_schema_new ("empty");
+
+  if (settings->priv->base_path == NULL && settings->priv->schema == NULL)
+    g_error ("Attempting to make settings with no schema or path");
+
+  if (settings->priv->base_path != NULL && settings->priv->schema != NULL)
+    {
+      const gchar *schema_path, *given_path;
+
+      schema_path = g_settings_schema_get_path (settings->priv->schema);
+      given_path = settings->priv->base_path;
+
+      if (schema_path && strcmp (schema_path, given_path) != 0)
+        g_error ("Specified path of '%s' but schema says '%s'",
+                 given_path, schema_path);
+     }
+
+  if (settings->priv->base_path == NULL)
+    settings->priv->base_path = g_strdup (
+      g_settings_schema_get_path (settings->priv->schema));
+
+  if (settings->priv->base_path == NULL)
+    g_error ("No base path given and none from schema");
+
+  g_settings_backend_subscribe (settings->priv->backend,
+                                settings->priv->base_path);
+}
+
+GSettings *
+g_settings_new (const gchar *schema)
+{
+  return g_object_new (G_TYPE_SETTINGS, "schema-name", schema, NULL);
+}
+
+GSettings *
+g_settings_new_from_path (const gchar *path)
+{
+  return g_object_new (G_TYPE_SETTINGS, "base-path", path, NULL);
+}
+
+static GType
+g_settings_get_gtype_for_schema (GSettingsSchema *schema)
+{
+  //extern GType g_settings_list_get_type (void);
+  GVariantIter iter;
+  const gchar *item;
+  GVariant *list;
+
+  list = g_settings_schema_get_inheritance (schema);
+  g_variant_iter_init (&iter, list);
+  g_variant_unref (list);
+
+  /*
+  while (g_variant_iter_next (&iter, "s", &item))
+    if (strcmp (item, "list") == 0)
+      return g_settings_list_get_type ();
+  */
+
+  return G_TYPE_SETTINGS;
+}
+
+GSettings *
+g_settings_get_settings (GSettings   *settings,
+                         const gchar *name)
+{
+  const gchar *schema_name;
+  GSettingsSchema *schema;
+  GSettings *child;
+  gchar *path;
+
+  schema_name = g_settings_schema_get_schema (settings->priv->schema, name);
+
+  if (schema_name == NULL)
+    {
+      schema_name = g_settings_schema_get_schema (settings->priv->schema,
+                                                  "//default");
+
+      if G_UNLIKELY (schema_name == NULL)
+        g_error ("Schema has no child schema named '%s' and no "
+                 "default child schema", name);
+    }
+
+  schema = g_settings_schema_new (schema_name);
+  path = g_strdup_printf ("%s%s/", settings->priv->base_path, name);
+
+  child = g_object_new (g_settings_get_gtype_for_schema (schema),
+                        "schema", schema,
+                        "backend", settings->priv->backend,
+                        "base-path", path,
+                        NULL);
+
+  g_free (path);
+ 
+  return child;
+}
+
+static void
+g_settings_class_init (GSettingsClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  class->changes = g_settings_real_changes;
+
+  object_class->set_property = g_settings_set_property;
+  object_class->get_property = g_settings_get_property;
+  object_class->constructed = g_settings_constructed;
+  object_class->finalize = g_settings_finalize;
+
+  g_type_class_add_private (object_class, sizeof (GSettingsPrivate));
+
+  g_settings_signals[SIGNAL_CHANGES] =
+    g_signal_new ("changes", G_TYPE_SETTINGS,
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (GSettingsClass, changes),
+                  NULL, NULL,
+                  _gio_marshal_VOID__POINTER_INT,
+                  G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_INT);
+
+  g_settings_signals[SIGNAL_CHANGED] =
+    g_signal_new ("changed", G_TYPE_SETTINGS,
+                  G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+                  G_STRUCT_OFFSET (GSettingsClass, changed),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__STRING,
+                  G_TYPE_NONE, 1, G_TYPE_STRING);
+
+  g_settings_signals[SIGNAL_DESTROYED] =
+    g_signal_new ("destroyed", G_TYPE_SETTINGS,
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (GSettingsClass, destroyed),
+                  NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+  g_object_class_install_property (object_class, PROP_STORAGE,
+    g_param_spec_object ("backend", "backend storage",
+                         "The GSettingsBackend object for this GSettings",
+                         G_TYPE_SETTINGS_BACKEND, G_PARAM_CONSTRUCT_ONLY |
+                         G_PARAM_READWRITE | G_PARAM_STATIC_NICK |
+                         G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (object_class, PROP_SCHEMA_NAME,
+    g_param_spec_string ("schema-name", "schema name",
+                         "The name of the schema for this settings object",
+                         NULL, G_PARAM_CONSTRUCT_ONLY |
+                         G_PARAM_READWRITE | G_PARAM_STATIC_NICK |
+                         G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB));
+
+   g_object_class_install_property (object_class, PROP_DELAY_APPLY,
+    g_param_spec_boolean ("delay-apply", "delayed apply",
+                          "If TRUE, you must call apply() to write changes",
+                          FALSE, G_PARAM_CONSTRUCT_ONLY |
+                          G_PARAM_READWRITE | G_PARAM_STATIC_NICK |
+                          G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB));
+
+   g_object_class_install_property (object_class, PROP_HAS_UNAPPLIED,
+    g_param_spec_boolean ("has-unapplied", "has unapplied changes",
+                          "TRUE if there are outstanding changes to apply()",
+                          FALSE, G_PARAM_READABLE | G_PARAM_STATIC_NICK |
+                          G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (object_class, PROP_SCHEMA,
+    g_param_spec_object ("schema", "schema",
+                         "The GSettingsSchema object for this GSettings",
+                         G_TYPE_SETTINGS_SCHEMA, G_PARAM_CONSTRUCT_ONLY |
+                         G_PARAM_READWRITE | G_PARAM_STATIC_NICK |
+                         G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (object_class, PROP_BASE_PATH,
+    g_param_spec_string ("base-path", "base path",
+                         "the path within the backend where the settings are",
+                         NULL, G_PARAM_CONSTRUCT_ONLY |
+                         G_PARAM_READWRITE | G_PARAM_STATIC_NICK |
+                         G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB));
+}
+
+GVariant *
+g_settings_get_value (GSettings   *settings,
+                      const gchar *key)
+{
+  const GVariantType *type;
+  const gchar *format;
+  GVariant *value;
+  gchar *path;
+
+  path = g_strconcat (settings->priv->base_path, key, NULL);
+  format = g_settings_schema_get_key_format (settings->priv->schema, key);
+  type = G_VARIANT_TYPE (format); /* XXX this is not valid. */
+  value = g_settings_backend_read (settings->priv->backend, path, type);
+  g_free (path);
+
+  if (value &&
+      !g_settings_schema_type_check_key (settings->priv->schema, key, value))
+    {
+      g_variant_unref (value);
+      value = NULL;
+    }
+
+  if (value == NULL)
+    value = g_settings_schema_get_key_default (settings->priv->schema, key);
+
+  return value;
+}
+
+/**
+ * g_settings_set_value:
+ * @settings: a #GSettings object
+ * @key: the name of the key to set
+ * @value: a #GVariant of the correct type
+ *
+ * Sets @key in @settings to @value.
+ *
+ * It is a programmer error to give a @key that isn't valid for
+ * @settings.  It is a programmer error to give a @value of the
+ * incorrect type.
+ *
+ * If @value is floating then this function consumes the reference.
+ **/
+void
+g_settings_set_value (GSettings   *settings,
+                      const gchar *key,
+                      GVariant    *value)
+{
+  GTree *tree;
+  gchar *path;
+
+  if (!g_settings_schema_type_check_key (settings->priv->schema, key, value))
+    g_error ("Key has the wrong type.");
+
+  tree = g_settings_backend_new_tree ();
+  path = g_strconcat (settings->priv->base_path, key, NULL);
+  g_tree_insert (tree, path, g_variant_ref_sink (value));
+  g_settings_backend_write (settings->priv->backend, "", tree, NULL);
+}
+
+void
+g_settings_get (GSettings   *settings,
+                const gchar *key,
+                ...)
+{
+  const gchar *format;
+  GVariant *value;
+  va_list ap;
+
+  format = g_settings_schema_get_key_format (settings->priv->schema, key);
+  value = g_settings_get_value (settings, key);
+
+  va_start (ap, key);
+  g_variant_get_va (value, NULL, format, NULL, &ap);
+  va_end (ap);
+
+  g_variant_unref (value);
+}
+
+void
+g_settings_set (GSettings   *settings,
+                const gchar *key,
+                ...)
+{
+  const gchar *format;
+  GVariant *value;
+  va_list ap;
+
+  format = g_settings_schema_get_key_format (settings->priv->schema, key);
+
+  va_start (ap, key);
+  value = g_variant_new_va (NULL, format, NULL, &ap);
+  va_end (ap);
+
+  g_settings_set_value (settings, key, value);
+}
+
+gboolean
+g_settings_is_writable (GSettings   *settings,
+                        const gchar *name)
+{
+  return TRUE;
+}
+
+void
+g_settings_destroy (GSettings *settings)
+{
+  g_signal_emit (settings, g_settings_signals[SIGNAL_DESTROYED], 0);
+}
+
+#define _gsettings_c_
+#include "gioaliasdef.c"
diff --git a/gio/gsettings.h b/gio/gsettings.h
new file mode 100644
index 0000000..508a7a8
--- /dev/null
+++ b/gio/gsettings.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright © 2009 Codethink Limited
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of version 3 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * See the included COPYING file for more information.
+ */
+
+#ifndef _gsettings_h_
+#define _gsettings_h_
+
+#include "gsettingsbackend.h"
+
+#define G_TYPE_SETTINGS                                     (g_settings_get_type ())
+#define G_SETTINGS(inst)                                    (G_TYPE_CHECK_INSTANCE_CAST ((inst),                     \
+                                                             G_TYPE_SETTINGS, GSettings))
+#define G_SETTINGS_CLASS(class)                             (G_TYPE_CHECK_CLASS_CAST ((class),                       \
+                                                             G_TYPE_SETTINGS, GSettingsClass))
+#define G_IS_SETTINGS(inst)                                 (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_SETTINGS))
+#define G_IS_SETTINGS_CLASS(class)                          (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_SETTINGS))
+#define G_SETTINGS_GET_CLASS(inst)                          (G_TYPE_INSTANCE_GET_CLASS ((inst),                      \
+                                                             G_TYPE_SETTINGS, GSettingsClass))
+
+typedef struct _GSettingsPrivate                            GSettingsPrivate;
+typedef struct _GSettingsClass                              GSettingsClass;
+typedef struct _GSettings                                   GSettings;
+
+struct _GSettingsClass
+{
+  GObjectClass parent_class;
+
+
+  GSettings * (*get_settings) (GSettings    *settings,
+                               const gchar  *name);
+
+
+  void        (*changes)      (GSettings    *settings,
+                               const GQuark *keys,
+                               gint          n_keys);
+  void        (*changed)      (GSettings    *settings,
+                               const gchar  *key);
+  void        (*destroyed)    (GSettings    *settings);
+};
+
+struct _GSettings
+{
+  GObject parent_instance;
+  GSettingsPrivate *priv;
+};
+
+G_BEGIN_DECLS
+
+GType                   g_settings_get_type                             (void);
+void                    g_settings_revert                               (GSettings      *settings);
+void                    g_settings_apply                                (GSettings      *settings);
+
+gboolean                g_settings_get_delay_apply                      (GSettings      *settings);
+gboolean                g_settings_get_has_unapplied                    (GSettings      *settings);
+void                    g_settings_set_delay_apply                      (GSettings      *settings,
+                                                                         gboolean        delay_apply);
+gboolean                g_settings_get_locked                           (GSettings      *settings);
+void                    g_settings_lock                                 (GSettings      *settings);
+
+GSettings *             g_settings_new                                  (const gchar    *schema);
+GSettings *             g_settings_new_from_path                        (const gchar    *path);
+
+void                    g_settings_set_value                            (GSettings      *settings,
+                                                                         const gchar    *key,
+                                                                         GVariant       *value);
+
+GVariant *              g_settings_get_value                            (GSettings      *settings,
+                                                                         const gchar    *key);
+
+void                    g_settings_set                                  (GSettings      *settings,
+                                                                         const gchar    *first_key,
+                                                                         ...);
+
+void                    g_settings_get                                  (GSettings      *settings,
+                                                                         const gchar     *first_key,
+                                                                         ...);
+
+GSettings *             g_settings_get_settings                         (GSettings      *settings,
+                                                                         const gchar    *name);
+
+gboolean                g_settings_is_writable                          (GSettings      *settings,
+                                                                         const gchar    *name);
+void                    g_settings_changes                              (GSettings      *settings,
+                                                                         const GQuark   *keys,
+                                                                         gint            n_keys);
+void                    g_settings_destroy                              (GSettings      *settings);
+
+
+G_END_DECLS
+
+#endif /* _gsettings_h_ */



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