Ticket #4279: 0002-TrayViewport-handle-the-case-of-the-widget-not-yet-a.patch

File 0002-TrayViewport-handle-the-case-of-the-widget-not-yet-a.patch, 1.6 KB (added by manuq, 11 years ago)

Improved commit comment.

  • src/sugar3/graphics/tray.py

    From 85e3df5a5debc32944cef6c8ef9bd945a1c28333 Mon Sep 17 00:00:00 2001
    From: Manuel Kaufmann <humitos@gmail.com>
    Date: Tue, 4 Dec 2012 17:40:26 -0300
    Subject: [PATCH toolkit 2/2] TrayViewport: handle the case of the widget not
     yet allocated in the size-allocate callback -
     SL #4279
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
    
    In the callback, the allocation can be 1x1 if it is yet unknown [1].
    This is the case of trays that start hidden by default, like the one
    in Browse activity.
    
    [1] http://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-size-allocate
    
    Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
    Signed-off-by: Manuel Quiñones <manuq@laptop.org>
    ---
     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 c0e5679..b460595 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: