# HG changeset patch # User Goffi # Date 1552289983 -3600 # Node ID 3e11b5d923e2f0f55d464fa005add17059d20224 # Parent fe540a6dc14dd8710e25072a85f5e3a9d70910d8 core: call new methods onVisible and onNotVisible when a widget is displayed or hidden + fixed a deletion bug on _removeVisibleWidget diff -r fe540a6dc14d -r 3e11b5d923e2 cagou/core/cagou_main.py --- 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): diff -r fe540a6dc14d -r 3e11b5d923e2 cagou/core/cagou_widget.py --- 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))