diff browser_side/base_widget.py @ 294:a6b3715f0bd6

browser_side: bug fixes for switching between unibox and rich text editor: - handle non selectable widget in UniBox._getTarget - reset the selection when selected LiberviaWidget is closed
author souliane <souliane@mailoo.org>
date Mon, 16 Dec 2013 16:39:03 +0100
parents 28d3315a8003
children 05e264e96a1c
line wrap: on
line diff
--- a/browser_side/base_widget.py	Sun Dec 15 12:01:25 2013 +0100
+++ b/browser_side/base_widget.py	Mon Dec 16 16:39:03 2013 +0100
@@ -177,12 +177,14 @@
         self.__close_button_id = HTMLPanel.createUniqueId()
         self.__title = Label(title)
         self.__title.setStyleName('widgetHeader_title')
+        self._close_listeners = []
         header = WidgetHeader(self, self.__title)
         self.add(header)
         self.setSize('100%', '100%')
         self.addStyleName('widget')
         if self.__selectable:
             self.addClickListener(self)
+            self.addCloseListener(self.host.uni_box.onWidgetClosed)
         self.host.registerWidget(self)
 
     def getDebugName(self):
@@ -204,12 +206,19 @@
         """ Called when the close button is pushed """
         _widgetspanel = self.getWidgetsPanel()
         _widgetspanel.removeWidget(self)
+        for callback in self._close_listeners:
+            callback(self)
         self.onQuit()
 
     def onQuit(self):
         """ Called when the widget is actually ending """
         pass
 
+    def addCloseListener(self, callback):
+        """Add a close listener to this widget
+        @param callback: function to be called from self.onClose"""
+        self._close_listeners.append(callback)
+
     def refresh(self):
         """This can be overwritten by a child class to refresh the display when,
         instead of creating a new one, an existing widget is found and reused.