[PATCH] Fix two problems with the volume label and combo on custom partitioning.

Chris Lumens clumens at redhat.com
Fri Aug 29 15:44:15 UTC 2014


These are both caused by the fact that we reset the label's text away from
what is defined in glade.

(1) Keep the colon on the end of the label.

(2) Change the label's accelerator key to V, which does conflict with the remove
button but we can't use keyboard accelerators to activate those buttons anyway.
---
 pyanaconda/ui/gui/spokes/custom.glade               |  2 +-
 pyanaconda/ui/gui/spokes/custom.py                  | 15 ++++++++-------
 .../ui/gui/spokes/lib/custom_storage_helpers.py     | 21 ++++++++++++---------
 3 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/custom.glade b/pyanaconda/ui/gui/spokes/custom.glade
index 9143b1d..8b46847 100644
--- a/pyanaconda/ui/gui/spokes/custom.glade
+++ b/pyanaconda/ui/gui/spokes/custom.glade
@@ -485,7 +485,7 @@
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
                                         <property name="xalign">0</property>
-                                        <property name="label" translatable="yes" context="GUI|Custom Partitioning|Configure">Volume _Group:</property>
+                                        <property name="label" translatable="yes" context="GUI|Custom Partitioning|Configure">_Volume Group:</property>
                                         <property name="use_underline">True</property>
                                         <property name="mnemonic_widget">containerCombo</property>
                                         <attributes>
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index 8380c3e..44b7943 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -80,7 +80,7 @@ from pyanaconda.ui.gui.spokes.lib.summary import ActionSummaryDialog
 from pyanaconda.ui.gui.spokes.lib.custom_storage_helpers import size_from_entry
 from pyanaconda.ui.gui.spokes.lib.custom_storage_helpers import validate_label, validate_mountpoint, get_raid_level
 from pyanaconda.ui.gui.spokes.lib.custom_storage_helpers import selectedRaidLevel, raidLevelSelection, defaultRaidLevel, requiresRaidSelection, containerRaidLevelsSupported, raidLevelsSupported, defaultContainerRaidLevel
-from pyanaconda.ui.gui.spokes.lib.custom_storage_helpers import get_container_type_name, RAID_NOT_ENOUGH_DISKS
+from pyanaconda.ui.gui.spokes.lib.custom_storage_helpers import get_container_type, RAID_NOT_ENOUGH_DISKS
 from pyanaconda.ui.gui.spokes.lib.custom_storage_helpers import AddDialog, ConfirmDeleteDialog, DisksDialog, ContainerDialog, HelpDialog
 
 from pyanaconda.ui.gui.utils import setViewportBackground, fancy_set_sensitive, ignoreEscape
@@ -2042,8 +2042,8 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
             return
 
         device_type = self._get_current_device_type()
-        container_type = get_container_type_name(device_type).lower()
-        new_text = _(NEW_CONTAINER_TEXT) % {"container_type": container_type}
+        container_type_name = get_container_type(device_type).name.lower()
+        new_text = _(NEW_CONTAINER_TEXT) % {"container_type": container_type_name}
         create_new_container = container_name == new_text
         if create_new_container:
             # run the vg editor dialog with a default name and disk set
@@ -2317,8 +2317,9 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
             if container:
                 container_size_policy = container.size_policy
 
-        container_type_text = get_container_type_name(device_type)
-        self._containerLabel.set_text(container_type_text.title())
+        container_type = get_container_type(device_type)
+        self._containerLabel.set_text(container_type.label.title())
+        self._containerLabel.set_use_underline(True)
         self._containerStore.clear()
         if device_type == DEVICE_TYPE_BTRFS:
             containers = self._storage_playground.btrfsVolumes
@@ -2344,8 +2345,8 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
             self._containerStore.append(self._container_store_row(default_container_name))
             self._containerCombo.set_active(len(self._containerStore) - 1)
 
