Пример #1
0
 def set_engines(self, engines):
     self.__model.clear()
     self.__engines = []
     for e in engines:
         if e in self.__engines:
             continue
         it = self.__model.append(None)
         i18n.init_textdomain(e.get_textdomain())
         self.__model.set(it, 0, e)
         self.__engines.append(e)
     self.__emit_changed()
Пример #2
0
 def set_engines(self, engines):
     self.__model.clear()
     self.__engines = []
     for e in engines:
         if e in self.__engines:
             continue
         it = self.__model.append(None)
         i18n.init_textdomain(e.get_textdomain())
         self.__model.set(it, 0, e)
         self.__engines.append(e)
     self.__emit_changed()
Пример #3
0
    def set_engines(self, engines):
        self.__engines_for_lang = {}
        self.__untrans_for_lang = {}
        for e in engines:
            l = IBus.get_language_name(e.get_language())
            if l == None:
                l = ''
            if l not in self.__engines_for_lang:
                self.__engines_for_lang[l] = []
            i18n.init_textdomain(e.get_textdomain())
            row = self.__engine_row_new(e)
            self.__engines_for_lang[l].append(row)

            # Retrieve Untranslated language names.
            untrans = IBus.get_untranslated_language_name(e.get_language())
            if untrans == None:
                untrans = ''
            self.__untrans_for_lang[l] = untrans

        keys = list(self.__engines_for_lang.keys())
        keys.sort(key=functools.cmp_to_key(locale.strcoll))
        loc = locale.getlocale()[0]
        # None on C locale
        if loc == None or loc == 'C':
            loc = 'en_US'
        current_lang = IBus.get_language_name(loc)
        # move current language to the first place
        if current_lang in keys:
            keys.remove(current_lang)
            keys.insert(0, current_lang)

        # move English to the second place
        en_lang = IBus.get_language_name('en_US')
        if en_lang != current_lang and en_lang in keys:
            keys.remove(en_lang)
            keys.insert(1, en_lang)

        #add 'Others' to the end of the combo box
        if IBus.get_language_name('Other') in keys:
            keys.remove(IBus.get_language_name('Other'))
            keys += [IBus.get_language_name('Other')]

        self.__langs = keys
        self.__show_lang_rows()
Пример #4
0
    def set_engines(self, engines):
        self.__engines_for_lang = {}
        self.__untrans_for_lang = {}
        for e in engines:
            l = IBus.get_language_name(e.get_language())
            if l == None:
                l = ''
            if l not in self.__engines_for_lang:
                self.__engines_for_lang[l] = []
            i18n.init_textdomain(e.get_textdomain())
            self.__engines_for_lang[l].append(e)

            # Retrieve Untranslated language names.
            untrans = IBus.get_untranslated_language_name(e.get_language())
            if untrans == None:
                untrans = ''
            self.__untrans_for_lang[l] = untrans

        keys = list(self.__engines_for_lang.keys())
        keys.sort(key=functools.cmp_to_key(locale.strcoll))
        loc = locale.getlocale()[0]
        # None on C locale
        if loc == None or loc == 'C':
            loc = 'en_US'
        current_lang = IBus.get_language_name(loc)
        # move current language to the first place
        if current_lang in keys:
            keys.remove(current_lang)
            keys.insert(0, current_lang)

        # move English to the second place
        en_lang = IBus.get_language_name('en_US')
        if en_lang != current_lang and en_lang in keys:
            keys.remove(en_lang)
            keys.insert(1, en_lang)

        #add 'Others' to the end of the combo box
        if IBus.get_language_name('Other') in keys:
            keys.remove(IBus.get_language_name('Other'))
            keys += [IBus.get_language_name('Other')]

        self.__langs = keys
        self.__show_lang_rows()
Пример #5
0
    replace = False
    shortopt = "hdr"
    longopt = ["help", "daemonize", "replace"]
    try:
        opts, args = getopt.getopt(sys.argv[1:], shortopt, longopt)
    except getopt.GetoptError, err:
        print_help(sys.stderr, 1)

    for o, a in opts:
        if o in ("-h", "--help"):
            print_help(sys.stdout)
        elif o in ("-d", "--daemonize"):
            daemonize = True
        elif o in ("-r", "--replace"):
            replace = True
        else:
            print >> sys.stderr, "Unknown argument: %s" % o
            print_help(sys.stderr, 1)

    if daemonize:
        if os.fork():
            sys.exit()

    launch_panel(replace)


if __name__ == "__main__":
    import i18n
    i18n.init_textdomain(DOMAINNAME)
    main()
Пример #6
0
        ibus_desktop = path.join(os.getenv("IBUS_PREFIX"),
                                 "share/applications/ibus.desktop")
        # unlink file
        try:
            os.unlink(link_file)
        except:
            pass
        if self.__checkbutton_auto_start.get_active():
            os.symlink(ibus_desktop, link_file)

    def __sigusr1_cb(self, *args):
        self.__window.present()

    def run(self):
        self.__window.show_all()
        signal.signal(signal.SIGUSR1, self.__sigusr1_cb)
        Gtk.main()


if __name__ == "__main__":
    try:
        locale.setlocale(locale.LC_ALL, '')
    except locale.Error:
        print("Using the fallback 'C' locale", file=sys.stderr)
        locale.setlocale(locale.LC_ALL, 'C')

    i18n.init_textdomain(DOMAINNAME)
    i18n.init_textdomain('xkeyboard-config')
    setup = Setup()
    setup.run()
Пример #7
0
                              "autostart/ibus.desktop")
        ibus_desktop = path.join(os.getenv("IBUS_PREFIX"),
                                 "share/applications/ibus.desktop")
        # unlink file
        try:
            os.unlink(link_file)
        except:
            pass
        if self.__checkbutton_auto_start.get_active():
            os.symlink(ibus_desktop, link_file)

    def __sigusr1_cb(self, *args):
        self.__window.present()

    def run(self):
        self.__window.show_all()
        signal.signal(signal.SIGUSR1, self.__sigusr1_cb)
        Gtk.main()

if __name__ == "__main__":
    try:
        locale.setlocale(locale.LC_ALL, '')
    except locale.Error:
        print("Using the fallback 'C' locale", file=sys.stderr)
        locale.setlocale(locale.LC_ALL, 'C')

    i18n.init_textdomain(DOMAINNAME)
    i18n.init_textdomain('xkeyboard-config')
    setup = Setup()
    setup.run()
Пример #8
0
    daemonize = False
    replace = False
    shortopt = "hdr"
    longopt = ["help", "daemonize", "replace"]
    try:
        opts, args = getopt.getopt(sys.argv[1:], shortopt, longopt)
    except getopt.GetoptError, err:
        print_help(sys.stderr, 1)

    for o, a in opts:
        if o in("-h", "--help"):
            print_help(sys.stdout)
        elif o in("-d", "--daemonize"):
            daemonize = True
        elif o in("-r", "--replace"):
            replace = True
        else:
            print >> sys.stderr, "Unknown argument: %s" % o
            print_help(sys.stderr, 1)

    if daemonize:
        if os.fork():
            sys.exit()

    launch_panel(replace)

if __name__ == "__main__":
    import i18n
    i18n.init_textdomain(DOMAINNAME)
    main()