From e24d0fddff4e27ffb8ffd191a6525fc872fa5d1f Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Sun, 26 Aug 2012 00:50:26 +0200 Subject: [PATCH] Use keyfile GSettings backend in Python player This requires a modification to gobject-introspection; see bugzilla.gnome.org #682702. If that fails, use the old behavior. --- player/player.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/player/player.py b/player/player.py index a50433f..8528f9e 100644 --- a/player/player.py +++ b/player/player.py @@ -15,10 +15,18 @@ class Player(GObject.GObject): def __init__(self): super(Player, self).__init__() - # FIXME: should use the Keyfile backend, but that's not available from - # Python - self.prefs_settings = Gio.Settings('org.chimara-if.player.preferences') - self.state_settings = Gio.Settings('org.chimara-if.player.state') + if os.path.exists('chimara-config'): + keyfile = 'chimara-config' + else: + keyfile = os.path.expanduser('~/.chimara/config') + try: + # This only works on my custom-built gobject-introspection; opened + # bug #682702 + backend = Gio.keyfile_settings_backend_new(keyfile, "/org/chimara-if/player/", None) + except AttributeError: + backend = None + self.prefs_settings = Gio.Settings('org.chimara-if.player.preferences', backend=backend) + self.state_settings = Gio.Settings('org.chimara-if.player.state', backend=backend) builder = Gtk.Builder() builder.add_from_file('chimara.ui') @@ -60,7 +68,10 @@ class Player(GObject.GObject): self.glk = Chimara.IF() self.glk.props.ignore_errors = True - self.glk.set_css_from_file('style.css') + css_file = _maybe(self.prefs_settings.get_value('css-file')) + if css_file is None: + css_file = 'style.css' + self.glk.set_css_from_file(css_file) vbox = builder.get_object('vbox') vbox.pack_end(self.glk, True, True, 0) -- 2.30.2