Ejemplo n.º 1
0
    def setup(self, args="anaconda"):
        TUIObject.setup(self, args)
        environment = args
        cats_and_spokes = self._collectCategoriesAndSpokes()
        categories = cats_and_spokes.keys()

        # display categories by sort order or class name if their
        # sort order is the same
        for c in common.sort_categories(categories):

            hub_spokes = []
            for spoke_class in cats_and_spokes[c]:
                # Do the checks for the spoke and create the spoke
                if spoke_class.should_run(environment, self.data):
                    spoke = spoke_class(self.data, self.storage, self.payload)

                    if spoke.showable:
                        spoke.initialize()
                    else:
                        log.warning("Spoke %s initialization failure!",
                                    spoke.__class__.__name__)
                        del spoke
                        continue

                    if spoke.indirect:
                        continue

                    hub_spokes.append(spoke)

            # sort created spokes and add them to result structures
            for spoke in sorted(hub_spokes, key=lambda s: s.title):

                self._spoke_count += 1
                self._spokes_map.append(spoke)
                self._spokes[spoke.__class__.__name__] = spoke

        if self._spoke_count:
            # 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__)

        # only schedule the hub if it has some spokes
        return self._spoke_count != 0
Ejemplo n.º 2
0
    def setup(self, environment="anaconda"):
        cats_and_spokes = self._collectCategoriesAndSpokes()
        categories = cats_and_spokes.keys()

        for c in sorted(categories, key=lambda c: c.title):

            for spokeClass in sorted(cats_and_spokes[c],
                                     key=lambda s: s.title):
                # Check if this spoke is to be shown in anaconda
                if not spokeClass.should_run(environment, self.data):
                    continue

                spoke = spokeClass(self.app, self.data, self.storage,
                                   self.payload, self.instclass)

                if spoke.showable:
                    spoke.initialize()
                else:
                    del spoke
                    continue

                if spoke.indirect:
                    continue

                self._spoke_count += 1
                self._keys[self._spoke_count] = spoke
                self._spokes[spokeClass.__name__] = spoke

        if self._spoke_count:
            # 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__)

        # only schedule the hub if it has some spokes
        return self._spoke_count != 0
Ejemplo n.º 3
0
    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()
Ejemplo n.º 4
0
    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()