[PATCH] Split the apply method into apply and save methods.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The apply methods have ended up trying to do two separate tasks at once:
setting values into ksdata, and applying changes (like keyboard or language)
to the running system.  This works okay for system installation, but is not
good for testing or for future use of the UI as a kickstart generator.

Thus, this patch starts splitting the current apply methods out into two
task-specific methods.  save methods will write values into the ksdata and
can optionally do stuff like download temporary files.  These methods are
mandatory.  apply methods will make permanent changes.  These methods are
optional, as not every spoke will need to do this.
---
 pyanaconda/ui/gui/hubs/__init__.py         |    5 ++++-
 pyanaconda/ui/gui/spokes/__init__.py       |   20 ++++++++++++++++++--
 pyanaconda/ui/gui/spokes/custom.py         |    2 +-
 pyanaconda/ui/gui/spokes/datetime_spoke.py |    2 +-
 pyanaconda/ui/gui/spokes/keyboard.py       |    5 ++++-
 pyanaconda/ui/gui/spokes/network.py        |    4 ++--
 pyanaconda/ui/gui/spokes/software.py       |    4 ++--
 pyanaconda/ui/gui/spokes/source.py         |    2 +-
 pyanaconda/ui/gui/spokes/storage.py        |    2 +-
 pyanaconda/ui/gui/spokes/welcome.py        |   10 ++++++----
 10 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/pyanaconda/ui/gui/hubs/__init__.py b/pyanaconda/ui/gui/hubs/__init__.py
index 40cc6ef..c996aa5 100644
--- a/pyanaconda/ui/gui/hubs/__init__.py
+++ b/pyanaconda/ui/gui/hubs/__init__.py
@@ -101,7 +101,10 @@ class Hub(UIObject):
         # prevent the user from switching away.  It's up to the spoke's back
         # button handler to kill its own layer of main loop.
         Gtk.main()
-        action.apply()
+        action.save()
+
+        if not flags.testing and not flags.imageInstall:
+            action.apply()
 
     def _createBox(self):
         from gi.repository import Gtk, AnacondaWidgets
diff --git a/pyanaconda/ui/gui/spokes/__init__.py b/pyanaconda/ui/gui/spokes/__init__.py
index 3f333ba..4531775 100644
--- a/pyanaconda/ui/gui/spokes/__init__.py
+++ b/pyanaconda/ui/gui/spokes/__init__.py
@@ -86,8 +86,24 @@ class Spoke(UIObject):
         self.instclass = instclass
 
     def apply(self):
