def __init__(self, datadir, options): LanguageSelectorBase.__init__(self, datadir) self._datadir = datadir self.widgets = Gtk.Builder() self.widgets.set_translation_domain('language-selector') self.widgets.add_from_file(datadir + "/data/LanguageSelector.ui") self.widgets.connect_signals(self) try: in_grp_admin = grp.getgrnam("admin")[2] in os.getgroups() except KeyError: in_grp_admin = False try: in_grp_sudo = grp.getgrnam("sudo")[2] in os.getgroups() except KeyError: in_grp_sudo = False self.is_admin = (os.getuid() == 0 or in_grp_sudo or in_grp_admin) # see if we have any other human users on this system self.has_other_users = False num = 0 for l in pwd.getpwall(): if l.pw_uid >= 500 and l.pw_uid < 65534: num += 1 if num >= 2: self.has_other_users = True break #build the comboboxes (with model) combo = self.combobox_locale_chooser model = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING) cell = Gtk.CellRendererText() combo.pack_start(cell, True) combo.add_attribute(cell, 'text', LANGTREEVIEW_LANGUAGE) combo.set_model(model) # self.combo_syslang_dirty = False # combo = self.combobox_user_language # model = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING) # cell = Gtk.CellRendererText() # combo.pack_start(cell, True) # combo.add_attribute(cell, 'text', COMBO_LANGUAGE) # combo.set_model(model) # self.combo_userlang_dirty = False self.options = options # get aptdaemon client self.ac = aptdaemon.client.AptClient() combo = self.combobox_input_method model = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING) cell = Gtk.CellRendererText() combo.pack_start(cell, True) combo.add_attribute(cell, 'text', IM_NAME) combo.set_model(model) self.ImConfig = ImConfig() self._blockSignals = False # build the treeview self.setupLanguageTreeView() self.setupInstallerTreeView() self.updateLanguageView() # self.updateUserDefaultCombo() self.updateLocaleChooserCombo() self.check_input_methods() # self.updateSyncButton() # apply button self.button_apply.set_sensitive(False) # 'Apply System-Wide...' and 'Install/Remove Languages...' buttons # # Distinction depending on the is_admin test dropped as a # temporary(?) fix of https://launchpad.net/bugs/1008344 # if self.is_admin: self.button_apply_system_wide_languages.set_sensitive(True) self.button_install_remove_languages.set_sensitive(True) self.button_apply_system_wide_locale.set_sensitive(True) # else: # self.button_apply_system_wide_languages.set_sensitive(False) # self.button_install_remove_languages.set_sensitive(False) # self.button_apply_system_wide_locale.set_sensitive(False) # show it self.window_main.show() self.setSensitive(False) if self.is_admin: # check if the package list is up-to-date if not self._cache.havePackageLists: d = Gtk.MessageDialog(message_type=Gtk.MessageType.INFO, buttons=Gtk.ButtonsType.CANCEL) d.set_modal(True) d.set_transient_for(self.window_main) d.set_markup( "<big><b>%s</b></big>\n\n%s" % (_("No language information available"), _("The system does not have information about the " "available languages yet. Do you want to perform " "a network update to get them now? "))) d.set_title = ("") d.add_button(_("_Update"), Gtk.ResponseType.YES) res = d.run() d.destroy() if res == Gtk.ResponseType.YES: self.setSensitive(False) self.update() self.updateLanguageView() self.setSensitive(True) # see if something is missing if self.options.verify_installed: self.verifyInstalledLangPacks() if not self.ImConfig.available(): self.combobox_input_method.set_sensitive(False) self.setSensitive(True)