diff 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
line wrap: on
line diff
--- a/src/browser/sat_browser/libervia_widget.py	Fri Feb 27 02:41:11 2015 +0100
+++ b/src/browser/sat_browser/libervia_widget.py	Fri Feb 27 13:00:04 2015 +0100
@@ -750,8 +750,8 @@
         ClickHandler.__init__(self)
         self.host = host
         self.setStyleName('liberviaTabPanel')
-
-        self.tabBar.addTab(u'✚', True)
+        self.tabBar.addTab(u'✚', asHTML=True)
+        self.tabBar.addStyleDependentName('oneTab')
 
     def onTabSelected(self, sender, tabIndex):
         if tabIndex < self.getWidgetCount():
@@ -762,7 +762,7 @@
         try:
             label = Window.prompt(_(u'Name of the new tab'), default_label)
             if not label:
-                label = default_label
+                return  # empty label or user pressed "cancel"
         except:  # this happens when the user prevents the page to open the prompt dialog
             label = default_label
         self.addWidgetsTab(label, select=True)
@@ -782,6 +782,8 @@
         @param select (bool): True to select the added tab
         """
         TabPanel.add(self, widget, DropTab(self, label), False)
+        if self.getWidgetCount() > 1:
+            self.tabBar.removeStyleDependentName('oneTab')
         if select:
             self.selectTab(self.getWidgetCount() - 1)
 
@@ -804,6 +806,6 @@
         widget_index = self.getWidgetIndex(panel)
         self.remove(panel)
         widgets_count = self.getWidgetCount()
+        if widgets_count == 1:
+            self.tabBar.addStyleDependentName('oneTab')
         self.selectTab(widget_index if widget_index < widgets_count else widgets_count - 1)
-
-