Ticket #3522: 0001-Tray-set-a-minimum-size-in-the-viewport-so-that-it-a.patch

File 0001-Tray-set-a-minimum-size-in-the-viewport-so-that-it-a.patch, 1.8 KB (added by garnacho, 12 years ago)

Patch, fixes size allocation bug in [VH]Tray widgets, so they don't make the window grow

  • src/sugar3/graphics/tray.py

    From f5166d682f075a50d98c638f4375638c812d039b Mon Sep 17 00:00:00 2001
    From: Carlos Garnacho <carlos@lanedo.com>
    Date: Fri, 4 May 2012 14:52:25 +0200
    Subject: [PATCH] Tray: set a minimum size in the viewport so that it allows
     scrolling
    
    The minimum height/width requested by the GtkViewport still tries to cater
    for all contained children, which makes the [VH]Tray widgets to grow as
    new items are added. Instead, request a minimum width/height of 0 to avoid
    the Tray from growing, and having scrolling kick in instead.
    
    Also, fixed what seemed to be a typo in do_get_preferred_height(), where
    the viewport width was requested instead.
    
    http://bugs.sugarlabs.org/ticket/3522
    
    Signed-off-by: Carlos Garnacho <carlos@lanedo.com>
    ---
     src/sugar3/graphics/tray.py |    6 ++++--
     1 file changed, 4 insertions(+), 2 deletions(-)
    
    diff --git a/src/sugar3/graphics/tray.py b/src/sugar3/graphics/tray.py
    index f4bfb83..d1c0cfd 100644
    a b class _TrayViewport(Gtk.Viewport): 
    115115
    116116    def do_get_preferred_width(self):
    117117        if self.orientation == Gtk.Orientation.HORIZONTAL:
    118             return Gtk.Viewport.do_get_preferred_width(self)
     118            min_width, nat_width = Gtk.Viewport.do_get_preferred_width(self)
     119            return 0, nat_width
    119120        child_minimum, child_natural = self.get_child().get_preferred_size()
    120121        return child_minimum.width, child_natural.width
    121122
    122123    def do_get_preferred_height(self):
    123124        if self.orientation != Gtk.Orientation.HORIZONTAL:
    124             return Gtk.Viewport.do_get_preferred_width(self)
     125            min_height, nat_height = Gtk.Viewport.do_get_preferred_height(self)
     126            return 0, nat_height
    125127        child_minimum, child_natural = self.get_child().get_preferred_size()
    126128        return child_minimum.height, child_natural.height
    127129