Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: ibus/bus.py

Issue 1735020: Support changing the global input method engine without focus. (Closed) Base URL: ssh://git@chromiumos-git/ibus.git
Patch Set: Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « bus/ibusimpl.c ('k') | ibus/interface/iibus.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # vim:set et sts=4 sw=4: 1 # vim:set et sts=4 sw=4:
2 # 2 #
3 # ibus - The Input Bus 3 # ibus - The Input Bus
4 # 4 #
5 # Copyright (c) 2007-2010 Peng Huang <shawn.p.huang@gmail.com> 5 # Copyright (c) 2007-2010 Peng Huang <shawn.p.huang@gmail.com>
6 # Copyright (c) 2007-2010 Red Hat, Inc. 6 # Copyright (c) 2007-2010 Red Hat, Inc.
7 # 7 #
8 # This library is free software; you can redistribute it and/or 8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public 9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either 10 # License as published by the Free Software Foundation; either
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 "config-reloaded" : ( 47 "config-reloaded" : (
48 gobject.SIGNAL_RUN_LAST, 48 gobject.SIGNAL_RUN_LAST,
49 gobject.TYPE_NONE, 49 gobject.TYPE_NONE,
50 () 50 ()
51 ), 51 ),
52 "registry-changed" : ( 52 "registry-changed" : (
53 gobject.SIGNAL_RUN_LAST, 53 gobject.SIGNAL_RUN_LAST,
54 gobject.TYPE_NONE, 54 gobject.TYPE_NONE,
55 () 55 ()
56 ), 56 ),
57 "global-engine-changed" : (
58 gobject.SIGNAL_RUN_LAST,
59 gobject.TYPE_NONE,
60 ()
61 ),
57 } 62 }
58 63
59 def __init__(self): 64 def __init__(self):
60 super(Bus, self).__init__() 65 super(Bus, self).__init__()
61 self.__dbusconn = dbus.connection.Connection(common.get_address()) 66 self.__dbusconn = dbus.connection.Connection(common.get_address())
62 self.__dbus = self.__dbusconn.get_object(dbus.BUS_DAEMON_NAME, 67 self.__dbus = self.__dbusconn.get_object(dbus.BUS_DAEMON_NAME,
63 dbus.BUS_DAEMON_PATH) 68 dbus.BUS_DAEMON_PATH)
64 self.__unique_name = self.hello() 69 self.__unique_name = self.hello()
65 self.__ibus = self.__dbusconn.get_object(common.IBUS_SERVICE_IBUS, 70 self.__ibus = self.__dbusconn.get_object(common.IBUS_SERVICE_IBUS,
66 common.IBUS_PATH_IBUS) 71 common.IBUS_PATH_IBUS)
67 self.__ibus.connect_to_signal("RegistryChanged", self.__registry_changed _cb) 72 self.__ibus.connect_to_signal("RegistryChanged", self.__registry_changed _cb)
73 self.__ibus.connect_to_signal("GlobalEngineChanged",
74 self.__global_engine_changed_cb)
68 75
69 self.__dbusconn.call_on_disconnection(self.__dbusconn_disconnected_cb) 76 self.__dbusconn.call_on_disconnection(self.__dbusconn_disconnected_cb)
70 # self.__dbusconn.add_message_filter(self.__filter_cb) 77 # self.__dbusconn.add_message_filter(self.__filter_cb)
71 78
72 def __filter_cb(self, conn, message): 79 def __filter_cb(self, conn, message):
73 if message.get_type() == 4: 80 if message.get_type() == 4:
74 print "Signal %s" % message.get_member() 81 print "Signal %s" % message.get_member()
75 print " sender = %s" % message.get_sender() 82 print " sender = %s" % message.get_sender()
76 print " path = %s" % message.get_path() 83 print " path = %s" % message.get_path()
77 return dbus.lowlevel.HANDLER_RESULT_NOT_YET_HANDLED 84 return dbus.lowlevel.HANDLER_RESULT_NOT_YET_HANDLED
78 85
79 def __dbusconn_disconnected_cb(self, dbusconn): 86 def __dbusconn_disconnected_cb(self, dbusconn):
80 assert self.__dbusconn == dbusconn 87 assert self.__dbusconn == dbusconn
81 self.__dbusconn = None 88 self.__dbusconn = None
82 self.emit("disconnected") 89 self.emit("disconnected")
83 90
84 def __registry_changed_cb(self): 91 def __registry_changed_cb(self):
85 self.emit("registry-changed") 92 self.emit("registry-changed")
86 93
94 def __global_engine_changed_cb(self):
95 self.emit("global-engine-changed")
96
87 def get_name(self): 97 def get_name(self):
88 return self.__unique_name 98 return self.__unique_name
89 99
90 def get_is_connected(self): 100 def get_is_connected(self):
91 if self.__dbusconn == None: 101 if self.__dbusconn == None:
92 return False 102 return False
93 return self.__dbusconn.get_is_connected() 103 return self.__dbusconn.get_is_connected()
94 104
95 # define dbus methods 105 # define dbus methods
96 def get_dbus(self): 106 def get_dbus(self):
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 def ping(self, data): 155 def ping(self, data):
146 flag = isinstance(data, serializable.Serializable) 156 flag = isinstance(data, serializable.Serializable)
147 if flag: 157 if flag:
148 data = serializable.serialize_object(data) 158 data = serializable.serialize_object(data)
149 data = self.__ibus.Ping(data, dbus_interface="org.freedesktop.IBus") 159 data = self.__ibus.Ping(data, dbus_interface="org.freedesktop.IBus")
150 if flag: 160 if flag:
151 data = serializable.deserialize_object(data) 161 data = serializable.deserialize_object(data)
152 return data 162 return data
153 163
154 def get_use_sys_layout(self): 164 def get_use_sys_layout(self):
155 return self.__ibus.GetUseSysLayout(); 165 return self.__ibus.GetUseSysLayout()
166
167 def get_use_global_engine(self):
168 return self.__ibus.GetUseGlobalEngine()
169
170 def get_global_engine(self):
171 try:
172 engine = self.__ibus.GetGlobalEngine()
173 engine = serializable.deserialize_object(engine)
174 return engine
175 except:
176 return None
177
178 def set_global_engine(self, engine):
179 return self.__ibus.SetGlobalEngine(engine.name)
180
181 def is_global_engine_enabled(self):
182 return self.__ibus.IsGlobalEngineEnabled()
156 183
157 def introspect_ibus(self): 184 def introspect_ibus(self):
158 return self.__ibus.Introspect() 185 return self.__ibus.Introspect()
159 186
160 def introspect_dbus(self): 187 def introspect_dbus(self):
161 return self.__dbus.Introspect() 188 return self.__dbus.Introspect()
162 189
163 def get_config(self): 190 def get_config(self):
164 try: 191 try:
165 return self.__config 192 return self.__config
(...skipping 19 matching lines...) Expand all
185 212
186 for i in b.list_factories(): 213 for i in b.list_factories():
187 print i.name 214 print i.name
188 215
189 mainloop.run() 216 mainloop.run()
190 print "Exit" 217 print "Exit"
191 218
192 219
193 if __name__ == "__main__": 220 if __name__ == "__main__":
194 test() 221 test()
OLDNEW
« no previous file with comments | « bus/ibusimpl.c ('k') | ibus/interface/iibus.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698