GNOME Bugzilla – Bug 668232
Unable to get description and summary for a key
Last modified: 2013-10-27 17:45:54 UTC
There is no API to get the description and summary strings for a key. Perhaps the following is needed? gchar *g_settings_schema_get_description (GSettingsSchema *schema, const gchar *key); gchar *g_settings_schema_get_summary (GSettingsSchema *schema, const gchar *key);
this is really annoying because the schema cache file doesn't have this information. best idea so far is to create a parallel cache file that only is opened when someone calls one of these APIs. i'd prefer not to parse XML from glib.
+1 from me. In gnome-tweak-tool I just parse the xml (stealing dconf-editors approach)
interesting point: do we expect that the summary/description will be translated?
Otherwise, there's no point - if you want to show these strings in the ui, they need to be translated.
Created attachment 219740 [details] [review] GSettingsSchema: add API for introspecting keys So far only supporting getting key summary/description.
Review of attachment 219740 [details] [review]: Who wants this and why out of curiosity? dconf-editor? ::: gio/gsettingsschema.c @@ +233,3 @@ + g_hash_table_unref (source->text_tables[0]); + g_hash_table_unref (source->text_tables[1]); + g_free (source->text_tables); The array of two hash tables seems weird. Why not just separate structure members? @@ +315,3 @@ + + if (source != NULL) + schema_sources = source; Hmm...is this supposed to be a list? @@ +1346,3 @@ + +GSettingsSchemaKey * +g_settings_schema_get_key (GSettingsSchema *schema, Missing docs.
(In reply to comment #6) > Review of attachment 219740 [details] [review]: > > Who wants this and why out of curiosity? dconf-editor? and gnome-tweak-tool (for the same reasons as dconf-editor)
Created attachment 258228 [details] [review] Clean up GSettingsSchema logic The way we created the global schema list predates g_settings_schema_source_new_from_directory() and therefore doesn't use it. Update it to use that function, removing some code.
Created attachment 258229 [details] [review] GSettingsSchema: store a backref to the source Record in each GSettingsSchema object the source from which it came. This will be useful in future commits.
Created attachment 258230 [details] [review] 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).
Created attachment 258231 [details] [review] Add g_settings_schema_key_get_summary/description Add an API to read the summary and description from the .xml schema files. This will be used by dconf-editor and gnome-tweak-tool. This API is a bit heavy -- it parses the XML and builds a table. It also loads gettext domains for translation. It only does these things if it is used, however, so it will not impact normal applications. We store the summary/description in a pair of hash tables on the schema source (which we have a backref to as of a few commits ago). We can't use a global table because people might want to request summary and description from non-default sources. We don't want to use per-schema tables because we'd have to reparse the directory every time (since we cannot guess which file a schema may have been in).
Created attachment 258232 [details] [review] Add a testcase for summary/description
Review of attachment 258228 [details] [review]: Ok.
Review of attachment 258229 [details] [review]: Ok.
Review of attachment 258230 [details] [review]: Looks good except the few issues in the doc strings. ::: gio/gsettingsschema.c @@ +1082,3 @@ +/** + * g_settings_schema_key_ref: + * @source: a #GSettingsSchemaKey wrong parameter name @@ +1092,3 @@ +GSettingsSchemaKey * +g_settings_schema_key_ref (GSettingsSchemaKey *key) +{ g_return_if_fail (key != NULL); @@ +1100,3 @@ +/** + * g_settings_schema_key_unref: + * @schema: a #GSettingsSchemaKey wrong parameter name @@ +1108,3 @@ +void +g_settings_schema_key_unref (GSettingsSchemaKey *key) +{ g_return_if_fail (key != NULL); @@ +1134,3 @@ +g_settings_schema_get_key (GSettingsSchema *schema, + const gchar *name) +{ preconditions
Review of attachment 258229 [details] [review]: Forgot to set the status.
Review of attachment 258231 [details] [review]: Looks good to me (except that this will choke on invalid schema files ;) )
Review of attachment 258232 [details] [review]: Ok.
Attachment 258228 [details] pushed as e462eda - Clean up GSettingsSchema logic Attachment 258229 [details] pushed as 0ef43ba - GSettingsSchema: store a backref to the source Attachment 258230 [details] pushed as 84fa07a - Make GSettingsSchemaKey public Attachment 258231 [details] pushed as 96a053e - Add g_settings_schema_key_get_summary/description Attachment 258232 [details] pushed as 00b35c7 - Add a testcase for summary/description