[glib] GSettings: add g_settings_list_keys()
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GSettings: add g_settings_list_keys()
- Date: Thu, 24 Jun 2010 06:17:25 +0000 (UTC)
commit 123699465d2d07c18823f41dfc6a48dd7cefc603
Author: Ryan Lortie <desrt desrt ca>
Date: Thu Jun 24 02:15:15 2010 -0400
GSettings: add g_settings_list_keys()
Second half of bug #622554.
docs/reference/gio/gio-sections.txt | 2 ++
gio/gio.symbols | 1 +
gio/gsettings.c | 33 ++++++++++++++++++++++++++++++++-
gio/gsettings.h | 1 +
4 files changed, 36 insertions(+), 1 deletions(-)
---
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index f970d12..5c62284 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -2135,6 +2135,7 @@ GSettingsBackendPrivate
<FILE>gsettings</FILE>
<TITLE>GSettings</TITLE>
GSettings
+g_settings_schema_exists
g_settings_new
g_settings_new_with_path
g_settings_new_with_backend
@@ -2148,6 +2149,7 @@ g_settings_apply
g_settings_revert
g_settings_get_has_unapplied
g_settings_get_child
+g_settings_list_keys
<SUBSECTION Convenience>
g_settings_get
diff --git a/gio/gio.symbols b/gio/gio.symbols
index 46af246..6ac8b59 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -1478,6 +1478,7 @@ g_settings_set_boolean
g_settings_get_enum
g_settings_set_enum
g_settings_sync
+g_settings_list_keys
#endif
#endif
diff --git a/gio/gsettings.c b/gio/gsettings.c
index c850f32..ee213ac 100644
--- a/gio/gsettings.c
+++ b/gio/gsettings.c
@@ -1762,7 +1762,7 @@ g_settings_get_has_unapplied (GSettings *settings)
G_DELAYED_SETTINGS_BACKEND (settings->priv->backend));
}
-/* Extra API (sync, get_child, is_writable) {{{1 */
+/* Extra API (sync, get_child, is_writable, list_keys) {{{1 */
/**
* g_settings_sync:
* @context: the context to sync, or %NULL
@@ -1855,6 +1855,37 @@ g_settings_get_child (GSettings *settings,
return child;
}
+/**
+ * g_settings_list_keys:
+ * @settings: a #GSettings object
+ * Returns: a list of the keys on @settings
+ *
+ * Introspects the list of keys on @settings.
+ *
+ * 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.
+ *
+ * You should free the return value with g_strfreev() when you are done
+ * with it.
+ */
+gchar **
+g_settings_list_keys (GSettings *settings)
+{
+ const GQuark *keys;
+ gchar **strv;
+ gint n_keys;
+ gint i;
+
+ keys = g_settings_schema_list (settings->priv->schema, &n_keys);
+ strv = g_new (gchar *, n_keys + 1);
+ for (i = 0; i < n_keys; i++)
+ strv[i] = g_strdup (g_quark_to_string (keys[i]));
+ strv[i] = NULL;
+
+ return strv;
+}
+
/* Binding {{{1 */
typedef struct
{
diff --git a/gio/gsettings.h b/gio/gsettings.h
index 9815364..ee5aac6 100644
--- a/gio/gsettings.h
+++ b/gio/gsettings.h
@@ -79,6 +79,7 @@ GSettings * g_settings_new_with_backend (const g
GSettings * g_settings_new_with_backend_and_path (const gchar *schema,
GSettingsBackend *backend,
const gchar *path);
+gchar ** g_settings_list_keys (GSettings *settings);
gboolean g_settings_set_value (GSettings *settings,
const gchar *key,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]