def _setup_locale(): ''' setup locales and gettext ''' import gettext import locale use_home_dir = sys.platform != 'win32' app_config = appconfig.AppConfig('photocat.cfg', __file__, use_home_dir=use_home_dir, app_name='photocat') locales_dir = app_config.locales_dir package_name = 'photocat' _LOG.debug('run: locale dir: %s' % locales_dir) try: locale.bindtextdomain(package_name, locales_dir) locale.bind_textdomain_codeset(package_name, "UTF-8") except: pass default_locale = locale.getdefaultlocale() locale.setlocale(locale.LC_ALL, '') if sys.platform == 'win32': os.environ['LC_ALL'] = os.environ.get('LC_ALL') or default_locale[0] gettext.install(package_name, localedir=locales_dir, unicode=True, names=("ngettext",)) gettext.bindtextdomain(package_name, locales_dir) gettext.bind_textdomain_codeset(package_name, "UTF-8") _LOG.debug('locale: %s' % str(locale.getlocale()))
def __init__(self, project): """Constructor""" self.project = project # Setup foreign language support langs = [] lc, encoding = locale.getlocale(locale.LC_MESSAGES) if (lc): langs = [lc] language = os.environ.get('LANGUAGE', None) if (language): langs += language.split(":") # Set locale specific settings locale.setlocale(locale.LC_ALL) locale.bindtextdomain("OpenShot", self.project.LOCALE_DIR) locale.bind_textdomain_codeset("OpenShot", "UTF-8") # Set gettext settings gettext.bindtextdomain("OpenShot", self.project.LOCALE_DIR) gettext.bind_textdomain_codeset("OpenShot", "UTF-8") gettext.textdomain("OpenShot") gettext.install(domain="OpenShot") # This reference is used by other classes to define the _ method self.lang = gettext.translation("OpenShot", self.project.LOCALE_DIR, languages = langs, fallback = True)
def on_load(self, container): self.Builder = Gtk.Builder() self.Builder.set_translation_domain("blueman") bind_textdomain_codeset("blueman", "UTF-8") self.Builder.add_from_file(UI_PATH + "/services-network.ui") self.widget = self.Builder.get_object("network_frame") container.pack_start(self.widget, True, True, 0) self.interfaces = [] for iface in get_net_interfaces(): if iface != "lo" and iface != "pan1": logging.info(iface) ip = inet_aton(get_net_address(iface)) mask = inet_aton(get_net_netmask(iface)) self.interfaces.append( (iface, ip, mask, mask_ip4_address(ip, mask))) self.setup_network() try: self.ip_check() except Exception as e: logging.exception(e) return (_("Network"), "network-workgroup")
def __init__(self, project): """Constructor""" self.project = project # Setup foreign language support langs = [] lc, encoding = locale.getlocale(locale.LC_MESSAGES) if (lc): langs = [lc] language = os.environ.get('LANGUAGE', None) if (language): langs += language.split(":") # Set locale specific settings locale.setlocale(locale.LC_ALL) locale.bindtextdomain("LibreShot", self.project.LOCALE_DIR) locale.bind_textdomain_codeset("LibreShot", "UTF-8") # Set gettext settings gettext.bindtextdomain("LibreShot", self.project.LOCALE_DIR) gettext.bind_textdomain_codeset("LibreShot", "UTF-8") gettext.textdomain("LibreShot") gettext.install(domain="LibreShot") # This reference is used by other classes to define the _ method self.lang = gettext.translation("LibreShot", self.project.LOCALE_DIR, languages = langs, fallback = True)
def bindtextdomain(app_name, locale_dir=None): """ Bind the domain represented by app_name to the locale directory locale_dir. It has the effect of loading translations, enabling applications for different languages. app_name: a domain to look for translations, tipically the name of an application. locale_dir: a directory with locales like locale_dir/lang_isocode/LC_MESSAGES/app_name.mo If omitted or None, then the current binding for app_name is used. """ # installa _() e ngettext() builtin gettext.install(app_name, localedir=locale_dir, names=("ngettext",)) try: locale.bindtextdomain(app_name, locale_dir) locale.bind_textdomain_codeset(app_name, "UTF-8") except AttributeError: pass try: locale.setlocale(locale.LC_ALL, "") except locale.Error as e: pass
def __init__(self, bd_address): GObject.GObject.__init__(self) self.device = bd_address self.Builder = Gtk.Builder() self.Builder.set_translation_domain("blueman") bind_textdomain_codeset("blueman", "UTF-8") self.Builder.add_from_file(UI_PATH + "/gsm-settings.ui") vbox = self.Builder.get_object("vbox1") self.config = Config("org.blueman.gsmsetting", "/org/blueman/gsmsettings/%s/" % bd_address) self.props.icon_name = "network-wireless" self.props.title = _("GSM Settings") self.props.resizable = False a = self.get_content_area() a.pack_start(vbox, True, True, 0) vbox.show() self.e_apn = self.Builder.get_object("e_apn") self.e_number = self.Builder.get_object("e_number") self.config.bind_to_widget("apn", self.e_apn, "text") self.config.bind_to_widget("number", self.e_number, "text") self.add_button("_Close", Gtk.ResponseType.CLOSE)
def build_passkey_dialog(self, device_alias, dialog_msg, is_numeric): def on_insert_text(editable, new_text, new_text_length, position): if not new_text.isdigit(): editable.stop_emission("insert-text") builder = Gtk.Builder() builder.add_from_file(UI_PATH + "/applet-passkey.ui") builder.set_translation_domain("blueman") bind_textdomain_codeset("blueman", "UTF-8") dialog = builder.get_object("dialog") dialog.props.icon_name = "blueman" dev_name = builder.get_object("device_name") dev_name.set_markup(device_alias) msg = builder.get_object("message") msg.set_text(dialog_msg) pin_entry = builder.get_object("pin_entry") show_input = builder.get_object("show_input_check") if (is_numeric): pin_entry.set_max_length(6) pin_entry.set_width_chars(6) pin_entry.connect("insert-text", on_insert_text) show_input.hide() else: pin_entry.set_max_length(16) pin_entry.set_width_chars(16) pin_entry.set_visibility(False) show_input.connect("toggled", lambda x: pin_entry.set_visibility(x.props.active)) accept_button = builder.get_object("accept") pin_entry.connect("changed", lambda x: accept_button.set_sensitive(x.get_text() != '')) return (dialog, pin_entry)
def __init__(self,data_dir,desktop_file_path,pkgname): self.file_path = data_dir self.dfile=Ini(desktop_file_path) self.user_set_img=False gettext.bindtextdomain(pkgname, os.path.dirname(data_dir)+"/locale") gettext.textdomain(pkgname) locale.bind_textdomain_codeset(pkgname,'UTF-8') _ = gettext.gettext self._=_ self.tree = Gtk.Builder() self.tree.set_translation_domain("light-desktop-item-edit")#doesn't work at all self.tree.add_from_file(os.path.join(self.file_path, 'directory-item-edit.ui')) for obj in self.tree.get_objects(): if obj.__gtype__==Gtk.Label.__gtype__ or obj.__gtype__==Gtk.CheckButton.__gtype__: obj.set_label(_(obj.get_label())) self.tree.get_object("dialog").set_title(_("Directory")) self.img=Gtk.Image() self.tree.get_object("icon-button").add(self.img) self.load_desktop_file() self.tree.get_object("ok").connect("released",self.ok_pressed) self.tree.get_object("cancel").connect("released",self.destroy) self.tree.get_object("name").connect("changed",self.name_changed) self.tree.get_object("icon-button").connect("released",self.icon_pressed) self.tree.get_object("icon-name").connect("changed",self.icon_name_changed) w=self.tree.get_object("dialog") w.connect("key-press-event",self.handle_escape) w.show_all() Gtk.main()
def __init__(self, locale_path="", app_name="msgu"): self.app_name = app_name if len(locale_path)!=0: self.locale_path = locale_path else: self.locale_path = os.path.join(sys.prefix, 'local', 'share', 'locale') self._languages = {} self._language = None # http://stackoverflow.com/questions/10094335/how-to-bind-a-text-domain-to-a-local-folder-for-gettext-under-gtk3 # https://github.com/dieterv/elib.intl/blob/master/lib/elib/intl/__init__.py locale.setlocale(locale.LC_ALL, '') locale.bindtextdomain(self.app_name, self.locale_path) locale.bind_textdomain_codeset(self.app_name, 'UTF-8') locale.textdomain(self.app_name) gettext.bindtextdomain(self.app_name, self.locale_path) gettext.bind_textdomain_codeset(self.app_name, 'UTF-8') gettext.textdomain(self.app_name) #_ = gettext.gettext print( "Using locale folder: {}".format(self.locale_path) ) self.install() #self.update(locale_path, app_name) pass
def setup_locale_and_gettext(): """Set up localization with gettext""" package_name = "kupfer" localedir = "./locale" try: from kupfer import version_subst except ImportError: pass else: package_name = version_subst.PACKAGE_NAME localedir = version_subst.LOCALEDIR # Install _() builtin for gettext; always returning unicode objects # also install ngettext() gettext.install(package_name, localedir=localedir, unicode=True, names=("ngettext", )) # For gtk.Builder, we need to call the C library gettext functions # As well as set the codeset to avoid locale-dependent translation # of the message catalog locale.bindtextdomain(package_name, localedir) locale.bind_textdomain_codeset(package_name, "UTF-8") # to load in current locale properly for sorting etc try: locale.setlocale(locale.LC_ALL, "") except locale.Error: pass
def build_passkey_dialog(self, device_alias, dialog_msg, is_numeric): def on_insert_text(editable, new_text, new_text_length, position): if not new_text.isdigit(): editable.stop_emission("insert-text") builder = Gtk.Builder() builder.add_from_file(UI_PATH + "/applet-passkey.ui") builder.set_translation_domain("blueman") bind_textdomain_codeset("blueman", "UTF-8") dialog = builder.get_object("dialog") dialog.props.icon_name = "blueman" dev_name = builder.get_object("device_name") dev_name.set_markup(device_alias) msg = builder.get_object("message") msg.set_text(dialog_msg) pin_entry = builder.get_object("pin_entry") show_input = builder.get_object("show_input_check") if is_numeric: pin_entry.set_max_length(6) pin_entry.set_width_chars(6) pin_entry.connect("insert-text", on_insert_text) show_input.hide() else: pin_entry.set_max_length(16) pin_entry.set_width_chars(16) pin_entry.set_visibility(False) show_input.connect("toggled", lambda x: pin_entry.set_visibility(x.props.active)) accept_button = builder.get_object("accept") pin_entry.connect( "changed", lambda x: accept_button.set_sensitive(x.get_text() != '')) return dialog, pin_entry
def setup_locale_and_gettext(): """Set up localization with gettext""" package_name = "kupfer" localedir = "./locale" try: from kupfer import version_subst except ImportError: pass else: package_name = version_subst.PACKAGE_NAME localedir = version_subst.LOCALEDIR # Install _() builtin for gettext; always returning unicode objects # also install ngettext() gettext.install(package_name, localedir=localedir, unicode=True, names=("ngettext",)) # For gtk.Builder, we need to call the C library gettext functions # As well as set the codeset to avoid locale-dependent translation # of the message catalog locale.bindtextdomain(package_name, localedir) locale.bind_textdomain_codeset(package_name, "UTF-8") # to load in current locale properly for sorting etc try: locale.setlocale(locale.LC_ALL, "") except locale.Error, e: pass
def __init__(self, bd_address): super(GsmSettings, self).__init__() self.set_name("GsmSettings") self.device = bd_address self.Builder = Gtk.Builder() self.Builder.set_translation_domain("blueman") bind_textdomain_codeset("blueman", "UTF-8") self.Builder.add_from_file(UI_PATH + "/gsm-settings.ui") gsm_grid = self.Builder.get_object("gsm_grid") self.config = Config("org.blueman.gsmsetting", "/org/blueman/gsmsettings/%s/" % bd_address) self.props.icon_name = "network-wireless" self.props.title = _("GSM Settings") self.props.resizable = False a = self.get_content_area() a.pack_start(gsm_grid, True, True, 0) gsm_grid.show() self.e_apn = self.Builder.get_object("e_apn") self.e_number = self.Builder.get_object("e_number") self.config.bind_to_widget("apn", self.e_apn, "text") self.config.bind_to_widget("number", self.e_number, "text") self.add_button("_Close", Gtk.ResponseType.CLOSE)
def __init__(self, data_dir, desktop_file_path, pkgname): self.file_path = data_dir self.dfile = Ini(desktop_file_path) self.user_set_img = False gettext.bindtextdomain(pkgname, os.path.dirname(data_dir) + "/locale") gettext.textdomain(pkgname) locale.bind_textdomain_codeset(pkgname, 'UTF-8') _ = gettext.gettext self._ = _ self.tree = Gtk.Builder() self.tree.set_translation_domain( "light-desktop-item-edit") # doesn't work at all self.tree.add_from_file( os.path.join(self.file_path, 'desktop-item-edit.ui')) for obj in self.tree.get_objects(): if obj.__gtype__ == Gtk.Label.__gtype__ or obj.__gtype__ == Gtk.CheckButton.__gtype__: obj.set_label(_(obj.get_label())) self.tree.get_object("browse").set_label(_("Browse...")) self.tree.get_object("dialog").set_title(_("Launcher")) list_store = Gtk.ListStore(str) self.positions = [_('Application'), _('Application in terminal'), _('Location')] for pos in self.positions: list_store.append([pos]) self.combobox = Gtk.ComboBox.new_with_model(list_store) renderer_text = Gtk.CellRendererText() self.combobox.pack_start(renderer_text, True) self.combobox.add_attribute(renderer_text, "text", 0) self.combobox.set_active(0) combobox_container = self.tree.get_object("combobox-container") combobox_container.pack_start(self.combobox, False, False, True) self.img = Gtk.Image() self.tree.get_object("icon-button").add(self.img) self.load_desktop_file() self.combobox.connect("changed", self.combobox_changed) self.tree.get_object("ok").connect("clicked", self.ok_pressed) self.tree.get_object("cancel").connect("clicked", self.destroy) self.tree.get_object("command").connect( "changed", self.command_changed) self.tree.get_object("name").connect("changed", self.name_changed) self.tree.get_object("browse").connect("clicked", self.browse_pressed) self.tree.get_object("icon-button").connect( "clicked", self.icon_pressed) w = self.tree.get_object("dialog") w.connect("key-press-event", self.handle_escape) w.show_all() Gtk.main()
def initializations(): """Initializations""" if not os.path.isdir(os.path.dirname(cons.CONFIG_DIR)): os.mkdir(os.path.dirname(cons.CONFIG_DIR)) if not os.path.isdir(cons.CONFIG_DIR): os.mkdir(cons.CONFIG_DIR) if hasattr(sys, 'frozen'): import warnings warnings.filterwarnings(cons.STR_IGNORE) if not cons.IS_WIN_OS: try: # change process name import ctypes, ctypes.util libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library("libc")) libc.prctl(15, cons.APP_NAME, 0, 0, 0) except: print "libc.prctl not available, the process name will be python and not cherrytree" import locale try: locale.setlocale(locale.LC_ALL, '') except: print "locale.setlocale failure" try: # change locale text domain locale.bindtextdomain(cons.APP_NAME, cons.LOCALE_PATH) locale.bind_textdomain_codeset(cons.APP_NAME, cons.STR_UTF8) except: try: from ctypes import cdll libintl = cdll.intl libintl.bindtextdomain(cons.APP_NAME, cons.LOCALE_PATH) libintl.bind_textdomain_codeset(cons.APP_NAME, cons.STR_UTF8) except: pass try: from ctypes import windll lcid = windll.kernel32.GetUserDefaultUILanguage() os.environ["LANGUAGE"] = cons.MICROSOFT_WINDOWS_LCID_to_ISO_LANG[ lcid] except: pass # language installation if os.path.isfile(cons.LANG_PATH): lang_file_descriptor = file(cons.LANG_PATH, 'r') lang_str = lang_file_descriptor.read() lang_file_descriptor.close() if lang_str != 'default': os.environ["LANGUAGE"] = lang_str else: lang_str = 'default' try: gettext.translation(cons.APP_NAME, cons.LOCALE_PATH).install() except: import __builtin__ def _(transl_str): return transl_str __builtin__._ = _ return lang_str
def __init__(self): super(Setup, self).__init__() locale.bind_textdomain_codeset("ibus", "UTF-8") glade.textdomain("ibus") glade_file = path.join(path.dirname(__file__), "./setup.glade") self.__xml = glade.XML(glade_file) self.__bus = None self.__init_bus() self.__init_ui()
def configure_gettext(): """Configure gettext for all RHSM-related code. Since Glade internally uses gettext, we need to use the C-level bindings in locale to adjust the encoding. See https://docs.python.org/2/library/locale.html#access-to-message-catalogs """ gettext.bindtextdomain(APP, DIR) gettext.textdomain(APP) locale.bind_textdomain_codeset(APP, "UTF-8")
def setup_gettext(domain, data_dir): directory = os.path.abspath(os.path.join(data_dir, "locale")) gettext.bindtextdomain(domain, directory) if hasattr(gettext, 'bind_textdomain_codeset'): gettext.bind_textdomain_codeset(domain, 'UTF-8') gettext.textdomain(domain) locale.bindtextdomain(domain, directory) if hasattr(locale, 'bind_textdomain_codeset'): locale.bind_textdomain_codeset(domain, 'UTF-8') locale.textdomain(domain)
def init_gettext(locale_dir): u'''Initialize gettext using the given directory containing the l10n data. ''' gettext.bindtextdomain('sdaps', locale_dir) if hasattr(gettext, 'bind_textdomain_codeset'): gettext.bind_textdomain_codeset('sdaps', 'UTF-8') gettext.textdomain('sdaps') if hasattr(locale, 'bind_textdomain_codeset'): locale.bindtextdomain('sdaps', locale_dir) locale.bind_textdomain_codeset('sdaps', 'UTF-8') locale.textdomain('sdaps')
def init(): localedir = os.getenv("IBUS_LOCALEDIR") # Python's locale module doesn't provide all methods on some # operating systems like FreeBSD try: # for non-standard localedir locale.bindtextdomain(DOMAINNAME, localedir) locale.bind_textdomain_codeset(DOMAINNAME, "UTF-8") except AttributeError: pass gettext.bindtextdomain(DOMAINNAME, localedir) gettext.bind_textdomain_codeset(DOMAINNAME, "UTF-8")
def init_textdomain(domainname): if domainname == '': return # Python's locale module doesn't provide all methods on some # operating systems like FreeBSD try: locale.bindtextdomain(domainname, LOCALEDIR) locale.bind_textdomain_codeset(domainname, 'UTF-8') except AttributeError: pass gettext.bindtextdomain(domainname, LOCALEDIR) gettext.bind_textdomain_codeset(domainname, 'UTF-8')
def setup_locale_and_gettext(): package_name = 'specto' # Install _() builtin for gettext; always returning unicode objects # also install ngettext() gettext.install(package_name, localedir=MESSAGES_DIR, names=("ngettext", )) locale.bindtextdomain(package_name, MESSAGES_DIR) locale.bind_textdomain_codeset(package_name, "UTF-8") _ = gettext.gettext try: locale.setlocale(locale.LC_ALL, "") except locale.Error as e: pass
def configure_gettext(): """Configure gettext for all RHSM-related code. Since Glade internally uses gettext, we need to use the C-level bindings in locale to adjust the encoding. See https://docs.python.org/2/library/locale.html#access-to-message-catalogs Exposed as its own function so that it can be called safely in the initial-setup case. """ gettext.bindtextdomain(APP, DIR) gettext.textdomain(APP) gettext.bind_textdomain_codeset(APP, 'UTF-8') locale.bind_textdomain_codeset(APP, 'UTF-8')
def init_gettext(locale_dir): u'''Initialize gettext. Tell it, where to find the translation files. ''' gettext.bindtextdomain('sdaps', locale_dir) if hasattr(gettext, 'bind_textdomain_codeset'): gettext.bind_textdomain_codeset('sdaps', 'UTF-8') gettext.textdomain('sdaps') if hasattr(locale, 'bind_textdomain_codeset'): locale.bindtextdomain('sdaps', locale_dir) locale.bind_textdomain_codeset('sdaps', 'UTF-8') locale.textdomain('sdaps')
def setup_locale_and_gettext(): package_name = 'specto' # Install _() builtin for gettext; always returning unicode objects # also install ngettext() gettext.install(package_name, localedir=MESSAGES_DIR, unicode=True, names=("ngettext",)) locale.bindtextdomain(package_name, MESSAGES_DIR) locale.bind_textdomain_codeset(package_name, "UTF-8") try: locale.setlocale(locale.LC_ALL, "") except locale.Error, e: pass
def initializations(): """Initializations""" if not os.path.isdir(os.path.dirname(cons.CONFIG_DIR)): os.mkdir(os.path.dirname(cons.CONFIG_DIR)) if not os.path.isdir(cons.CONFIG_DIR): os.mkdir(cons.CONFIG_DIR) if hasattr(sys, 'frozen'): import warnings warnings.filterwarnings(cons.STR_IGNORE) if not cons.IS_WIN_OS: try: # change process name import ctypes, ctypes.util libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library("libc")) libc.prctl(15, cons.APP_NAME, 0, 0, 0) except: print "libc.prctl not available, the process name will be python and not cherrytree" import locale try: locale.setlocale(locale.LC_ALL, '') except: print "locale.setlocale failure" try: # change locale text domain locale.bindtextdomain(cons.APP_NAME, cons.LOCALE_PATH) locale.bind_textdomain_codeset(cons.APP_NAME, cons.STR_UTF8) except: try: from ctypes import cdll libintl = cdll.intl libintl.bindtextdomain(cons.APP_NAME, cons.LOCALE_PATH) libintl.bind_textdomain_codeset(cons.APP_NAME, cons.STR_UTF8) except: pass try: from ctypes import windll lcid = windll.kernel32.GetUserDefaultUILanguage() os.environ["LANGUAGE"] = cons.MICROSOFT_WINDOWS_LCID_to_ISO_LANG[lcid] except: pass # language installation if os.path.isfile(cons.LANG_PATH): lang_file_descriptor = file(cons.LANG_PATH, 'r') lang_str = lang_file_descriptor.read() lang_file_descriptor.close() if lang_str != 'default': os.environ["LANGUAGE"] = lang_str else: lang_str = 'default' try: gettext.translation(cons.APP_NAME, cons.LOCALE_PATH).install() except: import __builtin__ def _(transl_str): return transl_str __builtin__._ = _ return lang_str
def install_locale(locale_dir): '''Install locale data from the provided directory.''' # This sets up the _ function gettext.install('entertainer', localedir=locale_dir, unicode=True) # Call the C library gettext functions and set the codeset # to avoid locale-dependent translation of the message catalog locale.bindtextdomain('entertainer', locale_dir) locale.bind_textdomain_codeset('entertainer', "UTF-8") # XXX: fmarl - setlocale load in current locale properly # We can remove it and get feedback from users to see if # this hack it's really needed. try: locale.setlocale(locale.LC_ALL, "") except locale.Error: pass
def _install(domain, localedir, asglobal=False): ''' :param domain: translation domain :param localedir: locale directory :param asglobal: if True, installs the function _() in Python�s builtin namespace. Default is False Private function doing all the work for the :func:`elib.intl.install` and :func:`elib.intl.install_module` functions. ''' # prep locale system if asglobal: locale.setlocale(locale.LC_ALL, '') # on windows systems, set the LANGUAGE environment variable if sys.platform == 'win32' or sys.platform == 'nt': _putenv('LANGUAGE', _getscreenlanguage()) #print "=========2>", os.getenv('LANGUAGE') # The locale module on Max OS X lacks bindtextdomain so we specifically # test on linux2 here. See commit 4ae8b26fd569382ab66a9e844daa0e01de409ceb if sys.platform == 'linux2': locale.bindtextdomain(domain, localedir) locale.bind_textdomain_codeset(domain, 'UTF-8') locale.textdomain(domain) # initialize Python's gettext interface gettext.bindtextdomain(domain, localedir) gettext.bind_textdomain_codeset(domain, 'UTF-8') if asglobal: gettext.textdomain(domain) # on windows systems, initialize libintl if sys.platform == 'win32' or sys.platform == 'nt': from ctypes import cdll try : libintl = cdll.intl except : libintl = cdll.LoadLibrary("libintl-8.dll") libintl.bindtextdomain(domain, localedir) libintl.bind_textdomain_codeset(domain, 'UTF-8') if asglobal: libintl.textdomain(domain) del libintl
def setup_locale_and_gettext(): #Set up localization with gettext localedir = join (config.get_base_data_prefix(),"locale") # Install _() builtin for gettext; always returning unicode objects # also install ngettext() gettext.install(APP_NAME, localedir=localedir, unicode=True, names=("ngettext",)) # For Gtk.Builder, we need to call the C library gettext functions # As well as set the codeset to avoid locale-dependent translation # of the message catalog locale.bindtextdomain(APP_NAME, localedir) locale.bind_textdomain_codeset(APP_NAME, "UTF-8") # to load in current locale properly for sorting etc try: locale.setlocale(locale.LC_ALL, "") except locale.Error, e: pass
def setup_locale_and_gettext(): """Set up localization with gettext""" localedir = join (config.get_base_data_prefix(),"locale") # Install _() builtin for gettext; always returning unicode objects # also install ngettext() gettext.install(APP_NAME, localedir=localedir, unicode=True, names=("ngettext",)) # For gtk.Builder, we need to call the C library gettext functions # As well as set the codeset to avoid locale-dependent translation # of the message catalog locale.bindtextdomain(APP_NAME, localedir) locale.bind_textdomain_codeset(APP_NAME, "UTF-8") # to load in current locale properly for sorting etc try: locale.setlocale(locale.LC_ALL, "") except locale.Error, e: pass
def _install(domain, localedir, asglobal=False): """ :param domain: translation domain :param localedir: locale directory :param asglobal: if True, installs the function _() in Python’s builtin namespace. Default is False Private function doing all the work for the :func:`elib.intl.install` and :func:`elib.intl.install_module` functions. """ # prep locale system if asglobal: locale.setlocale(locale.LC_ALL, "") # on windows systems, set the LANGUAGE environment variable if sys.platform == "win32" or sys.platform == "nt": _putenv("LANGUAGE", _getscreenlanguage()) # The locale module on Max OS X lacks bindtextdomain so we specifically # test on linux2 here. See commit 4ae8b26fd569382ab66a9e844daa0e01de409ceb if sys.platform == "linux2": locale.bindtextdomain(domain, localedir) locale.bind_textdomain_codeset(domain, "UTF-8") locale.textdomain(domain) # initialize Python's gettext interface gettext.bindtextdomain(domain, localedir) gettext.bind_textdomain_codeset(domain, "UTF-8") if asglobal: gettext.textdomain(domain) # on windows systems, initialize libintl if sys.platform == "win32" or sys.platform == "nt": from ctypes import cdll libintl = cdll.intl libintl.bindtextdomain(domain, localedir) libintl.bind_textdomain_codeset(domain, "UTF-8") if asglobal: libintl.textdomain(domain) del libintl
def initialize(self): """ Initialize the enviroment """ # Initialize i18n variables if os.path.exists("%s/locale" % self.BASEPATH): self.LOCALE_DIR = "%s/locale" % self.BASEPATH else: self.LOCALE_DIR = os.path.join(sys.prefix, 'share', 'locale') try: locale.setlocale(locale.LC_ALL, '') except locale.Error: locale.setlocale(locale.LC_ALL, 'en_US.utf8') locale.bindtextdomain(self.APP, self.LOCALE_DIR) locale.bind_textdomain_codeset(self.APP, 'UTF-8') gettext.bindtextdomain(self.APP, self.LOCALE_DIR) gettext.textdomain(self.APP) gettext.install(self.APP, localedir = self.LOCALE_DIR, unicode = True) # Initialize the Version number version = open("%s/VERSION" % self.BASEPATH, 'r') self.VERSION = version.readline() version.close() # Initialize configuration config = ConfigObj(self.config_defaults()) config.filename = self.get_config_filename() user_config = ConfigObj(self.get_config_filename()) config.merge(user_config) self._safe_create_dirs(self.get_config_directory()) self._safe_create_dirs(config['down_path']) self._safe_create_dirs(os.path.join(self.get_config_directory(), "covers")) config.write() self.set_config(config) # Initialize proxy # To avoid requests problems with Grooveshark, the proxy is initialized # one time and user needs to restart gSharkDown in order to use a new # proxy. This should be fixed! self.refresh_proxy()
def on_rename(_item, device): def on_response(dialog, response_id): if response_id == Gtk.ResponseType.ACCEPT: device.set('Alias', alias_entry.get_text()) elif response_id == 1: device.set('Alias', '') dialog.destroy() builder = Gtk.Builder() builder.set_translation_domain("blueman") bind_textdomain_codeset("blueman", "UTF-8") builder.add_from_file(UI_PATH + "/rename-device.ui") dialog = builder.get_object("dialog") dialog.set_transient_for(self.Blueman) dialog.props.icon_name = "blueman" alias_entry = builder.get_object("alias_entry") alias_entry.set_text(device['Alias']) dialog.connect("response", on_response) dialog.present()
def prepare_locale(): if os.name == 'nt': instdir = osp.abspath(osp.dirname(sys.argv[0])) localedir = osp.join(instdir, "locale") else: localedir = "/usr/share/locale" gettext.bindtextdomain('labyrinth', localedir) if hasattr(gettext, 'bind_textdomain_codeset'): gettext.bind_textdomain_codeset('labyrinth','UTF-8') gettext.textdomain('labyrinth') if hasattr(locale, 'bindtextdomain'): if not os.name == 'nt': locale.bindtextdomain('labyrinth', localedir) if hasattr(locale, 'bind_textdomain_codeset'): locale.bind_textdomain_codeset('labyrinth','UTF-8') locale.textdomain('labyrinth')
def on_load(self, container): self.Builder = Gtk.Builder() self.Builder.set_translation_domain("blueman") bind_textdomain_codeset("blueman", "UTF-8") self.Builder.add_from_file(UI_PATH + "/services-transfer.ui") self.widget = self.Builder.get_object("transfer") self.ignored_keys = [] container.pack_start(self.widget, True, True, 0) a = AppletService() if "TransferService" in a.QueryPlugins(): self._setup_transfer() else: self.widget.props.sensitive = False self.widget.props.tooltip_text = _("Applet's transfer service plugin is disabled") return True
def setup_locale(app_config): """ setup locales and gettext """ locales_dir = app_config.locales_dir package_name = 'wxgtd' _LOG.info('run: locale dir: %s', locales_dir) try: locale.bindtextdomain(package_name, locales_dir) locale.bind_textdomain_codeset(package_name, "UTF-8") except AttributeError: pass default_locale = locale.getdefaultlocale() locale.setlocale(locale.LC_ALL, '') os.environ['LC_ALL'] = os.environ.get('LC_ALL') or default_locale[0] gettext.install(package_name, localedir=locales_dir, unicode=True, names=("ngettext", )) gettext.bindtextdomain(package_name, locales_dir) gettext.textdomain(package_name) gettext.bindtextdomain('wxstd', locales_dir) gettext.bind_textdomain_codeset(package_name, "UTF-8") _LOG.info('locale: %s', str(locale.getlocale()))
def _setup_locale(): ''' setup locales and gettext ''' app_config = appconfig.AppConfig('alldb.cfg', 'alldb') locales_dir = app_config.locales_dir package_name = 'alldb' _LOG.info('run: locale dir: %s' % locales_dir) try: locale.bindtextdomain(package_name, locales_dir) locale.bind_textdomain_codeset(package_name, "UTF-8") except AttributeError: pass default_locale = locale.getdefaultlocale() locale.setlocale(locale.LC_ALL, '') os.environ['LC_ALL'] = os.environ.get('LC_ALL') or default_locale[0] gettext.install(package_name, localedir=locales_dir, unicode=True, names=("ngettext",)) gettext.bindtextdomain(package_name, locales_dir) gettext.bindtextdomain('wxstd', locales_dir) gettext.bind_textdomain_codeset(package_name, "UTF-8") _LOG.info('locale: %s' % str(locale.getlocale()))
def prepare_locale(): if os.name == 'nt': instdir = osp.abspath(osp.dirname(sys.argv[0])) localedir = osp.join(instdir, "locale") else: localedir = "/usr/share/locale" gettext.bindtextdomain('labyrinth', localedir) if hasattr(gettext, 'bind_textdomain_codeset'): gettext.bind_textdomain_codeset('labyrinth','UTF-8') gettext.textdomain('labyrinth') if hasattr(locale, 'bindtextdomain'): if not os.name == 'nt': locale.bindtextdomain('labyrinth', localedir) if hasattr(locale, 'bind_textdomain_codeset'): locale.bind_textdomain_codeset('labyrinth','UTF-8') locale.textdomain('labyrinth') gtk.glade.bindtextdomain('labyrinth') gtk.glade.textdomain('labyrinth')
def on_load(self, container): self.Builder = Gtk.Builder() self.Builder.set_translation_domain("blueman") bind_textdomain_codeset("blueman", "UTF-8") self.Builder.add_from_file(UI_PATH + "/services-network.ui") self.widget = self.Builder.get_object("network_frame") container.pack_start(self.widget, True, True, 0) self.interfaces = [] for iface in get_net_interfaces(): if iface != "lo" and iface != "pan1": logging.info(iface) ipiface = ipaddress.ip_interface('/'.join((get_net_address(iface), get_net_netmask(iface)))) self.interfaces.append((iface, ipiface)) self.setup_network() try: self.ip_check() except (ValueError, ipaddress.AddressValueError) as e: logging.exception(e) return _("Network"), "network-workgroup"
def on_load(self, container): self.Builder = Gtk.Builder() self.Builder.set_translation_domain("blueman") bind_textdomain_codeset("blueman", "UTF-8") self.Builder.add_from_file(UI_PATH + "/services-network.ui") self.widget = self.Builder.get_object("network_frame") container.pack_start(self.widget, True, True, 0) self.interfaces = [] for iface in get_net_interfaces(): if iface != "lo" and iface != "pan1": print(iface) ip = inet_aton(get_net_address(iface)) mask = inet_aton(get_net_netmask(iface)) self.interfaces.append((iface, ip, mask, mask_ip4_address(ip, mask))) self.setup_network() try: self.ip_check() except: pass return (_("Network"), "network-workgroup")
import defs localedir = abspath(join(defs.DATA_DIR, "locale")) except: localedir = "" gettext.bindtextdomain('labyrinth', localedir) if hasattr(gettext, 'bind_textdomain_codeset'): gettext.bind_textdomain_codeset('labyrinth', 'UTF-8') gettext.textdomain('labyrinth') if not os.name == 'nt': locale.bindtextdomain('labyrinth', localedir) if hasattr(locale, 'bind_textdomain_codeset'): locale.bind_textdomain_codeset('labyrinth', 'UTF-8') locale.textdomain('labyrinth') ## FIXME: ARREGLAR ESTO ##gtk.glade.bindtextdomain('labyrinth') ##gtk.glade.textdomain('labyrinth') def main(): parser = optparse.OptionParser() parser.add_option("--use-tray-icon", dest="tray_icon", action="store_true", default=False) parser.add_option("--no-tray-icon", dest="tray_icon", action="store_false") parser.add_option("--hide-main-window", action="store_true", default=False)
def __init__(self, applet): super().__init__( title=_("Plugins"), icon_name="blueman", name="PluginDialog", border_width=6, default_width=490, default_height=380, resizable=False, visible=False ) self.applet = applet self.Builder = Gtk.Builder(translation_domain="blueman") bind_textdomain_codeset("blueman", "UTF-8") self.Builder.add_from_file(UI_PATH + "/applet-plugins-widget.ui") self.description = self.Builder.get_object("description") self.icon = self.Builder.get_object("icon") self.author_txt = self.Builder.get_object("author_txt") self.depends_hdr = self.Builder.get_object("depends_hdr") self.depends_txt = self.Builder.get_object("depends_txt") self.conflicts_hdr = self.Builder.get_object("conflicts_hdr") self.conflicts_txt = self.Builder.get_object("conflicts_txt") self.plugin_name = self.Builder.get_object("name") self.main_container = self.Builder.get_object("main_container") self.content_grid = self.Builder.get_object("content") self.b_prefs = self.Builder.get_object("b_prefs") self.b_prefs.connect("toggled", self.on_prefs_toggled) ref = weakref.ref(self) self.add(self.Builder.get_object("all")) cr = Gtk.CellRendererToggle() cr.connect("toggled", lambda *args: ref() and ref().on_toggled(*args)) data = [ {"id": "active", "type": bool, "renderer": cr, "render_attrs": {"active": 0, "activatable": 1, "visible": 1}}, {"id": "activatable", "type": bool}, {"id": "icon", "type": str, "renderer": Gtk.CellRendererPixbuf(), "render_attrs": {"icon-name": 2}}, # device caption {"id": "desc", "type": str, "renderer": Gtk.CellRendererText(), "render_attrs": {"markup": 3}, "view_props": {"expand": True}}, {"id": "name", "type": str}, ] self.list = GenericList(data, headers_visible=False, visible=True) self.list.liststore.set_sort_column_id(3, Gtk.SortType.ASCENDING) self.list.liststore.set_sort_func(3, self.list_compare_func) self.list.selection.connect("changed", lambda *args: ref() and ref().on_selection_changed(*args)) plugin_list = self.Builder.get_object("plugin_list") plugin_info = self.Builder.get_object("main_scrolled_window") plugin_list.add(self.list) # Disable overlay scrolling if Gtk.get_minor_version() >= 16: plugin_list.props.overlay_scrolling = False plugin_info.props.overlay_scrolling = False self.populate() self.sig_a = self.applet.Plugins.connect("plugin-loaded", self.plugin_state_changed, True) self.sig_b = self.applet.Plugins.connect("plugin-unloaded", self.plugin_state_changed, False) self.connect("delete-event", self._on_close) self.list.set_cursor(0)
from MSSystray import MSSystray ## ## I18N ## import gettext, locale gettext.install(config.GETTEXT_PACKAGE(), config.GNOMELOCALEDIR(), unicode=1) gettext.bindtextdomain('mount-systray', config.GNOMELOCALEDIR()) if hasattr(gettext, 'bind_textdomain_codeset'): gettext.bind_textdomain_codeset('mount-systray', 'UTF-8') gettext.textdomain('mount-systray') locale.bindtextdomain('mount-systray', config.GNOMELOCALEDIR()) if hasattr(locale, 'bind_textdomain_codeset'): locale.bind_textdomain_codeset('mount-systray', 'UTF-8') locale.textdomain('mount-systray') try: import pygtk #tell pyGTK, if possible, that we want GTKv2 pygtk.require("2.0") except: #Some distributions come with GTK2, but not pyGTK pass try: import gtk import gtk.glade import gnome
import gettext import __builtin__ __builtin__._ = gettext.gettext from settings import LOCALE_PATH # i18n domain = 'migasfree-client' gettext.install(domain, LOCALE_PATH, unicode=1) gettext.bindtextdomain(domain, LOCALE_PATH) if hasattr(gettext, 'bind_textdomain_codeset'): gettext.bind_textdomain_codeset(domain, 'UTF-8') gettext.textdomain(domain) locale.bindtextdomain(domain, LOCALE_PATH) if hasattr(locale, 'bind_textdomain_codeset'): locale.bind_textdomain_codeset(domain, 'UTF-8') locale.textdomain(domain) # http://www.ianbicking.org/illusive-setdefaultencoding.html # begin unicode hack import sys if sys.getdefaultencoding() != 'utf-8': reload(sys) sys.setdefaultencoding('utf-8') # now default enconding is 'utf-8' ;) # end unicode hack
def __init__(self): super(Blueman, self).__init__(title=_("Bluetooth Devices")) self._applet_sig = None self.Config = Config("org.blueman.general") self.Builder = Gtk.Builder() self.Builder.set_translation_domain("blueman") bind_textdomain_codeset("blueman", "UTF-8") self.Builder.add_from_file(UI_PATH + "/manager-main.ui") grid = self.Builder.get_object("grid") self.add(grid) self.set_name("BluemanManager") self.Plugins = PluginManager(ManagerPlugin, blueman.plugins.manager, self) self.Plugins.load_plugin() area = MessageArea() grid.attach(area, 0, 3, 1, 1) # Add margin for resize grip or it will overlap if self.get_has_resize_grip(): statusbar = self.Builder.get_object("statusbar") margin_right = statusbar.get_margin_right() statusbar.set_margin_right(margin_right + 10) def do_present(time): if self.props.visible: self.present_with_time(time) check_single_instance("blueman-manager", do_present) def on_window_delete(window, event): w, h = self.get_size() x, y = self.get_position() self.Config["window-properties"] = [w, h, x, y] Gtk.main_quit() def bt_status_changed(status): if not status: self.hide() check_bluetooth_status(_("Bluetooth needs to be turned on for the device manager to function"), lambda: Gtk.main_quit()) else: self.show() def on_applet_signal(_proxy, _sender, signal_name, params): if signal_name == 'BluetoothStatusChanged': status = params.unpack() bt_status_changed(status) def on_dbus_name_vanished(_connection, name): logging.info(name) if self._applet_sig is not None: self.Applet.disconnect(self._applet_sig) self._applet_sig = None self.hide() d = ErrorDialog( _("Connection to BlueZ failed"), _("Bluez daemon is not running, blueman-manager cannot continue.\n" "This probably means that there were no Bluetooth adapters detected " "or Bluetooth daemon was not started."), icon_name="blueman") d.run() d.destroy() # FIXME ui can handle BlueZ start/stop but we should inform user Gtk.main_quit() def on_dbus_name_appeared(_connection, name, owner): logging.info("%s %s" % (name, owner)) setup_icon_path() try: self.Applet = AppletService() except DBusProxyFailed: print("Blueman applet needs to be running") exit() if 'PowerManager' in self.Applet.QueryPlugins(): if not self.Applet.get_bluetooth_status(): bt_status_changed(False) self._applet_sig = self.Applet.connect('g-signal', on_applet_signal) self.connect("delete-event", on_window_delete) self.props.icon_name = "blueman" w, h, x, y = self.Config["window-properties"] if w and h: self.resize(w, h) if x and y: self.move(x, y) sw = self.Builder.get_object("scrollview") # Disable overlay scrolling if Gtk.get_minor_version() >= 16: sw.props.overlay_scrolling = False self.List = ManagerDeviceList(adapter=self.Config["last-adapter"], inst=self) self.List.show() sw.add(self.List) self.Toolbar = ManagerToolbar(self) self.Menu = ManagerMenu(self) self.Stats = ManagerStats(self) if self.List.is_valid_adapter(): self.List.display_known_devices(autoselect=True) self.List.connect("adapter-changed", self.on_adapter_changed) toolbar = self.Builder.get_object("toolbar") statusbar = self.Builder.get_object("statusbar") self.Config.bind_to_widget("show-toolbar", toolbar, "visible") self.Config.bind_to_widget("show-statusbar", statusbar, "visible") self.show() bluez.Manager.watch_name_owner(on_dbus_name_appeared, on_dbus_name_vanished)
self.__hangul_key_list_str = value.split(',') elif name == "hanja-keys": self.__hanja_key_list_str = value.split(',') def __read(self, name, v): value = self.__config.get_value("engine/hangul", name) if value is None: return v return value def __write(self, name, v): return self.__config.set_value("engine/Hangul", name, v) if __name__ == "__main__": locale.bindtextdomain(config.gettext_package, config.localedir) locale.bind_textdomain_codeset(config.gettext_package, "UTF-8") bus = IBus.Bus() if bus.is_connected(): Setup(bus).run() else: message = _( "IBus daemon is not running.\nHangul engine settings cannot be saved." ) dialog = Gtk.MessageDialog(type=Gtk.MessageType.ERROR, buttons=Gtk.ButtonsType.CLOSE, message_format=message) dialog.run() sys.exit(1)
from gi.repository import IBus import config from dicttreeview import DictionaryTreeView from shortcuteditor import ShortcutEditor DOMAINNAME = 'ibus-libpinyin' locale.setlocale(locale.LC_ALL, "") localedir = os.getenv("IBUS_LOCALEDIR") pkgdatadir = os.getenv("IBUS_PKGDATADIR") or "." # Python's locale module doesn't provide all methods on some # operating systems like FreeBSD try: locale.bindtextdomain(DOMAINNAME, localedir) locale.bind_textdomain_codeset(DOMAINNAME, 'UTF-8') except AttributeError: pass gettext.bindtextdomain(DOMAINNAME, localedir) gettext.bind_textdomain_codeset(DOMAINNAME, 'UTF-8') gettext.install(DOMAINNAME, localedir) class PreferencesDialog: def __init__(self, engine): self.__bus = IBus.Bus() self.__builder = Gtk.Builder() self.__builder.set_translation_domain(DOMAINNAME) self.__builder.add_from_file("ibus-libpinyin-preferences.ui")
def __init__(self, parent): if not Dialog.running: Dialog.running = True else: return self.config = None self.parent = parent builder = Gtk.Builder() builder.add_from_file(UI_PATH + "/net-usage.ui") builder.set_translation_domain("blueman") bind_textdomain_codeset("blueman", "UTF-8") self.dialog = builder.get_object("dialog") self.dialog.connect("response", self.on_response) cr1 = Gtk.CellRendererText() cr1.props.ellipsize = Pango.EllipsizeMode.END self.devices = {} self._signals = [ parent.connect("monitor-added", self.monitor_added), parent.connect("monitor-removed", self.monitor_removed), parent.connect("stats", self.on_stats) ] cr2 = Gtk.CellRendererText() cr2.props.sensitive = False cr2.props.style = Pango.Style.ITALIC self.liststore = Gtk.ListStore(str, str, str, object) self.e_ul = builder.get_object("e_ul") self.e_dl = builder.get_object("e_dl") self.e_total = builder.get_object("e_total") self.l_started = builder.get_object("l_started") self.l_duration = builder.get_object("l_duration") self.b_reset = builder.get_object("b_reset") self.b_reset.connect("clicked", self.on_reset) self.cb_device = builder.get_object("cb_device") self.cb_device.props.model = self.liststore self.cb_device.connect("changed", self.on_selection_changed) self.cb_device.pack_start(cr1, True) self.cb_device.add_attribute(cr1, 'markup', 1) self.cb_device.pack_start(cr2, False) self.cb_device.add_attribute(cr2, 'markup', 2) general_config = Config("org.blueman.general") added = False for d in general_config["netusage-dev-list"]: for m in parent.monitors: if d == m.device["Address"]: titer = self.liststore.append( [d, self.get_caption(m.device["Alias"], m.device["Address"]), _("Connected:") + " " + m.interface, m]) if self.cb_device.get_active() == -1: self.cb_device.set_active_iter(titer) added = True break if not added: name = d if self.parent.Applet.Manager: device = self.parent.Applet.Manager.find_device(d) if device is None: pass else: name = self.get_caption(device["Alias"], device["Address"]) self.liststore.append([d, name, _("Not Connected"), None]) added = False if len(self.liststore) > 0: if self.cb_device.get_active() == -1: self.cb_device.set_active(0) else: d = Gtk.MessageDialog(parent=self.dialog, flags=Gtk.DialogFlags.MODAL, type=Gtk.MessageType.INFO, buttons=Gtk.ButtonsType.CLOSE, message_format=_( "No usage statistics are available yet. Try establishing a connection first and then check this page.")) d.props.icon_name = "blueman" d.run() d.destroy() self.on_response(None, None) return self.dialog.show()
def __init__(self, applet): super(PluginDialog, self).__init__(buttons=("_Close", Gtk.ResponseType.CLOSE)) self.set_name("PluginDialog") self.applet = applet self.Builder = Gtk.Builder() self.Builder.set_translation_domain("blueman") bind_textdomain_codeset("blueman", "UTF-8") self.Builder.add_from_file(UI_PATH + "/applet-plugins-widget.ui") self.set_title(_("Plugins")) self.props.icon_name = "blueman" self.description = self.Builder.get_object("description") self.description.props.wrap = True self.icon = self.Builder.get_object("icon") self.author_txt = self.Builder.get_object("author_txt") self.depends_hdr = self.Builder.get_object("depends_hdr") self.depends_txt = self.Builder.get_object("depends_txt") self.conflicts_hdr = self.Builder.get_object("conflicts_hdr") self.conflicts_txt = self.Builder.get_object("conflicts_txt") self.plugin_name = self.Builder.get_object("name") self.main_container = self.Builder.get_object("main_container") self.content_grid = self.Builder.get_object("content") self.b_prefs = self.Builder.get_object("b_prefs") self.b_prefs.connect("toggled", self.on_prefs_toggled) widget = self.Builder.get_object("all") ref = weakref.ref(self) self.vbox.pack_start(widget, True, True, 0) cr = Gtk.CellRendererToggle() cr.connect("toggled", lambda *args: ref() and ref().on_toggled(*args)) data = [ ["active", bool, cr, {"active": 0, "activatable": 1, "visible": 1}, None], ["activatable", bool], ["icon", str, Gtk.CellRendererPixbuf(), {"icon-name": 2}, None], # device caption ["desc", str, Gtk.CellRendererText(), {"markup": 3}, None, {"expand": True}], ["name", str] ] self.list = GenericList(data) # self.sorted = Gtk.TreeModelSort(self.list.liststore) self.list.liststore.set_sort_column_id(3, Gtk.SortType.ASCENDING) self.list.liststore.set_sort_func(3, self.list_compare_func) self.list.selection.connect("changed", lambda *args: ref() and ref().on_selection_changed(*args)) self.list.props.headers_visible = False self.list.show() self.props.border_width = 6 self.resize(490, 380) viewport = self.Builder.get_object("viewport") viewport.add(self.list) sw = self.Builder.get_object("main_scrolled_window") # Disable overlay scrolling if Gtk.get_minor_version() >= 16: viewport.props.overlay_scrolling = False sw.props.overlay_scrolling = False self.populate() self.sig_a = self.applet.Plugins.connect("plugin-loaded", self.plugin_state_changed, True) self.sig_b = self.applet.Plugins.connect("plugin-unloaded", self.plugin_state_changed, False) self.connect("response", self.on_response) self.list.set_cursor(0)
import aptdaemon.client import aptdaemon.errors from aptdaemon.enums import * import apt_pkg, apt from apt.cache import FilteredCache from defer import inline_callbacks from defer.utils import deferable # i18n import gettext, locale LOCALE_PATH = DIR_PATH + "locale" DOMAIN = "cinnamon-installer" locale.bindtextdomain(DOMAIN, LOCALE_PATH) locale.bind_textdomain_codeset(DOMAIN, "UTF-8") gettext.bindtextdomain(DOMAIN, LOCALE_PATH) gettext.bind_textdomain_codeset(DOMAIN, "UTF-8") gettext.textdomain(DOMAIN) #_ = gettext.gettext _ = lambda msg: gettext.dgettext("aptdaemon", msg) from gi.repository import GObject, Gtk, GLib, Gio CI_STATUS = { "status-resolving-dep": "RESOLVING_DEPENDENCIES", "status-setting-up": "SETTING-UP", "status-loading-cache": "LOADING_CACHE", "status-authenticating": "AUTHENTICATING", "status-downloading": "DOWNLOADING", "status-downloading-repo": "DOWNLOADING_REPO",