[PATCH 4/4] Add an installclass property for the default package environment (#1175826)

David Shea dshea at redhat.com
Fri Jan 9 19:00:28 UTC 2015


This adds a new property to the installclass,
'defaultPackageEnvironment'. When set, the software spoke will choose
this environment id as the default environment during an interactive
install. When not set it will revert to the previous behavior of
choosing the first environment listed in comps.
---
 pyanaconda/installclass.py           |  3 +++
 pyanaconda/ui/gui/spokes/software.py |  6 ++++++
 pyanaconda/ui/tui/spokes/software.py | 12 ++++++++++--
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/pyanaconda/installclass.py b/pyanaconda/installclass.py
index 223bae5..0a92000 100644
--- a/pyanaconda/installclass.py
+++ b/pyanaconda/installclass.py
@@ -67,6 +67,9 @@ class BaseInstallClass(object):
     # path to the installclass stylesheet, if any
     stylesheet = None
 
+    # comps environment id to select by default
+    defaultPackageEnvironment = None
+
     @property
     def l10n_domain(self):
         if self._l10n_domain is None:
diff --git a/pyanaconda/ui/gui/spokes/software.py b/pyanaconda/ui/gui/spokes/software.py
index 67b1b28..2721ef9 100644
--- a/pyanaconda/ui/gui/spokes/software.py
+++ b/pyanaconda/ui/gui/spokes/software.py
@@ -277,6 +277,12 @@ class SoftwareSelectionSpoke(NormalSpoke):
         if self.environment not in self.payload.environments:
             self.environment = None
 
+        # If no environment is selected, use the default from the instclass.
+        # If nothing is set in the instclass, the first environment will be
+        # selected below.
+        if not self.environment:
+            self.environment = self.payload.instclass.defaultPackageEnvironment
+
         firstEnvironment = True
         firstRadio = None
 
diff --git a/pyanaconda/ui/tui/spokes/software.py b/pyanaconda/ui/tui/spokes/software.py
index 03f5347..0c375c9 100644
--- a/pyanaconda/ui/tui/spokes/software.py
+++ b/pyanaconda/ui/tui/spokes/software.py
@@ -69,9 +69,17 @@ class SoftwareSpoke(NormalTUISpoke):
         threadMgr.wait(THREAD_PAYLOAD)
 
         if not self._kickstarted:
-            # Select the first environment by default
+            # If an environment was specified in the instclass, use that.
+            # Otherwise, select the first environment.
             if self.payload.environments:
-                self._selection = 0
+                environments = self.payload.environments
+                instclass = self.payload.instclass
+
+                if instclass.defaultPackageEnvironment and \
+                        instclass.defaultPackageEnvironment in environments:
+                    self._selection = environments.index(instclass.defaultPackageEnvironment)
+                else:
+                    self._selection = 0
 
         # Apply the initial selection
         self._apply()
-- 
2.1.0



More information about the anaconda-patches mailing list