[glib] Make GSettingsSchemaKey public
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Make GSettingsSchemaKey public
- Date: Sun, 27 Oct 2013 17:45:42 +0000 (UTC)
commit 84fa07aeb1e3e41deac3508231712967366abfbd
Author: Ryan Lortie <desrt desrt ca>
Date: Sat Oct 26 18:57:24 2013 -0400
Make GSettingsSchemaKey public
Take this private API and make it public along with a boxed type and
ref/unref functions.
Future commits will add accessors with new functionality and some that
allow us to deprecate functions on GSettings itself (such as
g_settings_get_range).
https://bugzilla.gnome.org/show_bug.cgi?id=668232
docs/reference/gio/gio-sections.txt | 7 +++
gio/gsettingsschema-internal.h | 6 ++-
gio/gsettingsschema.c | 73 +++++++++++++++++++++++++++++++++++
gio/gsettingsschema.h | 13 ++++++
4 files changed, 97 insertions(+), 2 deletions(-)
---
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index 2c9813f..be7da51 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -2406,8 +2406,15 @@ g_settings_schema_unref
g_settings_schema_get_id
g_settings_schema_get_path
+<SUBSECTION>
+GSettingsSchemaKey
+g_settings_schema_get_key
+g_settings_schema_key_ref
+g_settings_schema_key_unref
+
<SUBSECTION Private>
g_settings_schema_get_type
+g_settings_schema_key_get_type
g_settings_schema_source_get_type
</SECTION>
diff --git a/gio/gsettingsschema-internal.h b/gio/gsettingsschema-internal.h
index 7b002c2..d701f5c 100644
--- a/gio/gsettingsschema-internal.h
+++ b/gio/gsettingsschema-internal.h
@@ -22,7 +22,7 @@
#include "gsettingsschema.h"
-typedef struct
+struct _GSettingsSchemaKey
{
GSettingsSchema *schema;
const gchar *name;
@@ -39,7 +39,9 @@ typedef struct
const GVariantType *type;
GVariant *minimum, *maximum;
GVariant *default_value;
-} GSettingsSchemaKey;
+
+ gint ref_count;
+};
const gchar * g_settings_schema_get_gettext_domain (GSettingsSchema *schema);
GVariantIter * g_settings_schema_get_value (GSettingsSchema *schema,
diff --git a/gio/gsettingsschema.c b/gio/gsettingsschema.c
index cac5f71..5919ff6 100644
--- a/gio/gsettingsschema.c
+++ b/gio/gsettingsschema.c
@@ -1076,3 +1076,76 @@ g_settings_schema_key_from_flags (GSettingsSchemaKey *key,
return g_variant_builder_end (&builder);
}
+
+G_DEFINE_BOXED_TYPE (GSettingsSchemaKey, g_settings_schema_key, g_settings_schema_key_ref,
g_settings_schema_key_unref)
+
+/**
+ * g_settings_schema_key_ref:
+ * @key: a #GSettingsSchemaKey
+ *
+ * Increase the reference count of @key, returning a new reference.
+ *
+ * Returns: a new reference to @key
+ *
+ * Since: 2.40
+ **/
+GSettingsSchemaKey *
+g_settings_schema_key_ref (GSettingsSchemaKey *key)
+{
+ g_return_val_if_fail (key != NULL, NULL);
+
+ g_atomic_int_inc (&key->ref_count);
+
+ return key;
+}
+
+/**
+ * g_settings_schema_key_unref:
+ * @key: a #GSettingsSchemaKey
+ *
+ * Decrease the reference count of @key, possibly freeing it.
+ *
+ * Since: 2.40
+ **/
+void
+g_settings_schema_key_unref (GSettingsSchemaKey *key)
+{
+ g_return_if_fail (key != NULL);
+
+ if (g_atomic_int_dec_and_test (&key->ref_count))
+ {
+ g_settings_schema_key_clear (key);
+
+ g_slice_free (GSettingsSchemaKey, key);
+ }
+}
+
+/**
+ * g_settings_schema_get_key:
+ * @schema: a #GSettingsSchema
+ * @name: the name of a key
+ *
+ * Gets the key named @name from @schema.
+ *
+ * It is a programmer error to request a key that does not exist. See
+ * g_settings_schema_list_keys().
+ *
+ * Returns: (transfer full): the #GSettingsSchemaKey for @name
+ *
+ * Since: 2.40
+ **/
+GSettingsSchemaKey *
+g_settings_schema_get_key (GSettingsSchema *schema,
+ const gchar *name)
+{
+ GSettingsSchemaKey *key;
+
+ g_return_val_if_fail (schema != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+
+ key = g_slice_new (GSettingsSchemaKey);
+ g_settings_schema_key_init (key, schema, name);
+ key->ref_count = 1;
+
+ return key;
+}
diff --git a/gio/gsettingsschema.h b/gio/gsettingsschema.h
index 20bf99f..e84029e 100644
--- a/gio/gsettingsschema.h
+++ b/gio/gsettingsschema.h
@@ -27,6 +27,7 @@ G_BEGIN_DECLS
typedef struct _GSettingsSchemaSource GSettingsSchemaSource;
typedef struct _GSettingsSchema GSettingsSchema;
+typedef struct _GSettingsSchemaKey GSettingsSchemaKey;
#define G_TYPE_SETTINGS_SCHEMA_SOURCE (g_settings_schema_source_get_type
())
GLIB_AVAILABLE_IN_2_32
@@ -63,6 +64,18 @@ GLIB_AVAILABLE_IN_2_32
const gchar * g_settings_schema_get_id (GSettingsSchema *schema);
GLIB_AVAILABLE_IN_2_32
const gchar * g_settings_schema_get_path (GSettingsSchema *schema);
+GLIB_AVAILABLE_IN_2_40
+GSettingsSchemaKey * g_settings_schema_get_key (GSettingsSchema *schema,
+ const gchar *key);
+
+#define G_TYPE_SETTINGS_SCHEMA_KEY (g_settings_schema_key_get_type ())
+GLIB_AVAILABLE_IN_2_40
+GType g_settings_schema_key_get_type (void) G_GNUC_CONST;
+
+GLIB_AVAILABLE_IN_2_40
+GSettingsSchemaKey * g_settings_schema_key_ref (GSettingsSchemaKey *key);
+GLIB_AVAILABLE_IN_2_40
+void g_settings_schema_key_unref (GSettingsSchemaKey *key);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]