I’m trying to find the right place to discuss GNOME application development questions (tried on IRC #gnome before). The GNOME developer docs don’t clarify this. I hope I can place developer questions here.
I need to write and read
Gio.Settings from a GEdit plugin, written in Python. I’m looking for good examples. Reading is pretty straight-forward, but I’d like to write the value to Gio.Settings when they’re not yet there. Hence, create a
GSettingsSchema first, and a value therein. That seems tricky.
What is the correct approach to do this? My strategy is:
- Try to read out the value, e.g.
settings = Gio.Settings.new('org.gnome.gedit.plugins.foobar')
- If that fails create the schema and write the default value in it.
# Gio.Settings doesn't seem to provide an interface for that # Gio.SettingsSchema doesn't create an instance with the constructor
- In the (GEdit plugin Preferences dialog) update the value as required after user input.
my_value = settings.get_string('my-key-in-foobar') ... settings.set_string('my-key-in-foobar', my_value)
Next time GEdit accesses the
Gio.Settings 1. should succeed, and 2. can be skipped.
Where can I find related coding examples? Preferably in Python, but C/C++/Vala would also be fine, as long as it’s sufficiently easy to match the implementation to the Python world, mentally.
Thanks in advance,