changeset 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
files src/browser/libervia_main.py src/browser/sat_browser/base_widget.py
diffstat 2 files changed, 11 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/browser/libervia_main.py	Mon Feb 23 18:44:58 2015 +0100
+++ b/src/browser/libervia_main.py	Mon Feb 23 18:44:58 2015 +0100
@@ -620,7 +620,12 @@
         except quick_widgets.WidgetAlreadyExistsError:
             kwargs['on_existing_widget'] = C.WIDGET_KEEP
             wid = self.widgets.getOrCreateWidget(class_, target, *args, **kwargs)
-            if wid.getWidgetsPanel() != self.tab_panel.getCurrentPanel():
+            widgets_panel = wid.getParent(base_widget.WidgetsPanel, expect=False)
+            if widgets_panel is None:
+                # The widget exists but is hidden
+                self.addWidget(wid)
+            elif widgets_panel != self.tab_panel.getCurrentPanel():
+                # the widget is on an other tab, so we add a new one here
                 kwargs['on_existing_widget'] = C.WIDGET_RECREATE
                 wid = self.widgets.getOrCreateWidget(class_, target, *args, **kwargs)
                 self.addWidget(wid)
--- a/src/browser/sat_browser/base_widget.py	Mon Feb 23 18:44:58 2015 +0100
+++ b/src/browser/sat_browser/base_widget.py	Mon Feb 23 18:44:58 2015 +0100
@@ -170,7 +170,7 @@
             if self == _new_panel:  # We can't drop on ourself
                 return
             # we need to remove the widget from the panel as it will be inserted elsewhere
-            widgets_panel = _new_panel.getWidgetsPanel()
+            widgets_panel = _new_panel.getParent(WidgetsPanel, expect=True)
             wid_row = widgets_panel.getWidgetCoords(_new_panel)[0]
             row_wids = widgets_panel.getLiberviaRowWidgets(wid_row)
             if len(row_wids) == 1 and wid_row == widgets_panel.getWidgetCoords(self)[0]:
@@ -330,9 +330,6 @@
     def getDebugName(self):
         return "%s (%s)" % (self, self._title.getText())
 
-    def getWidgetsPanel(self, expect=True):
-        return self.getParent(WidgetsPanel, expect)
-
     def getParent(self, class_=None, expect=True):
         """Return the closest ancestor of the specified class.
 
@@ -357,8 +354,8 @@
 
     def onClose(self, sender):
         """ Called when the close button is pushed """
-        _widgetspanel = self.getWidgetsPanel()
-        _widgetspanel.removeWidget(self)
+        widgets_panel = self.getParent(WidgetsPanel, expect=True)
+        widgets_panel.removeWidget(self)
         self.onQuit()
         self.host.widgets.deleteWidget(self)
 
@@ -373,7 +370,7 @@
         pass
 
     def onSetting(self, sender):
-        widpanel = self.getWidgetsPanel()
+        widpanel = self.getParent(WidgetsPanel, expect=True)
         row, col = widpanel.getIndex(self)
         body = VerticalPanel()
 
@@ -798,7 +795,7 @@
                 log.error("No widget registered in LiberviaDragWidget !")
                 return
             _new_panel = LiberviaDragWidget.current
-            _new_panel.getWidgetsPanel().removeWidget(_new_panel)
+            _new_panel.getParent(WidgetsPanel, expect=True).removeWidget(_new_panel)
         elif item_type in DropCell.drop_keys:
             _new_panel = DropCell.drop_keys[item_type](self.tab_panel.host, item)
         else: