diff src/cagou/core/widgets_handler.py @ 34:02acbb297a61

handler, widget: deleteWidget is now properly called when a QuickWidget is deleted
author Goffi <goffi@goffi.org>
date Mon, 22 Aug 2016 20:58:12 +0200
parents ba14b596b90e
children 9f45098289cc
line wrap: on
line diff
--- a/src/cagou/core/widgets_handler.py	Sun Aug 21 21:41:52 2016 +0200
+++ b/src/cagou/core/widgets_handler.py	Mon Aug 22 20:58:12 2016 +0200
@@ -20,6 +20,7 @@
 
 from sat.core import log as logging
 log = logging.getLogger(__name__)
+from sat_frontends.quick_frontend import quick_widgets
 from kivy.uix.boxlayout import BoxLayout
 from kivy.uix.button import Button
 from kivy import properties
@@ -88,9 +89,11 @@
     def removeWidget(self, vertical):
         if vertical and self.vert_wid is not None:
             self.remove_widget(self.vert_wid)
+            self.vert_wid.onDelete()
             self.vert_wid = None
         elif self.hor_wid is not None:
             self.blh.remove_widget(self.hor_wid)
+            self.hor_wid.onDelete()
             self.hor_wid = None
 
     def setWidgetSize(self, vertical, size):
@@ -104,3 +107,9 @@
                 self.hor_wid = WidgetsHandler(self.default_widget, size_hint=(None, 1))
                 self.blh.add_widget(self.hor_wid, len(self.blh.children))
             self.hor_wid.width=size
+
+    def onDelete(self):
+        # when this handler is deleted, we need to delete the holded CagouWidget
+        cagou_widget = self.children[0].children[0].children[0]
+        if isinstance(cagou_widget, quick_widgets.QuickWidget):
+            G.host.widgets.deleteWidget(cagou_widget)