comparison 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
comparison
equal deleted inserted replaced
293:7c79d4d66161 294:a6b3715f0bd6
175 self.__title_id = HTMLPanel.createUniqueId() 175 self.__title_id = HTMLPanel.createUniqueId()
176 self.__setting_button_id = HTMLPanel.createUniqueId() 176 self.__setting_button_id = HTMLPanel.createUniqueId()
177 self.__close_button_id = HTMLPanel.createUniqueId() 177 self.__close_button_id = HTMLPanel.createUniqueId()
178 self.__title = Label(title) 178 self.__title = Label(title)
179 self.__title.setStyleName('widgetHeader_title') 179 self.__title.setStyleName('widgetHeader_title')
180 self._close_listeners = []
180 header = WidgetHeader(self, self.__title) 181 header = WidgetHeader(self, self.__title)
181 self.add(header) 182 self.add(header)
182 self.setSize('100%', '100%') 183 self.setSize('100%', '100%')
183 self.addStyleName('widget') 184 self.addStyleName('widget')
184 if self.__selectable: 185 if self.__selectable:
185 self.addClickListener(self) 186 self.addClickListener(self)
187 self.addCloseListener(self.host.uni_box.onWidgetClosed)
186 self.host.registerWidget(self) 188 self.host.registerWidget(self)
187 189
188 def getDebugName(self): 190 def getDebugName(self):
189 return "%s (%s)" % (self, self.__title.getText()) 191 return "%s (%s)" % (self, self.__title.getText())
190 192
202 204
203 def onClose(self, sender): 205 def onClose(self, sender):
204 """ Called when the close button is pushed """ 206 """ Called when the close button is pushed """
205 _widgetspanel = self.getWidgetsPanel() 207 _widgetspanel = self.getWidgetsPanel()
206 _widgetspanel.removeWidget(self) 208 _widgetspanel.removeWidget(self)
209 for callback in self._close_listeners:
210 callback(self)
207 self.onQuit() 211 self.onQuit()
208 212
209 def onQuit(self): 213 def onQuit(self):
210 """ Called when the widget is actually ending """ 214 """ Called when the widget is actually ending """
211 pass 215 pass
216
217 def addCloseListener(self, callback):
218 """Add a close listener to this widget
219 @param callback: function to be called from self.onClose"""
220 self._close_listeners.append(callback)
212 221
213 def refresh(self): 222 def refresh(self):
214 """This can be overwritten by a child class to refresh the display when, 223 """This can be overwritten by a child class to refresh the display when,
215 instead of creating a new one, an existing widget is found and reused. 224 instead of creating a new one, an existing widget is found and reused.
216 """ 225 """