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 695558 - The --schemadir option has no effect
The --schemadir option has no effect
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gsettings
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Allison Karlitskaya (desrt)
gtkdev
Depends on: 680838
Blocks:
 
 
Reported: 2013-03-10 12:35 UTC by Jiro Matsuzawa
Modified: 2013-10-28 18:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GSettings tool: stop using deprecated APIs (14.66 KB, patch)
2013-10-27 17:31 UTC, Allison Karlitskaya (desrt)
none Details | Review
gsettings(1): use global variables (11.88 KB, patch)
2013-10-28 17:57 UTC, Allison Karlitskaya (desrt)
committed Details | Review
gsettings(1): stop using deprecated APIs (7.29 KB, patch)
2013-10-28 17:58 UTC, Allison Karlitskaya (desrt)
committed Details | Review

Description Jiro Matsuzawa 2013-03-10 12:35:56 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
Comment 1 Matthias Clasen 2013-03-11 10:04:44 UTC
The schema source api doesn't currently allow to implement this.
Comment 2 Allison Karlitskaya (desrt) 2013-03-13 13:58:28 UTC
Interesting.

We could be smarter and build the list by iterating each source...
Comment 3 Allison Karlitskaya (desrt) 2013-10-27 17:31:26 UTC
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.
Comment 4 Lars Karlitski 2013-10-27 17:49:06 UTC
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.
Comment 5 Allison Karlitskaya (desrt) 2013-10-28 17:57:58 UTC
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...
Comment 6 Allison Karlitskaya (desrt) 2013-10-28 17:58:04 UTC
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.
Comment 7 Lars Karlitski 2013-10-28 18:47:07 UTC
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 8 Allison Karlitskaya (desrt) 2013-10-28 18:49:52 UTC
Comment on attachment 258324 [details] [review]
gsettings(1): use global variables

Attachment 258324 [details] pushed as a1a4dbf - gsettings(1): use global variables
Comment 9 Lars Karlitski 2013-10-28 18:52:16 UTC
Review of attachment 258325 [details] [review]:

Ok.
Comment 10 Allison Karlitskaya (desrt) 2013-10-28 18:53:55 UTC
Attachment 258325 [details] pushed as b304869 - gsettings(1): stop using deprecated APIs