From 43a72ce1bea72a581faf34a505004cac941690c3 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Fri, 16 Apr 2010 23:20:48 -0400 Subject: [PATCH] GSettingsSchema: add call to get list of keys --- gio/gsettingsschema.c | 32 ++++++++++++++++++++++++++++++++ gio/gsettingsschema.h | 3 +++ 2 files changed, 35 insertions(+) diff --git a/gio/gsettingsschema.c b/gio/gsettingsschema.c index 188201d37..af2c7d8fe 100644 --- a/gio/gsettingsschema.c +++ b/gio/gsettingsschema.c @@ -30,6 +30,8 @@ struct _GSettingsSchemaPrivate { const gchar *gettext_domain; const gchar *path; + GQuark *items; + gint n_items; GvdbTable *table; gchar *name; }; @@ -86,6 +88,7 @@ g_settings_schema_finalize (GObject *object) GSettingsSchema *schema = G_SETTINGS_SCHEMA (object); gvdb_table_unref (schema->priv->table); + g_free (schema->priv->items); g_free (schema->priv->name); G_OBJECT_CLASS (g_settings_schema_parent_class) @@ -203,3 +206,32 @@ g_settings_schema_has_key (GSettingsSchema *schema, { return gvdb_table_has_value (schema->priv->table, key); } + +const GQuark * +g_settings_schema_list (GSettingsSchema *schema, + gint *n_items) +{ + gint i, j; + + if (schema->priv->items == NULL) + { + gchar **list; + gint len; + + list = gvdb_table_list (schema->priv->table, ""); + len = g_strv_length (list); + + schema->priv->items = g_new (GQuark, len); + j = 0; + + for (i = 0; i < len; i++) + if (list[i][0] != '.') + schema->priv->items[j++] = g_quark_from_string (list[i]); + schema->priv->n_items = j; + + g_strfreev (list); + } + + *n_items = schema->priv->n_items; + return schema->priv->items; +} diff --git a/gio/gsettingsschema.h b/gio/gsettingsschema.h index f813a959a..f57b01582 100644 --- a/gio/gsettingsschema.h +++ b/gio/gsettingsschema.h @@ -67,6 +67,9 @@ GVariant * g_settings_schema_get_value (GSettin G_GNUC_INTERNAL gboolean g_settings_schema_has_key (GSettingsSchema *schema, const gchar *key); +G_GNUC_INTERNAL +const GQuark * g_settings_schema_list (GSettingsSchema *schema, + gint *n_items); G_END_DECLS