Adding new keys to GSettings registry during runtime.



Hello,

I want to convert my application to use GSettings (and dconf) instead of GConf2.

In the old GConf it was possible to add new keys and values during runtime. Eg. I could recklessly write

conf_save_int_value("a_new_key", 1234);

and GCond simply created "a_new_key" and saved the value in the registry. No complains or errors, it just worked. And it was good.

The old GConf-based code is here:
http://bazaar.launchpad.net/~osmoma/audio-recorder/trunk/view/head:/src/gconf.c
---

GSettings seems to be different.
All keys and their types must be *strictly pre-defined* in a xml schema file. And the schema must be compiled and installed to /usr/share/glib-2.0/schemas/ directory.

Ok, I have successfully defined and installed my schema file.
Ref: http://www.futuredesktop.com/tmp/org.gnome.audio-recorder.gschema.xml (a simple test).

And I can read/write the values via the GSettings object. That's fine!
Ref: http://www.futuredesktop.com/tmp/dconf.c

But sometimes my code gets a new key (eg. a device name), and I want to store it and its value to GSettings registry.

?It's impossible to add new keys to schema (and GSettings) during runtime? Is the predefined schema the only way?


Guides:
http://live.gnome.org/GnomeGoals/GSettingsMigration
http://developer.gnome.org/gio/2.28/GSettings.html

// Osmo Antero












[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]