changeset 248:b6e33b35538b

core, widgets handler: visible_widgets now keep all CagouWidgets, not only QuickWidgets. visible_quick_widgets can be used if only QuickWidgets are desired.
author Goffi <goffi@goffi.org>
date Sat, 26 Jan 2019 20:24:48 +0100
parents cf61a011f731
children 5d69e4cab925
files cagou/core/cagou_main.py cagou/core/widgets_handler.py
diffstat 2 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/cagou/core/cagou_main.py	Sat Jan 26 20:24:48 2019 +0100
+++ b/cagou/core/cagou_main.py	Sat Jan 26 20:24:48 2019 +0100
@@ -687,27 +687,28 @@
 
         wrapper.changeWidget(new)
 
-    def addVisibleWidget(self, widget):
+    def _addVisibleWidget(self, widget):
         """declare a widget visible
 
         for internal use only!
         """
-        assert isinstance(widget, quick_widgets.QuickWidget)
+        assert isinstance(widget, CagouWidget)
         self._visible_widgets.setdefault(widget.__class__, []).append(widget)
 
-    def removeVisibleWidget(self, widget):
+    def _removeVisibleWidget(self, widget):
         """declare a widget not visible anymore
 
         for internal use only!
         """
         self._visible_widgets[widget.__class__].remove(widget)
-        self.widgets.deleteWidget(widget)
+        if isinstance(self, quick_widgets.QuickWidget):
+            self.widgets.deleteWidget(widget)
 
     def getVisibleList(self, cls):
         """get list of visible widgets for a given class
 
-        @param cls(QuickWidget class): type of widgets to get
-        @return (list[QuickWidget class]): visible widgets of this class
+        @param cls(type): type of widgets to get
+        @return (list[type]): visible widgets of this class
         """
         try:
             return self._visible_widgets[cls]
--- a/cagou/core/widgets_handler.py	Sat Jan 26 20:24:48 2019 +0100
+++ b/cagou/core/widgets_handler.py	Sat Jan 26 20:24:48 2019 +0100
@@ -323,11 +323,11 @@
         self.updateHiddenSlides()
 
     def onSlideChange(self, handler, new_slide):
-        if isinstance(self._former_slide, quick_widgets.QuickWidget):
-            G.host.removeVisibleWidget(self._former_slide)
+        if self._former_slide is not None:
+            G.host._removeVisibleWidget(self._former_slide)
         self._former_slide = new_slide
-        if isinstance(new_slide, quick_widgets.QuickWidget):
-            G.host.addVisibleWidget(new_slide)
+        if new_slide is not None:
+            G.host._addVisibleWidget(new_slide)
             self.updateHiddenSlides()
 
     def hiddenList(self, visible_list):