[gnome-tweak-tool] don't crash on old gnomedesktop.gir or input-schema
- From: John Stowers <jstowers src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tweak-tool] don't crash on old gnomedesktop.gir or input-schema
- Date: Wed, 26 Sep 2012 21:20:07 +0000 (UTC)
commit 73aaffabd1d974dc7dfb797c50172080acaac946
Author: John Stowers <john stowers gmail com>
Date: Wed Sep 26 23:19:55 2012 +0200
don't crash on old gnomedesktop.gir or input-schema
gtweak/tweaks/tweak_typing.py | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/gtweak/tweaks/tweak_typing.py b/gtweak/tweaks/tweak_typing.py
index bdf028e..09a8863 100644
--- a/gtweak/tweaks/tweak_typing.py
+++ b/gtweak/tweaks/tweak_typing.py
@@ -17,6 +17,8 @@
# Authors:
# Rui Matos
+import logging
+
from gi.repository import Pango, Gtk, GnomeDesktop
from gtweak.tweakmodel import Tweak, TweakGroup, TWEAK_GROUP_TYPING
@@ -89,27 +91,31 @@ class _XkbOption(Tweak):
class TypingTweakGroup(TweakGroup):
+ XKB_GSETTINGS_SCHEMA = "org.gnome.desktop.input-sources"
XKB_GSETTINGS_NAME = "xkb-options"
XKB_OPTIONS = ("ctrl","grp_led","keypad","kpdl","caps","altwin","compat","eurosign",
"lv5","nbsp","japan","esperanto","terminate")
def __init__(self):
TweakGroup.__init__(self, TWEAK_GROUP_TYPING)
-
self._option_objects = []
+ ok = False
try:
- self._kbdsettings = GSettingsSetting("org.gnome.desktop.input-sources")
+ self._kbdsettings = GSettingsSetting(self.XKB_GSETTINGS_SCHEMA)
self._kbdsettings.connect("changed::"+self.XKB_GSETTINGS_NAME, self._on_changed)
+ self._xkb_info = GnomeDesktop.XkbInfo()
+ ok = True
except GSettingsMissingError:
- self._kbdsettings = GSettingsFakeSetting()
-
- self._xkb_info = GnomeDesktop.XkbInfo()
-
- for opt in self.XKB_OPTIONS:
- self._option_objects.append(
- _XkbOption(opt, self._kbdsettings, self._xkb_info)
- )
+ logging.warning("Missing schema %s" % self.XKB_GSETTINGS_SCHEMA)
+ except AttributeError:
+ logging.warning("Missing GnomeDesktop.gir with Xkb support")
+ finally:
+ if ok:
+ for opt in self.XKB_OPTIONS:
+ self._option_objects.append(
+ _XkbOption(opt, self._kbdsettings, self._xkb_info)
+ )
self.set_tweaks(*self._option_objects)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]