def changed(self, entry):
        from gi.repository import Gtk, GObject, GLib, Soup

        text = misc.utf8(self.city_entry.get_text())
        if not text:
            return
        # TODO if the completion widget has a selection, return?  How do we
        # determine this?
        if text in self.geoname_cache:
            model = self.geoname_cache[text]
            self.city_entry.get_completion().set_model(model)
        else:
            model = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING,
                                  GObject.TYPE_STRING, GObject.TYPE_STRING,
                                  GObject.TYPE_STRING)

            if self.geoname_session is None:
                self.geoname_session = Soup.SessionAsync()
            url = _geoname_url % (quote(text), misc.get_release().version)
            message = Soup.Message.new('GET', url)
            message.request_headers.append('User-agent', 'Ubiquity/1.0')
            self.geoname_session.abort()
            if self.geoname_timeout_id is not None:
                GLib.source_remove(self.geoname_timeout_id)
            self.geoname_timeout_id = \
                GLib.timeout_add_seconds(2, self.geoname_timeout,
                                         (text, model))
            self.geoname_session.queue_message(message, self.geoname_cb,
                                               (text, model))
示例#2
0
    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 = []
示例#3
0
    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)
示例#4
0
    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 = []
示例#5
0
 def test_get_release(self, mock_open):
     magic = mock.MagicMock(spec=io.TextIOBase)
     magic.__enter__.return_value = magic
     mock_open.return_value = magic
     magic.readline.return_value = _disk_info
     release = misc.get_release()
     self.assertEqual(release.name, 'Ubuntu Server')
     self.assertEqual(release.version, '10.04.1 LTS')
示例#6
0
 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)
示例#7
0
 def test_get_release(self, mock_open):
     magic = mock.MagicMock(spec=io.TextIOBase)
     magic.__enter__.return_value = magic
     mock_open.return_value = magic
     magic.readline.return_value = _disk_info
     release = misc.get_release()
     self.assertEqual(release.name, 'Ubuntu Server')
     self.assertEqual(release.version, '10.04.1 LTS')
示例#8
0
 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)
示例#9
0
 def plugin_translate(self, lang):
     PreparePageBase.plugin_translate(self, lang)
     #gtk does the ${RELEASE} replace for the title in gtk_ui but we do it per plugin because our title widget is per plugin
     #also add Bold here (not sure how the gtk side keeps that formatting)
     release = misc.get_release()
     for widget in (self.page.prepare_heading_label, self.page.prepare_best_results, self.page.prepare_foss_disclaimer):
         text = widget.text()
         text = text.replace('${RELEASE}', release.name)
         text = text.replace('Ubuntu', 'Kubuntu')
         text = "<b>" + text + "</b>"
         widget.setText(text)
示例#10
0
    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 plugin_translate(self, lang):
     PreparePageBase.plugin_translate(self, lang)
     #gtk does the ${RELEASE} replace for the title in gtk_ui but we do it per plugin because our title widget is per plugin
     #also add Bold here (not sure how the gtk side keeps that formatting)
     release = misc.get_release()
     for widget in (self.page.prepare_heading_label,
                    self.page.prepare_best_results,
                    self.page.prepare_foss_disclaimer):
         text = widget.text()
         text = text.replace('${RELEASE}', release.name)
         text = text.replace('Ubuntu', 'Kubuntu')
         text = "<b>" + text + "</b>"
         widget.setText(text)
示例#12
0
 def plugin_translate(self, lang):
     PreparePageBase.plugin_translate(self, lang)
     # gtk does the ${RELEASE} replace for the title in gtk_ui but we do
     # it per plugin because our title widget is per plugin
     release = misc.get_release()
     widgets = (
         self.page.prepare_heading_label,
         self.page.prepare_download_updates,
     )
     for widget in widgets:
         text = widget.text()
         text = text.replace('${RELEASE}', release.name)
         text = text.replace('Ubuntu', 'Maui')
         widget.setText(text)
示例#13
0
 def plugin_translate(self, lang):
     PreparePageBase.plugin_translate(self, lang)
     # gtk does the ${RELEASE} replace for the title in gtk_ui but we do
     # it per plugin because our title widget is per plugin
     release = misc.get_release()
     widgets = (
         self.page.prepare_heading_label,
         self.page.prepare_best_results,
         self.page.prepare_foss_disclaimer,
     )
     for widget in widgets:
         text = widget.text()
         text = text.replace('${RELEASE}', release.name)
         text = text.replace('Ubuntu', 'Linux Mint')
         widget.setText(text)
