diff options
author | Eitan Isaacson <eitan@monotonous.org> | 2010-12-14 15:54:07 -0800 |
---|---|---|
committer | Eitan Isaacson <eitan@monotonous.org> | 2011-01-07 13:34:34 -0800 |
commit | 1788b7a040fcb6074ab2bbf322e2385be5661b28 (patch) | |
tree | 90ede3d28dfec6b0621044272b40f8bd5711922c /caribou/common/setting_types.py | |
parent | 0b5e10eed67e5aa0734735ea19c11a611b486624 (diff) | |
download | caribou-1788b7a040fcb6074ab2bbf322e2385be5661b28.tar.gz |
Transitioned to introspection GTK3. Things that are not working yet:
- GConf notification. Not critical, will get it working when we move to
GSettings.
- Scanning. The module needs a lot of work anyway, will probably be doing alot
of cleanup with transition.
- Proximity opacity. This has been a hidden feature anyway.
- Animation. Ditto, it's been hidden. Need to expose those two settings in the
UI.
Diffstat (limited to 'caribou/common/setting_types.py')
-rw-r--r-- | caribou/common/setting_types.py | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/caribou/common/setting_types.py b/caribou/common/setting_types.py index 17faa61..5b8aa95 100644 --- a/caribou/common/setting_types.py +++ b/caribou/common/setting_types.py @@ -1,4 +1,5 @@ import gobject +from gi.repository import GConf GCONF_DIR="/apps/caribou/osk/" @@ -36,7 +37,6 @@ class Setting(gobject.GObject): self._sensitive = sensitive self.emit('sensitivity-changed', sensitive) - def __len__(self): return len(self.children) @@ -56,7 +56,7 @@ class SettingsGroup(Setting): pass class ValueSetting(Setting): - gconf_type = '' + gconf_type = GConf.ValueType.INVALID entry_type=ENTRY_DEFAULT def __init__(self, name, label, default, short_desc="", long_desc="", allowed=[], entry_type=ENTRY_DEFAULT, sensitive=None, @@ -80,7 +80,7 @@ class ValueSetting(Setting): @value.setter def value(self, val): - _val = self.convert_value(val) + _val = self.convert_value(self._from_gconf_value(val)) if self.allowed and _val not in [a for a, b in self.allowed]: raise ValueError, "'%s' not a valid value" % _val self._value = _val @@ -98,8 +98,32 @@ class ValueSetting(Setting): def gconf_default(self): return self.default + def set_gconf_value(self, val): + if val.type == GConf.ValueType.BOOL: + return val.set_bool(self.value) + if val.type == GConf.ValueType.FLOAT: + return val.set_float(self.value) + if val.type == GConf.ValueType.INT: + return val.set_int(self.value) + if val.type == GConf.ValueType.STRING: + return val.set_string(self.value) + + def _from_gconf_value(self, val): + if not isinstance(val, GConf.Value): + return val + if val.type == GConf.ValueType.BOOL: + return val.get_bool() + if val.type == GConf.ValueType.FLOAT: + return val.get_float() + if val.type == GConf.ValueType.INT: + return val.get_int() + if val.type == GConf.ValueType.STRING: + return val.get_string() + + return val.to_string() + class BooleanSetting(ValueSetting): - gconf_type = 'boolean' + gconf_type = GConf.ValueType.BOOL entry_type = ENTRY_CHECKBOX def convert_value(self, val): # Almost anything could be a boolean. @@ -110,7 +134,7 @@ class BooleanSetting(ValueSetting): str(self.default).lower() class IntegerSetting(ValueSetting): - gconf_type = 'int' + gconf_type = GConf.ValueType.INT entry_type = ENTRY_SPIN def __init__(self, *args, **kwargs): self.min = kwargs.pop('min', gobject.G_MININT) @@ -121,7 +145,7 @@ class IntegerSetting(ValueSetting): return int(val) class FloatSetting(ValueSetting): - gconf_type = 'float' + gconf_type = GConf.ValueType.FLOAT entry_type = ENTRY_SPIN def __init__(self, *args, **kwargs): self.min = kwargs.pop('min', gobject.G_MINFLOAT) @@ -132,7 +156,7 @@ class FloatSetting(ValueSetting): return float(val) class StringSetting(ValueSetting): - gconf_type = 'string' + gconf_type = GConf.ValueType.STRING def convert_value(self, val): return str(val) |