Mercurial > libervia-web
comparison src/browser/sat_browser/base_widget.py @ 636:86ae737da6f3 frontends_multi_profiles
browser side (widgets management): removed getWidgetsPanel: we use directly getParent which do the same thing + displayWidget now detect hidden widgets (widgets without parent WidgetsPanel)
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 23 Feb 2015 18:44:58 +0100 |
parents | 40c3c6aaafaa |
children | 7113d40533d6 |
comparison
equal
deleted
inserted
replaced
635:40c3c6aaafaa | 636:86ae737da6f3 |
---|---|
168 return | 168 return |
169 _new_panel = LiberviaDragWidget.current | 169 _new_panel = LiberviaDragWidget.current |
170 if self == _new_panel: # We can't drop on ourself | 170 if self == _new_panel: # We can't drop on ourself |
171 return | 171 return |
172 # we need to remove the widget from the panel as it will be inserted elsewhere | 172 # we need to remove the widget from the panel as it will be inserted elsewhere |
173 widgets_panel = _new_panel.getWidgetsPanel() | 173 widgets_panel = _new_panel.getParent(WidgetsPanel, expect=True) |
174 wid_row = widgets_panel.getWidgetCoords(_new_panel)[0] | 174 wid_row = widgets_panel.getWidgetCoords(_new_panel)[0] |
175 row_wids = widgets_panel.getLiberviaRowWidgets(wid_row) | 175 row_wids = widgets_panel.getLiberviaRowWidgets(wid_row) |
176 if len(row_wids) == 1 and wid_row == widgets_panel.getWidgetCoords(self)[0]: | 176 if len(row_wids) == 1 and wid_row == widgets_panel.getWidgetCoords(self)[0]: |
177 # the dropped widget is the only one in the same row | 177 # the dropped widget is the only one in the same row |
178 # as the target widget (self), we don't do anything | 178 # as the target widget (self), we don't do anything |
328 # self.host.registerWidget(self) # FIXME | 328 # self.host.registerWidget(self) # FIXME |
329 | 329 |
330 def getDebugName(self): | 330 def getDebugName(self): |
331 return "%s (%s)" % (self, self._title.getText()) | 331 return "%s (%s)" % (self, self._title.getText()) |
332 | 332 |
333 def getWidgetsPanel(self, expect=True): | |
334 return self.getParent(WidgetsPanel, expect) | |
335 | |
336 def getParent(self, class_=None, expect=True): | 333 def getParent(self, class_=None, expect=True): |
337 """Return the closest ancestor of the specified class. | 334 """Return the closest ancestor of the specified class. |
338 | 335 |
339 Note: this method overrides pyjamas.ui.Widget.getParent | 336 Note: this method overrides pyjamas.ui.Widget.getParent |
340 | 337 |
355 def onClick(self, sender): | 352 def onClick(self, sender): |
356 self.host.setSelected(self) | 353 self.host.setSelected(self) |
357 | 354 |
358 def onClose(self, sender): | 355 def onClose(self, sender): |
359 """ Called when the close button is pushed """ | 356 """ Called when the close button is pushed """ |
360 _widgetspanel = self.getWidgetsPanel() | 357 widgets_panel = self.getParent(WidgetsPanel, expect=True) |
361 _widgetspanel.removeWidget(self) | 358 widgets_panel.removeWidget(self) |
362 self.onQuit() | 359 self.onQuit() |
363 self.host.widgets.deleteWidget(self) | 360 self.host.widgets.deleteWidget(self) |
364 | 361 |
365 def onQuit(self): | 362 def onQuit(self): |
366 """ Called when the widget is actually ending """ | 363 """ Called when the widget is actually ending """ |
371 instead of creating a new one, an existing widget is found and reused. | 368 instead of creating a new one, an existing widget is found and reused. |
372 """ | 369 """ |
373 pass | 370 pass |
374 | 371 |
375 def onSetting(self, sender): | 372 def onSetting(self, sender): |
376 widpanel = self.getWidgetsPanel() | 373 widpanel = self.getParent(WidgetsPanel, expect=True) |
377 row, col = widpanel.getIndex(self) | 374 row, col = widpanel.getIndex(self) |
378 body = VerticalPanel() | 375 body = VerticalPanel() |
379 | 376 |
380 # colspan & rowspan | 377 # colspan & rowspan |
381 colspan = widpanel.getColSpan(row, col) | 378 colspan = widpanel.getColSpan(row, col) |
796 if item_type == "WIDGET": | 793 if item_type == "WIDGET": |
797 if not LiberviaDragWidget.current: | 794 if not LiberviaDragWidget.current: |
798 log.error("No widget registered in LiberviaDragWidget !") | 795 log.error("No widget registered in LiberviaDragWidget !") |
799 return | 796 return |
800 _new_panel = LiberviaDragWidget.current | 797 _new_panel = LiberviaDragWidget.current |
801 _new_panel.getWidgetsPanel().removeWidget(_new_panel) | 798 _new_panel.getParent(WidgetsPanel, expect=True).removeWidget(_new_panel) |
802 elif item_type in DropCell.drop_keys: | 799 elif item_type in DropCell.drop_keys: |
803 _new_panel = DropCell.drop_keys[item_type](self.tab_panel.host, item) | 800 _new_panel = DropCell.drop_keys[item_type](self.tab_panel.host, item) |
804 else: | 801 else: |
805 log.warning("unmanaged item type") | 802 log.warning("unmanaged item type") |
806 return | 803 return |