summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuang Peng <shawn.p.huang@gmail.com>2008-10-03 23:50:55 +0800
committerHuang Peng <shawn.p.huang@gmail.com>2008-10-03 23:50:55 +0800
commit0d2c788dfdd7a00f1ca2310a846357f485aa2432 (patch)
treec5d496825e8bd99c69fa9ec5cb6bed0cec43e76c
parent6515cb122eea13c16d5f936a346acbc1369b2d64 (diff)
downloadibus-0d2c788dfdd7a00f1ca2310a846357f485aa2432.tar.gz
ibus-0d2c788dfdd7a00f1ca2310a846357f485aa2432.tar.xz
ibus-0d2c788dfdd7a00f1ca2310a846357f485aa2432.zip
WIP.
-rw-r--r--ibus/bus.py21
-rw-r--r--ibus/common.py10
-rw-r--r--launcher/ibus.in29
3 files changed, 51 insertions, 9 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)
diff --git a/launcher/ibus.in b/launcher/ibus.in
index 0f7cb21..f4ac580 100644
--- a/launcher/ibus.in
+++ b/launcher/ibus.in
@@ -39,6 +39,7 @@ class Launcher(object):
super(Launcher, self).__init__()
self.__daemon_pid = 0
self.__panel_pid = 0
+ self.__conf_pid = 0
self.__x11_pid = 0
self.__bus = None
@@ -66,6 +67,8 @@ class Launcher(object):
self.__x11_pid = 0
elif pid == self.__panel_pid:
self.__panel_pid = 0
+ elif pid == self.__conf_pid:
+ self.__conf_pid = 0
elif sig == signal.SIGTERM or sig == signal.SIGINT:
sys.exit(1)
@@ -113,10 +116,32 @@ class Launcher(object):
self.__bus.connect("destroy", self.__bus_destroy_cb)
- self.__x11_pid = self.__start_process(x11, [x11, "--kill-daemon"], "ibus-x11")
+ self.__conf_pid = self.__start_process(conf, [conf], "ibus-conf")
self.__panel_pid = self.__start_process(panel, [panel], "ibus-panel")
-
+ self.__x11_pid = self.__start_process(x11, [x11, "--kill-daemon"], "ibus-x11")
+ time.sleep(1)
+ while ibus.main_iteration(False):
+ pass
+ self.__launch_auto_load_engines()
ibus.main()
+ def __launch_auto_load_engines(self):
+ engines = []
+ try:
+ engines = self.__bus.config_get_value("general", "preload_engines", None)
+ if not engines:
+ engines = []
+ except:
+ pass
+ for e in engines:
+ try:
+ lang, name = e.split(":")
+ self.__bus.register_start_engine(lang, name)
+ except:
+ import traceback
+ traceback.print_exc()
+
+
+
if __name__ == "__main__":
Launcher().run()