示例#14
0
 def plugin_translate(self, lang):
     PreparePageBase.plugin_translate(self, lang)
     # gtk does the ${RELEASE} replace for the title in gtk_ui but we do
     # it per plugin because our title widget is per plugin
     release = misc.get_release()
     widgets = (
         self.page.prepare_heading_label,
         self.page.prepare_best_results,
         self.page.prepare_foss_disclaimer,
     )
     for widget in widgets:
         text = widget.text()
         text = text.replace('${RELEASE}', release.name)
         text = text.replace('Ubuntu', 'Linux Mint')
         widget.setText(text)
示例#15
0
 def plugin_translate(self, lang):
     PreparePageBase.plugin_translate(self, lang)
     # Translate the progress label
     self.progress_indicator.setText(
         self.controller.get_string('ubiquity/text/preparing_ud_label',
                                    lang))
     # gtk does the ${RELEASE} replace for the title in gtk_ui but we do
     # it per plugin because our title widget is per plugin
     release = misc.get_release()
     widgets = (
         self.page.prepare_heading_label,
         self.page.prepare_download_updates,
     )
     for widget in widgets:
         text = widget.text()
         text = text.replace('${RELEASE}', release.name)
         text = text.replace('Linux Mint', 'Kubuntu')
         widget.setText(text)
示例#16
0
        def changed(entry):
            text = entry.get_text()
            if not text:
                return
            # TODO if the completion widget has a selection, return?  How do we determine this?
            if text in changed.cache:
                model = changed.cache[text]
            else:
                # fetch
                model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
                                      gobject.TYPE_STRING, gobject.TYPE_STRING,
                                      gobject.TYPE_STRING)
                changed.cache[text] = model
                # TODO benchmark this
                results = [(name, self.tzdb.get_loc(city))
                            for (name, city) in
                                [(x[0], x[1]) for x in self.zones
                                    if x[0].lower().split('(', 1)[-1] \
                                                    .startswith(text.lower())]]
                for result in results:
                    # We use name rather than loc.human_zone for i18n.
                    # TODO this looks pretty awful for US results:
                    # United States (New York) (United States)
                    # Might want to match the debconf format.
                    name, loc = result
                    model.append([name, '', loc.human_country,
                                  loc.latitude, loc.longitude])

                try:
                    import urllib2, urllib, json
                    opener = urllib2.build_opener()
                    opener.addheaders = [('User-agent', 'Ubiquity/1.0')]
                    url = opener.open(_geoname_url %
                        (urllib.quote(text), misc.get_release().version))
                    for result in json.loads(url.read()):
                        model.append([result['name'],
                                      result['admin1'],
                                      result['country'],
                                      result['latitude'],
                                      result['longitude']])
                except Exception, e:
                    print 'exception:', e
示例#17
0
 def test_get_release_fail(self, mock_open):
     mock_open.side_effect = Exception('Pow!')
     release = misc.get_release()
     self.assertEqual(release.name, 'Ubuntu')
     self.assertEqual(release.version, '')
示例#18
0
    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()
