def __init__(self, exec_by_ibus): self.__component = ibus.Component(BUS_NAME, BUS_DESCRIPTION, VERSION, LICENSE, AUTHOR, HOMEPAGE) self.__component.add_engine(ENGINE_NAME, ENGINE_LONG_NAME, ENGINE_DESCRIPTION, LANGUAGE, LICENSE, AUTHOR, ICON, LAYOUT) self.__mainloop = gobject.MainLoop() self.__bus = ibus.Bus() self.__bus.connect("disconnected", self.__bus_disconnected_cb) self.__factory = factory.EngineFactory(self.__bus) if exec_by_ibus: self.__bus.request_name(BUS_NAME, 0) else: self.__bus.register_component(self.__component)
def __init__(self,engine): locale.setlocale(locale.LC_ALL, "") localedir = os.getenv("IBUS_LOCALEDIR") gettext.bindtextdomain("ibus-pinyin", localedir) gettext.bind_textdomain_codeset("ibus-pinyin", "UTF-8") self.__bus = ibus.Bus() self.__config = self.__bus.get_config() self.__builder = gtk.Builder() self.__builder.set_translation_domain("ibus-pinyin") self.__builder.add_from_file("ibus-pinyin-preferences.ui") self.__dialog = self.__builder.get_object("dialog") self.__init_pages() if engine == "pinyin": self.__config_namespace = "engine/Pinyin" self.__init_general() self.__init_pinyin() self.__init_fuzzy() self.__init_dictionary() self.__init_about() elif engine == "bopomofo": self.__config_namespace = "engine/Bopomofo" self.__init_general() self.__init_bopomofo() self.__init_fuzzy() self.__init_dictionary() self.__init_about() self.__convert_fuzzy_pinyin_to_bopomofo() else: print("Error: Unknown Engine") exit() self.__pages.set_current_page(0)
class Option(object): """Option serves as an interface of ibus.config it is used to synchronize the configuration with setting on user interface """ config = ibus.Bus().get_config() def __init__(self, name, default): self.name = name self.default = default def read(self): section, key = self.__get_config_name() return self.config.get_value(section, key, self.default) def write(self, v): section, key = self.__get_config_name() return self.config.set_value(section, key, type(self.default)(v)) def __get_config_name(self): keys = self.name.rsplit(SEPARATOR ,1) if len(keys) == 2: return SEPARATOR.join(("engine/SunPinyin", keys[0])), keys[1] else: assert len(keys) == 1 return "engine/SunPinyin", keys[0]
def __init__(self, replace): pynotify.init("ibus") self.__bus = ibus.Bus() self.__bus.connect("disconnected", gtk.main_quit) self.__bus.connect("registry-changed", self.__registry_changed_cb) match_rule = "type='signal',\ sender='org.freedesktop.IBus',\ path='/org/freedesktop/IBus'" self.__bus.add_match(match_rule) self.__panel = panel.Panel(self.__bus) flag = ibus.BUS_NAME_FLAG_ALLOW_REPLACEMENT if replace: flag = flag | ibus.BUS_NAME_FLAG_REPLACE_EXISTING self.__bus.request_name(ibus.IBUS_SERVICE_PANEL, flag) self.__bus.get_dbusconn().add_signal_receiver( self.__name_acquired_cb, signal_name="NameAcquired") self.__bus.get_dbusconn().add_signal_receiver(self.__name_lost_cb, signal_name="NameLost") self.__notify = pynotify.Notification("IBus", \ _("Some input methods have been installed, removed or updated. " \ "Please restart ibus input platform."), \ "ibus") self.__notify.set_timeout(10 * 1000) self.__notify.add_action("restart", _("Restart Now"), self.__restart_cb, None) self.__notify.add_action("ignore", _("Later"), lambda *args: None, None)
def __init__(self, dbfile, exec_by_ibus): self.__mainloop = gobject.MainLoop() self.__bus = ibus.Bus() self.__bus.connect("disconnected", self.__bus_destroy_cb) self.__factory = factory.EngineFactory(self.__bus, dbfile) self.destroied = False if exec_by_ibus: self.__bus.request_name("org.freedesktop.IBus.Table", 0) else: self.__component = ibus.Component("org.freedesktop.IBus.Table", "Table Component", "0.1.0", "GPL", "Yuwei Yu <*****@*****.**>") # now we get IME info from self.__factory.db name = self.__factory.db.get_ime_property("name") longname = name description = self.__factory.db.get_ime_property("description") language = self.__factory.db.get_ime_property("languages") license = self.__factory.db.get_ime_property("credit") author = self.__factory.db.get_ime_property("author") icon = self.__factory.db.get_ime_property("icon") if icon: icon = os.path.join(icon_dir, icon) if not os.access(icon, os.F_OK): icon = '' layout = self.__factory.db.get_ime_property("layout") self.__component.add_engine(name, longname, description, language, license, author, icon, layout) self.__bus.register_component(self.__component)
def __init__(self): self.connected = False try: self.vkb = VKBProxy(ibus.Bus().get_dbusconn()) self.connected = True except: print "Warning: can not connect to ibus daemon. Virtual keyboard runs just in demo mode."
def __init__(self): self.__init_curses() self.__bus = ibus.Bus() self.__ic_path = self.__bus.create_input_context("DemoTerm") self.__ic = ibus.InputContext(self.__bus, self.__ic_path, True) self.__ic.set_capabilities(7) self.__ic.connect("commit-text", self.__commit_text_cb) self.__ic.connect("update-preedit-text", self.__update_preedit_text_cb) self.__ic.connect("show-preedit-text", self.__show_preedit_text_cb) self.__ic.connect("hide-preedit-text", self.__hide_preedit_text_cb) self.__ic.connect("update-auxiliary-text", self.__update_aux_text_cb) self.__ic.connect("show-auxiliary-text", self.__show_aux_text_cb) self.__ic.connect("hide-auxiliary-text", self.__hide_aux_text_cb) self.__ic.connect("update-lookup-table", self.__update_lookup_table_cb) self.__ic.connect("show-lookup-table", self.__show_lookup_table_cb) self.__ic.connect("hide-lookup-table", self.__hide_lookup_table_cb) glib.io_add_watch(0, glib.IO_IN, self.__stdin_cb) # glib.timeout_add(500, self.__timeout_cb) # self.__master_fd, self.__slave_fd = os.openpty() # self.__run_shell() self.__is_invalidate = False self.__preedit = None self.__preedit_visible = False self.__aux_string = None self.__aux_string_visible = False self.__lookup_table = None self.__lookup_table_visible = False
class Option(object): """Option serves as an interface of ibus.config it is used to synchronize the configuration with setting on user interface """ config = ibus.Bus().get_config() __wrappers = { type(True): glib.Variant.new_boolean, type(1): glib.Variant.new_int32, type('str'): glib.Variant.new_string, type([]): glib.Variant.new_strv, } def __init__(self, name, default): self.name = name self.default = default self.__wrap = self.__wrappers[type(self.default)] def read(self): section, key = self.__get_config_name() wrapped = self.config.get_value(section, key) return self.default if wrapped is None else wrapped.unpack() def write(self, v): section, key = self.__get_config_name() return self.config.set_value(section, key, self.__wrap(v)) def __get_config_name(self): keys = self.name.rsplit(SEPARATOR, 1) if len(keys) == 2: return SEPARATOR.join(("engine/SunPinyin", keys[0])), keys[1] else: assert len(keys) == 1 return "engine/SunPinyin", keys[0]
def __init__(self, bus=ibus.Bus()): self.__bus = bus self.__config = self.__bus.get_config() config_path = os.path.expanduser(self.__config_path_unexpanded) try: with open(config_path, 'r') as f: self.__config_from_file = json.load(f) except: print "Can't read config file:", self.__config_path_unexpanded, sys.exc_info()[:1] self.__config_from_file = dict() self.fetch_all()
def test(): vkb = VKBProxy(ibus.Bus().get_dbusconn()) print "Send VKB String" vkb.SendText(serializable.serialize_object(ibus.Text("TEST VKB STRING"))) print "Send Retrun Key" vkb.SendKey(keysyms.Return, 0) import gobject loop = gobject.MainLoop() loop.run()
def __init_bus(self): try: self.__bus = ibus.Bus() # self.__bus.connect("config-value-changed", self.__config_value_changed_cb) # self.__bus.connect("config-reloaded", self.__config_reloaded_cb) # self.__bus.config_add_watch("/general") # self.__bus.config_add_watch("/general/hotkey") # self.__bus.config_add_watch("/panel") except: while self.__bus == None: message = _( "IBus daemon is not started. Do you want to start it now?") dlg = gtk.MessageDialog(type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_YES_NO, message_format=message) id = dlg.run() dlg.destroy() self.__flush_gtk_events() if id != gtk.RESPONSE_YES: sys.exit(0) pid = os.spawnlp(os.P_NOWAIT, "ibus-daemon", "ibus-daemon", "--xim") time.sleep(1) try: self.__bus = ibus.Bus() except: continue message = _( "IBus has been started! " "If you can not use IBus, please add below lines in $HOME/.bashrc, and relogin your desktop.\n" " export GTK_IM_MODULE=ibus\n" " export XMODIFIERS=@im=ibus\n" " export QT_IM_MODULE=ibus") dlg = gtk.MessageDialog(type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_OK, message_format=message) id = dlg.run() dlg.destroy() self.__flush_gtk_events()
def __init__(self, exec_by_ibus): self.__component = ibus.Component( "org.freedesktop.IBus.GooglePinyin", "GooglePinyin Component", "0.1.1", "GPL", "Jiahua Huang <*****@*****.**>") self.__component.add_engine("googlepinyin", "googlepinyin", "GooglePinyin", "zh_CN", "GPL", "Jiahu Huang <*****@*****.**>", "", "en") self.__mainloop = gobject.MainLoop() self.__bus = ibus.Bus() self.__bus.connect("destroy", self.__bus_destroy_cb) self.__factory = factory.EngineFactory(self.__bus) if exec_by_ibus: self.__bus.request_name("org.freedesktop.IBus.GooglePinyin", 0) else: self.__bus.register_component(self.__component)
def __init__(self): self.default = {} self.modified = {} self.new = {} self.__physical_layout = None self.__cycle_hotkeys = None self.__rcycle_hotkeys = None self.__all_layout = None try: self.__config = ibus.Bus().get_config() except: # for standalone debug self.__config = _ConfigDummy() self.__user_layout = self.get_user_layouts_from_config()
def __init__(self, exec_by_ibus): self.__component = ibus.Component( "org.freedesktop.IBus.Sulekha", "Sulekha Component", "0.1.0", "GPL", "Peng Huang <*****@*****.**>") self.__component.add_engine("sulekha", "Sulekha", "Sulekha Input method", "ml_IN", "GPL", "Peng Huang <*****@*****.**>", "", "en") self.__mainloop = gobject.MainLoop() self.__bus = ibus.Bus() self.__bus.connect("destroy", self.__bus_destroy_cb) self.__factory = factory.EngineFactory(self.__bus) if exec_by_ibus: self.__bus.request_name("org.freedesktop.IBus.Sulekha", 0) else: self.__bus.register_component(self.__component)
def __init__(self, exec_by_ibus): self.__component = ibus.Component( "org.freedesktop.IBus.EnchantPython", "Enchant Python Component", "0.1.0", "GPL", "Peng Huang <*****@*****.**>") self.__component.add_engine("enchant-python", "enchant python", "English Enchant", "en", "GPL", "Peng Huang <*****@*****.**>", "", "en") self.__mainloop = gobject.MainLoop() self.__bus = ibus.Bus() self.__bus.connect("disconnected", self.__bus_disconnected_cb) self.__factory = factory.EngineFactory(self.__bus) if exec_by_ibus: self.__bus.request_name("org.freedesktop.IBus.EnchantPython", 0) else: self.__bus.register_component(self.__component)
def __init__(self): locale.setlocale(locale.LC_ALL, "") localedir = os.getenv("IBUS_LOCALEDIR") gettext.bindtextdomain("ibus-pinyin", localedir) gettext.bind_textdomain_codeset("ibus-pinyin", "UTF-8") self.__bus = ibus.Bus() self.__config = self.__bus.get_config() self.__builder = gtk.Builder() self.__builder.set_translation_domain("ibus-pinyin") self.__builder.add_from_file("ibus-pinyin-preferences.ui") self.__dialog = self.__builder.get_object("dialog") self.__init_pinyin() self.__init_init_state() self.__init_others() self.__init_correct_pinyin() self.__init_fuzzy_pinyin()
def __init__(self, exec_by_ibus): print("IM App initialzation begin") self.__component = ibus.Component( "org.freedesktop.IBus.WaitZar", "WaitZar Component", "1.0.0", "GPLv3", "Seth N. Hetu <*****@*****.**>") self.__component.add_engine("waitzar", "waitzar", "Myanmar WaitZar", "my", "GPLv3", "Seth N. Hetu <*****@*****.**>", "", "en") self.__mainloop = gobject.MainLoop() self.__bus = ibus.Bus() self.__factory = factory.EngineFactory(self.__bus) if exec_by_ibus: self.__bus.request_name("org.freedesktop.IBus.WaitZar", 0) else: self.__bus.register_component(self.__component) print("IM App initialzation end")
def __init__(self, exec_by_ibus): self.__component = ibus.Component("cn.zzsst.Rime", "Rime Component", "0.1.0", "GPL", "GONG Chen <*****@*****.**>") self.__component.add_engine("rime", "Rime", "ibus-rime, powered by Rime Input Method Engine", "zh_CN", "GPL", "GONG Chen <*****@*****.**>", "", "en") self.__mainloop = gobject.MainLoop() self.__bus = ibus.Bus() self.__bus.connect("destroy", self.__bus_destroy_cb) self.__factory = factory.EngineFactory(self.__bus) if exec_by_ibus: self.__bus.request_name("cn.zzsst.Rime", 0) else: self.__bus.register_component(self.__component)
def __init__(self, exec_by_ibus): self.__component = ibus.Component("org.freedesktop.IBus.Plover", "Plover IBus", "0.1.0", "GPL", "Rick Lupton") self.__component.add_engine("plover", "plover", "Plover", "en", "GPL", "Rick Lupton", "", "en") self.__mainloop = gobject.MainLoop() self.__bus = ibus.Bus() self.__bus.connect("disconnected", self.__bus_disconnected_cb) self.__factory = factory.EngineFactory(self.__bus) if exec_by_ibus: self.__bus.request_name("org.freedesktop.IBus.Plover", 0) else: self.__bus.register_component(self.__component)
def __init__(self): pynotify.init("ibus") self.__bus = ibus.Bus() self.__bus.connect("disconnected", gtk.main_quit) self.__bus.connect("registry-changed", self.__registry_changed_cb) match_rule = "type='signal',\ sender='org.freedesktop.IBus',\ path='/org/freedesktop/IBus'" self.__bus.add_match(match_rule) self.__panel = panel.Panel(self.__bus) self.__bus.request_name(ibus.IBUS_SERVICE_PANEL, 0) self.__notify = pynotify.Notification("IBus", \ _("Some input methods have been installed, removed or updated. " \ "Please restart ibus input platform."), \ "ibus") self.__notify.set_timeout(10 * 1000) self.__notify.add_action("restart", _("Restart Now"), self.__restart_cb, None) self.__notify.add_action("ignore", _("Later"), lambda *args: None, None)
def __init__(self, exec_by_ibus): self.__mainloop = gobject.MainLoop() self.__bus = ibus.Bus() self.__bus.connect("disconnected", self.__bus_destroy_cb) self.__factory = factory.EngineFactory(self.__bus) self.destroied = False if exec_by_ibus: self.__bus.request_name("org.freedesktop.IBus.Sdim", 0) else: self.__component = ibus.Component("org.freedesktop.IBus.Sdim", "Sdim Component", "0.1.0", "GPL", "Yuwei Yu <*****@*****.**>") name = 'SDIM' longname = name description = 'Shadow Dance Input Method' language = 'zh' license = 'LGPL' author = 'Bao Haojun <*****@*****.**>' icon = icon_dir + "/sdim.png" if icon: icon = os.path.join (icon_dir, icon) if not os.access( icon, os.F_OK): icon = '' layout = 'us' self.__component.add_engine(name, longname, description, language, license, author, icon, layout) self.__bus.register_component(self.__component)
def __init__(self, bus): self.conf = bus.get_config() if bus else ibus.Bus().get_config()
def close_notification(self, id): if self.__notifications == None: return return self.__notifications.CloseNotifications(id) def __notification_closed_cb(self, id, reason): if self.__notifications == None: return if id in self.__ids: self.notification_closed(id, reason) def __action_invoked_cb(self, id, action_key): if self.__notifications == None: return if id in self.__ids: self.action_invoked(id, action_key) if __name__ == "__main__": import gtk icon = gtk.StatusIcon() icon.set_visible(True) notify = Notifications(ibus.Bus()) notify.set_status_icon(icon) while ibus.main_iteration(): pass notify.notify(0, "", "Hello Summary", "Hello Body", ["NoAgain", "Do not show me again"], 5000) ibus.main()
def __init__(self): try: self._config = ibus.Bus().get_config() except: self._config = _ConfigDummy()
#!/usr/bin/env python import ibus bus = ibus.Bus() print bus.introspect_dbus()
def __init__(self): self.__bus = ibus.Bus() self.__config = self.__bus.get_config()