diff options
author | Huang Peng <shawn.p.huang@gmail.com> | 2008-10-03 23:50:55 +0800 |
---|---|---|
committer | Huang Peng <shawn.p.huang@gmail.com> | 2008-10-03 23:50:55 +0800 |
commit | 0d2c788dfdd7a00f1ca2310a846357f485aa2432 (patch) | |
tree | c5d496825e8bd99c69fa9ec5cb6bed0cec43e76c /ibus | |
parent | 6515cb122eea13c16d5f936a346acbc1369b2d64 (diff) | |
download | ibus-0d2c788dfdd7a00f1ca2310a846357f485aa2432.tar.gz ibus-0d2c788dfdd7a00f1ca2310a846357f485aa2432.tar.xz ibus-0d2c788dfdd7a00f1ca2310a846357f485aa2432.zip |
WIP.
Diffstat (limited to 'ibus')
-rw-r--r-- | ibus/bus.py | 21 | ||||
-rw-r--r-- | ibus/common.py | 10 |
2 files changed, 24 insertions, 7 deletions
diff --git a/ibus/bus.py b/ibus/bus.py index 4eb7b36..9ac7b20 100644 --- a/ibus/bus.py +++ b/ibus/bus.py @@ -123,11 +123,16 @@ class Bus(ibus.Object): self.__ibus = self.__dbusconn.get_object(ibus.IBUS_NAME, ibus.IBUS_PATH) self.__dbus = self.__dbusconn.get_object(dbus.BUS_DAEMON_NAME, dbus.BUS_DAEMON_PATH) try: - unique_name = self.__dbus.get_name_owner(ibus.IBUS_CONFIG_NAME) + unique_name = self.get_name_owner(ibus.IBUS_CONFIG_NAME) self.__config = self.__dbusconn.get_object(unique_name, ibus.IBUS_CONFIG_PATH) except: self.__config = None self.__dbusconn.add_message_filter(self.__dbus_message_cb) + self.add_match( + "type='signal'," + "interface='" + dbus.BUS_DAEMON_IFACE + "'," + "member='NameOwnerChanged'," + "arg0='" + ibus.IBUS_CONFIG_NAME + "'") # define dbus methods def get_dbus(self): @@ -145,6 +150,12 @@ class Bus(ibus.Object): def get_name_owner(self, name): return self.__dbus.GetNameOwner(name) + def add_match(self, rule): + return self.__dbus.AddMatch(rule) + + def remove_match(self, rule): + return self.__dbus.RemoveMatch(rule) + def get_dbusconn(self): return self.__dbusconn @@ -200,7 +211,7 @@ class Bus(ibus.Object): return self.__ibus.GetInputContextStates(ic) def config_add_watch(self, section): - return self.__dbus.AddMatch( + return self.add_match( "type='signal'," "interface='" + ibus.IBUS_CONFIG_NAME + "'," "member='ValueChanged'," @@ -208,7 +219,7 @@ class Bus(ibus.Object): ) def config_remove_watch(self, section): - return self.__dbus.RemoveMatch( + return self.remove_match( "type='signal'," "interface='" + ibus.IBUS_CONFIG_NAME + "'," "member='ValueChanged'," @@ -252,10 +263,10 @@ class Bus(ibus.Object): args = message.get_args_list() if args[0] == ibus.IBUS_CONFIG_NAME: if args[2] != "": - self.__config = self.__dbusconn.get_object(ibus.IBUS_CONFIG_NAME, ibus.IBUS_CONFIG_PATH) + self.__config = self.__dbusconn.get_object(args[2], ibus.IBUS_CONFIG_PATH) else: self.__config = None - + retval = dbus.lowlevel.HANDLER_RESULT_HANDLED # commit string signal elif message.is_signal(ibus.IBUS_IFACE, "CommitString"): args = message.get_args_list() diff --git a/ibus/common.py b/ibus/common.py index 11e8185..7180acb 100644 --- a/ibus/common.py +++ b/ibus/common.py @@ -38,7 +38,8 @@ __all__ = ( "CONFIG_GENERAL_SHORTCUT_NEXT_ENGINE_DEFAULT", "CONFIG_GENERAL_SHORTCUT_PREV_ENGINE_DEFAULT", "main", - "main_quit" + "main_quit", + "main_iteration" ) import os @@ -100,12 +101,14 @@ CONFIG_GENERAL_SHORTCUT_PREV_ENGINE_DEFAULT = [] __mainloop = None -def main(): +def __init_main_loop(): global __mainloop if __mainloop == None: import gobject __mainloop = gobject.MainLoop() +def main(): + __init_main_loop() __mainloop.run() def main_quit(): @@ -113,3 +116,6 @@ def main_quit(): if __mainloop: __mainloop.quit() +def main_iteration(may_block=False): + __init_main_loop() + return __mainloop.get_context().iteration(may_block) |