#include "gsettingsschema.h"
-typedef struct
+struct _GSettingsSchemaKey
{
GSettingsSchema *schema;
const gchar *name;
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,
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;
+}
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
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