mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-12 20:36:15 +01:00
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
This commit is contained in:
parent
0ef43ba743
commit
84fa07aeb1
@ -2406,8 +2406,15 @@ g_settings_schema_unref
|
|||||||
g_settings_schema_get_id
|
g_settings_schema_get_id
|
||||||
g_settings_schema_get_path
|
g_settings_schema_get_path
|
||||||
|
|
||||||
|
<SUBSECTION>
|
||||||
|
GSettingsSchemaKey
|
||||||
|
g_settings_schema_get_key
|
||||||
|
g_settings_schema_key_ref
|
||||||
|
g_settings_schema_key_unref
|
||||||
|
|
||||||
<SUBSECTION Private>
|
<SUBSECTION Private>
|
||||||
g_settings_schema_get_type
|
g_settings_schema_get_type
|
||||||
|
g_settings_schema_key_get_type
|
||||||
g_settings_schema_source_get_type
|
g_settings_schema_source_get_type
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "gsettingsschema.h"
|
#include "gsettingsschema.h"
|
||||||
|
|
||||||
typedef struct
|
struct _GSettingsSchemaKey
|
||||||
{
|
{
|
||||||
GSettingsSchema *schema;
|
GSettingsSchema *schema;
|
||||||
const gchar *name;
|
const gchar *name;
|
||||||
@ -39,7 +39,9 @@ typedef struct
|
|||||||
const GVariantType *type;
|
const GVariantType *type;
|
||||||
GVariant *minimum, *maximum;
|
GVariant *minimum, *maximum;
|
||||||
GVariant *default_value;
|
GVariant *default_value;
|
||||||
} GSettingsSchemaKey;
|
|
||||||
|
gint ref_count;
|
||||||
|
};
|
||||||
|
|
||||||
const gchar * g_settings_schema_get_gettext_domain (GSettingsSchema *schema);
|
const gchar * g_settings_schema_get_gettext_domain (GSettingsSchema *schema);
|
||||||
GVariantIter * g_settings_schema_get_value (GSettingsSchema *schema,
|
GVariantIter * g_settings_schema_get_value (GSettingsSchema *schema,
|
||||||
|
@ -1076,3 +1076,76 @@ g_settings_schema_key_from_flags (GSettingsSchemaKey *key,
|
|||||||
|
|
||||||
return g_variant_builder_end (&builder);
|
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;
|
||||||
|
}
|
||||||
|
@ -27,6 +27,7 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
typedef struct _GSettingsSchemaSource GSettingsSchemaSource;
|
typedef struct _GSettingsSchemaSource GSettingsSchemaSource;
|
||||||
typedef struct _GSettingsSchema GSettingsSchema;
|
typedef struct _GSettingsSchema GSettingsSchema;
|
||||||
|
typedef struct _GSettingsSchemaKey GSettingsSchemaKey;
|
||||||
|
|
||||||
#define G_TYPE_SETTINGS_SCHEMA_SOURCE (g_settings_schema_source_get_type ())
|
#define G_TYPE_SETTINGS_SCHEMA_SOURCE (g_settings_schema_source_get_type ())
|
||||||
GLIB_AVAILABLE_IN_2_32
|
GLIB_AVAILABLE_IN_2_32
|
||||||
@ -63,6 +64,18 @@ GLIB_AVAILABLE_IN_2_32
|
|||||||
const gchar * g_settings_schema_get_id (GSettingsSchema *schema);
|
const gchar * g_settings_schema_get_id (GSettingsSchema *schema);
|
||||||
GLIB_AVAILABLE_IN_2_32
|
GLIB_AVAILABLE_IN_2_32
|
||||||
const gchar * g_settings_schema_get_path (GSettingsSchema *schema);
|
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
|
G_END_DECLS
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user