[PATCH rhel7-branch] The autopart scheme combo should work for creating partitions manually, too.

Vratislav Podzimek vpodzime at redhat.com
Tue Feb 4 07:51:00 UTC 2014


On Mon, 2014-02-03 at 13:32 -0500, Chris Lumens wrote:
> Previous changes moved the autopart scheme combo onto the custom partitioning
> screen, on the left side where we list options for creating mount points.
> However, this change made it appear that the combo did not affect mount points
> created on this screen manually.  This change moves the combo down a little
> under a different heading and makes sure it works for manually created
> mount points.
> 
> Related: rhbz#1014671
> ---
>  pyanaconda/ui/gui/spokes/custom.py        | 12 ++++++
>  pyanaconda/ui/gui/spokes/lib/accordion.py | 62 +++++++++++++++++++------------
>  2 files changed, 50 insertions(+), 24 deletions(-)
> 
> diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
> index 7c9747f..b2fdc9b 100644
> --- a/pyanaconda/ui/gui/spokes/custom.py
> +++ b/pyanaconda/ui/gui/spokes/custom.py
> @@ -898,6 +898,17 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
>              self._current_selector.set_chosen(False)
>              self._current_selector = None
>  
> +    def _change_autopart_type(self, autopartTypeCombo):
> +        # This is called when the autopart type combo on the left hand side of
> +        # custom partitioning is changed.  We already know how to handle the
> +        # case where the user changes the type and then clicks the autopart
> +        # link button.  This handles the case where the user changes the type
> +        # and then clicks the '+' button.
> +
> +        # NOTE: This assumes the order of things in the combo box and the order
> +        # of the pykickstart AUTOPART_TYPE_* constants are the same.
> +        self.data.autopart.type = autopartTypeCombo.get_active()
> +
>      def _do_refresh(self, mountpointToShow=None):
>          # block mountpoint selector signal handler for now
>          self._initialized = False
> @@ -941,6 +952,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
>          if not new_devices:
>              page = CreateNewPage(self.translated_new_install_name,
>                                   self.on_create_clicked,
> +                                 self._change_autopart_type,
>                                   partitionsToReuse=bool(ui_roots))
>              self._accordion.addPage(page, cb=self.on_page_clicked)
>  
> diff --git a/pyanaconda/ui/gui/spokes/lib/accordion.py b/pyanaconda/ui/gui/spokes/lib/accordion.py
> index 7def9e7..b5f8993 100644
> --- a/pyanaconda/ui/gui/spokes/lib/accordion.py
> +++ b/pyanaconda/ui/gui/spokes/lib/accordion.py
> @@ -1,7 +1,7 @@
>  # vim: set fileencoding=utf-8
>  # Mountpoint selector accordion and page classes
>  #
> -# Copyright (C) 2012  Red Hat, Inc.
> +# Copyright (C) 2012-2014 Red Hat, Inc.
>  #
>  # This copyrighted material is made available to anyone wishing to use,
>  # modify, copy, or redistribute it subject to the terms and conditions of
> @@ -247,7 +247,7 @@ class UnknownPage(Page):
>  # of this class will be packed into the Accordion first and then when the new installation
>  # is created, it will be removed and replaced with a Page for it.
>  class CreateNewPage(Page):
> -    def __init__(self, title, cb, partitionsToReuse=True):
> +    def __init__(self, title, createClickedCB, autopartTypeChangedCB, partitionsToReuse=True):
>          Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL, spacing=6)
>          self.members = []
>          self.pageTitle = title
> @@ -261,55 +261,69 @@ class CreateNewPage(Page):
>          label = Gtk.Label(_("You haven't created any mount points for your %s %s installation yet.  You can:") % (productName, productVersion))
>          label.set_line_wrap(True)
>          label.set_alignment(0, 0.5)
> -        self._createBox.attach(label, 0, 0, 3, 1)
> +        self._createBox.attach(label, 0, 0, 2, 1)
>  
>          dot = Gtk.Label("•")
> -        dot.set_alignment(0.5, 0)
> +        dot.set_alignment(0.5, 0.4)
>          dot.set_hexpand(False)
>          self._createBox.attach(dot, 0, 1, 1, 1)
>  
> -        label = Gtk.Label(_("Create them _automatically:"))
> -        label.set_use_underline(True)
> -        label.set_line_wrap(True)
> +        self._createNewButton = Gtk.LinkButton("", label=_("_Click here to create them automatically."))
> +        label = self._createNewButton.get_children()[0]
>          label.set_alignment(0, 0.5)
> -        self._createBox.attach(label, 1, 1, 2, 1)
> +        label.set_hexpand(True)
> +        label.set_line_wrap(True)
> +        label.set_use_underline(True)
>  
> +        # Create this now to pass into the callback.  It will be populated later
> +        # on in this method.
>          combo = Gtk.ComboBoxText()
> -        label.set_mnemonic_widget(combo)
> -        combo.append_text(_("Standard Partition"))
> -        combo.append_text(_("BTRFS"))
> -        combo.append_text(_("LVM"))
> -        combo.append_text(_("LVM Thin Provisioning"))
> -        combo.set_active(2)
> -        self._createBox.attach(combo, 1, 2, 1, 1)
> +        combo.connect("changed", autopartTypeChangedCB)
>  
> -        button = Gtk.Button(_("_Create"))
> -        button.set_margin_right(6)
> -        button.set_use_underline(True)
> -        button.connect("clicked", cb, combo)
> -        self._createBox.attach(button, 2, 2, 1, 1)
> +        self._createNewButton.set_has_tooltip(False)
> +        self._createNewButton.set_halign(Gtk.Align.START)
> +        self._createNewButton.connect("clicked", createClickedCB, combo)
> +        self._createNewButton.connect("activate-link", lambda *args: Gtk.true())
Any reason for using Gtk.true() instead of Python's True?

Otherwise this looks good to me and seems to work as expected.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list