def __init__(self): self._bus = IBus.Bus() self._dbusconn = dbus.connection.Connection(IBus.get_address()) # XXX: the new IBus bindings do not export create_input_context for # introspection. This is troublesome - so, to workaround this problem # we're directly fetching a new input context manually ibus_obj = self._dbusconn.get_object(IBus.SERVICE_IBUS, IBus.PATH_IBUS) self._test = dbus.Interface(ibus_obj, dbus_interface="org.freedesktop.IBus") path = self._test.CreateInputContext("IBusQuery") self._context = IBus.InputContext.new(path, self._bus.get_connection(), None) self._glibloop = GLib.MainLoop() self._context.connect("commit-text", self.__commit_text_cb) self._context.connect("update-preedit-text", self.__update_preedit_cb) self._context.connect("disabled", self.__disabled_cb) self._context.set_capabilities (9)
def __init__(self): self._bus = IBus.Bus() self._dbusconn = dbus.connection.Connection(IBus.get_address()) # XXX: the new IBus bindings do not export create_input_context for # introspection. This is troublesome - so, to workaround this problem # we're directly fetching a new input context manually ibus_obj = self._dbusconn.get_object(IBus.SERVICE_IBUS, IBus.PATH_IBUS) self._test = dbus.Interface(ibus_obj, dbus_interface="org.freedesktop.IBus") path = self._test.CreateInputContext("IBusQuery") self._context = IBus.InputContext.new(path, self._bus.get_connection(), None) self._glibloop = GLib.MainLoop() self._context.connect("commit-text", self.__commit_text_cb) self._context.connect("update-preedit-text", self.__update_preedit_cb) self._context.connect("disabled", self.__disabled_cb) self._context.set_capabilities(9)
os.path.expanduser('~/.local/share/ibus-typing-booster'), os.F_OK)): os.system('mkdir -p ~/.local/share/ibus-typing-booster') LOGFILE = os.path.expanduser( '~/.local/share/ibus-typing-booster/setup-debug.log') sys.stdout = open(LOGFILE, mode='a', buffering=1) sys.stderr = open(LOGFILE, mode='a', buffering=1) print('--- %s ---' %strftime('%Y-%m-%d: %H:%M:%S')) # Workaround for # https://bugzilla.gnome.org/show_bug.cgi?id=622084 # Bug 622084 - Ctrl+C does not exit gtk app signal.signal(signal.SIGINT, signal.SIG_DFL) try: locale.setlocale(locale.LC_ALL, '') except locale.Error: sys.stderr.write("IBUS-WARNING **: Using the fallback 'C' locale") locale.setlocale(locale.LC_ALL, 'C') i18n_init() if IBus.get_address() is None: DIALOG = Gtk.MessageDialog( flags=Gtk.DialogFlags.MODAL, message_type=Gtk.MessageType.ERROR, buttons=Gtk.ButtonsType.OK, message_format=_('ibus is not running.')) DIALOG.run() DIALOG.destroy() sys.exit(1) SETUP_UI = SetupUI(IBus.Bus()) Gtk.main()
if (not os.access( os.path.expanduser('~/.local/share/ibus-typing-booster'), os.F_OK)): os.system('mkdir -p ~/.local/share/ibus-typing-booster') logfile = os.path.expanduser( '~/.local/share/ibus-typing-booster/setup-debug.log') sys.stdout = open(logfile, mode='a', buffering=1) sys.stderr = open(logfile, mode='a', buffering=1) print('--- %s ---' % strftime('%Y-%m-%d: %H:%M:%S')) # Workaround for # https://bugzilla.gnome.org/show_bug.cgi?id=622084 # Bug 622084 - Ctrl+C does not exit gtk app signal.signal(signal.SIGINT, signal.SIG_DFL) try: locale.setlocale(locale.LC_ALL, '') except locale.Error: sys.stderr.write("IBUS-WARNING **: Using the fallback 'C' locale") locale.setlocale(locale.LC_ALL, 'C') i18n_init() if IBus.get_address() == None: dlg = Gtk.MessageDialog(flags=Gtk.DialogFlags.MODAL, message_type=Gtk.MessageType.ERROR, buttons=Gtk.ButtonsType.OK, message_format=_('ibus is not running.')) dlg.run() dlg.destroy() sys.exit(1) SetupUi = SetupUI(IBus.Bus()) Gtk.main()