# vim:set et sts=4 sw=4: # # ibus - The Input Bus # # Copyright (c) 2007-2008 Huang Peng # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this program; if not, write to the # Free Software Foundation, Inc., 59 Temple Place, Suite 330, # Boston, MA 02111-1307 USA __all__ = ( "IBUS_ADDR", "IBUS_IFACE_IBUS", "IBUS_SERVICE_IBUS", "IBUS_PATH_IBUS", "IBUS_IFACE_CONFIG", "IBUS_IFACE_PANEL", "IBUS_IFACE_ENGINE", "IBUS_IFACE_ENGINE_FACTORY", "IBUS_IFACE_INPUT_CONTEXT", "IBUS_IFACE_NOTIFICATIONS", "default_reply_handler", "default_error_handler", "DEFAULT_ASYNC_HANDLERS", "CONFIG_GENERAL_SHORTCUT_TRIGGER", "CONFIG_GENERAL_SHORTCUT_NEXT_ENGINE", "CONFIG_GENERAL_SHORTCUT_PREV_ENGINE", "CONFIG_GENERAL_SHORTCUT_TRIGGER_DEFAULT", "CONFIG_GENERAL_SHORTCUT_NEXT_ENGINE_DEFAULT", "CONFIG_GENERAL_SHORTCUT_PREV_ENGINE_DEFAULT", "main", "main_quit", "main_iteration" ) import os import sys __display = os.environ["DISPLAY"] __hostname, __display_screen = __display.split(":", 1) if not __hostname.strip(): __hostname = "unix" __display_number = __display_screen.split(".")[0] __username = None try: __username = os.getlogin() except: pass if not __username: __username = os.getenv ("LOGNAME") if not __username: __username = os.getenv ("USER") if not __username: __username = os.getenv ("LNAME") if not __username: __username = os.getenv ("USERNAME") IBUS_ADDR = "unix:path=/tmp/ibus-%s/ibus-%s-%s" % (__username, __hostname, __display_number) # IBUS_ADDR = "tcp:host=localhost,port=7799" IBUS_IFACE_IBUS = "org.freedesktop.IBus" IBUS_PATH_IBUS = "/org/freedesktop/IBus" IBUS_SERVICE_IBUS = "org.freedesktop.IBus" IBUS_IFACE_PANEL = "org.freedesktop.IBus.Panel" IBUS_IFACE_CONFIG = "org.freedesktop.IBus.Config" IBUS_IFACE_ENGINE = "org.freedesktop.IBus.Engine" IBUS_IFACE_ENGINE_FACTORY = "org.freedesktop.IBus.EngineFactory" IBUS_IFACE_INPUT_CONTEXT = "org.freedesktop.IBus.InputContext" IBUS_IFACE_NOTIFICATIONS = "org.freedesktop.IBus.Notifications" def default_reply_handler( *args): pass def default_error_handler(e): print >> sys.stderr, e DEFAULT_ASYNC_HANDLERS = { "reply_handler" : default_reply_handler, "error_handler" : default_error_handler } CONFIG_GENERAL_SHORTCUT_TRIGGER = "/general/keyboard_shortcut_trigger" CONFIG_GENERAL_SHORTCUT_TRIGGER_DEFAULT = [ "Ctrl+space", "Zenkaku_Hankaku", "Hangul"] CONFIG_GENERAL_SHORTCUT_NEXT_ENGINE = "/general/keyboard_shortcut_next_engine" CONFIG_GENERAL_SHORTCUT_NEXT_ENGINE_DEFAULT = [] CONFIG_GENERAL_SHORTCUT_PREV_ENGINE = "/general/keyboard_shortcut_prev_engine" CONFIG_GENERAL_SHORTCUT_PREV_ENGINE_DEFAULT = [] __mainloop = None def __init_main_loop(): global __mainloop if __mainloop == None: import gobject __mainloop = gobject.MainLoop() def main(): __init_main_loop() __mainloop.run() def main_quit(): global __mainloop if __mainloop: __mainloop.quit() def main_iteration(may_block=False): __init_main_loop() return __mainloop.get_context().iteration(may_block)