Center the icon in the allocation space

This commit is contained in:
Marco Pesenti Gritti 2006-10-18 19:41:34 +02:00
parent ea8d801ad8
commit 6c375a20f3
2 changed files with 6 additions and 2 deletions

View File

@ -75,7 +75,7 @@ class FriendView(hippo.CanvasBox):
self._activity_icon.props.icon_name = name
self._activity_icon.props.color = buddy.get_color()
if not self._activity_icon_visible:
self.append(self._activity_icon)
self.append(self._activity_icon, hippo.PACK_EXPAND)
self._activity_icon_visible = True
else:
self._remove_activity_icon()

View File

@ -143,7 +143,11 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem):
icon_name, self._color, self._size)
buf = self._get_buffer(cr, handle, self._size)
cr.set_source_surface(buf, 0.0, 0.0)
[width, height] = self.get_allocation()
x = (width - self._size) / 2
y = (height - self._size) / 2
cr.set_source_surface(buf, x, y)
cr.paint()
def do_get_width_request(self):