After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 683017 - API for accessing GSettings Schema metadata
API for accessing GSettings Schema metadata
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gsettings
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: Allison Karlitskaya (desrt)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-08-30 04:35 UTC by Danny Kirchmeier
Modified: 2013-10-28 18:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GSettingsSchemaKey: getters for type and default (2.88 KB, patch)
2013-10-27 16:34 UTC, Allison Karlitskaya (desrt)
reviewed Details | Review
GsettingsSchemaKey: add range operations (17.20 KB, patch)
2013-10-27 16:34 UTC, Allison Karlitskaya (desrt)
reviewed Details | Review
GSettingsSchemaKey: add introspection APIs (17.70 KB, patch)
2013-10-28 00:04 UTC, Allison Karlitskaya (desrt)
committed Details | Review

Description Danny Kirchmeier 2012-08-30 04:35:28 UTC
Right now, GSettings can only be used to read the saved settings data. I would also like to be able to access schema metadata, such as description, summary, range, default value, and so forth.

To do this presently, I must find the .gschema.xml file and parse it manually.
Comment 1 Allison Karlitskaya (desrt) 2013-10-27 16:34:18 UTC
Created attachment 258233 [details] [review]
GSettingsSchemaKey: getters for type and default

Add getters for the type of the key and the default value.
Comment 2 Allison Karlitskaya (desrt) 2013-10-27 16:34:20 UTC
Created attachment 258234 [details] [review]
GsettingsSchemaKey: add range operations

Add g_settings_schema_key_get_range() and
g_settings_schema_key_range_check(), deprecating the equivalent APIs on
GSettings.

Also: expose g_settings_schema_has_key(), which already existed.
Comment 3 Lars Karlitski 2013-10-27 17:12:37 UTC
Review of attachment 258233 [details] [review]:

Ok.

::: gio/gsettingsschema.c
@@ +1511,3 @@
+const GVariantType *
+g_settings_schema_key_get_value_type (GSettingsSchemaKey *key)
+{

key != NULL

@@ +1530,3 @@
+GVariant *
+g_settings_schema_key_get_default_value (GSettingsSchemaKey *key)
+{

key != NULL
Comment 4 Lars Karlitski 2013-10-27 17:29:41 UTC
Review of attachment 258234 [details] [review]:

::: gio/gsettings.c
@@ +2903,3 @@
 g_settings_action_get_state_hint (GAction *action)
 {
+  return NULL;

Why not implement this with the new g_settings_schema_key_get_range()?

::: gio/gsettingsschema.c
@@ +1513,3 @@
+
+  if (!value)
+    value = key->default_value;

This is missing a g_variant_ref()
Comment 5 Allison Karlitskaya (desrt) 2013-10-28 00:04:57 UTC
Created attachment 258253 [details] [review]
GSettingsSchemaKey: add introspection APIs

Add g_settings_schema_has_key() and _get_range(), _range_check(),
_get_value_type(), _get_default_value() methods on GSettingsSchemaKey.

Deprecate the equivalent APIs on GSettings.
Comment 6 Lars Karlitski 2013-10-28 18:07:01 UTC
Review of attachment 258253 [details] [review]:

Ok, thanks.
Comment 7 Allison Karlitskaya (desrt) 2013-10-28 18:32:27 UTC
Attachment 258253 [details] pushed as bcb030a - GSettingsSchemaKey: add introspection APIs

pushed, with the state hint code restored (as mentioned in person).

thanks!