From f96776a4705e0b131d34c1a519b92615c97cf980 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Fri, 12 Oct 2012 13:01:18 +0000 Subject: New layout of tabs SL #3560 When Browse starts it shows just one tab sized half of the whole canvas. Every time a new tab is added they are resized and expanded over the full canvas width to make them fit. Once the 9th[1] tab is reached, all of them keep the same size and two buttons are added to be able to scroll over them. [1] this decision was taken here 959f86e0406914267047dc10302f98a059b6ba21 Signed-off-by: Manuel Kaufmann Acked-by: Manuel QuiƱones --- (limited to 'browser.py') diff --git a/browser.py b/browser.py index 8b3463a..472d83b 100644 --- a/browser.py +++ b/browser.py @@ -249,29 +249,27 @@ class TabbedView(BrowserNotebook): tab_page.destroy() def _update_tab_sizes(self): - """Update ta widths based in the amount of tabs.""" + """Update tab widths based in the amount of tabs.""" n_pages = self.get_n_pages() canvas_size = self.get_allocation() - # FIXME - # overlap_size = self.style_get_property('tab-overlap') * n_pages - 1 - overlap_size = 0 - allowed_size = canvas_size.width - overlap_size - - tab_new_size = int(allowed_size * 1.0 / (n_pages + 1)) - # Four tabs ensured: - tab_max_size = int(allowed_size * 1.0 / (5)) - # Eight tabs ensured: - tab_min_size = int(allowed_size * 1.0 / (9)) - - if tab_new_size < tab_min_size: - tab_new_size = tab_min_size - elif tab_new_size > tab_max_size: - tab_new_size = tab_max_size + allowed_size = canvas_size.width + if n_pages == 1: + # use half of the whole space + tab_expand = False + tab_new_size = int(allowed_size / 2) + elif n_pages <= 8: # ensure eight tabs + tab_expand = True # use all the space available by tabs + tab_new_size = -1 + else: + # scroll the tab toolbar if there are more than 8 tabs + tab_expand = False + tab_new_size = (allowed_size / 8) for page_idx in range(n_pages): page = self.get_nth_page(page_idx) label = self.get_tab_label(page) + self.child_set_property(page, 'tab-expand', tab_expand) label.update_size(tab_new_size) def _update_closing_buttons(self): -- cgit v0.9.1