changeset 264:3e11b5d923e2

core: call new methods onVisible and onNotVisible when a widget is displayed or hidden + fixed a deletion bug on _removeVisibleWidget
author Goffi <goffi@goffi.org>
date Mon, 11 Mar 2019 08:39:43 +0100
parents fe540a6dc14d
children 805c4103dac5
files cagou/core/cagou_main.py cagou/core/cagou_widget.py
diffstat 2 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/cagou/core/cagou_main.py	Mon Mar 11 08:39:43 2019 +0100
+++ b/cagou/core/cagou_main.py	Mon Mar 11 08:39:43 2019 +0100
@@ -732,6 +732,7 @@
         """
         assert isinstance(widget, CagouWidget)
         self._visible_widgets.setdefault(widget.__class__, []).append(widget)
+        widget.onVisible()
 
     def _removeVisibleWidget(self, widget):
         """declare a widget not visible anymore
@@ -739,7 +740,9 @@
         for internal use only!
         """
         self._visible_widgets[widget.__class__].remove(widget)
-        if isinstance(self, quick_widgets.QuickWidget):
+        if isinstance(widget, CagouWidget):
+            widget.onNotVisible()
+        if isinstance(widget, quick_widgets.QuickWidget):
             self.widgets.deleteWidget(widget)
 
     def getVisibleList(self, cls):
--- a/cagou/core/cagou_widget.py	Mon Mar 11 08:39:43 2019 +0100
+++ b/cagou/core/cagou_widget.py	Mon Mar 11 08:39:43 2019 +0100
@@ -89,3 +89,11 @@
     def headerInputAddExtra(self, widget):
         """add a widget on the right of header input"""
         self.header_box.add_widget(widget)
+
+    def onVisible(self):
+        pass
+        # log.debug(u"{self} is visible".format(self=self))
+
+    def onNotVisible(self):
+        pass
+        # log.debug(u"{self} is not visible anymore".format(self=self))