summaryrefslogtreecommitdiffstats
path: root/gconf
diff options
context:
space:
mode:
authorHuang Peng <shawn.p.huang@gmail.com>2008-10-03 20:19:03 +0800
committerHuang Peng <shawn.p.huang@gmail.com>2008-10-03 20:19:03 +0800
commit6515cb122eea13c16d5f936a346acbc1369b2d64 (patch)
tree697ecf0303f04e7452364ce17fb44df79d01662b /gconf
parent09a7df4511f12e447d1f43ad485b375a3e5b26c6 (diff)
downloadibus-6515cb122eea13c16d5f936a346acbc1369b2d64.tar.gz
ibus-6515cb122eea13c16d5f936a346acbc1369b2d64.tar.xz
ibus-6515cb122eea13c16d5f936a346acbc1369b2d64.zip
WIP.
Diffstat (limited to 'gconf')
-rw-r--r--gconf/config.py37
-rw-r--r--gconf/main.py5
2 files changed, 8 insertions, 34 deletions
diff --git a/gconf/config.py b/gconf/config.py
index 4b67106..8ec0d5f 100644
--- a/gconf/config.py
+++ b/gconf/config.py
@@ -30,11 +30,10 @@ except:
from ibus import gconf
import dbus
import ibus
-from ibus import interface
GCONF_IBUS_PATH = "/desktop/ibus"
-class Config(ibus.Object):
+class Config(ibus.ConfigBase):
__gsignals__ = {
"value-changed" : (
gobject.SIGNAL_RUN_FIRST,
@@ -42,10 +41,8 @@ class Config(ibus.Object):
(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)),
}
- def __init__ (self, bus = None, path = None):
- super(Config, self).__init__()
- conn = bus.get_dbusconn() if bus != None else None
- self.__proxy = ConfigProxy(self, conn, path)
+ def __init__ (self, bus):
+ super(Config, self).__init__(bus)
self.__client = gconf.Client()
self.__handler_id = self.__client.connect("value-changed", self.__value_changed_cb)
self.__client.add_dir(GCONF_IBUS_PATH, gconf.CLIENT_PRELOAD_NONE)
@@ -63,12 +60,10 @@ class Config(ibus.Object):
self.__client.set(key, value)
def do_destroy(self):
- if self.__proxy:
- self.__proxy.Destriy()
- self.__proxy = None
if self.__client:
self.__client.disconnect(self.__handler_id)
self.__client = None
+ super(Config, self).do_destroy()
def __to_py_value(self, value):
if value.type == gconf.VALUE_STRING:
@@ -139,28 +134,8 @@ class Config(ibus.Object):
section_name = key.replace(GCONF_IBUS_PATH + "/", "")
section_name = section_name.rsplit("/", 1)
if len(section_name) == 1:
- self.emit("value-changed", "", section_name[0], value)
+ self.value_changed("", section_name[0], value)
elif len(section_name) == 2:
- self.emit("value-changed", section_name[0], section_name[1], value)
+ self.value_changed(section_name[0], section_name[1], value)
else:
print "Can not process %s" % key
-
-gobject.type_register(Config)
-
-class ConfigProxy(interface.IConfig):
- def __init__ (self, config, conn, object_path):
- super(ConfigProxy, self).__init__(conn, object_path)
- self.__config = config
- self.__config.connect("value-changed", lambda c, s, n, v: self.ValueChanged(s, n, v))
-
- def GetValue(self, section, name):
- return self.__config.get_value(section, name)
-
- def SetValue(self, section, name, value):
- self.__config.set_value(section, name, value)
-
- def Destroy(self):
- self.remove_from_connection()
- if self.__config:
- self.__config.destroy()
- self.__config = None
diff --git a/gconf/main.py b/gconf/main.py
index 3b915df..5410872 100644
--- a/gconf/main.py
+++ b/gconf/main.py
@@ -34,10 +34,9 @@ class GconfApplication:
self.__bus = ibus.Bus()
self.__bus.connect("destroy", self.__bus_destroy_cb)
- self.__config = config.Config(self.__bus, CONFIG_PATH)
+ self.__config = config.Config(self.__bus)
self.__config.connect("destroy", self.__config_destroy_cb)
-
- self.__bus.register_config(CONFIG_PATH, True)
+ self.__bus.request_name(ibus.IBUS_CONFIG_NAME, 0)
def run(self):
self.__mainloop.run()