GNOME Bugzilla – Bug 695558
The --schemadir option has no effect
Last modified: 2013-10-28 18:53:58 UTC
[Problem] The --schemadir option of gsettings command has no effect on list-schemas, list-relocatable-schemas, or etc. "gsettings help list-schemas" says that the --schemadir option may be given. It seems, however, that an additional schema directory is not respected. g_settings_list_schemas() internally initialize the schema sources. So, it returns only the schemas installed on the system. gio/gsettings-tool.c: 151 static void 152 gsettings_list_schemas (GSettings *settings, 153 const gchar *key, 154 const gchar *value) 155 { 156 output_list (g_settings_list_schemas ()); 157 } On the other hand, an additional directory is respected with list-keys, get, set, etc.. [How to Reproduce] $ pwd /tmp $ echo $XDG_DATA_DIRS /usr/share/gnome:/usr/local/share/:/usr/share/ $ cat org.example.additional.gschema.xml <?xml version="1.0" encoding="UTF-8"?> <schemalist> <schema path="/org/example/additional/" id="org.example.additional"> <key type="b" name="dummy-key"> <default>true</default> <summary>Dummy key</summary> <description>Dummy key in additional schema</description> </key> </schema> </schemalist> $ glib-compile-schemas . $ gsettings list-keys org.example.additional No such schema 'org.example.additional' $ gsettings --schemadir . list-keys org.example.additional dummy-key $ gsettings --schemadir . list-schemas | grep org.example.additional $ echo $? 1 $ exit
The schema source api doesn't currently allow to implement this.
Interesting. We could be smarter and build the list by iterating each source...
Created attachment 258238 [details] [review] GSettings tool: stop using deprecated APIs Stop using the recently-deprecated GSettings APIs. This fixes a number of bugs and also a net reduction of code. In particular, list-schemas will now work in context of a given --schemadir argument.
Review of attachment 258238 [details] [review]: Can you please break the two changes out (global vars and new apis)? It'll make it easier to review.
Created attachment 258324 [details] [review] gsettings(1): use global variables The number of arguments passed to each function is about to increase, so just use global variables instead. This is a commandline tool, after all...
Created attachment 258325 [details] [review] gsettings(1): stop using deprecated APIs Stop using the recently-deprecated GSettings APIs. Use the GSettingsSchema-based APIs instead. This fixes a number of bugs and also a net reduction of code. In particular, list-schemas will now work in context of a given --schemadir argument.
Review of attachment 258324 [details] [review]: Please reinsert that unref() in the first patch. ::: gio/gsettings-tool.c @@ +481,2 @@ } existing is not unreffed() anymore. You're doing that in the next patch.
Comment on attachment 258324 [details] [review] gsettings(1): use global variables Attachment 258324 [details] pushed as a1a4dbf - gsettings(1): use global variables
Review of attachment 258325 [details] [review]: Ok.
Attachment 258325 [details] pushed as b304869 - gsettings(1): stop using deprecated APIs