[PATCH] Add a function to allow ignoring escape, and use it on rescan (#965770).

Chris Lumens clumens at redhat.com
Fri Jun 21 18:45:00 UTC 2013


This dialog is doing an important background task, and it's the intention
that it not be closeable while running.  Thus, this function.  There are
likely other places (iscsi, at least) where this could be used.
---
 pyanaconda/ui/gui/spokes/custom.py |  3 ++-
 pyanaconda/ui/gui/utils.py         | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index da2808c..98aa4d1 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -72,7 +72,7 @@ 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, gtk_action_wait, enlightbox, fancy_set_sensitive
+from pyanaconda.ui.gui.utils import setViewportBackground, gtk_action_wait, enlightbox, fancy_set_sensitive, ignoreEscape
 from pyanaconda.ui.gui.categories.storage import StorageCategory
 from pyanaconda.ui.lib.disks import size_str
 
@@ -2714,6 +2714,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
     # disks to pick up whatever changes the user made outside our control.
     def on_refresh_clicked(self, *args):
         dialog = RefreshDialog(self.data, self.storage)
+        ignoreEscape(dialog.window)
         with enlightbox(self.window, dialog.window):
             rc = dialog.run()
             dialog.window.destroy()
diff --git a/pyanaconda/ui/gui/utils.py b/pyanaconda/ui/gui/utils.py
index 1be3bd1..829e2c2 100644
--- a/pyanaconda/ui/gui/utils.py
+++ b/pyanaconda/ui/gui/utils.py
@@ -102,6 +102,20 @@ def enlightbox(mainWindow, dialog):
     yield
     lightbox.destroy()
 
+def ignoreEscape(dlg):
+    """Prevent a dialog from accepting the escape keybinding, which emits a
+       close signal and will cause the dialog to close with some return value
+       we are likely not expecting.  Instead, this method will cause the
+       escape key to do nothing for the given GtkDialog.
+    """
+    provider = Gtk.CssProvider()
+    provider.load_from_data("""@binding-set IgnoreEscape {
+   unbind "Escape";
+};
+GtkDialog { gtk-key-bindings: IgnoreEscape }""")
+    context = dlg.get_style_context()
+    context.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
+
 def setViewportBackground(vp, color="@theme_bg_color"):
     """Set the background color of the GtkViewport vp to be the same as the
        overall UI background.  This should not be called for every viewport,
-- 
1.8.1.2



More information about the anaconda-patches mailing list