def _add_disk_overview(self, device_data, box): if device_data.type == "dm-multipath": # We don't want to display the whole huge WWID for a multipath device. wwn = device_data.attrs.get("wwn", "") description = wwn[0:6] + "..." + wwn[-8:] elif device_data.type == "zfcp": # Manually mangle the desc of a zFCP device to be multi-line since # it's so long it makes the disk selection screen look odd. description = _( "FCP device {hba_id}\nWWPN {wwpn}\nLUN {lun}").format( hba_id=device_data.attrs.get("hba-id", ""), wwpn=device_data.attrs.get("wwpn", ""), lun=device_data.attrs.get("fcp-lun", "")) elif device_data.type == "nvdimm": description = _("NVDIMM device {namespace}").format( namespace=device_data.attrs.get("namespace", "")) else: description = device_data.description kind = "drive-removable-media" if device_data.removable else "drive-harddisk" free_space = self._device_tree.GetDiskFreeSpace([device_data.name]) serial_number = device_data.attrs.get("serial") or None overview = AnacondaWidgets.DiskOverview( description, kind, str(Size(device_data.size)), _("{} free").format(str(Size(free_space))), device_data.name, serial_number) box.pack_start(overview, False, False, 0) overview.set_chosen(device_data.name in self._selected_disks) overview.connect("button-press-event", self._on_disk_clicked) overview.connect("key-release-event", self._on_disk_clicked) overview.connect("focus-in-event", self._on_disk_focus_in) overview.show_all()
def enlightbox(mainWindow, dialog): from pyanaconda.ui.gui import ANACONDA_WINDOW_GROUP from gi.repository import AnacondaWidgets lightbox = AnacondaWidgets.lb_show_over(mainWindow) ANACONDA_WINDOW_GROUP.add_window(lightbox) dialog.set_transient_for(lightbox) yield lightbox.destroy()
def enlightbox(mainWindow, dialog): # importing globally would cause a circular dependency from pyanaconda.ui.gui import ANACONDA_WINDOW_GROUP lightbox = AnacondaWidgets.Lightbox(parent_window=mainWindow) ANACONDA_WINDOW_GROUP.add_window(lightbox) dialog.set_transient_for(lightbox) yield lightbox.destroy()
def lightbox_over_current_action(self, window): """ Creates lightbox over current action for the given window. Or DOES NOTHING IF THERE ARE NO ACTIONS. """ # if there are no actions (not populated yet), we can do nothing if len(self._actions) > 0 and self._currentAction: lightbox = AnacondaWidgets.Lightbox(parent_window=self._currentAction.window) ANACONDA_WINDOW_GROUP.add_window(lightbox) window.main_window.set_transient_for(lightbox)
def lightbox_over_current_action(self, window): """ Creates lightbox over current action for the given window. Or DOES NOTHING IF THERE ARE NO ACTIONS. """ from gi.repository import AnacondaWidgets # if there are no actions (not populated yet), we can do nothing if len(self._actions) > 0 and self._currentAction: lightbox = AnacondaWidgets.lb_show_over(self._currentAction.window) ANACONDA_WINDOW_GROUP.add_window(lightbox) window.main_window.set_transient_for(lightbox)
def _add_disk_overview(self, disk, box): if disk.removable: kind = "drive-removable-media" else: kind = "drive-harddisk" if disk.serial: popup_info = "%s" % disk.serial else: popup_info = None # We don't want to display the whole huge WWID for a multipath device. # That makes the DO way too wide. if isinstance(disk, MultipathDevice): desc = disk.wwid.split(":") description = ":".join(desc[0:3]) + "..." + ":".join(desc[-4:]) elif isinstance(disk, ZFCPDiskDevice): # manually mangle the desc of a zFCP device to be multi-line since # it's so long it makes the disk selection screen look odd description = _("FCP device %(hba_id)s\nWWPN %(wwpn)s\nLUN %(lun)s") % \ {"hba_id": disk.hba_id, "wwpn": disk.wwpn, "lun": disk.fcp_lun} else: description = disk.description free = self.storage.getFreeSpace(disks=[disk])[disk.name][0] overview = AnacondaWidgets.DiskOverview(description, kind, str(disk.size), _("%s free") % free, disk.name, popup=popup_info) box.pack_start(overview, False, False, 0) # FIXME: this will need to get smarter # # maybe a little function that resolves each item in onlyuse using # udev_resolve_devspec and compares that to the DiskDevice? overview.set_chosen(disk.name in self.selected_disks) overview.connect("button-press-event", self._on_disk_clicked) overview.connect("key-release-event", self._on_disk_clicked) overview.connect("focus-in-event", self._on_disk_focus_in) overview.show_all()
def _add_disk_overview(self, disk, box): if disk.removable: kind = "drive-removable-media" else: kind = "drive-harddisk" size = size_str(disk.size) if disk.serial: popup_info = "%s" % disk.serial else: popup_info = None # We don't want to display the whole huge WWID for a multipath device. # That makes the DO way too wide. if isinstance(disk, MultipathDevice): desc = disk.wwid.split(":") description = ":".join(desc[0:3]) + "..." + ":".join(desc[-4:]) else: description = disk.description free = self.storage.getFreeSpace(disks=[disk])[disk.name][0] overview = AnacondaWidgets.DiskOverview(description, kind, size, _("%s free") % size_str(free), disk.name, popup=popup_info) box.pack_start(overview, False, False, 0) # FIXME: this will need to get smarter # # maybe a little function that resolves each item in onlyuse using # udev_resolve_devspec and compares that to the DiskDevice? overview.set_chosen(disk.name in self.selected_disks) overview.connect("button-press-event", self._on_disk_clicked) overview.connect("key-release-event", self._on_disk_clicked) overview.connect("focus-in-event", self._on_disk_focus_in) overview.show_all()
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 flags.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_start(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 # initialization of all expected spokes has been started, so notify the controller hub_controller = lifecycle.get_controller_by_name( self.__class__.__name__) if hub_controller: hub_controller.all_modules_added() else: log.error( "Initialization controller for hub %s expected but missing.", self.__class__.__name__) spokeArea = self.window.get_spoke_area() viewport = Gtk.Viewport() viewport.add(grid) spokeArea.add(viewport) self._updateContinue()
def _on_child_added(self, widget, user_data): # If this is GtkLabel, apply the language attribute if isinstance(widget, Gtk.Label): AnacondaWidgets.apply_language(widget, user_data)
def _createBox(self): """Create and fill the list of categories and spokes.""" import gi 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=18, column_spacing=18, column_homogeneous=True, margin_bottom=12, margin_left=12, margin_right=12, halign=Gtk.Align.CENTER, valign=Gtk.Align.CENTER, row_homogeneous=True) col = 0 row_in_column = [-1] * self._gridColumns for category in common.sort_categories(categories): selectors = [] for spokeClass in sorted(cats_and_spokes[category], 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 flags.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) spoke.window.set_beta(self.window.get_beta()) spoke.window.set_property("distribution", distributionText()) # 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) selectors.append(spoke.selector) if not selectors: continue # category handling # excape unwanted markup cat_title = escape_markup(category.get_title()) # generate pango markup cat_label = '<span size="larger" weight="bold">{}</span>'.format( cat_title) # setup the category label label = Gtk.Label(label=cat_label, use_markup=True, halign=Gtk.Align.START, valign=Gtk.Align.END, margin_bottom=6, wrap=True, xalign=0.0) grid.attach(label, col, row_in_column[col], 1, 1) row_in_column[col] += 1 for selector in selectors: grid.attach(selector, col, row_in_column[col], 1, 1) row_in_column[col] += 1 col = (col + 1) % self._gridColumns # initialization of all expected spokes has been started, so notify the controller hub_controller = lifecycle.get_controller_by_name( self.__class__.__name__) if hub_controller: hub_controller.all_modules_added() else: log.error( "Initialization controller for hub %s expected but missing.", self.__class__.__name__) spokeArea = self.window.get_spoke_area() viewport = Gtk.Viewport() viewport.add(grid) spokeArea.add(viewport) self._updateContinue()
def _createBox(self): from gi.repository import Gtk, AnacondaWidgets from pyanaconda.ui.gui.utils import setViewportBackground cats_and_spokes = self._collectCategoriesAndSpokes() categories = cats_and_spokes.keys() grid = Gtk.Grid() grid.set_row_spacing(6) grid.set_column_spacing(6) grid.set_column_homogeneous(True) grid.set_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 # Hubs and spokes might be used outside of Anaconda # (for example in initial-setup) and individual spokes might # also have different translation domains (usually spokes # taken from Anaconda will have the "anaconda" domain and # external spokes will have their own). # Therefore we need to forward the domain of the spoke to # gettext to properly translate its title. spoke.selector = AnacondaWidgets.SpokeSelector( gettext.ldgettext(spoke.translationDomain, 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) 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("<span font-desc=\"Sans 14\">%s</span>" % escape_markup(_(obj.title))) label.set_use_markup(True) label.set_halign(Gtk.Align.START) label.set_margin_top(12) label.set_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) setViewportBackground(viewport)