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>
Acked-by: Simon Schampijer <simon@laptop.org>
This commit is contained in:
Carlos Garnacho 2012-05-04 14:52:25 +02:00 committed by Simon Schampijer
parent abe02123b7
commit f36fc4ae85

View File

@ -115,13 +115,15 @@ class _TrayViewport(Gtk.Viewport):
def do_get_preferred_width(self): def do_get_preferred_width(self):
if self.orientation == Gtk.Orientation.HORIZONTAL: if self.orientation == Gtk.Orientation.HORIZONTAL:
return Gtk.Viewport.do_get_preferred_width(self) min_width, nat_width = Gtk.Viewport.do_get_preferred_width(self)
return 0, nat_width
child_minimum, child_natural = self.get_child().get_preferred_size() child_minimum, child_natural = self.get_child().get_preferred_size()
return child_minimum.width, child_natural.width return child_minimum.width, child_natural.width
def do_get_preferred_height(self): def do_get_preferred_height(self):
if self.orientation != Gtk.Orientation.HORIZONTAL: if self.orientation != Gtk.Orientation.HORIZONTAL:
return Gtk.Viewport.do_get_preferred_width(self) min_height, nat_height = Gtk.Viewport.do_get_preferred_height(self)
return 0, nat_height
child_minimum, child_natural = self.get_child().get_preferred_size() child_minimum, child_natural = self.get_child().get_preferred_size()
return child_minimum.height, child_natural.height return child_minimum.height, child_natural.height