comparison src/browser/sat_browser/libervia_widget.py @ 656:4dbd99de3aaa frontends_multi_profiles

browser_side: only display "+" button when the tab bar contains only 1 tab, and display it over the contact list to not use vertical space
author souliane <souliane@mailoo.org>
date Fri, 27 Feb 2015 13:00:04 +0100
parents 40c72f3b7638
children 0b7e4226378d
comparison
equal deleted inserted replaced
655:048401e5c506 656:4dbd99de3aaa
748 def __init__(self, host): 748 def __init__(self, host):
749 TabPanel.__init__(self, FloatingTab=True) 749 TabPanel.__init__(self, FloatingTab=True)
750 ClickHandler.__init__(self) 750 ClickHandler.__init__(self)
751 self.host = host 751 self.host = host
752 self.setStyleName('liberviaTabPanel') 752 self.setStyleName('liberviaTabPanel')
753 753 self.tabBar.addTab(u'✚', asHTML=True)
754 self.tabBar.addTab(u'✚', True) 754 self.tabBar.addStyleDependentName('oneTab')
755 755
756 def onTabSelected(self, sender, tabIndex): 756 def onTabSelected(self, sender, tabIndex):
757 if tabIndex < self.getWidgetCount(): 757 if tabIndex < self.getWidgetCount():
758 TabPanel.onTabSelected(self, sender, tabIndex) 758 TabPanel.onTabSelected(self, sender, tabIndex)
759 return 759 return
760 # user clicked the "+" tab 760 # user clicked the "+" tab
761 default_label = _(u'new tab') 761 default_label = _(u'new tab')
762 try: 762 try:
763 label = Window.prompt(_(u'Name of the new tab'), default_label) 763 label = Window.prompt(_(u'Name of the new tab'), default_label)
764 if not label: 764 if not label:
765 label = default_label 765 return # empty label or user pressed "cancel"
766 except: # this happens when the user prevents the page to open the prompt dialog 766 except: # this happens when the user prevents the page to open the prompt dialog
767 label = default_label 767 label = default_label
768 self.addWidgetsTab(label, select=True) 768 self.addWidgetsTab(label, select=True)
769 769
770 def getCurrentPanel(self): 770 def getCurrentPanel(self):
780 @param widget (Widget): widget to associate to the tab 780 @param widget (Widget): widget to associate to the tab
781 @param label (unicode): label of the tab 781 @param label (unicode): label of the tab
782 @param select (bool): True to select the added tab 782 @param select (bool): True to select the added tab
783 """ 783 """
784 TabPanel.add(self, widget, DropTab(self, label), False) 784 TabPanel.add(self, widget, DropTab(self, label), False)
785 if self.getWidgetCount() > 1:
786 self.tabBar.removeStyleDependentName('oneTab')
785 if select: 787 if select:
786 self.selectTab(self.getWidgetCount() - 1) 788 self.selectTab(self.getWidgetCount() - 1)
787 789
788 def addWidgetsTab(self, label, select=False, locked=False): 790 def addWidgetsTab(self, label, select=False, locked=False):
789 """Create a new tab for containing LiberviaWidgets. 791 """Create a new tab for containing LiberviaWidgets.
802 def onWidgetPanelRemove(self, panel): 804 def onWidgetPanelRemove(self, panel):
803 """ Called when a child WidgetsPanel is empty and need to be removed """ 805 """ Called when a child WidgetsPanel is empty and need to be removed """
804 widget_index = self.getWidgetIndex(panel) 806 widget_index = self.getWidgetIndex(panel)
805 self.remove(panel) 807 self.remove(panel)
806 widgets_count = self.getWidgetCount() 808 widgets_count = self.getWidgetCount()
809 if widgets_count == 1:
810 self.tabBar.addStyleDependentName('oneTab')
807 self.selectTab(widget_index if widget_index < widgets_count else widgets_count - 1) 811 self.selectTab(widget_index if widget_index < widgets_count else widgets_count - 1)
808
809