示例#19
0
    def setupChoices(self, choices, extra_options, resize_choice,
                     manual_choice, biggest_free_choice, use_device_choice,
                     lvm_choice, crypto_choice):
        self._clearInfo()

        self.resizeChoice = resize_choice
        self.manualChoice = manual_choice
        self.useDeviceChoice = use_device_choice
        self.extra_options = extra_options
        self.lvm_choice = lvm_choice
        self.crypto_choice = crypto_choice

        # remove any previous autopartition selections
        for child in self.autopart_selection_frame.children():
            if isinstance(child, QtGui.QWidget):
                child.setParent(None)
                del child

        for child in self.barsFrame.children():
            if isinstance(child, QtGui.QWidget):
                self.barsFrame.layout().removeWidget(child)
                child.setParent(None)
                del child

        release_name = misc.get_release().name

        bId = 0
        if 'resize' in extra_options:
            button = QtGui.QRadioButton(
                self.resizeChoice, self.autopart_selection_frame)
            self.autopart_selection_frame.layout().addWidget(button)
            self.autopartition_buttongroup.addButton(button, bId)
            self.autopartitionTexts.append(resize_choice)
            button.clicked.connect(self.controller.setNextButtonTextInstallNow)
            bId += 1

            disks = []
            for disk_id in extra_options['resize']:
                # information about what can be resized
                unused, min_size, max_size, pref_size, \
                resize_path, unused, unused = \
                    extra_options['resize'][disk_id]

                for text, path in extra_options['use_device'][1].items():
                    path = path[0]
                    if path.rsplit('/', 1)[1] == disk_id:
                        bar_frame = QtGui.QFrame()
                        bar_frame.setLayout(QtGui.QVBoxLayout())
                        bar_frame.setVisible(False)
                        bar_frame.layout().setSpacing(0)
                        self.barsFrame.layout().addWidget(bar_frame)
                        self.bar_frames.append(bar_frame)

                        disks.append((text, bar_frame))
                        self.resizeSize = pref_size
                        dev = self.diskLayout[disk_id]
                        before_bar = PartitionsBar()
                        after_bar = PartitionsBar()

                        for p in dev:
                            before_bar.addPartition(p[0], int(p[1]), p[3])
                            after_bar.addPartition(p[0], int(p[1]), p[3])

                        after_bar.setResizePartition(
                            resize_path, min_size, max_size, pref_size,
                            release_name)
                        after_bar.partitionResized.connect(
                            self.on_partitionResized)
                        addBars(bar_frame, before_bar, after_bar)
            self.disks.append(disks)

        # TODO biggest_free_choice

        # Use entire disk.
        button = QtGui.QRadioButton(
            self.useDeviceChoice, self.autopart_selection_frame)
        self.autopartitionTexts.append(self.useDeviceChoice)
        self.autopart_selection_frame.layout().addWidget(button)
        self.autopartition_buttongroup.addButton(button, bId)
        button.clicked.connect(self.controller.setNextButtonTextInstallNow)
        bId += 1

        disks = []
        for text, path in extra_options['use_device'][1].items():
            path = path[0]
            bar_frame = QtGui.QFrame()
            bar_frame.setLayout(QtGui.QVBoxLayout())
            bar_frame.setVisible(False)
            bar_frame.layout().setSpacing(0)
            self.barsFrame.layout().addWidget(bar_frame)
            self.bar_frames.append(bar_frame)

            disks.append((text, bar_frame))

            dev = self.diskLayout[path.rsplit('/', 1)[1]]
            before_bar = PartitionsBar()
            after_bar = PartitionsBar()

            for p in dev:
                before_bar.addPartition(p.device, int(p.size), p.filesystem)
            if before_bar.diskSize > 0:
                after_bar.addPartition(
                    release_name, before_bar.diskSize, 'auto')
            else:
                after_bar.addPartition(release_name, 1, 'auto')

            addBars(bar_frame, before_bar, after_bar)
        self.disks.append(disks)

        #LVM
        button = QtGui.QRadioButton(
            self.lvm_choice, self.autopart_selection_frame)
        self.autopartitionTexts.append(self.lvm_choice)
        self.autopart_selection_frame.layout().addWidget(button)
        self.autopartition_buttongroup.addButton(button, bId)
        button.clicked.connect(self.controller.setNextButtonTextInstallNow)
        bId += 1
        #add use entire disk options to combobox again
        self.disks.append(disks)

        #Crypto
        button = QtGui.QRadioButton(
            self.crypto_choice, self.autopart_selection_frame)
        self.autopartitionTexts.append(self.crypto_choice)
        self.autopart_selection_frame.layout().addWidget(button)
        self.autopartition_buttongroup.addButton(button, bId)
        button.clicked.connect(self.controller.setNextButtonTextInstallNow)
        self.crypto_button_id = bId
        bId += 1
        #add use entire disk options to combobox again
        self.disks.append(disks)

        box = QtGui.QHBoxLayout()
        box.addStretch()
        self.autopart_selection_frame.layout().addLayout(box)

        self.passwordIcon = QtGui.QLabel()
        self.passwordIcon.setPixmap(QtGui.QPixmap(
            "/usr/share/icons/oxygen/16x16/status/dialog-password.png"))
        box.addWidget(self.passwordIcon)
        self.password = QtGui.QLineEdit()
        self.password.setEchoMode(QtGui.QLineEdit.Password)
        self.password.textChanged.connect(self.verify_password)
        box.addWidget(self.password)
        self.verified_password = QtGui.QLineEdit()
        self.verified_password.setEchoMode(QtGui.QLineEdit.Password)
        self.verified_password.textChanged.connect(self.verify_password)
        box.addWidget(self.verified_password)
        self.badPassword = QtGui.QLabel()
        self.badPassword.setPixmap(QtGui.QPixmap(
            "/usr/share/icons/oxygen/16x16/status/dialog-warning.png"))
        self.badPassword.hide()
        box.addWidget(self.badPassword)

        # Manual partitioning.

        button = QtGui.QRadioButton(
            manual_choice, self.autopart_selection_frame)
        self.autopartitionTexts.append(manual_choice)
        self.autopart_selection_frame.layout().addWidget(button)
        self.autopartition_buttongroup.addButton(button, bId)
        button.clicked.connect(self.controller.setNextButtonTextNext)
        self.disks.append([])

        #select the first button
        b = self.autopartition_buttongroup.button(0)
        b and b.click()
示例#20
0
    def setupChoices(self, choices, extra_options, resize_choice,
                     manual_choice, biggest_free_choice, use_device_choice,
                     lvm_choice, crypto_choice):
        self._clearInfo()

        self.resizeChoice = resize_choice
        self.manualChoice = manual_choice
        self.useDeviceChoice = use_device_choice
        self.extra_options = extra_options
        self.lvm_choice = lvm_choice
        self.crypto_choice = crypto_choice

        # remove any previous autopartition selections
        for child in self.autopart_selection_frame.children():
            if isinstance(child, QtWidgets.QWidget):
                child.setParent(None)
                del child

        for child in self.barsFrame.children():
            if isinstance(child, QtWidgets.QWidget):
                self.barsFrame.layout().removeWidget(child)
                child.setParent(None)
                del child

        release_name = misc.get_release().name

        bId = 0
        if 'resize' in extra_options:
            button = QtWidgets.QRadioButton(self.resizeChoice,
                                            self.autopart_selection_frame)
            self.autopart_selection_frame.layout().addWidget(button)
            self.autopartition_buttongroup.addButton(button, bId)
            self.autopartitionTexts.append(resize_choice)
            button.clicked.connect(self.controller.setNextButtonTextInstallNow)
            bId += 1

            disks = []
            for disk_id in extra_options['resize']:
                # information about what can be resized
                _, min_size, max_size, pref_size, resize_path, _, _ = (
                    extra_options['resize'][disk_id])

                for text, path in extra_options['use_device'][1].items():
                    path = path[0]
                    if path.rsplit('/', 1)[1] == disk_id:
                        bar_frame = QtWidgets.QFrame()
                        bar_frame.setLayout(QtWidgets.QVBoxLayout())
                        bar_frame.setVisible(False)
                        bar_frame.layout().setSpacing(0)
                        self.barsFrame.layout().addWidget(bar_frame)
                        self.bar_frames.append(bar_frame)

                        disks.append((text, bar_frame))
                        self.resizeSize = pref_size
                        dev = self.diskLayout[disk_id]
                        before_bar = PartitionsBar()
                        after_bar = PartitionsBar()

                        for p in dev:
                            before_bar.addPartition(p[0], int(p[1]), p[3])
                            after_bar.addPartition(p[0], int(p[1]), p[3])

                        after_bar.setResizePartition(resize_path, min_size,
                                                     max_size, pref_size,
                                                     release_name)
                        after_bar.partitionResized.connect(
                            self.on_partitionResized)
                        addBars(bar_frame, before_bar, after_bar)
            self.disks.append(disks)

        # TODO biggest_free_choice

        # Use entire disk.
        button = QtWidgets.QRadioButton(self.useDeviceChoice,
                                        self.autopart_selection_frame)
        self.autopartitionTexts.append(self.useDeviceChoice)
        self.autopart_selection_frame.layout().addWidget(button)
        self.autopartition_buttongroup.addButton(button, bId)
        button.clicked.connect(self.controller.setNextButtonTextInstallNow)
        bId += 1

        disks = []
        for text, path in extra_options['use_device'][1].items():
            path = path[0]
            bar_frame = QtWidgets.QFrame()
            bar_frame.setLayout(QtWidgets.QVBoxLayout())
            bar_frame.setVisible(False)
            bar_frame.layout().setSpacing(0)
            self.barsFrame.layout().addWidget(bar_frame)
            self.bar_frames.append(bar_frame)

            disks.append((text, bar_frame))

            dev = self.diskLayout[path.rsplit('/', 1)[1]]
            before_bar = PartitionsBar(controller=self.controller)
            after_bar = PartitionsBar(controller=self.controller)

            for p in dev:
                before_bar.addPartition(p.device, int(p.size), p.filesystem)
            if before_bar.diskSize > 0:
                after_bar.addPartition('',
                                       before_bar.diskSize,
                                       'auto',
                                       name=release_name)
            else:
                after_bar.addPartition('', 1, 'auto', name=release_name)

            addBars(bar_frame, before_bar, after_bar)
        self.disks.append(disks)

        # LVM
        button = QtWidgets.QRadioButton(self.lvm_choice,
                                        self.autopart_selection_frame)
        self.autopartitionTexts.append(self.lvm_choice)
        self.autopart_selection_frame.layout().addWidget(button)
        self.autopartition_buttongroup.addButton(button, bId)
        button.clicked.connect(self.controller.setNextButtonTextInstallNow)
        bId += 1
        # add use entire disk options to combobox again
        self.disks.append(disks)

        # Crypto
        button = QtWidgets.QRadioButton(self.crypto_choice,
                                        self.autopart_selection_frame)
        self.autopartitionTexts.append(self.crypto_choice)
        self.autopart_selection_frame.layout().addWidget(button)
        self.autopartition_buttongroup.addButton(button, bId)
        button.clicked.connect(self.controller.setNextButtonTextInstallNow)
        self.crypto_button_id = bId
        bId += 1
        # add use entire disk options to combobox again
        self.disks.append(disks)

        box = QtWidgets.QHBoxLayout()
        box.addStretch()
        self.autopart_selection_frame.layout().addLayout(box)

        self.passwordIcon = QtWidgets.QLabel()
        self.passwordIcon.setPixmap(
            QtGui.QPixmap(
                "/usr/share/icons/oxygen/16x16/status/dialog-password.png"))
        box.addWidget(self.passwordIcon)
        self.password = QtWidgets.QLineEdit()
        self.password.setEchoMode(QtWidgets.QLineEdit.Password)
        self.password.textChanged.connect(self.verify_password)
        box.addWidget(self.password)
        self.verified_password = QtWidgets.QLineEdit()
        self.verified_password.setEchoMode(QtWidgets.QLineEdit.Password)
        self.verified_password.textChanged.connect(self.verify_password)
        box.addWidget(self.verified_password)
        self.badPassword = QtWidgets.QLabel()
        self.badPassword.setPixmap(
            QtGui.QPixmap(
                "/usr/share/icons/oxygen/16x16/status/dialog-warning.png"))
        self.badPassword.hide()
        box.addWidget(self.badPassword)

        # Manual partitioning.

        button = QtWidgets.QRadioButton(manual_choice,
                                        self.autopart_selection_frame)
        self.autopartitionTexts.append(manual_choice)
        self.autopart_selection_frame.layout().addWidget(button)
        self.autopartition_buttongroup.addButton(button, bId)
        button.clicked.connect(self.controller.setNextButtonTextNext)
        self.disks.append([])

        # select the first button
        b = self.autopartition_buttongroup.button(0)
        b and b.click()
    def setupChoices (self, choices, extra_options, resize_choice,
                      manual_choice, biggest_free_choice, use_device_choice):
        self._clearInfo()

        self.resizeChoice = resize_choice
        self.manualChoice = manual_choice
        self.useDeviceChoice = use_device_choice
        self.extra_options = extra_options

        # remove any previous autopartition selections
        for child in self.autopart_selection_frame.children():
            if isinstance(child, QtGui.QWidget):
                child.setParent(None)
                del child

        for child in self.barsFrame.children():
            if isinstance(child, QtGui.QWidget):
                self.barsFrame.layout().removeWidget(child)
                child.setParent(None)
                del child

        release_name = misc.get_release().name

        bId = 0
        if 'resize' in extra_options:
            button = QtGui.QRadioButton(self.resizeChoice, self.autopart_selection_frame)
            self.autopart_selection_frame.layout().addWidget(button)
            self.autopartition_buttongroup.addButton(button, bId)
            self.autopartitionTexts.append(resize_choice)
            button.clicked.connect(self.controller.setNextButtonTextInstallNow)
            bId += 1

            disks = []
            for disk_id in extra_options['resize']:
                # information about what can be resized
                unused, min_size, max_size, pref_size, \
                resize_path, unused, unused = \
                    extra_options['resize'][disk_id]

                for text, path in extra_options['use_device'][1].items():
                    path = path[0]
                    if path.rsplit('/', 1)[1] == disk_id:
                        bar_frame = QtGui.QFrame()
                        bar_frame.setLayout(QtGui.QVBoxLayout())
                        bar_frame.setVisible(False)
                        bar_frame.layout().setSpacing(0)
                        self.barsFrame.layout().addWidget(bar_frame)
                        self.bar_frames.append(bar_frame)

                        disks.append((text, bar_frame))
                        self.resizeSize = pref_size
                        dev = self.diskLayout[disk_id]
                        before_bar = PartitionsBar()
                        after_bar = PartitionsBar()

                        for p in dev:
                            before_bar.addPartition(p[0], int(p[1]), p[3])
                            after_bar.addPartition(p[0], int(p[1]), p[3])

                        after_bar.setResizePartition(resize_path,
                            min_size, max_size, pref_size, release_name)
                        after_bar.partitionResized.connect(self.on_partitionResized)
                        addBars(bar_frame, before_bar, after_bar)
            self.disks.append(disks)

        # TODO biggest_free_choice

        # Use entire disk.
        button = QtGui.QRadioButton(self.useDeviceChoice, self.autopart_selection_frame)
        self.autopartitionTexts.append(self.useDeviceChoice)
        self.autopart_selection_frame.layout().addWidget(button)
        self.autopartition_buttongroup.addButton(button, bId)
        button.clicked.connect(self.controller.setNextButtonTextInstallNow)
        bId += 1

        disks = []
        for text, path in extra_options['use_device'][1].items():
            path = path[0]
            bar_frame = QtGui.QFrame()
            bar_frame.setLayout(QtGui.QVBoxLayout())
            bar_frame.setVisible(False)
            bar_frame.layout().setSpacing(0)
            self.barsFrame.layout().addWidget(bar_frame)
            self.bar_frames.append(bar_frame)

            disks.append((text, bar_frame))

            dev = self.diskLayout[path.rsplit('/', 1)[1]]
            before_bar = PartitionsBar()
            after_bar = PartitionsBar()

            for p in dev:
                before_bar.addPartition(p.device, int(p.size), p.filesystem)
            if before_bar.diskSize > 0:
                after_bar.addPartition(release_name, before_bar.diskSize, 'auto')
            else:
                after_bar.addPartition(release_name, 1, 'auto')

            addBars(bar_frame, before_bar, after_bar)
        self.disks.append(disks)

        # Manual partitioning.

        button = QtGui.QRadioButton(manual_choice, self.autopart_selection_frame)
        self.autopartitionTexts.append(manual_choice)
        self.autopart_selection_frame.layout().addWidget(button)
        self.autopartition_buttongroup.addButton(button, bId)
        button.clicked.connect(self.controller.setNextButtonTextNext)
        self.disks.append([])

        #select the first button
        b = self.autopartition_buttongroup.button(0)
        b and b.click()
