Ticket #3560: 0001-New-layout-of-tabs-SL-3560.patch

File 0001-New-layout-of-tabs-SL-3560.patch, 2.5 KB (added by humitos, 12 years ago)
  • browser.py

    From 773aba569adecf8f167b0754c9181ac76112538a Mon Sep 17 00:00:00 2001
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Fri, 12 Oct 2012 10:01:18 -0300
    Subject: [PATCH Browse] 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 <humitos@gmail.com>
    ---
     browser.py | 31 +++++++++++++++----------------
     1 file changed, 15 insertions(+), 16 deletions(-)
    
    diff --git a/browser.py b/browser.py
    index fbcdace..555c623 100644
    a b class TabbedView(BrowserNotebook): 
    249249        tab_page.destroy()
    250250
    251251    def _update_tab_sizes(self):
    252         """Update ta widths based in the amount of tabs."""
     252        """Update tab widths based in the amount of tabs."""
    253253
    254254        n_pages = self.get_n_pages()
    255255        canvas_size = self.get_allocation()
    256         # FIXME
    257         # overlap_size = self.style_get_property('tab-overlap') * n_pages - 1
    258         overlap_size = 0
    259         allowed_size = canvas_size.width - overlap_size
    260 
    261         tab_new_size = int(allowed_size * 1.0 / (n_pages + 1))
    262         # Four tabs ensured:
    263         tab_max_size = int(allowed_size * 1.0 / (5))
    264         # Eight tabs ensured:
    265         tab_min_size = int(allowed_size * 1.0 / (9))
    266 
    267         if tab_new_size < tab_min_size:
    268             tab_new_size = tab_min_size
    269         elif tab_new_size > tab_max_size:
    270             tab_new_size = tab_max_size
     256        allowed_size = canvas_size.width
     257        if n_pages == 1:
     258            # use half of the whole space
     259            tab_expand = False
     260            tab_new_size = int(allowed_size / 2)
     261        elif n_pages > 8:
     262            # scroll the tab toolbar if there are more than 8 tabs
     263            tab_expand = False
     264            tab_new_size = (allowed_size / 8)
     265        else:
     266            # use all the space available by tabs
     267            tab_expand = True
     268            tab_new_size = -1
    271269
    272270        for page_idx in range(n_pages):
    273271            page = self.get_nth_page(page_idx)
    274272            label = self.get_tab_label(page)
     273            self.child_set_property(page, 'tab-expand', tab_expand)
    275274            label.update_size(tab_new_size)
    276275
    277276    def _update_closing_buttons(self):