[PATCH] Hook up the "Modify Software Selection" button on install opts dialogs.
Vratislav Podzimek
vpodzime at redhat.com
Fri Oct 5 08:08:08 UTC 2012
Looks good to me.
On Thu, 2012-10-04 at 15:34 -0400, Chris Lumens wrote:
> This uses the main loop to mark the button as insensitive until software
> selection is ready, then the user can press the button and go to that spoke.
> I'd also like to add a spinner to the button, but that appears to be beyond
> glade for the moment.
> ---
> pyanaconda/ui/gui/spokes/storage.glade | 2 ++
> pyanaconda/ui/gui/spokes/storage.py | 45 +++++++++++++++++++++++++++++++---
> 2 files changed, 43 insertions(+), 4 deletions(-)
>
> diff --git a/pyanaconda/ui/gui/spokes/storage.glade b/pyanaconda/ui/gui/spokes/storage.glade
> index 42ca926..7cca602 100644
> --- a/pyanaconda/ui/gui/spokes/storage.glade
> +++ b/pyanaconda/ui/gui/spokes/storage.glade
> @@ -175,6 +175,7 @@
> <property name="visible">True</property>
> <property name="can_focus">True</property>
> <property name="receives_default">True</property>
> + <property name="tooltip_text" translatable="yes">Please wait... software metadata still loading.</property>
> <property name="halign">center</property>
> <property name="border_width">6</property>
> <property name="use_underline">True</property>
> @@ -451,6 +452,7 @@
> <property name="halign">center</property>
> <property name="border_width">6</property>
> <property name="use_underline">True</property>
> + <property name="tooltip_text" translatable="yes">Please wait... software metadata still loading.</property>
> <signal name="clicked" handler="on_modify_sw_clicked" swapped="no"/>
> </object>
> <packing>
> diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py
> index db4887f..f8a7a54 100644
> --- a/pyanaconda/ui/gui/spokes/storage.py
> +++ b/pyanaconda/ui/gui/spokes/storage.py
> @@ -38,7 +38,7 @@
>
> """
>
> -from gi.repository import Gdk, Gtk
> +from gi.repository import Gdk, GLib, Gtk
> from gi.repository import AnacondaWidgets
>
> from pyanaconda.ui.gui import GUIObject, communication
> @@ -126,6 +126,10 @@ class InstallOptions1Dialog(GUIObject):
> RESPONSE_RECLAIM = 3
> RESPONSE_QUIT = 4
>
> + def __init__(self, *args, **kwargs):
> + self.payload = kwargs.pop("payload")
> + GUIObject.__init__(self, *args, **kwargs)
> +
> def run(self):
> rc = self.window.run()
> self.window.destroy()
> @@ -162,6 +166,34 @@ class InstallOptions1Dialog(GUIObject):
> % (productName, required_space_text))
> return sw_text
>
> + # Methods to handle sensitivity of the modify button.
> + def _software_is_ready(self):
> + # FIXME: Would be nicer to just ask the spoke if it's ready.
> + return (not threadMgr.get("AnaPayloadThread") and
> + not threadMgr.get("AnaSoftwareWatcher") and
> + not threadMgr.get("AnaCheckSoftwareThread") and
> + self.payload.baseRepo is not None)
> +
> + def _check_for_storage_thread(self, button):
> + if self._software_is_ready():
> + button.set_sensitive(True)
> + button.set_has_tooltip(False)
> + button.show_all()
> +
> + # False means this function should never be called again.
> + return False
> + else:
> + return True
> +
> + def _add_button_watcher(self, widgetName):
> + # If the payload fetching thread is still running, the user can't go to
> + # modify the software selection screen. Thus, we have to set the button
> + # insensitive and wait until software selection is ready to go.
> + modify_button = self.builder.get_object(widgetName)
> + if not self._software_is_ready():
> + modify_button.set_sensitive(False)
> + GLib.timeout_add_seconds(1, self._check_for_storage_thread, modify_button)
> +
> # signal handlers
> def on_cancel_clicked(self, button):
> # return to the spoke without making any changes
> @@ -209,6 +241,8 @@ class InstallOptions2Dialog(InstallOptions1Dialog):
> % productName)
> self.builder.get_object("options2_label2").set_markup(label_text)
>
> + self._add_button_watcher("options2_modify_sw_button")
> +
> def on_custom_toggled(self, checkbutton):
> super(InstallOptions2Dialog, self).on_custom_toggled(checkbutton)
> self.builder.get_object("options2_cancel_button").set_sensitive(not self.custom)
> @@ -240,6 +274,8 @@ class InstallOptions3Dialog(InstallOptions1Dialog):
> "version of <b>%s</b>, or quit the installer.") % (productName, productName)
> self.builder.get_object("options3_label2").set_markup(label_text)
>
> + self._add_button_watcher("options3_modify_sw_button")
> +
> class StorageChecker(object):
> errors = []
> warnings = []
> @@ -565,9 +601,9 @@ class StorageSpoke(NormalSpoke, StorageChecker):
> if disk_free + new_free >= required_space:
> dialog = InstallOptions1Dialog(self.data)
> elif disks_size >= required_space:
> - dialog = InstallOptions2Dialog(self.data)
> + dialog = InstallOptions2Dialog(self.data, payload=self.payload)
> else:
> - dialog = InstallOptions3Dialog(self.data)
> + dialog = InstallOptions3Dialog(self.data, payload=self.payload)
>
> dialog.refresh(required_space, disks_size, disk_free, fs_free, self.autopart)
> rc = self.run_lightbox_dialog(dialog)
> @@ -584,7 +620,8 @@ class StorageSpoke(NormalSpoke, StorageChecker):
> print "user chose to continue disk selection"
> elif rc == dialog.RESPONSE_MODIFY_SW:
> # go to software spoke
> - print "user chose to modify software selection"
> + self.skipTo = "SoftwareSelectionSpoke"
> + self.on_back_clicked(self.window)
> elif rc == dialog.RESPONSE_RECLAIM:
> if dialog.custom:
> self.skipTo = "CustomPartitioningSpoke"
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list