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): 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 _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)