How to use the keyfile settings backend from PyGObject?

499 views Asked by At

GIO (GLib's I/O library) has a backend for GSettings that uses a keyfile. From C, you can create an instance of this backend in order to force use of a keyfile instead of the system registry, using g_keyfile_settings_backend_new() and then g_settings_new_with_backend(). However, to do this, you must #define G_SETTINGS_ENABLE_BACKEND in your code, since the backend public API is unstable.

I would like to do this from Python, using PyGObject (just to be clear, since this term is confusing - this is the GObject introspection library that goes with GTK 3, not the PyGObject that goes with PyGTK and GTK 2.) I can do

>>> from gi.repository import Gio
>>> 'SettingsBackend' in dir(Gio)
True

However, there's no function corresponding to g_keyfile_settings_backend_new() in dir(Gio). If I try instantiating a backend,

>>> Gio.SettingsBackend()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
MemoryError

So, does anybody have any pointers? Or maybe the Python module wasn't compiled with G_SETTINGS_ENABLE_BACKEND and I'm out of luck?

0

There are 0 answers