---
pyanaconda/ui/gui/spokes/custom.py | 21 ++++++++++-
pyanaconda/ui/gui/spokes/lib/refresh.py | 62 ++++++++++++++++++++++++++++++++-
2 files changed, 81 insertions(+), 2 deletions(-)
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index 3a94dbd..bc18eab 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -77,6 +77,7 @@ from pyanaconda.ui.gui.spokes.storage import StorageChecker
from pyanaconda.ui.gui.spokes.lib.cart import SelectedDisksDialog
from pyanaconda.ui.gui.spokes.lib.passphrase import PassphraseDialog
from pyanaconda.ui.gui.spokes.lib.accordion import *
+from pyanaconda.ui.gui.spokes.lib.refresh import RefreshDialog
from pyanaconda.ui.gui.spokes.lib.summary import ActionSummaryDialog
from pyanaconda.ui.gui.utils import setViewportBackground
from pyanaconda.ui.gui.categories.storage import StorageCategory
@@ -2369,7 +2370,25 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
# This callback is for the button that has anaconda go back and rescan the
# disks to pick up whatever changes the user made outside our control.
def on_refresh_clicked(self, *args):
- pass
+ dialog = RefreshDialog(self.data, self.storage)
+ with enlightbox(self.window, dialog.window):
+ rc = dialog.run()
+ dialog.window.destroy()
+
+ if rc == 0:
+ # User hit cancel on the dialog, so there was no rescanning done.
+ return
+ elif rc == 1:
+ # User hit OK on the dialog, indicating they stayed on the dialog
+ # until rescanning completed and now needs to go back to the
+ # main storage spoke.
+ self.skipTo = "StorageSpoke"
+
+ # Can't use this spoke's on_back_clicked method as that will try to
+ # save the right hand side, which is no longer valid. The user must
+ # go back and select their disks all over again since whatever they
+ # did on the shell could have changed what disks are available.
+ NormalSpoke.on_back_clicked(self, None)
def on_info_bar_clicked(self, *args):
log.debug("info bar clicked: %s (%s)" % (self._error, args))
diff --git a/pyanaconda/ui/gui/spokes/lib/refresh.py
b/pyanaconda/ui/gui/spokes/lib/refresh.py
index 83d2efb..3fc9b57 100644
--- a/pyanaconda/ui/gui/spokes/lib/refresh.py
+++ b/pyanaconda/ui/gui/spokes/lib/refresh.py
@@ -19,10 +19,13 @@
# Red Hat Author(s): Chris Lumens <clumens(a)redhat.com>
#
-from gi.repository import Gtk
+from gi.repository import GLib, Gtk
+from pyanaconda.threads import threadMgr, AnacondaThread
from pyanaconda.ui.gui import GUIObject
+from blivet import storageInitialize
+
import gettext
_ = lambda x: gettext.ldgettext("anaconda", x)
@@ -33,7 +36,64 @@ class RefreshDialog(GUIObject):
mainWidgetName = "refreshDialog"
uiFile = "spokes/lib/refresh.glade"
+ def __init__(self, data, storage):
+ GUIObject.__init__(self, data)
+
+ self.storage = storage
+
+ self._notebook = self.builder.get_object("refreshNotebook")
+ self._cancel_button = self.builder.get_object("refreshCancelButton")
+ self._ok_button = self.builder.get_object("refreshOKButton")
+
def run(self):
rc = self.window.run()
self.window.destroy()
return rc
+
+ def _check_rescan(self, *args):
+ if threadMgr.get("AnaStorageThread"):
+ self._elapsed += 1
+
+ # If more than five seconds has elapsed since the rescan started,
+ # give the user the option to return to the hub.
+ if self._elapsed >= 5:
+ self._notebook.set_current_page(2)
+
+ return True
+
+ # Seems a little silly to have this warning text still displayed
+ # when everything is done.
+ box = self.builder.get_object("warningBox")
+ box.set_visible(False)
+
+ self._cancel_button.set_sensitive(False)
+ self._ok_button.set_sensitive(True)
+ self._notebook.set_current_page(3)
+ return False
+
+ def return_to_hub_link_clicked(self, label, uri):
+ # The user clicked on the link that takes them back to the hub. We need
+ # to kill the _check_rescan watcher and then emit a special response ID
+ # indicating the user did not press OK.
+ #
+ # NOTE: There is no button with response_id=2.
+ GLib.source_remove(self._watcher_id)
+ self.window.response(2)
+
+ def on_rescan_clicked(self, button):
+ # Once the rescan button is clicked, the option to cancel expires.
+ # We also need to display the spinner showing activity.
+ self._cancel_button.set_sensitive(False)
+ self._ok_button.set_sensitive(False)
+ self._notebook.set_current_page(1)
+
+ # And now to fire up the storage reinitialization.
+ protectedNames = map(lambda d: d.name, self.storage.protectedDevices)
+ threadMgr.add(AnacondaThread(name="AnaStorageThread",
target=storageInitialize,
+ args=(self.storage, self.data, protectedNames)))
+
+ self._elapsed = 0
+
+ # This watches for the rescan to be finished and updates the dialog when
+ # that happens.
+ self._watcher_id = GLib.timeout_add_seconds(1, self._check_rescan)
--
1.8.1.2