def _add_free_space(self, itr, device_name): # Calculate the free space. disk_free = Size(self._device_tree.GetDiskFreeSpace([device_name])) if disk_free < Size("1MiB"): return # Add a new row. free_space_string = "<span foreground='grey' style='italic'>{}</span>".format( escape_markup(_("Free space"))) disk_free_string = "<span foreground='grey' style='italic'>{}</span>".format( escape_markup(disk_free.human_readable(max_places=1))) self._disk_store.append(itr, [ "", free_space_string, "", disk_free_string, NOTHING, False, TY_FREE_SPACE, None, disk_free, ]) # Update the total free space. self._initial_free_space += disk_free
def refresh(self, required_space, auto_swap, disk_free, fs_free): label_text = self._get_sw_needs_text(required_space, auto_swap) label_text += ( _(" You don't have enough space available to install " "<b>%(product)s</b>, even if you used all of the free space " "available on the selected disks.") % { "product": escape_markup(productName) }) label = self.builder.get_object("no_space_desc_label") label.set_markup(label_text) if not flags.livecdInstall: label.connect("activate-link", self._modify_sw_link_clicked) self._set_free_space_labels(disk_free, fs_free) label_text = _("<b>You don't have enough space available to install " "%(productName)s</b>, even if you used all of the free space " "available on the selected disks. You could add more " "disks for additional space, " "modify your software selection to install a smaller " "version of <b>%(productName)s</b>, or quit the installer.") % \ {"productName": escape_markup(productName)} self.builder.get_object("no_space_options_label").set_markup( label_text) self._add_modify_watcher(label)
def initialize(self, actions): for (i, action) in enumerate(actions, start=1): mountpoint = "" if action.type in [ACTION_TYPE_DESTROY, ACTION_TYPE_RESIZE]: typeString = """<span foreground='red'>%s</span>""" % \ escape_markup(action.type_desc.title()) else: typeString = """<span foreground='green'>%s</span>""" % \ escape_markup(action.type_desc.title()) if action.obj == ACTION_OBJECT_FORMAT: mountpoint = getattr(action.device.format, "mountpoint", "") if hasattr(action.device, "description"): desc = _("%(description)s (%(deviceName)s)") % {"deviceName": action.device.name, "description": action.device.description} serial = action.device.serial elif hasattr(action.device, "disk"): desc = _("%(deviceName)s on %(container)s") % {"deviceName": action.device.name, "container": action.device.disk.description} serial = action.device.disk.serial else: desc = action.device.name serial = action.device.serial self._store.append([i, typeString, action.object_type_string, desc, mountpoint, serial])
def initialize(self, actions): for (i, action) in enumerate(actions, start=1): mountpoint = "" if action.type in [ACTION_TYPE_DESTROY, ACTION_TYPE_RESIZE]: typeString = """<span foreground='red'>%s</span>""" % \ escape_markup(action.typeDesc.title()) else: typeString = """<span foreground='green'>%s</span>""" % \ escape_markup(action.typeDesc.title()) if action.obj == ACTION_OBJECT_FORMAT: mountpoint = getattr(action.device.format, "mountpoint", "") if hasattr(action.device, "description"): desc = _("%(description)s (%(deviceName)s)") % { "deviceName": action.device.name, "description": action.device.description } serial = action.device.serial elif hasattr(action.device, "disk"): desc = _("%(deviceName)s on %(container)s") % { "deviceName": action.device.name, "container": action.device.disk.description } serial = action.device.disk.serial else: desc = action.device.name serial = action.device.serial self._store.append([ i, typeString, action.objectTypeString, desc, mountpoint, serial ])
def on_start_clicked(self, *args): # First, update some widgets to not be usable while discovery happens. self._startButton.hide() self._cancelButton.set_sensitive(False) self._okButton.set_sensitive(False) self._conditionNotebook.set_current_page(1) self._set_configure_sensitive(False) self._initiatorEntry.set_sensitive(False) # Now get the node discovery credentials. credentials = discoverMap[self._authNotebook.get_current_page()](self.builder) discoveredLabelText = _("The following nodes were discovered using the iSCSI initiator "\ "<b>%(initiatorName)s</b> using the target IP address "\ "<b>%(targetAddress)s</b>. Please select which nodes you "\ "wish to log into:") % \ {"initiatorName": escape_markup(credentials.initiator), "targetAddress": escape_markup(credentials.targetIP)} discoveredLabel = self.builder.get_object("discoveredLabel") discoveredLabel.set_markup(discoveredLabelText) bind = self._bindCheckbox.get_active() spinner = self.builder.get_object("waitSpinner") spinner.start() threadMgr.add(AnacondaThread(name=constants.THREAD_ISCSI_DISCOVER, target=self._discover, args=(credentials, bind))) GLib.timeout_add(250, self._check_discover)
def on_start_clicked(self, *args): # First, update some widgets to not be usable while discovery happens. self._startButton.hide() self._cancelButton.set_sensitive(False) self._okButton.set_sensitive(False) self._conditionNotebook.set_current_page(1) self._set_configure_sensitive(False) self._initiatorEntry.set_sensitive(False) # Now get the node discovery credentials. credentials = discoverMap[self._authNotebook.get_current_page()]( self.builder) discoveredLabelText = _("The following nodes were discovered using the iSCSI initiator "\ "<b>%(initiatorName)s</b> using the target IP address "\ "<b>%(targetAddress)s</b>. Please select which nodes you "\ "wish to log into:") % \ {"initiatorName": escape_markup(credentials.initiator), "targetAddress": escape_markup(credentials.targetIP)} discoveredLabel = self.builder.get_object("discoveredLabel") discoveredLabel.set_markup(discoveredLabelText) bind = self._bindCheckbox.get_active() spinner = self.builder.get_object("waitSpinner") spinner.start() threadMgr.add( AnacondaThread(name=constants.THREAD_ISCSI_DISCOVER, target=self._discover, args=(credentials, bind))) GLib.timeout_add(250, self._check_discover)
def refresh(self): NormalSpoke.refresh(self) threadMgr.wait(constants.THREAD_PAYLOAD_MD) self._environmentStore.clear() if self.environment not in self.payload.environments: self.environment = None firstEnvironment = True for environment in self.payload.environments: (name, desc) = self.payload.environmentDescription(environment) itr = self._environmentStore.append([environment == self.environment, "<b>%s</b>\n%s" % \ (escape_markup(name), escape_markup(desc)), environment]) # Either: # (1) Select the environment given by kickstart or selected last # time this spoke was displayed; or # (2) Select the first environment given by display order as the # default if nothing is selected. if (environment == self.environment) or \ (not self.environment and firstEnvironment): self.environment = environment sel = self.builder.get_object("environmentSelector") sel.select_iter(itr) firstEnvironment = False self.refreshAddons()
def _add_locale(self, store, native, locale): native_span = '<span lang="%s">%s</span>' % \ (escape_markup(re.sub(r'\..*', '', locale)), escape_markup(native)) # native, locale, selected, additional store.append([native_span, locale, locale in self._selected_locales, locale != self.data.lang.lang])
def _add_locale(self, store, native, locale): native_span = '<span lang="%s">%s</span>' % \ (escape_markup(re.sub(r'\..*', '', locale)), escape_markup(native)) # native, locale, selected, additional store.append([native_span, locale, locale in self._selected_locales, locale != self._l12_module.proxy.Language])
def _get_sw_needs_text(self, required_space, auto_swap): sw_text = (_("Your current <a href=\"\"><b>%(product)s</b> software " "selection</a> requires <b>%(total)s</b> of available " "space, including <b>%(software)s</b> for software and " "<b>%(swap)s</b> for swap space.") % {"product": escape_markup(productName), "total": escape_markup(str(required_space + auto_swap)), "software": escape_markup(str(required_space)), "swap": escape_markup(str(auto_swap))}) return sw_text
def _get_sw_needs_text(self, required_space, auto_swap): tooltip = _("Please wait... software metadata still loading.") if flags.livecdInstall: sw_text = ( _("Your current <b>%(product)s</b> software " "selection requires <b>%(total)s</b> of available " "space, including <b>%(software)s</b> for software and " "<b>%(swap)s</b> for swap space.") % { "product": escape_markup(productName), "total": escape_markup(str(required_space + auto_swap)), "software": escape_markup(str(required_space)), "swap": escape_markup(str(auto_swap)) }) else: sw_text = (_( "Your current <a href=\"\" title=\"%(tooltip)s\"><b>%(product)s</b> software " "selection</a> requires <b>%(total)s</b> of available " "space, including <b>%(software)s</b> for software and " "<b>%(swap)s</b> for swap space.") % { "tooltip": escape_markup(tooltip), "product": escape_markup(productName), "total": escape_markup(str(required_space + auto_swap)), "software": escape_markup(str(required_space)), "swap": escape_markup(str(auto_swap)) }) return sw_text
def _update_labels(self, nDisks=None, totalReclaimable=None, selectedReclaimable=None): if nDisks is not None and totalReclaimable is not None: text = P_("<b>%(count)s disk; %(size)s reclaimable space</b> (in file systems)", "<b>%(count)s disks; %(size)s reclaimable space</b> (in file systems)", nDisks) % {"count" : escape_markup(str(nDisks)), "size" : escape_markup(totalReclaimable)} self._reclaimable_label.set_markup(text) if selectedReclaimable is not None: text = _("Total selected space to reclaim: <b>%s</b>") % \ escape_markup(selectedReclaimable) self._selected_label.set_markup(text)
def _create_label(self): """Create a row label.""" text = "<b>{}</b>\n{}".format(escape_markup(self.data.name), escape_markup(self.data.description)) label = Gtk.Label(label=text, use_markup=True, wrap=True, wrap_mode=Pango.WrapMode.WORD_CHAR, hexpand=True, xalign=0, yalign=0.5) return label
def _get_sw_needs_text(self, required_space, auto_swap): sw_text = (_("Your current <a href=\"\"><b>%(product)s</b> software " "selection</a> requires <b>%(total)s</b> of available " "space, including <b>%(software)s</b> for software and " "<b>%(swap)s</b> for swap space.") % { "product": escape_markup(productName), "total": escape_markup(str(required_space + auto_swap)), "software": escape_markup(str(required_space)), "swap": escape_markup(str(auto_swap)) }) return sw_text
def _addAddon(self, grp): (name, desc) = self.payload.groupDescription(grp) # If the add-on was previously selected by the user, select it if self._addonStates[grp] == self._ADDON_SELECTED: selected = True # If the add-on was previously de-selected by the user, de-select it elif self._addonStates[grp] == self._ADDON_DESELECTED: selected = False # Otherwise, use the default state else: selected = self.payload.environmentOptionIsDefault(self.environment, grp) self._addonStore.append([selected, "<b>%s</b>\n%s" % \ (escape_markup(name), escape_markup(desc)), grp, False])
def _add_row(self, listbox, name, desc, button, clicked): row = Gtk.ListBoxRow() box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6) button.set_valign(Gtk.Align.START) button.connect("toggled", clicked, row) box.add(button) label = Gtk.Label(label="<b>%s</b>\n%s" % (escape_markup(name), escape_markup(desc)), use_markup=True, wrap=True, wrap_mode=Pango.WrapMode.WORD_CHAR, hexpand=True, xalign=0, yalign=0.5) box.add(label) row.add(box) listbox.insert(row, -1)
def __init__(self, data, storage, payload): super().__init__(data) self.storage = storage self.payload = payload self._device_tree_proxy = STORAGE.get_proxy(DEVICE_TREE) # Get the required device size. required_space = self.payload.space_required.get_bytes() required_size = self._device_tree_proxy.GetRequiredDeviceSize(required_space) self._required_size = Size(required_size) self._initial_free_space = Size(0) self._selected_reclaimable_space = Size(0) self._disk_store = self.builder.get_object("diskStore") self._selection = self.builder.get_object("diskView-selection") self._view = self.builder.get_object("diskView") self._disk_store = self.builder.get_object("diskStore") self._reclaimable_label = self.builder.get_object("reclaimableSpaceLabel") self._selected_label = self.builder.get_object("selectedSpaceLabel") self._required_label = self.builder.get_object("requiredSpaceLabel") self._required_label.set_markup( _("Installation requires a total of <b>%s</b> for system data.") % escape_markup(str(self._required_size)) ) self._reclaim_desc_label = self.builder.get_object("reclaimDescLabel") self._resize_button = self.builder.get_object("resizeButton") self._preserve_button = self.builder.get_object("preserveButton") self._shrink_button = self.builder.get_object("shrinkButton") self._delete_button = self.builder.get_object("deleteButton") self._resize_slider = self.builder.get_object("resizeSlider")
def __init__(self, data, storage, payload): GUIObject.__init__(self, data) self.storage = storage self.payload = payload self._initialFreeSpace = Size(0) self._selectedReclaimableSpace = Size(0) self._actionStore = self.builder.get_object("actionStore") self._diskStore = self.builder.get_object("diskStore") self._selection = self.builder.get_object("diskView-selection") self._view = self.builder.get_object("diskView") self._diskStore = self.builder.get_object("diskStore") self._reclaimable_label = self.builder.get_object("reclaimableSpaceLabel") self._selected_label = self.builder.get_object("selectedSpaceLabel") self._required_label = self.builder.get_object("requiredSpaceLabel") markup = self._required_label.get_label() self._required_label.set_markup(markup % escape_markup(str(self.payload.spaceRequired))) self._reclaimDescLabel = self.builder.get_object("reclaimDescLabel") self._resizeButton = self.builder.get_object("resizeButton") self._preserveButton = self.builder.get_object("preserveButton") self._shrinkButton = self.builder.get_object("shrinkButton") self._deleteButton = self.builder.get_object("deleteButton") self._resizeSlider = self.builder.get_object("resizeSlider")
def __init__(self, data, storage, payload): GUIObject.__init__(self, data) self.storage = storage self.payload = payload self._initialFreeSpace = Size(0) self._selectedReclaimableSpace = Size(0) self._actionStore = self.builder.get_object("actionStore") self._diskStore = self.builder.get_object("diskStore") self._selection = self.builder.get_object("diskView-selection") self._view = self.builder.get_object("diskView") self._diskStore = self.builder.get_object("diskStore") self._reclaimable_label = self.builder.get_object("reclaimableSpaceLabel") self._selected_label = self.builder.get_object("selectedSpaceLabel") self._required_label = self.builder.get_object("requiredSpaceLabel") markup = _("Installation requires a total of <b>%s</b> for system data.") required_dev_size = self.payload.requiredDeviceSize(FS.biggest_overhead_FS()) self._required_label.set_markup(markup % escape_markup(str(required_dev_size))) self._reclaimDescLabel = self.builder.get_object("reclaimDescLabel") self._resizeButton = self.builder.get_object("resizeButton") self._preserveButton = self.builder.get_object("preserveButton") self._shrinkButton = self.builder.get_object("shrinkButton") self._deleteButton = self.builder.get_object("deleteButton") self._resizeSlider = self.builder.get_object("resizeSlider")
def refresh(self, required_space, auto_swap, disk_free, fs_free, autoPartType, encrypted): self.autoPartType = autoPartType self.autoPartTypeCombo.set_active(self.autoPartType) self.encrypted = encrypted self.encryptCheckbutton.set_active(self.encrypted) sw_text = self._get_sw_needs_text(required_space, auto_swap) label_text = _("%s The disks you've selected have the following " "amounts of free space:") % sw_text label = self.builder.get_object("options2_label1") label.set_markup(label_text) label.set_tooltip_text(_("Please wait... software metadata still loading.")) label.connect("activate-link", self._modify_sw_link_clicked) self._set_free_space_labels(disk_free, fs_free) label_text = _("<b>You don't have enough space available to install " "%s</b>. You can shrink or remove existing partitions " "via our guided reclaim space tool, or you can adjust your " "partitions on your own in the custom partitioning " "interface.") % escape_markup(productName) self.builder.get_object("options2_label2").set_markup(label_text) self._add_modify_watcher("options2_label1")
def __init__(self, data, storage, payload): GUIObject.__init__(self, data) self.storage = storage self.payload = payload self._initialFreeSpace = Size(0) self._selectedReclaimableSpace = Size(0) self._actionStore = self.builder.get_object("actionStore") self._diskStore = self.builder.get_object("diskStore") self._selection = self.builder.get_object("diskView-selection") self._view = self.builder.get_object("diskView") self._diskStore = self.builder.get_object("diskStore") self._reclaimable_label = self.builder.get_object( "reclaimableSpaceLabel") self._selected_label = self.builder.get_object("selectedSpaceLabel") self._required_label = self.builder.get_object("requiredSpaceLabel") markup = self._required_label.get_label() required_dev_size = self.payload.requiredDeviceSize( FS.biggestOverheadFS()) self._required_label.set_markup(markup % escape_markup(str(required_dev_size))) self._reclaimDescLabel = self.builder.get_object("reclaimDescLabel") self._resizeButton = self.builder.get_object("resizeButton") self._preserveButton = self.builder.get_object("preserveButton") self._shrinkButton = self.builder.get_object("shrinkButton") self._deleteButton = self.builder.get_object("deleteButton") self._resizeSlider = self.builder.get_object("resizeSlider")
def __init__(self, data, storage, payload): GUIObject.__init__(self, data) self.storage = storage self.payload = payload self._initialFreeSpace = Size(0) self._selectedReclaimableSpace = Size(0) self._actionStore = self.builder.get_object("actionStore") self._diskStore = self.builder.get_object("diskStore") self._selection = self.builder.get_object("diskView-selection") self._view = self.builder.get_object("diskView") self._diskStore = self.builder.get_object("diskStore") self._reclaimable_label = self.builder.get_object("reclaimableSpaceLabel") self._selected_label = self.builder.get_object("selectedSpaceLabel") self._required_label = self.builder.get_object("requiredSpaceLabel") markup = _("Installation requires a total of <b>%s</b> for system data.") self._required_label.set_markup(markup % escape_markup(str(self.payload.spaceRequired))) self._reclaimDescLabel = self.builder.get_object("reclaimDescLabel") self._resizeButton = self.builder.get_object("resizeButton") self._preserveButton = self.builder.get_object("preserveButton") self._shrinkButton = self.builder.get_object("shrinkButton") self._deleteButton = self.builder.get_object("deleteButton") self._resizeSlider = self.builder.get_object("resizeSlider")
def __init__(self, data, storage, payload): super().__init__(data) self.storage = storage self.payload = payload self._initialFreeSpace = Size(0) self._selectedReclaimableSpace = Size(0) self._diskStore = self.builder.get_object("diskStore") self._selection = self.builder.get_object("diskView-selection") self._view = self.builder.get_object("diskView") self._diskStore = self.builder.get_object("diskStore") self._reclaimable_label = self.builder.get_object("reclaimableSpaceLabel") self._selected_label = self.builder.get_object("selectedSpaceLabel") self._required_label = self.builder.get_object("requiredSpaceLabel") markup = _("Installation requires a total of <b>%s</b> for system data.") required_dev_size = self.payload.requiredDeviceSize(FS.biggest_overhead_FS()) self._required_label.set_markup(markup % escape_markup(str(required_dev_size))) self._reclaimDescLabel = self.builder.get_object("reclaimDescLabel") self._resizeButton = self.builder.get_object("resizeButton") self._preserveButton = self.builder.get_object("preserveButton") self._shrinkButton = self.builder.get_object("shrinkButton") self._deleteButton = self.builder.get_object("deleteButton") self._resizeSlider = self.builder.get_object("resizeSlider")
def _make_category_label(self, name): label = Gtk.Label() label.set_markup("""<span fgcolor='dark grey' size='large' weight='bold'>%s</span>""" % escape_markup(name)) label.set_halign(Gtk.Align.START) label.set_margin_left(24) return label
def _add_row(self, listbox, name, desc, selected=False): row = Gtk.ListBoxRow() box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6) check = Gtk.CheckButton() check.set_active(selected) box.add(check) label = Gtk.Label(label="<b>%s</b>\n%s" % (escape_markup(name), escape_markup(desc)), use_markup=True, wrap=True, wrap_mode=Pango.WrapMode.WORD_CHAR, hexpand=True, xalign=0, yalign=0.5) label.id = name box.add(label) row.add(box) listbox.insert(row, -1)
def _make_category_label(self, name): label = Gtk.Label() label.set_markup("""<span fgcolor='dark grey' size='large' weight='bold'>%s</span>""" % escape_markup(name)) label.set_halign(Gtk.Align.START) label.set_margin_start(24) return label
def on_start_clicked(self, *args): """Start the discovery task.""" # First update widgets. self._startButton.hide() self._cancelButton.set_sensitive(False) self._okButton.set_sensitive(False) self._conditionNotebook.set_current_page(1) self._set_configure_sensitive(False) self._initiatorEntry.set_sensitive(False) # Get the node discovery credentials. style = self._authNotebook.get_current_page() portal = self._get_portal() credentials = self._get_discover_credentials(style) initiator = self._get_text("initiatorEntry") self._discoveredLabel.set_markup(_( "The following nodes were discovered using the iSCSI initiator " "<b>%(initiatorName)s</b> using the portal IP address " "<b>%(portalAddress)s</b>. Please select which nodes you " "wish to log into:") % { "initiatorName": escape_markup(initiator), "portalAddress": escape_markup(portal.ip_address) } ) # Get the discovery task. if self._bindCheckbox.get_active(): interfaces_mode = ISCSI_INTERFACE_IFACENAME else: interfaces_mode = ISCSI_INTERFACE_DEFAULT task_path = self._iscsi_module.DiscoverWithTask( Portal.to_structure(portal), Credentials.to_structure(credentials), interfaces_mode ) task_proxy = STORAGE.get_proxy(task_path) if self._iscsi_module.CanSetInitiator(): self._iscsi_module.Initiator = initiator # Start the discovery. async_run_task(task_proxy, self.process_discovery_result) self._discoverySpinner.start()
def _update_summary(self): count = 0 size = Size(0) free = Size(0) for row in self._store: count += 1 size += Size(row[SIZE_COL]) free += Size(row[FREE_SPACE_COL]) # pylint: disable=unescaped-markup text = P_("<b>%(count)d disk; %(size)s capacity; %(free)s free space</b> " "(unpartitioned and in file systems)", "<b>%(count)d disks; %(size)s capacity; %(free)s free space</b> " "(unpartitioned and in file systems)", count) % {"count" : count, "size" : escape_markup(size), "free" : escape_markup(free)} self._summary_label.set_markup(text)
def initialize(self, actions): for (i, action) in enumerate(actions, start=1): mountpoint = "" if action.type in [ACTION_TYPE_DESTROY, ACTION_TYPE_RESIZE]: typeString = """<span foreground='red'>%s</span>""" % \ escape_markup(action.typeDesc.title()) else: typeString = """<span foreground='green'>%s</span>""" % \ escape_markup(action.typeDesc.title()) if action.obj == ACTION_OBJECT_FORMAT: mountpoint = getattr(action.device.format, "mountpoint", "") self._store.append([i, typeString, action.objectTypeString, action.device.name, mountpoint])
def _add_row(self, listbox, name, desc, button): row = Gtk.ListBoxRow() box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) box.set_spacing(6) button.set_valign(Gtk.Align.START) button.connect("clicked", self.on_button_toggled, row) box.add(button) label = Gtk.Label() label.set_line_wrap(True) label.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR) label.set_markup("<b>%s</b>\n%s" % (escape_markup(name), escape_markup(desc))) label.set_hexpand(True) label.set_alignment(0, 0.5) box.add(label) row.add(box) listbox.insert(row, -1)
def _update_summary(self): count = 0 size = 0 free = 0 for row in self._store: count += 1 size += Size(spec=row[SIZE_COL]) free += Size(spec=row[FREE_SPACE_COL]) size = str(Size(bytes=long(size))).upper() free = str(Size(bytes=long(free))).upper() text = P_("<b>%(count)d disk; %(size)s capacity; %(free)s free space</b> " "(unpartitioned and in filesystems)", "<b>%(count)d disks; %(size)s capacity; %(free)s free space</b> " "(unpartitioned and in filesystems)", count) % {"count" : count, "size" : escape_markup(size), "free" : escape_markup(free)} self._summary_label.set_markup(text)
def _add_partition(self, itr, device_name): # Get the device data. device_data = DeviceData.from_structure( self._device_tree.GetDeviceData(device_name) ) format_data = DeviceFormatData.from_structure( self._device_tree.GetFormatData(device_name) ) # Calculate the free size. # Devices that are not resizable are still deletable. is_shrinkable = self._device_tree.IsDeviceShrinkable(device_name) size_limits = self._device_tree.GetDeviceSizeLimits(device_name) min_size = Size(size_limits[0]) device_size = Size(device_data.size) if is_shrinkable: free_size = device_size - min_size resize_string = _("%(freeSize)s of %(devSize)s") % { "freeSize": free_size.human_readable(max_places=1), "devSize": device_size.human_readable(max_places=1) } if not device_data.protected: self._can_shrink_something = True else: free_size = device_size resize_string = "<span foreground='grey'>%s</span>" % \ escape_markup(_("Not resizeable")) # Choose the type. if device_data.protected: ty = TY_PROTECTED else: ty = TY_NORMAL # Generate the description. description = self._get_partition_description(device_data, format_data) # Add a new row. self._disk_store.append(itr, [ device_name, description, format_data.description, resize_string, _(PRESERVE), not device_data.protected, ty, self._get_tooltip(device_data), int(device_size), ]) return free_size
def _update_summary(self): count = 0 size = 0 free = 0 for row in self._store: count += 1 size += Size(spec=row[SIZE_COL]) free += Size(spec=row[FREE_SPACE_COL]) size = str(Size(bytes=long(size))).upper() free = str(Size(bytes=long(free))).upper() # pylint: disable=W9922 text = P_("<b>%(count)d disk; %(size)s capacity; %(free)s free space</b> " "(unpartitioned and in filesystems)", "<b>%(count)d disks; %(size)s capacity; %(free)s free space</b> " "(unpartitioned and in filesystems)", count) % {"count" : count, "size" : escape_markup(size), "free" : escape_markup(free)} self._summary_label.set_markup(text)
def add_page(self, contents, cb): label = Gtk.Label(label="""<span size='large' weight='bold' fgcolor='black'>%s</span>""" % escape_markup(contents.page_title), use_markup=True, xalign=0, yalign=0.5, wrap=True) expander = Gtk.Expander() expander.set_label_widget(label) expander.add(contents) self.add(expander) self._expanders.append(expander) expander.connect("activate", self._on_expanded, cb) expander.show_all()
def addPage(self, contents, cb): label = Gtk.Label(label="""<span size='large' weight='bold' fgcolor='black'>%s</span>""" % escape_markup(contents.pageTitle), use_markup=True, xalign=0, yalign=0.5, wrap=True) expander = Gtk.Expander() expander.set_label_widget(label) expander.add(contents) self.add(expander) self._expanders.append(expander) expander.connect("activate", self._onExpanded, cb) expander.show_all()
def refresh(self, required_space, auto_swap, disk_free, fs_free, autoPartType, encrypted): self.autoPartType = autoPartType self.autoPartTypeCombo.set_active(self.autoPartType) self.encrypted = encrypted self.encryptCheckbutton.set_active(self.encrypted) options_label = self.builder.get_object("options1_label") options_text = _("<span font-desc=\"Cantarell 11\">You have <b>%(freeSpace)s</b> " "of free space, which is enough to install %(productName)s. " "What would you like to do?</span>") %\ {"freeSpace": escape_markup(disk_free), "productName": escape_markup(productName)} options_label.set_markup(options_text) label = self.builder.get_object("options1_autopart_label") label.set_text(C_("GUI|Storage|Options 1 Dialog", "A_utomatically configure my %(productName)s installation to the " "disk(s) I selected and return me to the main menu.") % {"productName": productName}) label.set_use_underline(True) radio = self.builder.get_object("options1_reclaim_radio") if self.showReclaim: label = self.builder.get_object("options1_reclaim_label") label.set_text(C_("GUI|Storage|Options 1 Dialog", "I want more space. _Guide me through shrinking and/or removing " "partitions so I can have more space for %(productName)s.") % {"productName": productName}) label.set_use_underline(True) else: radio.hide() label = self.builder.get_object("options1_custom_label") label.set_text(C_("GUI|Storage|Options 1 Dialog", "I want to review/_modify my disk partitions before continuing.")) label.set_use_underline(True)
def __init__(self, data, actions): super().__init__(data) self._store = self.builder.get_object("actionStore") for (i, action) in enumerate(actions, start=1): mountpoint = "" if action.type in [ACTION_TYPE_DESTROY, ACTION_TYPE_RESIZE]: action_type = """<span foreground='red'>%s</span>""" % \ escape_markup(action.type_desc.title()) else: action_type = """<span foreground='green'>%s</span>""" % \ escape_markup(action.type_desc.title()) if action.obj == ACTION_OBJECT_FORMAT: mountpoint = getattr(action.device.format, "mountpoint", "") if hasattr(action.device, "description"): desc = _("%(description)s (%(deviceName)s)") % { "deviceName": action.device.name, "description": action.device.description } serial = action.device.serial elif hasattr(action.device, "disk"): desc = _("%(deviceName)s on %(container)s") % { "deviceName": action.device.name, "container": action.device.disk.description } serial = action.device.disk.serial else: desc = action.device.name serial = action.device.serial self._store.append([ i, action_type, action.object_type_string, desc, mountpoint, serial ])
def refresh(self, required_space, auto_swap, disk_free, fs_free, autoPartType, encrypted): sw_text = self._get_sw_needs_text(required_space, auto_swap) label_text = (_("%(sw_text)s You don't have enough space available to install " "<b>%(product)s</b>, even if you used all of the free space " "available on the selected disks.") % {"sw_text": escape_markup(sw_text), "product": escape_markup(productName)}) label = self.builder.get_object("options3_label1") label.set_markup(label_text) label.set_tooltip_text(_("Please wait... software metadata still loading.")) label.connect("activate-link", self._modify_sw_link_clicked) self._set_free_space_labels(disk_free, fs_free) label_text = _("<b>You don't have enough space available to install " "%(productName)s</b>, even if you used all of the free space " "available on the selected disks. You could add more " "disks for additional space, " "modify your software selection to install a smaller " "version of <b>%(productName)s</b>, or quit the installer.") % \ {"productName": escape_markup(productName)} self.builder.get_object("options3_label2").set_markup(label_text) self._add_modify_watcher("options3_label1")
def addPage(self, contents, cb=None): label = Gtk.Label() label.set_markup("""<span size='large' weight='bold' fgcolor='black'>%s</span>""" % escape_markup(contents.pageTitle)) label.set_alignment(0, 0.5) label.set_line_wrap(True) expander = Gtk.Expander() expander.set_label_widget(label) expander.add(contents) self.add(expander) self._expanders.append(expander) expander.connect("activate", self._onExpanded, cb) expander.show_all()
def _storageResetHandler(self, exn): message = (_("There is a problem with your existing storage " "configuration: <b>%(errortxt)s</b>\n\n" "You must resolve this matter before the installation can " "proceed. There is a shell available for use which you " "can access by pressing ctrl-alt-f1 and then ctrl-b 2." "\n\nOnce you have resolved the issue you can retry the " "storage scan. If you do not fix it you will have to exit " "the installer.") % {"errortxt": escape_markup(exn.message)}) details = _(exn.suggestion) buttons = (_("_Exit Installer"), _("_Retry")) if self.ui.showDetailedError(message, details, buttons=buttons): return ERROR_RETRY else: return ERROR_RAISE
def refresh(self, required_space, auto_swap, disk_free, fs_free): label_text = self._get_sw_needs_text(required_space, auto_swap) label_text += (_(" You don't have enough space available to install " "<b>%(product)s</b>, even if you used all of the free space " "available on the selected disks.") % {"product": escape_markup(productName)}) label = self.builder.get_object("no_space_desc_label") label.set_markup(label_text) if not flags.livecdInstall: label.connect("activate-link", self._modify_sw_link_clicked) self._set_free_space_labels(disk_free, fs_free) label_text = _("<b>You don't have enough space available to install " "%(productName)s</b>, even if you used all of the free space " "available on the selected disks. You could add more " "disks for additional space, " "modify your software selection to install a smaller " "version of <b>%(productName)s</b>, or quit the installer.") % \ {"productName": escape_markup(productName)} self.builder.get_object("no_space_options_label").set_markup(label_text) self._add_modify_watcher(label)
def addPage(self, contents, cb=None): label = Gtk.Label() label.set_markup( """<span size='large' weight='bold' fgcolor='black'>%s</span>""" % escape_markup(contents.pageTitle)) label.set_alignment(0, 0.5) label.set_line_wrap(True) expander = Gtk.Expander() expander.set_label_widget(label) expander.add(contents) self.add(expander) self._expanders.append(expander) expander.connect("activate", self._onExpanded, cb) expander.show_all()
def _get_sw_needs_text(self, required_space, auto_swap): tooltip = _("Please wait... software metadata still loading.") if flags.livecdInstall: sw_text = (_("Your current <b>%(product)s</b> software " "selection requires <b>%(total)s</b> of available " "space, including <b>%(software)s</b> for software and " "<b>%(swap)s</b> for swap space.") % {"product": escape_markup(productName), "total": escape_markup(str(required_space + auto_swap)), "software": escape_markup(str(required_space)), "swap": escape_markup(str(auto_swap))}) else: sw_text = (_("Your current <a href=\"\" title=\"%(tooltip)s\"><b>%(product)s</b> software " "selection</a> requires <b>%(total)s</b> of available " "space, including <b>%(software)s</b> for software and " "<b>%(swap)s</b> for swap space.") % {"tooltip": escape_markup(tooltip), "product": escape_markup(productName), "total": escape_markup(str(required_space + auto_swap)), "software": escape_markup(str(required_space)), "swap": escape_markup(str(auto_swap))}) return sw_text
def refresh(self, required_space, sw_space, auto_swap, disk_free, fs_free): sw_text = self._get_sw_needs_text(required_space, sw_space, auto_swap) label_text = _("%s The disks you've selected have the following " "amounts of free space:") % sw_text label = self.builder.get_object("need_space_desc_label") label.set_markup(label_text) if self.payload.type not in PAYLOAD_LIVE_TYPES: label.connect("activate-link", self._modify_sw_link_clicked) self._set_free_space_labels(disk_free, fs_free) label_text = _("<b>You don't have enough space available to install " "%s</b>. You can shrink or remove existing partitions " "via our guided reclaim space tool, or you can adjust your " "partitions on your own in the custom partitioning " "interface.") % escape_markup(productName) self.builder.get_object("need_space_options_label").set_markup(label_text) self._add_modify_watcher(label)
def __init__(self, data, payload, partitioning, disks): super().__init__(data) self._disks = disks # Get the device tree. self._device_tree = STORAGE.get_proxy( partitioning.GetDeviceTree() ) # Get roots of existing systems. self._roots = OSData.from_structure_list( self._device_tree.GetExistingSystems() ) # Get the required device size. required_space = payload.space_required.get_bytes() required_size = self._device_tree.GetRequiredDeviceSize(required_space) self._required_size = Size(required_size) self._initial_free_space = Size(0) self._selected_reclaimable_space = Size(0) self._can_shrink_something = False self._disk_store = self.builder.get_object("diskStore") self._selection = self.builder.get_object("diskView-selection") self._view = self.builder.get_object("diskView") self._disk_store = self.builder.get_object("diskStore") self._reclaimable_label = self.builder.get_object("reclaimableSpaceLabel") self._selected_label = self.builder.get_object("selectedSpaceLabel") self._required_label = self.builder.get_object("requiredSpaceLabel") self._required_label.set_markup( _("Installation requires a total of <b>%s</b> for system data.") % escape_markup(str(self._required_size)) ) self._reclaim_desc_label = self.builder.get_object("reclaimDescLabel") self._resize_button = self.builder.get_object("resizeButton") self._preserve_button = self.builder.get_object("preserveButton") self._shrink_button = self.builder.get_object("shrinkButton") self._delete_button = self.builder.get_object("deleteButton") self._resize_slider = self.builder.get_object("resizeSlider")
def refresh(self, required_space, auto_swap, disk_free, fs_free): sw_text = self._get_sw_needs_text(required_space, auto_swap) label_text = _("%s The disks you've selected have the following " "amounts of free space:") % sw_text label = self.builder.get_object("need_space_desc_label") label.set_markup(label_text) if not flags.livecdInstall: label.connect("activate-link", self._modify_sw_link_clicked) self._set_free_space_labels(disk_free, fs_free) label_text = _("<b>You don't have enough space available to install " "%s</b>. You can shrink or remove existing partitions " "via our guided reclaim space tool, or you can adjust your " "partitions on your own in the custom partitioning " "interface.") % escape_markup(productName) self.builder.get_object("need_space_options_label").set_markup(label_text) self._add_modify_watcher(label)
def __init__(self, data, storage, payload): super().__init__(data) self.storage = storage self.payload = payload self._device_tree_proxy = STORAGE.get_proxy(DEVICE_TREE) # Get the required device size. required_space = self.payload.space_required.get_bytes() required_size = self._device_tree_proxy.GetRequiredDeviceSize(required_space) self._required_size = Size(required_size) self._initialFreeSpace = Size(0) self._selectedReclaimableSpace = Size(0) self._diskStore = self.builder.get_object("diskStore") self._selection = self.builder.get_object("diskView-selection") self._view = self.builder.get_object("diskView") self._diskStore = self.builder.get_object("diskStore") self._reclaimable_label = self.builder.get_object("reclaimableSpaceLabel") self._selected_label = self.builder.get_object("selectedSpaceLabel") self._required_label = self.builder.get_object("requiredSpaceLabel") self._required_label.set_markup( _("Installation requires a total of <b>%s</b> for system data.") % escape_markup(str(self._required_size)) ) self._reclaimDescLabel = self.builder.get_object("reclaimDescLabel") self._resizeButton = self.builder.get_object("resizeButton") self._preserveButton = self.builder.get_object("preserveButton") self._shrinkButton = self.builder.get_object("shrinkButton") self._deleteButton = self.builder.get_object("deleteButton") self._resizeSlider = self.builder.get_object("resizeSlider")
def _add_language(self, store, native, english, lang): native_span = '<span lang="%s">%s</span>' % \ (escape_markup(lang), escape_markup(native)) store.append([native_span, english, lang])
def _show_description(column, renderer, model, itr, wrapper): value = wrapper.get_switch_opt_description(model[itr][0]) if model[itr][1]: value = "<b>%s</b>" % escape_markup(value) return value
def _createBox(self): gi.require_version("Gtk", "3.0") gi.require_version("AnacondaWidgets", "3.3") from gi.repository import Gtk, AnacondaWidgets cats_and_spokes = self._collectCategoriesAndSpokes() categories = cats_and_spokes.keys() grid = Gtk.Grid(row_spacing=6, column_spacing=6, column_homogeneous=True, margin_bottom=12) row = 0 for c in sorted(categories, key=lambda c: c.title): obj = c() selectors = [] for spokeClass in sorted(cats_and_spokes[c], key=lambda s: s.title): # Check if this spoke is to be shown in the supported environments if not any(spokeClass.should_run(environ, self.data) for environ in self._environs): continue # Create the new spoke and populate its UI with whatever data. # From here on, this Spoke will always exist. spoke = spokeClass(self.data, self.storage, self.payload, self.instclass) spoke.window.set_beta(self.window.get_beta()) spoke.window.set_property("distribution", distributionText().upper()) # If a spoke is not showable, it is unreachable in the UI. We # might as well get rid of it. # # NOTE: Any kind of spoke can be unshowable. if not spoke.showable: del(spoke) continue # This allows being able to jump between two spokes without # having to directly involve the hub. self._spokes[spokeClass.__name__] = spoke # If a spoke is indirect, it is reachable but not directly from # a hub. This is for things like the custom partitioning spoke, # which you can only get to after going through the initial # storage configuration spoke. # # NOTE: This only makes sense for NormalSpokes. Other kinds # of spokes do not involve a hub. if spoke.indirect: spoke.initialize() continue spoke.selector = AnacondaWidgets.SpokeSelector(C_("GUI|Spoke", spoke.title), spoke.icon) # Set all selectors to insensitive before initialize runs. The call to # _updateCompleteness later will take care of setting it straight. spoke.selector.set_sensitive(False) spoke.initialize() if not spoke.ready: self._notReadySpokes.append(spoke) # Set some default values on the associated selector that # affect its display on the hub. self._updateCompleteness(spoke, update_continue=False) spoke.selector.connect("button-press-event", self._on_spoke_clicked, spoke) spoke.selector.connect("key-release-event", self._on_spoke_clicked, spoke) # If this is a kickstart install, attempt to execute any provided ksdata now. if flags.automatedInstall and spoke.ready and spoke.changed and \ spoke.visitedSinceApplied: spoke.execute() spoke.visitedSinceApplied = False selectors.append(spoke.selector) if not selectors: continue label = Gtk.Label(label="<span font-desc=\"Sans 14\">%s</span>" % escape_markup(_(obj.title)), use_markup=True, halign=Gtk.Align.START, margin_top=12, margin_bottom=12) grid.attach(label, 0, row, 2, 1) row += 1 col = 0 for selector in selectors: selector.set_margin_left(12) grid.attach(selector, col, row, 1, 1) col = int(not col) if col == 0: row += 1 # If this category contains an odd number of selectors, the above # row += 1 will not have run for the last row, which puts the next # category's title in the wrong place. if len(selectors) % 2: row += 1 spokeArea = self.window.get_spoke_area() viewport = Gtk.Viewport() viewport.add(grid) spokeArea.add(viewport) self._updateContinue()
def _updateCompleteness(self, spoke, update_continue=True): spoke.selector.set_sensitive(spoke.sensitive and spoke.ready) spoke.selector.set_property("status", spoke.status) spoke.selector.set_tooltip_markup(escape_markup(spoke.status)) spoke.selector.set_incomplete(not spoke.completed and spoke.mandatory) self._handleCompleteness(spoke, update_continue)
def _add_locale(self, store, native, locale): native_span = '<span lang="%s">%s</span>' % (escape_markup(re.sub(r"\..*", "", locale)), escape_markup(native)) store.append([native_span, locale])