[f21/master] Allow recursive lightbox calls (#1147337)

David Shea dshea at redhat.com
Wed Oct 8 15:56:18 UTC 2014


This way a lightbox on top of a lightbox (such as an error window on top
of a dialog, or multiple dialogs accidentally being opened on top of one
another) only adds one overlay image, and turning the lightbox off on
the way back out doesn't crash.
---
 pyanaconda/ui/gui/__init__.py | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/pyanaconda/ui/gui/__init__.py b/pyanaconda/ui/gui/__init__.py
index a8269fb..5b809d4 100644
--- a/pyanaconda/ui/gui/__init__.py
+++ b/pyanaconda/ui/gui/__init__.py
@@ -280,6 +280,8 @@ class MainWindow(Gtk.Window):
         self._overlay_img = None
         self._overlay.connect("get-child-position", self._on_overlay_get_child_position)
 
+        self._overlay_depth = 0
+
         # Create a stack and a list of what's been added to the stack
         self._stack = Gtk.Stack()
         self._stack_contents = set()
@@ -398,15 +400,19 @@ class MainWindow(Gtk.Window):
         self._setVisibleChild(self._current_action)
 
     def lightbox_on(self):
-        # Add an overlay image that will be filled and scaled in get-child-position
-        self._overlay_img = Gtk.Image()
-        self._overlay_img.show_all()
-        self._overlay.add_overlay(self._overlay_img)
+        self._overlay_depth += 1
+        if not self._overlay_img:
+            # Add an overlay image that will be filled and scaled in get-child-position
+            self._overlay_img = Gtk.Image()
+            self._overlay_img.show_all()
+            self._overlay.add_overlay(self._overlay_img)
 
     def lightbox_off(self):
-        # Remove the overlay image
-        self._overlay_img.destroy()
-        self._overlay_img = None
+        self._overlay_depth -= 1
+        if self._overlay_depth == 0 and self._overlay_img:
+            # Remove the overlay image
+            self._overlay_img.destroy()
+            self._overlay_img = None
 
     @contextmanager
     def enlightbox(self, dialog):
-- 
2.1.0



More information about the anaconda-patches mailing list