comparison src/browser/libervia_main.py @ 631:e287a4b431c1 frontends_multi_profiles

browser side (libervia main): implemented visible_widgets property
author Goffi <goffi@goffi.org>
date Mon, 23 Feb 2015 18:20:04 +0100
parents 1c0d5a87c554
children 86ae737da6f3
comparison
equal deleted inserted replaced
630:71abccd8d228 631:e287a4b431c1
24 from sat.core.log import getLogger 24 from sat.core.log import getLogger
25 log = getLogger(__name__) 25 log = getLogger(__name__)
26 ### 26 ###
27 27
28 from sat_frontends.quick_frontend.quick_app import QuickApp 28 from sat_frontends.quick_frontend.quick_app import QuickApp
29 from sat_frontends.quick_frontend.quick_widgets import WidgetAlreadyExistsError 29 from sat_frontends.quick_frontend import quick_widgets
30 30
31 from sat_frontends.tools.misc import InputHistory 31 from sat_frontends.tools.misc import InputHistory
32 from sat_frontends.tools import strings 32 from sat_frontends.tools import strings
33 from sat_frontends.tools import jid 33 from sat_frontends.tools import jid
34 from sat.core.i18n import _ 34 from sat.core.i18n import _
109 return self.profiles[C.PROF_KEY_NONE].whoami 109 return self.profiles[C.PROF_KEY_NONE].whoami
110 110
111 @property 111 @property
112 def contact_list(self): 112 def contact_list(self):
113 return self.contact_lists[C.PROF_KEY_NONE] 113 return self.contact_lists[C.PROF_KEY_NONE]
114
115 @property
116 def visible_widgets(self):
117 widgets_panel = self.tab_panel.getCurrentPanel()
118 return [wid for wid in widgets_panel.widgets if isinstance(wid, quick_widgets.QuickWidget)]
114 119
115 @property 120 @property
116 def base_location(self): 121 def base_location(self):
117 """Return absolute base url of this Libervia instance""" 122 """Return absolute base url of this Libervia instance"""
118 url = Window.getLocation().getHref() 123 url = Window.getLocation().getHref()
582 def displayWidget(self, class_, target, dropped=False, new_tab=None, *args, **kwargs): 587 def displayWidget(self, class_, target, dropped=False, new_tab=None, *args, **kwargs):
583 """Get or create a LiberviaWidget and select it. When the user dropped 588 """Get or create a LiberviaWidget and select it. When the user dropped
584 something, a new widget is always created, otherwise we look for an 589 something, a new widget is always created, otherwise we look for an
585 existing widget and re-use it if it's in the current tab. 590 existing widget and re-use it if it's in the current tab.
586 591
587 @arg class_(class): see sat_frontends.quick_frontend.quick_widgets.getOrCreateWidget 592 @arg class_(class): see quick_widgets.getOrCreateWidget
588 @arg target: see sat_frontends.quick_frontend.quick_widgets.getOrCreateWidget 593 @arg target: see quick_widgets.getOrCreateWidget
589 @arg dropped(bool): if True, assume the widget has been dropped 594 @arg dropped(bool): if True, assume the widget has been dropped
590 @arg new_tab(unicode): if not None, it holds the name of a new tab to 595 @arg new_tab(unicode): if not None, it holds the name of a new tab to
591 open for the widget. If None, use the default behavior. 596 open for the widget. If None, use the default behavior.
592 @param args(list): optional args to create a new instance of class_ 597 @param args(list): optional args to create a new instance of class_
593 @param kwargs(list): optional kwargs to create a new instance of class_ 598 @param kwargs(list): optional kwargs to create a new instance of class_
610 return wid 615 return wid
611 616
612 kwargs['on_existing_widget'] = C.WIDGET_RAISE 617 kwargs['on_existing_widget'] = C.WIDGET_RAISE
613 try: 618 try:
614 wid = self.widgets.getOrCreateWidget(class_, target, *args, **kwargs) 619 wid = self.widgets.getOrCreateWidget(class_, target, *args, **kwargs)
615 except WidgetAlreadyExistsError: 620 except quick_widgets.WidgetAlreadyExistsError:
616 kwargs['on_existing_widget'] = C.WIDGET_KEEP 621 kwargs['on_existing_widget'] = C.WIDGET_KEEP
617 wid = self.widgets.getOrCreateWidget(class_, target, *args, **kwargs) 622 wid = self.widgets.getOrCreateWidget(class_, target, *args, **kwargs)
618 if wid.getWidgetsPanel() != self.tab_panel.getCurrentPanel(): 623 if wid.getWidgetsPanel() != self.tab_panel.getCurrentPanel():
619 kwargs['on_existing_widget'] = C.WIDGET_RECREATE 624 kwargs['on_existing_widget'] = C.WIDGET_RECREATE
620 wid = self.widgets.getOrCreateWidget(class_, target, *args, **kwargs) 625 wid = self.widgets.getOrCreateWidget(class_, target, *args, **kwargs)