comparison src/browser/libervia_main.py @ 620:ac5881d683d3 frontends_multi_profiles

browser_side: move SatWebFrontend.addTab to MainTabPanel.addWidgetsTab and rename MainTabPanel.add to MainTabPanel.addTab
author souliane <souliane@mailoo.org>
date Fri, 20 Feb 2015 19:38:11 +0100
parents 1c0d5a87c554
children 4f7550a083b4
comparison
equal deleted inserted replaced
619:11a0a32144a5 620:ac5881d683d3
78 self.bridge_signals = json.BridgeSignals(self) 78 self.bridge_signals = json.BridgeSignals(self)
79 QuickApp.__init__(self, json.BridgeCall) 79 QuickApp.__init__(self, json.BridgeCall)
80 self.uni_box = None # FIXME: to be removed 80 self.uni_box = None # FIXME: to be removed
81 self.status_panel = HTML('<br />') 81 self.status_panel = HTML('<br />')
82 self.panel = panels.MainPanel(self) 82 self.panel = panels.MainPanel(self)
83 self.discuss_panel = self.panel.discuss_panel
84 self.tab_panel = self.panel.tab_panel 83 self.tab_panel = self.panel.tab_panel
85 self.tab_panel.addTabListener(self) 84 self.tab_panel.addTabListener(self)
86 self._register_box = None 85 self._register_box = None
87 RootPanel().add(self.panel) 86 RootPanel().add(self.panel)
88 87
231 """Refresh the general display.""" 230 """Refresh the general display."""
232 self.panel.refresh() 231 self.panel.refresh()
233 for lib_wid in self.libervia_widgets: 232 for lib_wid in self.libervia_widgets:
234 lib_wid.refresh() 233 lib_wid.refresh()
235 self.resize() 234 self.resize()
236
237 def addTab(self, label, wid=None, select=False):
238 """Create a new tab and eventually add a widget to it.
239
240 @param label (unicode): label of the tab
241 @param wid (LiberviaWidget): optional widget to add
242 @param select (bool): True to select the added tab
243 @return: WidgetsPanel
244 """
245 widgets_panel = base_widget.WidgetsPanel(self)
246 self.tab_panel.add(widgets_panel, label)
247 tab_index = self.tab_panel.getWidgetCount() - 1
248 if wid is not None:
249 self.addWidget(wid, tab_index)
250 if select:
251 self.tab_panel.selectTab(tab_index)
252 if wid is not None:
253 self.setSelected(wid)
254 return widgets_panel
255 235
256 def addWidget(self, wid, tab_index=None): 236 def addWidget(self, wid, tab_index=None):
257 """ Add a widget at the bottom of the current or specified tab 237 """ Add a widget at the bottom of the current or specified tab
258 238
259 @param wid: LiberviaWidget to add 239 @param wid: LiberviaWidget to add
604 584
605 if new_tab: 585 if new_tab:
606 kwargs['on_new_widget'] = None 586 kwargs['on_new_widget'] = None
607 kwargs['on_existing_widget'] = C.WIDGET_RECREATE 587 kwargs['on_existing_widget'] = C.WIDGET_RECREATE
608 wid = self.widgets.getOrCreateWidget(class_, target, *args, **kwargs) 588 wid = self.widgets.getOrCreateWidget(class_, target, *args, **kwargs)
609 self.addTab(new_tab, wid) 589 self.tab_panel.addWidgetsTab(new_tab)
590 self.addWidget(wid)
610 return wid 591 return wid
611 592
612 kwargs['on_existing_widget'] = C.WIDGET_RAISE 593 kwargs['on_existing_widget'] = C.WIDGET_RAISE
613 try: 594 try:
614 wid = self.widgets.getOrCreateWidget(class_, target, *args, **kwargs) 595 wid = self.widgets.getOrCreateWidget(class_, target, *args, **kwargs)