-        """Apply the selections made on this Spoke to the object's preset
-           data object.  This method must be provided by every subclass.
+        """Immediately apply the selections made on this Spoke to the runtime
+           system.  This does not do anything to the object's preset data
+           object.  That is handled by the save method.  This method need only
+           be provided if this object needs to set up something for the
+           installation environment (examples are things like language and
+           keyboard).
+
+           This method can assume that save has been called first, thus the data
+           object is up-to-date.
+        """
+        pass
+
+    def save(self):
+        """Take the selections made on this Spoke and save them to the object's
+           preset data object.  This method does not cause any permanent changes
+           to be made to the runtime system, though it may do things like download
+           temporary files.  No changes will be made to the target system.  This
+           method must be provided by every subclass.
         """
         raise NotImplementedError
 
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index bc9a52e..ee6596f 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -111,7 +111,7 @@ class CustomPartitioningSpoke(NormalSpoke):
         self._current_selector = None
         self._ran_autopart = False
 
-    def apply(self):
+    def save(self):
         pass
 
     @property
diff --git a/pyanaconda/ui/gui/spokes/datetime_spoke.py b/pyanaconda/ui/gui/spokes/datetime_spoke.py
index 789e6c9..05f5ea6 100644
--- a/pyanaconda/ui/gui/spokes/datetime_spoke.py
+++ b/pyanaconda/ui/gui/spokes/datetime_spoke.py
@@ -325,7 +325,7 @@ class DatetimeSpoke(NormalSpoke):
         else:
             return _("%s timezone") % self._tzmap.get_timezone()
 
-    def apply(self):
+    def save(self):
         GLib.source_remove(self._update_datetime_timer_id)
         self._update_datetime_timer_id = None
 
diff --git a/pyanaconda/ui/gui/spokes/keyboard.py b/pyanaconda/ui/gui/spokes/keyboard.py
index 154a88c..951dbd4 100644
--- a/pyanaconda/ui/gui/spokes/keyboard.py
+++ b/pyanaconda/ui/gui/spokes/keyboard.py
@@ -131,11 +131,14 @@ class KeyboardSpoke(NormalSpoke):
         self._xkl_wrapper = keyboard.XklWrapper.get_instance()
 
     def apply(self):
+        # FIXME:  Set the keyboard layout here
+        pass
+
+    def save(self):
         # Clear and repopulate self.data with actual values
         self.data.keyboard.layouts_list = list()
         for row in self._store:
             self.data.keyboard.layouts_list.append(row[0])
-        # FIXME:  Set the keyboard layout here, too.
 
     @property
     def completed(self):
diff --git a/pyanaconda/ui/gui/spokes/network.py b/pyanaconda/ui/gui/spokes/network.py
index a7eb3b6..52015c8 100644
--- a/pyanaconda/ui/gui/spokes/network.py
+++ b/pyanaconda/ui/gui/spokes/network.py
@@ -929,7 +929,7 @@ class NetworkSpoke(NormalSpoke):
         NormalSpoke.__init__(self, *args, **kwargs)
         self.network_control_box = NetworkControlBox(self.builder)
 
-    def apply(self):
+    def save(self):
         self.data.network.network = []
         for dev in self.network_control_box.listed_devices:
             network_data = getKSNetworkData(dev)
@@ -992,7 +992,7 @@ class NetworkStandaloneSpoke(StandaloneSpoke):
         self._initially_available = False
         self._now_available = False
 
-    def apply(self):
+    def save(self):
         self.data.network.network = []
         for dev in self.network_control_box.listed_devices:
             network_data = getKSNetworkData(dev)
diff --git a/pyanaconda/ui/gui/spokes/software.py b/pyanaconda/ui/gui/spokes/software.py
index 8919da4..b99d38b 100644
--- a/pyanaconda/ui/gui/spokes/software.py
+++ b/pyanaconda/ui/gui/spokes/software.py
@@ -52,8 +52,8 @@ class SoftwareSelectionSpoke(NormalSpoke):
 
         self._addRepoDialog = AdditionalReposDialog(self.data)
 
-    def apply(self):
-        # NOTE:  Other apply methods work directly with the ksdata, but this
+    def save(self):
+        # NOTE:  Other save methods work directly with the ksdata, but this
         # one does not.  However, selectGroup/deselectGroup modifies ksdata as
         # part of its operation.  So this is fine.
         from pyanaconda.threads import threadMgr, AnacondaThread
diff --git a/pyanaconda/ui/gui/spokes/source.py b/pyanaconda/ui/gui/spokes/source.py
index 9a87c03..0774c4d 100644
--- a/pyanaconda/ui/gui/spokes/source.py
+++ b/pyanaconda/ui/gui/spokes/source.py
@@ -419,7 +419,7 @@ class SourceSpoke(NormalSpoke):
         self._ready = False
         self._error = False
 
-    def apply(self):
+    def save(self):
         from pyanaconda.threads import threadMgr, AnacondaThread
         from pyanaconda.packaging import PayloadError
         import copy
diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py
index 26095f5..57fb1b0 100644
--- a/pyanaconda/ui/gui/spokes/storage.py
+++ b/pyanaconda/ui/gui/spokes/storage.py
@@ -245,7 +245,7 @@ class StorageSpoke(NormalSpoke):
         # FIXME:  This needs to be set to a real value via some TBD UI.
         self.clearPartType = CLEARPART_TYPE_LINUX
 
-    def apply(self):
+    def save(self):
         self.data.clearpart.drives = self.selected_disks[:]
         self.data.autopart.autopart = self.autopart
         self.data.bootloader.location = "mbr"
diff --git a/pyanaconda/ui/gui/spokes/welcome.py b/pyanaconda/ui/gui/spokes/welcome.py
index f1b6963..0fcc81c 100644
--- a/pyanaconda/ui/gui/spokes/welcome.py
+++ b/pyanaconda/ui/gui/spokes/welcome.py
@@ -49,13 +49,12 @@ class LanguageMixIn(object):
         self._viewName = viewName
         self._selectionName = selectionName
 
-    def apply(self):
+    def save(self):
         selected = self.builder.get_object(self._selectionName)
         (store, itr) = selected.get_selected()
 
-        lang = store[itr][2]
+        self.data.lang.lang = store[itr][2]
         self.language.select_translation(lang)
-        self.data.lang.lang = lang
 
         #TODO: better use GeoIP data once it is available
         if self.language.territory and not self.data.timezone.timezone:
@@ -81,7 +80,10 @@ class LanguageMixIn(object):
         for layout in new_layouts:
             if layout not in self.data.keyboard.layouts_list:
                 self.data.keyboard.layouts_list.append(layout)
-                self._xklwrapper.add_layout(layout)
+
+    def apply(self):
+        for layout in self.data.keyboard.layouts_list:
+            self._xklwrapper.add_layout(layout)
 
     @property
     def completed(self):
-- 
1.7.8.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux