Ticket #4279: 0001-Do-not-show-Prev-Next-button-the-first-time-a-Tray-i.patch

File 0001-Do-not-show-Prev-Next-button-the-first-time-a-Tray-i.patch, 1.7 KB (added by humitos, 11 years ago)

A candidate solution; not the best one.

  • src/sugar3/graphics/tray.py

    From 39f485218175454daff788633cd3bd69861e6b79 Mon Sep 17 00:00:00 2001
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Tue, 4 Dec 2012 17:40:26 -0300
    Subject: [PATCH sugar-toolkit-gtk3] Do not show Prev/Next button the first
     time a Tray is shown SL #4279
    
    The first time '_TrayViewport._size_allocate_cb' is called
    'allocation.width' and 'allocation.height' are 1, so we mark the
    Viewport as scrollable and we show the Prev / Next buttons.
    
    Immediately after that, the callback is called again with the right
    values for 'allocation.width' and 'allocation.height', so as we are
    showing just one element at this moment the Prev / Next buttons are
    not needed and they are set as 'self.props.visible = False' but the
    space that they occupied is not freed.
    
    This patch makes '_TrayViewport._size_allocate_cb' to return if the
    values for allocation is 1 avoiding the space requested for the Prev /
    Next buttons.
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    ---
     src/sugar3/graphics/tray.py | 6 ++++++
     1 file changed, 6 insertions(+)
    
    diff --git a/src/sugar3/graphics/tray.py b/src/sugar3/graphics/tray.py
    index 9d12883..6b1c912 100644
    a b class _TrayViewport(Gtk.Viewport): 
    137137            return self._can_scroll_prev
    138138
    139139    def _size_allocate_cb(self, viewport, allocation):
     140        if allocation.width == 1 and allocation.height == 1:
     141            # HACK: the first time this callback is called 'width' and
     142            # 'height' are 1 so we mark the Viewport as scrollable and
     143            # we show the Prev / Next buttons
     144            return
     145
    140146        bar_minimum, bar_natural = self.traybar.get_preferred_size()
    141147
    142148        if self.orientation == Gtk.Orientation.HORIZONTAL: