def plugin_translate(self, lang): PreparePageBase.plugin_translate(self, lang) frontend = self.controller._wizard frontend.status_label.set_text( self.controller.get_string('ubiquity/text/preparing_ud_label', lang)) release = misc.get_release() self.prepare_nonfree_software.set_label( gettext.dgettext("mintreport", "Install multimedia codecs")) self.prepare_foss_disclaimer.set_label( gettext.dgettext( "mintreport", "Multimedia codecs are required to play some video formats and to properly render some websites." )) from gi.repository import Gtk for widget in [ self.prepare_download_updates, self.label_required_space, self.label_free_space ]: text = i18n.get_string(Gtk.Buildable.get_name(widget), lang) text = text.replace('${RELEASE}', release.name) widget.set_label(text)
def on_link_clicked(self, widget, uri): # Connected in glade. lang = self.get_language() if not lang: lang = 'C' lang = lang.split('.')[0] # strip encoding if uri == 'update': if self.updating_installer: return True self.updating_installer = True if not auto_update.update(self.controller._wizard): # no updates, so don't check again if self.release_notes_url: text = i18n.get_string('release_notes_only', lang) self.release_notes_label.set_markup(text) else: self.release_notes_label.hide() self.updating_installer = False elif uri == 'release-notes': import subprocess uri = self.release_notes_url.replace('${LANG}', lang) subprocess.Popen(['sensible-browser', uri], close_fds=True, preexec_fn=misc.drop_all_privileges) return True
def on_link_clicked(self, widget, uri): # Connected in glade. lang = self.get_language() if not lang: lang = 'C' lang = lang.split('.')[0] # strip encoding if uri == 'update': if self.updating_installer: return True self.updating_installer = True if not auto_update.update(self.controller._wizard): # no updates, so don't check again if self.release_notes_url: text = i18n.get_string('release_notes_only', lang) self.release_notes_label.set_markup(text) else: self.release_notes_label.hide() self.updating_installer = False elif uri == 'release-notes': import subprocess # uri = self.release_notes_url.replace('${LANG}', lang) #subprocess.Popen(['sensible-browser', uri], close_fds=True, # preexec_fn=misc.drop_all_privileges) uri = '/cdrom/.disk/release_notes_url' subprocess.Popen(['/usr/bin/gedit', uri], close_fds=True, preexec_fn=misc.drop_all_privileges) #change by wangjingsi return True
def on_language_selection_changed(self): lang = self.selected_language() if not lang: return # strip encoding; we use UTF-8 internally no matter what lang = lang.split('.')[0] self.controller.translate(lang) if not self.only: release = misc.get_release() install_medium = misc.get_install_medium() install_medium = i18n.get_string(install_medium, lang) for widget in (self.page.try_install_text_label, self.page.try_ubuntu, self.page.install_ubuntu, self.page.alpha_warning_label): text = widget.text() text = text.replace('${RELEASE}', release.name) text = text.replace('${MEDIUM}', install_medium) text = text.replace('Ubuntu', 'Kubuntu') widget.setText(text) self.update_release_notes_label() for w in self.widgetHidden: w.show() self.widgetHidden = []
def get_string(self, name, lang=None, prefix=None): """Get the string name in the given lang or a default.""" if lang is None: lang = self.locale if lang is None and 'LANG' in os.environ: lang = os.environ['LANG'] return i18n.get_string(name, lang, prefix)
def plugin_translate(self, lang): PreparePageBase.plugin_translate(self, lang) release = misc.get_release() from gi.repository import Gtk for widget in [self.prepare_foss_disclaimer]: text = i18n.get_string(Gtk.Buildable.get_name(widget), lang) text = text.replace('${RELEASE}', release.name) widget.set_label(text)
def update_release_notes_label(self): lang = self.selected_language() if not lang: return # strip encoding; we use UTF-8 internally no matter what lang = lang.split('.')[0] # Either leave the release notes label alone (both release notes and a # critical update are available), set it to just the release notes, # just the critical update, or neither, as appropriate. if self.page.release_notes_label: if self.release_notes_found and self.update_installer: text = i18n.get_string('release_notes_label', lang) self.page.release_notes_label.setText(text) elif self.release_notes_found: text = i18n.get_string('release_notes_only', lang) self.page.release_notes_label.setText(text) elif self.update_installer: text = i18n.get_string('update_installer_only', lang) self.page.release_notes_label.setText(text)
def on_language_selection_changed(self, *args, **kwargs): lang = self.get_language() if not lang: return # strip encoding; we use UTF-8 internally no matter what lang = lang.split(".")[0] self.controller.translate(lang) import gtk ltr = i18n.get_string("default-ltr", lang, "ubiquity/imported") if ltr == "default:RTL": gtk.widget_set_default_direction(gtk.TEXT_DIR_RTL) else: gtk.widget_set_default_direction(gtk.TEXT_DIR_LTR) if not self.only: release_name = misc.get_release_name() install_medium = misc.get_install_medium() install_medium = i18n.get_string(install_medium, lang) for widget in ( self.try_text_label, self.try_ubuntu, self.install_ubuntu, self.ready_text_label, self.alpha_warning_label, ): text = i18n.get_string(gtk.Buildable.get_name(widget), lang) text = text.replace("${RELEASE}", release_name) text = text.replace("${MEDIUM}", install_medium) widget.set_label(text) if self.release_notes_label: if self.release_notes_url and self.update_installer: pass elif self.release_notes_url: text = i18n.get_string("release_notes_only", lang) self.release_notes_label.set_markup(text) elif self.update_installer: text = i18n.get_string("update_installer_only", lang) self.release_notes_label.set_markup(text) else: self.release_notes_label.hide() for w in self.page.get_children(): w.show()
def plugin_translate(self, lang): PreparePageBase.plugin_translate(self, lang) release = misc.get_release() from gi.repository import Gtk for widget in [self.prepare_download_updates, self.label_required_space, self.label_free_space]: text = i18n.get_string(Gtk.Buildable.get_name(widget), lang) text = text.replace('${RELEASE}', release.name) widget.set_label(text)
def on_release_notes_link(self, link): lang = self.selected_language() if link == "release-notes": if lang: lang = lang.split(".")[0].lower() url = self.release_notes_url.replace("${LANG}", lang) self.openURL(url) elif link == "update": if not auto_update.update(self.controller._wizard): # no updates, so don't check again text = i18n.get_string("release_notes_only", lang) self.page.release_notes_label.setText(text)
def on_release_notes_link(self, link): lang = self.selected_language() if link == "release-notes": if lang: lang = lang.split('.')[0].lower() url = self.release_notes_url.replace('${LANG}', lang) self.openURL(url) elif link == "update": if not auto_update.update(self.controller._wizard): # no updates, so don't check again text = i18n.get_string('release_notes_only', lang) self.page.release_notes_label.setText(text)
def on_language_selection_changed(self, *args, **kwargs): lang = self.get_language() if not lang: return # strip encoding; we use UTF-8 internally no matter what lang = lang.split('.')[0] self.controller.translate(lang) import gtk ltr = i18n.get_string('default-ltr', lang, 'ubiquity/imported') if ltr == 'default:RTL': gtk.widget_set_default_direction(gtk.TEXT_DIR_RTL) else: gtk.widget_set_default_direction(gtk.TEXT_DIR_LTR) if not self.only: release_name = misc.get_release_name() install_medium = misc.get_install_medium() install_medium = i18n.get_string(install_medium, lang) for widget in (self.try_text_label, self.try_ubuntu, self.install_ubuntu, self.ready_text_label, self.alpha_warning_label): text = i18n.get_string(gtk.Buildable.get_name(widget), lang) text = text.replace('${RELEASE}', release_name) text = text.replace('${MEDIUM}', install_medium) widget.set_label(text) if self.release_notes_label: if self.release_notes_url and self.update_installer: pass elif self.release_notes_url: text = i18n.get_string('release_notes_only', lang) self.release_notes_label.set_markup(text) elif self.update_installer: text = i18n.get_string('update_installer_only', lang) self.release_notes_label.set_markup(text) else: self.release_notes_label.hide() for w in self.page.get_children(): w.show()
def on_release_notes_link(self, link): lang = self.selected_language() if link == "release-notes": if lang: lang = lang.split('.')[0].lower() url = self.release_notes_url.replace('${LANG}', lang) self.openURL(url) elif link == "update": if self.updating_installer: return self.updating_installer = True if not auto_update.update(self.controller._wizard): # no updates, so don't check again text = i18n.get_string('release_notes_only', lang) self.page.release_notes_label.setText(text) self.updating_installer = False
def on_link_clicked(self, widget, uri): # Connected in glade. lang = self.get_language() lang = lang.split(".")[0] # strip encoding if uri == "update": if not auto_update.update(self.controller._wizard): # no updates, so don't check again if self.release_notes_url: text = i18n.get_string("release_notes_only", lang) self.release_notes_label.set_markup(text) else: self.release_notes_label.hide() elif uri == "release-notes": import subprocess uri = self.release_notes_url.replace("${LANG}", lang) subprocess.Popen(["sensible-browser", uri], close_fds=True, preexec_fn=misc.drop_all_privileges) return True
def on_link_clicked(self, widget, uri): # Connected in glade. lang = self.get_language() if not lang: lang = 'C' lang = lang.split('.')[0] # strip encoding if uri == 'update': if self.updating_installer: return True self.updating_installer = True if not auto_update.update(self.controller._wizard): # no updates, so don't check again if self.release_notes_url: text = i18n.get_string('release_notes_only', lang) self.release_notes_label.set_markup(text) else: self.release_notes_label.hide() self.updating_installer = False elif uri == 'release-notes': uri = self.release_notes_url.replace('${LANG}', lang) misc.launch_uri(uri) return True
def on_language_selection_changed(self, *args, **kwargs): lang = self.get_language() self.controller.allow_go_forward(bool(lang)) if not lang: return if 'UBIQUITY_GREETER' in os.environ: misc.set_indicator_keymaps(lang) # strip encoding; we use UTF-8 internally no matter what lang = lang.split('.')[0] self.controller.translate(lang) from gi.repository import Gtk ltr = i18n.get_string('default-ltr', lang, 'ubiquity/imported') if ltr == 'default:RTL': Gtk.Widget.set_default_direction(Gtk.TextDirection.RTL) else: Gtk.Widget.set_default_direction(Gtk.TextDirection.LTR) if self.only: # The language page for oem-config doesn't have the fancy greeter. return # TODO: Cache these. release = misc.get_release() install_medium = misc.get_install_medium() install_medium = i18n.get_string(install_medium, lang) # Set the release name (Linux Mint 10.04) and medium (USB or CD) where # necessary. w = self.try_install_text_label text = i18n.get_string(Gtk.Buildable.get_name(w), lang) text = text.replace('${RELEASE}', release.name) text = text.replace('${MEDIUM}', install_medium) w.set_label(text) # Big buttons. for w in (self.try_ubuntu, self.install_ubuntu): text = i18n.get_string(Gtk.Buildable.get_name(w), lang) text = text.replace('${RELEASE}', release.name) text = text.replace('${MEDIUM}', install_medium) w.get_child().set_markup('<span size="x-large">%s</span>' % text) # We need to center each button under each image *and* have a homogeous # size between the two buttons. self.try_ubuntu.set_size_request(-1, -1) self.install_ubuntu.set_size_request(-1, -1) try_w = self.try_ubuntu.size_request().width install_w = self.install_ubuntu.size_request().width if try_w > install_w: self.try_ubuntu.set_size_request(try_w, -1) self.install_ubuntu.set_size_request(try_w, -1) elif install_w > try_w: self.try_ubuntu.set_size_request(install_w, -1) self.install_ubuntu.set_size_request(install_w, -1) # Make the forward button a consistent size, regardless of its text. install_label = i18n.get_string('install_button', lang) next_button = self.controller._wizard.next next_label = next_button.get_label() next_button.set_size_request(-1, -1) next_w = next_button.size_request().width next_button.set_label(install_label) install_w = next_button.size_request().width next_button.set_label(next_label) if next_w > install_w: next_button.set_size_request(next_w, -1) else: next_button.set_size_request(install_w, -1) self.update_release_notes_label() for w in self.page.get_children(): w.show()
def progress_loop(self): """prepare, copy and config the system in the core install process.""" syslog.syslog('progress_loop()') self.current_page = None slideshow_dir = '/usr/share/ubiquity-slideshow' slideshow_locale = self.slideshow_get_available_locale(slideshow_dir, self.locale) slideshow_main = slideshow_dir + '/slides/index.html' s = self.app.desktop().availableGeometry() fail = None if os.path.exists(slideshow_main): if s.height >= 600 and s.width >= 800: slides = 'file://' + slideshow_main if slideshow_locale != 'c': #slideshow will use default automatically slides += '#?locale=' + slideshow_locale ltr = i18n.get_string('default-ltr', slideshow_locale, 'ubiquity/imported') if ltr == 'default:RTL': slides += '?rtl' try: from PyQt4.QtWebKit import QWebView from PyQt4.QtWebKit import QWebPage def openLink(qUrl): QDesktopServices.openUrl(qUrl) webView = QWebView() webView.linkClicked.connect(openLink) webView.setContextMenuPolicy(Qt.NoContextMenu) webView.page().setLinkDelegationPolicy(QWebPage.DelegateExternalLinks) webView.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff) webView.page().mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff) webView.setFixedSize(700,420) webView.load(QUrl(slides)) #add the webview to the extra frame of the progress dialog self.progressDialog.extraFrame.layout().addWidget(webView) self.progressDialog.extraFrame.setVisible(True) except ImportError: fail = 'Webkit not present.' else: fail = 'Display < 800x600 (%sx%s).' % (s.width, s.height) else: fail = 'No slides present for %s.' % slideshow_dir if fail: syslog.syslog('Not displaying the slideshow: %s' % fail) self.progressDialog.show() self.debconf_progress_start( 0, 100, self.get_string('ubiquity/install/title')) self.debconf_progress_region(0, 15) if not self.oem_user_config: self.start_debconf() dbfilter = partman_commit.PartmanCommit(self) if dbfilter.run_command(auto_process=True) != 0: while self.progress_position.depth() != 0: self.debconf_progress_stop() self.progressDialog.hide() self.return_to_partitioning() return # No return to partitioning from now on self.installing_no_return = True self.debconf_progress_region(15, 100) self.start_debconf() dbfilter = install.Install(self) ret = dbfilter.run_command(auto_process=True) if ret != 0: self.installing = False if ret == 3: # error already handled by Install sys.exit(ret) elif (os.WIFSIGNALED(ret) and os.WTERMSIG(ret) in (signal.SIGINT, signal.SIGKILL, signal.SIGTERM)): sys.exit(ret) elif os.path.exists('/var/lib/ubiquity/install.trace'): tbfile = open('/var/lib/ubiquity/install.trace') realtb = tbfile.read() tbfile.close() raise RuntimeError, ("Install failed with exit code %s\n%s" % (ret, realtb)) else: raise RuntimeError, ("Install failed with exit code %s; see " "/var/log/syslog" % ret) while self.progress_position.depth() != 0: self.debconf_progress_stop() # just to make sure self.progressDialog.hide() self.installing = False quitText = '<qt>%s</qt>' % self.get_string("finished_label") rebootButtonText = self.get_string("reboot_button") quitButtonText = self.get_string("quit_button") titleText = self.get_string("finished_dialog") ##FIXME use non-stock messagebox to customise button text #quitAnswer = QMessageBox.question(self.ui, titleText, quitText, rebootButtonText, quitButtonText) self.run_success_cmd() if self.oem_user_config: self.quit() elif not self.get_reboot_seen(): if ('UBIQUITY_ONLY' in os.environ or 'UBIQUITY_GREETER' in os.environ): quitText = self.get_string('ubiquity/finished_restart_only') messageBox = QMessageBox(QMessageBox.Question, titleText, quitText, QMessageBox.NoButton, self.ui) messageBox.addButton(rebootButtonText, QMessageBox.AcceptRole) if ('UBIQUITY_ONLY' not in os.environ and 'UBIQUITY_GREETER' not in os.environ): messageBox.addButton(quitButtonText, QMessageBox.RejectRole) messageBox.setWindowFlags(messageBox.windowFlags() | Qt.WindowStaysOnTopHint) quitAnswer = messageBox.exec_() if quitAnswer == 0: self.reboot() elif self.get_reboot(): self.reboot()
def on_language_selection_changed(self, *args, **kwargs): lang = self.get_language() self.controller.allow_go_forward(bool(lang)) if not lang: return if 'UBIQUITY_GREETER' in os.environ: misc.set_indicator_keymaps(lang) # strip encoding; we use UTF-8 internally no matter what lang = lang.split('.')[0] self.controller.translate(lang) from gi.repository import Gtk ltr = i18n.get_string('default-ltr', lang, 'ubiquity/imported') if ltr == 'default:RTL': Gtk.Widget.set_default_direction(Gtk.TextDirection.RTL) else: Gtk.Widget.set_default_direction(Gtk.TextDirection.LTR) if self.only: # The language page for oem-config doesn't have the fancy greeter. return # TODO: Cache these. release = misc.get_release() install_medium = misc.get_install_medium() install_medium = i18n.get_string(install_medium, lang) # Set the release name (Ubuntu 10.04) and medium (USB or CD) where # necessary. w = self.try_install_text_label text = i18n.get_string(Gtk.Buildable.get_name(w), lang) text = text.replace('${RELEASE}', release.name) text = text.replace('${MEDIUM}', install_medium) w.set_label(text) # Big buttons. for w in (self.try_ubuntu, self.install_ubuntu): text = i18n.get_string(Gtk.Buildable.get_name(w), lang) text = text.replace('${RELEASE}', release.name) text = text.replace('${MEDIUM}', install_medium) w.get_child().set_markup('<span size="x-large">%s</span>' % text) # We need to center each button under each image *and* have a homogeous # size between the two buttons. self.try_ubuntu.set_size_request(-1, -1) self.install_ubuntu.set_size_request(-1, -1) try_w = self.try_ubuntu.size_request().width install_w = self.install_ubuntu.size_request().width if try_w > install_w: self.try_ubuntu.set_size_request(try_w, -1) self.install_ubuntu.set_size_request(try_w, -1) elif install_w > try_w: self.try_ubuntu.set_size_request(install_w, -1) self.install_ubuntu.set_size_request(install_w, -1) # Make the forward button a consistent size, regardless of its text. install_label = i18n.get_string('install_button', lang) next_button = self.controller._wizard.next next_label = next_button.get_label() next_button.set_size_request(-1, -1) next_w = next_button.size_request().width next_button.set_label(install_label) install_w = next_button.size_request().width next_button.set_label(next_label) if next_w > install_w: next_button.set_size_request(next_w, -1) else: next_button.set_size_request(install_w, -1) self.update_release_notes_label() for w in self.page.get_children(): w.show()
def plugin_translate(self, lang): self.login_encrypt.set_label( i18n.get_string('mint:Encrypt my home folder', lang))
def plugin_translate(self, lang): self.rst_title_text = i18n.get_string('rst_header', lang) return
def plugin_translate(self, lang): self.hostname_error_text = i18n.get_string('hostname_error', lang) self.domain_connection_error_text = i18n.get_string( 'domain_connection_error', lang) self.login_encrypt.set_label( i18n.get_string('mint:Encrypt my home folder', lang))
def get_string(self, name, lang=None): """Get the string name in the given lang or a default.""" if lang is None: lang = self.locale return i18n.get_string(name, lang)