Tray size allocation fixes.

This commit is contained in:
Marco Pesenti Gritti 2007-08-29 14:04:46 +02:00
parent 0512ae5853
commit 710f3eba00
3 changed files with 23 additions and 18 deletions

View File

@ -54,7 +54,7 @@ class ActivitiesBox(hippo.CanvasBox):
self._invites = self._shell_model.get_invites()
self.tray = HTray()
self.append(hippo.CanvasWidget(widget=self.tray))
self.append(hippo.CanvasWidget(widget=self.tray), hippo.PACK_EXPAND)
self.tray.show()
registry = activity.get_registry()
@ -87,8 +87,7 @@ class ActivitiesBox(hippo.CanvasBox):
self.remove_invite(invite)
def _activity_removed_cb(self, item):
index = self.tray.get_item_index(item)
self.tray.remove_item(index)
self.tray.remove_item(item)
def _activity_added_cb(self, activity_registry, activity_info):
self.add_activity(activity_info)

View File

@ -222,7 +222,7 @@ class Frame(object):
panel = self._create_panel(gtk.POS_BOTTOM)
box = ActivitiesBox(self._shell)
panel.append(box)
panel.append(box, hippo.PACK_EXPAND)
return panel

View File

@ -18,6 +18,7 @@
import gobject
import gtk
from sugar.graphics import style
from sugar.graphics.toolbutton import ToolButton
from sugar.graphics.icon import Icon
@ -51,6 +52,11 @@ class _TrayViewport(gtk.Viewport):
new_value = adj.value - self.allocation.width
adj.value = max(adj.lower, new_value)
def do_size_request(self, requisition):
child_requisition = self.child.size_request()
requisition[0] = 0
requisition[1] = child_requisition[1]
def do_get_property(self, pspec):
if pspec.name == 'can-scroll':
return self._can_scroll
@ -66,18 +72,24 @@ class _TrayViewport(gtk.Viewport):
self._can_scroll = can_scroll
self.notify('can-scroll')
class _TrayScrollButton(gtk.Button):
def __init__(self, icon_name):
gobject.GObject.__init__(self)
self.set_relief(gtk.RELIEF_NONE)
self.set_size_request(style.GRID_CELL_SIZE, style.GRID_CELL_SIZE)
icon = Icon(icon_name = icon_name,
icon_size=gtk.ICON_SIZE_SMALL_TOOLBAR)
self.set_image(icon)
icon.show()
class HTray(gtk.HBox):
def __init__(self, **kwargs):
gobject.GObject.__init__(self, **kwargs)
self._scroll_left = gtk.Button()
self._scroll_left.set_relief(gtk.RELIEF_NONE)
self._scroll_left = _TrayScrollButton('go-left')
self._scroll_left.connect('clicked', self._scroll_left_cb)
icon = Icon(icon_name='go-left', icon_size=gtk.ICON_SIZE_MENU)
self._scroll_left.set_image(icon)
icon.show()
self.pack_start(self._scroll_left, False)
self._viewport = _TrayViewport()
@ -86,14 +98,8 @@ class HTray(gtk.HBox):
self.pack_start(self._viewport)
self._viewport.show()
self._scroll_right = gtk.Button()
self._scroll_right.set_relief(gtk.RELIEF_NONE)
self._scroll_right = _TrayScrollButton('go-right')
self._scroll_right.connect('clicked', self._scroll_right_cb)
icon = Icon(icon_name='go-right', icon_size=gtk.ICON_SIZE_MENU)
self._scroll_right.set_image(icon)
icon.show()
self.pack_start(self._scroll_right, False)
def _viewport_can_scroll_changed_cb(self, viewport, pspec):