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 668232 - Unable to get description and summary for a key
Unable to get description and summary for a key
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gsettings
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Allison Karlitskaya (desrt)
gtkdev
Depends on:
Blocks: 668234
 
 
Reported: 2012-01-19 02:35 UTC by Robert Ancell
Modified: 2013-10-27 17:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GSettingsSchema: add API for introspecting keys (17.51 KB, patch)
2012-07-27 14:27 UTC, Allison Karlitskaya (desrt)
reviewed Details | Review
Clean up GSettingsSchema logic (3.60 KB, patch)
2013-10-27 16:32 UTC, Allison Karlitskaya (desrt)
committed Details | Review
GSettingsSchema: store a backref to the source (1.31 KB, patch)
2013-10-27 16:32 UTC, Allison Karlitskaya (desrt)
committed Details | Review
Make GSettingsSchemaKey public (5.28 KB, patch)
2013-10-27 16:32 UTC, Allison Karlitskaya (desrt)
committed Details | Review
Add g_settings_schema_key_get_summary/description (13.50 KB, patch)
2013-10-27 16:32 UTC, Allison Karlitskaya (desrt)
committed Details | Review
Add a testcase for summary/description (3.11 KB, patch)
2013-10-27 16:32 UTC, Allison Karlitskaya (desrt)
committed Details | Review

Description Robert Ancell 2012-01-19 02:35:59 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);
Comment 1 Allison Karlitskaya (desrt) 2012-01-19 03:09:11 UTC
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.
Comment 2 John Stowers 2012-01-22 01:57:50 UTC
+1 from me.

In gnome-tweak-tool I just parse the xml (stealing dconf-editors approach)
Comment 3 Allison Karlitskaya (desrt) 2012-01-26 20:26:43 UTC
interesting point: do we expect that the summary/description will be translated?
Comment 4 Matthias Clasen 2012-01-27 03:38:22 UTC
Otherwise, there's no point - if you want to show these strings in the ui, they need to be translated.
Comment 5 Allison Karlitskaya (desrt) 2012-07-27 14:27:23 UTC
Created attachment 219740 [details] [review]
GSettingsSchema: add API for introspecting keys

So far only supporting getting key summary/description.
Comment 6 Colin Walters 2012-07-27 15:03:39 UTC
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.
Comment 7 John Stowers 2012-07-27 16:46:05 UTC
(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)
Comment 8 Allison Karlitskaya (desrt) 2013-10-27 16:32:11 UTC
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.
Comment 9 Allison Karlitskaya (desrt) 2013-10-27 16:32:13 UTC
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.
Comment 10 Allison Karlitskaya (desrt) 2013-10-27 16:32:15 UTC
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).
Comment 11 Allison Karlitskaya (desrt) 2013-10-27 16:32:18 UTC
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).
Comment 12 Allison Karlitskaya (desrt) 2013-10-27 16:32:21 UTC
Created attachment 258232 [details] [review]
Add a testcase for summary/description
Comment 13 Lars Karlitski 2013-10-27 16:34:40 UTC
Review of attachment 258228 [details] [review]:

Ok.
Comment 14 Lars Karlitski 2013-10-27 16:35:19 UTC
Review of attachment 258229 [details] [review]:

Ok.
Comment 15 Lars Karlitski 2013-10-27 16:43:40 UTC
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
Comment 16 Lars Karlitski 2013-10-27 16:44:13 UTC
Review of attachment 258229 [details] [review]:

Forgot to set the status.
Comment 17 Lars Karlitski 2013-10-27 17:08:31 UTC
Review of attachment 258231 [details] [review]:

Looks good to me (except that this will choke on invalid schema files ;) )
Comment 18 Lars Karlitski 2013-10-27 17:10:16 UTC
Review of attachment 258232 [details] [review]:

Ok.
Comment 19 Allison Karlitskaya (desrt) 2013-10-27 17:45:42 UTC
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