summaryrefslogtreecommitdiffstats
path: root/setup
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2014-01-17 14:45:34 +0800
committerPeng Wu <alexepico@gmail.com>2014-01-17 14:45:34 +0800
commit54afa6da054f90c19df1184e95e15cd00e68b400 (patch)
tree86ab29d62f797e7af23dc2c8e19fd49f89e98067 /setup
parent3eae27a1e309cfa6615853b899acf91c69cc2acf (diff)
downloadibus-libzhuyin-54afa6da054f90c19df1184e95e15cd00e68b400.tar.gz
ibus-libzhuyin-54afa6da054f90c19df1184e95e15cd00e68b400.tar.xz
ibus-libzhuyin-54afa6da054f90c19df1184e95e15cd00e68b400.zip
add set/get values for main.py
Diffstat (limited to 'setup')
-rw-r--r--setup/main.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/setup/main.py b/setup/main.py
index 5d30ffd..c61baca 100644
--- a/setup/main.py
+++ b/setup/main.py
@@ -44,6 +44,8 @@ class PreferencesWindow:
self.__init_pages()
if engine == "zhuyin":
+ self.__config_namespace = "engine/zhuyin"
+ self.__values = dict(self.__config.get_values(self.__config_namespace))
self.__init_inputting()
self.__init_keyboard()
self.__init_fuzzy_zhuyin()
@@ -111,6 +113,33 @@ class PreferencesWindow:
self.__builder.get_object(name).set_label(label)
+ def __toggled_cb(self, widget, name):
+ self.__set_value(name, widget.get_active ())
+
+ def __get_value(self, name, defval):
+ if name in self.__values:
+ var = self.__values[name]
+ if isinstance(defval, type(var)):
+ return var
+ self.__set_value(name, defval)
+ return defval
+
+ def __set_value(self, name, val):
+ var = None
+ if isinstance(val, bool):
+ var = GLib.Variant.new_boolean(val)
+ elif isinstance(val, int):
+ var = GLib.Variant.new_int32(val)
+ elif isinstance(val, str):
+ var = GLib.Variant.new_string(val)
+ else:
+ print >> sys.stderr, "val(%s) is not in support type." % repr(val)
+ return
+
+ self.__values[name] = val
+ self.__config.set_value(self.__config_namespace, name, var)
+
+
def show(self):
self.__window.show()