-        self._containerStore.append(self._container_store_row(_(NEW_CONTAINER_TEXT) % {"container_type": container_type_text.lower()}))
-        self._containerCombo.set_tooltip_text(_(CONTAINER_TOOLTIP) % {"container_type": container_type_text.lower()})
+        self._containerStore.append(self._container_store_row(_(NEW_CONTAINER_TEXT) % {"container_type": container_type.name.lower()}))
+        self._containerCombo.set_tooltip_text(_(CONTAINER_TOOLTIP) % {"container_type": container_type.name.lower()})
         if default_container_name is None:
             self._containerCombo.set_active(len(self._containerStore) - 1)
 
diff --git a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
index 6f6a1e9..fc99981 100644
--- a/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
+++ b/pyanaconda/ui/gui/spokes/lib/custom_storage_helpers.py
@@ -27,10 +27,11 @@ __all__ = ["size_from_entry", "populate_mountpoint_store", "validate_label",
            "validate_mountpoint", "get_raid_level",
            "selectedRaidLevel", "raidLevelSelection",
            "defaultRaidLevel", "requiresRaidSelection", "defaultContainerRaidLevel",
-           "containerRaidLevelsSupported", "raidLevelsSupported", "get_container_type_name",
+           "containerRaidLevelsSupported", "raidLevelsSupported", "get_container_type",
            "AddDialog", "ConfirmDeleteDialog", "DisksDialog", "ContainerDialog",
            "HelpDialog"]
 
+from collections import namedtuple
 import functools
 import re
 
@@ -68,9 +69,11 @@ CONTAINER_DIALOG_TITLE = N_("CONFIGURE %(container_type)s")
 CONTAINER_DIALOG_TEXT = N_("Please create a name for this %(container_type)s "
                            "and select at least one disk below.")
 
-CONTAINER_TYPE_NAMES = {DEVICE_TYPE_LVM: N_("Volume Group"),
-                        DEVICE_TYPE_LVM_THINP: N_("Volume Group"),
-                        DEVICE_TYPE_BTRFS: N_("Volume")}
+ContainerType = namedtuple("ContainerType", ["name", "label"])
+
+CONTAINER_TYPES = {DEVICE_TYPE_LVM:       ContainerType(N_("Volume Group"), N_("_Volume Group:")),
+                   DEVICE_TYPE_LVM_THINP: ContainerType(N_("Volume Group"), N_("_Volume Group:")),
+                   DEVICE_TYPE_BTRFS:     ContainerType(N_("Volume"), N_("_Volume:"))}
 
 # These cannot be specified as mountpoints
 system_mountpoints = ["/dev", "/proc", "/run", "/sys"]
@@ -283,8 +286,8 @@ def containerRaidLevelsSupported(device_type):
         return get_supported_raid_levels(DEVICE_TYPE_BTRFS).intersection(supported)
     return set()
 
-def get_container_type_name(device_type):
-    return CONTAINER_TYPE_NAMES.get(device_type, _("container"))
+def get_container_type(device_type):
+    return CONTAINER_TYPES.get(device_type, ContainerType(_("container"), _("container")))
 
 class AddDialog(GUIObject):
     builderObjects = ["addDialog", "mountPointStore", "mountPointCompletion", "mountPointEntryBuffer"]
@@ -462,11 +465,11 @@ class ContainerDialog(GUIObject, GUIDialogInputCheckHandler):
         self._grabObjects()
 
         # set up the dialog labels with device-type-specific text
-        container_type = get_container_type_name(self.device_type)
-        title_text = _(CONTAINER_DIALOG_TITLE) % {"container_type": container_type.upper()}
+        container_type = get_container_type(self.device_type)
+        title_text = _(CONTAINER_DIALOG_TITLE) % {"container_type": container_type.name.upper()}
         self._title_label.set_text(title_text)
 
-        dialog_text = _(CONTAINER_DIALOG_TEXT) % {"container_type": container_type.lower()}
+        dialog_text = _(CONTAINER_DIALOG_TEXT) % {"container_type": container_type.name.lower()}
         self._dialog_label.set_text(dialog_text)
 
         # populate the dialog widgets
-- 
1.9.3



More information about the anaconda-patches mailing list