mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
GSettingsSchema: add g_settings_schema_list_keys()
The list of keys in a GSettings object depends entirely on the schema, so it makes sense to expose this API there. Move the implementation out of gsettings.c and into gsettingsschema.c, replacing the earlier with a simple call to the new location. We don't do the same for children because the children can change. https://bugzilla.gnome.org/show_bug.cgi?id=740308
This commit is contained in:
parent
36e093a31a
commit
82fcfeb3b0
@ -2308,23 +2308,7 @@ g_settings_get_child (GSettings *settings,
|
|||||||
gchar **
|
gchar **
|
||||||
g_settings_list_keys (GSettings *settings)
|
g_settings_list_keys (GSettings *settings)
|
||||||
{
|
{
|
||||||
const GQuark *keys;
|
return g_settings_schema_list_keys (settings->priv->schema);
|
||||||
gchar **strv;
|
|
||||||
gint n_keys;
|
|
||||||
gint i, j;
|
|
||||||
|
|
||||||
keys = g_settings_schema_list (settings->priv->schema, &n_keys);
|
|
||||||
strv = g_new (gchar *, n_keys + 1);
|
|
||||||
for (i = j = 0; i < n_keys; i++)
|
|
||||||
{
|
|
||||||
const gchar *key = g_quark_to_string (keys[i]);
|
|
||||||
|
|
||||||
if (!g_str_has_suffix (key, "/"))
|
|
||||||
strv[j++] = g_strdup (key);
|
|
||||||
}
|
|
||||||
strv[j] = NULL;
|
|
||||||
|
|
||||||
return strv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1036,6 +1036,8 @@ g_settings_schema_list_children (GSettingsSchema *schema)
|
|||||||
gint n_keys;
|
gint n_keys;
|
||||||
gint i, j;
|
gint i, j;
|
||||||
|
|
||||||
|
g_return_val_if_fail (schema != NULL, NULL);
|
||||||
|
|
||||||
keys = g_settings_schema_list (schema, &n_keys);
|
keys = g_settings_schema_list (schema, &n_keys);
|
||||||
strv = g_new (gchar *, n_keys + 1);
|
strv = g_new (gchar *, n_keys + 1);
|
||||||
for (i = j = 0; i < n_keys; i++)
|
for (i = j = 0; i < n_keys; i++)
|
||||||
@ -1056,6 +1058,45 @@ g_settings_schema_list_children (GSettingsSchema *schema)
|
|||||||
return strv;
|
return strv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_settings_schema_list_keys:
|
||||||
|
* @schema: a #GSettingsSchema
|
||||||
|
*
|
||||||
|
* Introspects the list of keys on @schema.
|
||||||
|
*
|
||||||
|
* You should probably not be calling this function from "normal" code
|
||||||
|
* (since you should already know what keys are in your schema). This
|
||||||
|
* function is intended for introspection reasons.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full) (element-type utf8): a list of the keys on
|
||||||
|
* @schema
|
||||||
|
*
|
||||||
|
* Since: 2.46
|
||||||
|
*/
|
||||||
|
gchar **
|
||||||
|
g_settings_schema_list_keys (GSettingsSchema *schema)
|
||||||
|
{
|
||||||
|
const GQuark *keys;
|
||||||
|
gchar **strv;
|
||||||
|
gint n_keys;
|
||||||
|
gint i, j;
|
||||||
|
|
||||||
|
g_return_val_if_fail (schema != NULL, NULL);
|
||||||
|
|
||||||
|
keys = g_settings_schema_list (schema, &n_keys);
|
||||||
|
strv = g_new (gchar *, n_keys + 1);
|
||||||
|
for (i = j = 0; i < n_keys; i++)
|
||||||
|
{
|
||||||
|
const gchar *key = g_quark_to_string (keys[i]);
|
||||||
|
|
||||||
|
if (!g_str_has_suffix (key, "/"))
|
||||||
|
strv[j++] = g_strdup (key);
|
||||||
|
}
|
||||||
|
strv[j] = NULL;
|
||||||
|
|
||||||
|
return strv;
|
||||||
|
}
|
||||||
|
|
||||||
const GQuark *
|
const GQuark *
|
||||||
g_settings_schema_list (GSettingsSchema *schema,
|
g_settings_schema_list (GSettingsSchema *schema,
|
||||||
gint *n_items)
|
gint *n_items)
|
||||||
|
@ -74,6 +74,9 @@ GSettingsSchemaKey * g_settings_schema_get_key (GSettin
|
|||||||
GLIB_AVAILABLE_IN_2_40
|
GLIB_AVAILABLE_IN_2_40
|
||||||
gboolean g_settings_schema_has_key (GSettingsSchema *schema,
|
gboolean g_settings_schema_has_key (GSettingsSchema *schema,
|
||||||
const gchar *name);
|
const gchar *name);
|
||||||
|
GLIB_AVAILABLE_IN_2_46
|
||||||
|
gchar** g_settings_schema_list_keys (GSettingsSchema *schema);
|
||||||
|
|
||||||
|
|
||||||
GLIB_AVAILABLE_IN_2_44
|
GLIB_AVAILABLE_IN_2_44
|
||||||
gchar ** g_settings_schema_list_children (GSettingsSchema *schema);
|
gchar ** g_settings_schema_list_children (GSettingsSchema *schema);
|
||||||
|
Loading…
Reference in New Issue
Block a user