5 # Copyright (c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2 of the License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this program; if not, write to the
19 # Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20 # Boston, MA 02111-1307 USA
26 import dbus.connection
27 import dbus.mainloop.glib
34 self._dbusconn = dbus.connection.Connection (ibus.IBUS_ADDR)
35 self._dbusconn.add_signal_receiver (self._disconnected_cb,
37 dbus_interface = dbus.LOCAL_IFACE)
38 self._engine = factory.DemoEngineFactory (self._dbusconn)
39 self._ibus = self._dbusconn.get_object (ibus.IBUS_NAME, ibus.IBUS_PATH)
40 self._ibus.RegisterFactories ([factory.FACTORY_PATH], **ibus.DEFAULT_ASYNC_HANDLERS)
45 def _disconnected_cb (self):
51 dbus.mainloop.glib.DBusGMainLoop (set_as_default=True)
54 def print_help (out, v = 0):
55 print >> out, "-h, --help show this message."
56 print >> out, "-d, --daemonize daemonize ibus"
62 longopt = ["help", "daemonize"]
64 opts, args = getopt.getopt (sys.argv[1:], shortopt, longopt)
65 except getopt.GetoptError, err:
66 print_help (sys.stderr, 1)
69 if o in ("-h", "--help"):
70 print_help (sys.stdout)
71 elif o in ("-d", "--daemonize"):
74 print >> sys.stderr, "Unknown argument: %s" % o
75 print_help (sys.stderr, 1)
83 if __name__ == "__main__":