示例#22
0
    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()
示例#23
0
 def apply_debconf_branding(self):
     release = misc.get_release()
     for template in ['ubiquity/text/required_space',
                      'ubiquity/text/free_space']:
         self.db.subst(template, 'RELEASE', release.name)
示例#24
0
    def setupChoices(self, choices, extra_options, resize_choice,
                     manual_choice, biggest_free_choice, use_device_choice):
        self._clearInfo()

        self.resizeChoice = resize_choice
        self.manualChoice = manual_choice
        self.useDeviceChoice = use_device_choice
        self.extra_options = extra_options

        # remove any previous autopartition selections
        for child in self.autopart_selection_frame.children():
            if isinstance(child, QtGui.QWidget):
                child.setParent(None)
                del child

        for child in self.barsFrame.children():
            if isinstance(child, QtGui.QWidget):
                self.barsFrame.layout().removeWidget(child)
                child.setParent(None)
                del child

        release_name = misc.get_release().name

        bId = 0
        if 'resize' in extra_options:
            button = QtGui.QRadioButton(self.resizeChoice,
                                        self.autopart_selection_frame)
            self.autopart_selection_frame.layout().addWidget(button)
            self.autopartition_buttongroup.addButton(button, bId)
            self.autopartitionTexts.append(resize_choice)
            button.clicked.connect(self.controller.setNextButtonTextInstallNow)
            bId += 1

            disks = []
            for disk_id in extra_options['resize']:
                # information about what can be resized
                unused, min_size, max_size, pref_size, \
                resize_path, unused, unused = \
                    extra_options['resize'][disk_id]

                for text, path in extra_options['use_device'][1].items():
                    path = path[0]
                    if path.rsplit('/', 1)[1] == disk_id:
                        bar_frame = QtGui.QFrame()
                        bar_frame.setLayout(QtGui.QVBoxLayout())
                        bar_frame.setVisible(False)
                        bar_frame.layout().setSpacing(0)
                        self.barsFrame.layout().addWidget(bar_frame)
                        self.bar_frames.append(bar_frame)

                        disks.append((text, bar_frame))
                        self.resizeSize = pref_size
                        dev = self.diskLayout[disk_id]
                        before_bar = PartitionsBar()
                        after_bar = PartitionsBar()

                        for p in dev:
                            before_bar.addPartition(p[0], int(p[1]), p[3])
                            after_bar.addPartition(p[0], int(p[1]), p[3])

                        after_bar.setResizePartition(resize_path, min_size,
                                                     max_size, pref_size,
                                                     release_name)
                        after_bar.partitionResized.connect(
                            self.on_partitionResized)
                        addBars(bar_frame, before_bar, after_bar)
            self.disks.append(disks)

        # TODO biggest_free_choice

        # Use entire disk.
        button = QtGui.QRadioButton(self.useDeviceChoice,
                                    self.autopart_selection_frame)
        self.autopartitionTexts.append(self.useDeviceChoice)
        self.autopart_selection_frame.layout().addWidget(button)
        self.autopartition_buttongroup.addButton(button, bId)
        button.clicked.connect(self.controller.setNextButtonTextInstallNow)
        bId += 1

        disks = []
        for text, path in extra_options['use_device'][1].items():
            path = path[0]
            bar_frame = QtGui.QFrame()
            bar_frame.setLayout(QtGui.QVBoxLayout())
            bar_frame.setVisible(False)
            bar_frame.layout().setSpacing(0)
            self.barsFrame.layout().addWidget(bar_frame)
            self.bar_frames.append(bar_frame)

            disks.append((text, bar_frame))

            dev = self.diskLayout[path.rsplit('/', 1)[1]]
            before_bar = PartitionsBar()
            after_bar = PartitionsBar()

            for p in dev:
                before_bar.addPartition(p.device, int(p.size), p.filesystem)
            if before_bar.diskSize > 0:
                after_bar.addPartition(release_name, before_bar.diskSize,
                                       'auto')
            else:
                after_bar.addPartition(release_name, 1, 'auto')

            addBars(bar_frame, before_bar, after_bar)
        self.disks.append(disks)

        # Manual partitioning.

        button = QtGui.QRadioButton(manual_choice,
                                    self.autopart_selection_frame)
        self.autopartitionTexts.append(manual_choice)
        self.autopart_selection_frame.layout().addWidget(button)
        self.autopartition_buttongroup.addButton(button, bId)
        button.clicked.connect(self.controller.setNextButtonTextNext)
        self.disks.append([])

        #select the first button
        b = self.autopartition_buttongroup.button(0)
        b and b.click()
示例#25
0
 def test_get_release_fail(self, mock_open):
     mock_open.side_effect = Exception('Pow!')
     release = misc.get_release()
     self.assertEqual(release.name, 'Ubuntu')
     self.assertEqual(release.version, '')