From 0788e546f62f6cb389220b53743808cd232a61d5 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 4 Dec 2012 17:40:26 -0300 Subject: [PATCH] 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 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 Signed-off-by: Manuel QuiƱones Acked-by: Simon Schampijer --- 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 c0e56794..b4605959 100644 --- a/src/sugar3/graphics/tray.py +++ b/src/sugar3/graphics/tray.py @@ -137,6 +137,12 @@ class _TrayViewport(Gtk.Viewport): return self._can_scroll_prev def _size_allocate_cb(self, viewport, allocation): + if allocation.width == 1 and allocation.height == 1: + # HACK: the first time this callback is called 'width' and + # 'height' are 1 so we mark the Viewport as scrollable and + # we show the Prev / Next buttons + return + bar_minimum, bar_natural = self.traybar.get_preferred_size() if self.orientation == Gtk.Orientation.HORIZONTAL: