Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorManuel QuiƱones <manuq@laptop.org>2012-09-04 07:58:51 (GMT)
committer Simon Schampijer <simon@laptop.org>2012-09-07 09:14:25 (GMT)
commit26fcb0f82f23e03d25baec8a3adc14d2fdc89c68 (patch)
tree2067c65c12f8883594a9986a9728b71cf6e57492 /src
parent8c267d5130914288a1eacfa32c97a9c4f30ff8f4 (diff)
FavoritesLayout: fix allocation and requisition
Signed-off-by: Manuel QuiƱones <manuq@laptop.org> Acked-by: Simon Schampijer <simon@laptop.org>
Diffstat (limited to 'src')
-rw-r--r--src/jarabe/desktop/favoriteslayout.py107
1 files changed, 60 insertions, 47 deletions
diff --git a/src/jarabe/desktop/favoriteslayout.py b/src/jarabe/desktop/favoriteslayout.py
index 1734da6..13b5095 100644
--- a/src/jarabe/desktop/favoriteslayout.py
+++ b/src/jarabe/desktop/favoriteslayout.py
@@ -22,6 +22,7 @@ from gettext import gettext as _
from gi.repository import Gtk
from gi.repository import Gdk
+from gi.repository import cairo
from sugar3.graphics import style
@@ -67,7 +68,8 @@ class ViewLayout(Layout):
def _allocate_owner_icon(self, allocation, owner_icon, activity_icon):
# add owner icon to the grid, precisely centered on the screen
# if not None, add an activity icon directly below the owner icon
- owner_width, owner_height = owner_icon.size_request()
+ owner_request = owner_icon.size_request()
+ owner_width, owner_height = owner_request.width, owner_request.height
height = allocation.height + allocation.y
width = allocation.width
@@ -84,36 +86,39 @@ class ViewLayout(Layout):
y -= owner_height / 2
# calculate x coordinate and create allocation
- x = (width - owner_width) / 2
- owner_icon_allocation = (x, allocation.y + y,
- owner_width, owner_height)
+ owner_icon_allocation = cairo.RectangleInt()
+ owner_icon_allocation.x = (width - owner_width) / 2
+ owner_icon_allocation.y = allocation.y + y
+ owner_icon_allocation.width = owner_width
+ owner_icon_allocation.height = owner_height
owner_icon.size_allocate(owner_icon_allocation)
# Determine grid coordinates and add to grid
owner_grid_width, owner_grid_height = \
self._get_child_grid_size(owner_icon)
- x = int(x / float(_CELL_SIZE))
- y = int(y / float(_CELL_SIZE))
+ grid_x = int(owner_icon_allocation.x / float(_CELL_SIZE))
+ grid_y = int(owner_icon_allocation.y / float(_CELL_SIZE))
self._grid.add(owner_icon, owner_grid_width, owner_grid_height,
- x, y, locked=True)
+ grid_x, grid_y, locked=True)
if activity_icon is None:
return
# Position the current activity below the XO icon
# FIXME must ensure we cross into next grid cell here..
- activity_width, activity_height = activity_icon.size_request()
- x = (width - activity_width) / 2
- y = owner_icon_allocation.y + owner_height
- activity_icon_allocation = (x, y, activity_width,
- activity_height)
+ activity_request = activity_icon.size_request()
+ activity_icon_allocation = cairo.RectangleInt()
+ activity_icon_allocation.x = (width - activity_request.width) / 2
+ activity_icon_allocation.y = owner_icon_allocation.y + owner_height
+ activity_icon_allocation.width = activity_request.width
+ activity_icon_allocation.height = activity_request.height
activity_icon.size_allocate(activity_icon_allocation)
# Determine grid coordinates and add to grid
activity_grid_width, activity_grid_height = \
self._get_child_grid_size(activity_icon)
- x = int(x / float(_CELL_SIZE))
- y = int(y / float(_CELL_SIZE))
+ x = int(activity_icon_allocation.x / float(_CELL_SIZE))
+ y = int(activity_icon_allocation.y / float(_CELL_SIZE))
self._grid.add(activity_icon, activity_grid_width,
activity_grid_height, x, y, locked=True)
@@ -122,27 +127,30 @@ class ViewLayout(Layout):
def move(self, child, x, y, allocation=None):
self._grid.move(child, x / _CELL_SIZE, y / _CELL_SIZE, locked=True)
- width, height = child.size_request()
+ child_request = child.size_request()
rect = self._grid.get_child_rect(child)
- child_allocation = (int(round(rect.x * _CELL_SIZE)),
- int(round(rect.y * _CELL_SIZE)),
- width,
- height)
+
+ child_allocation = cairo.RectangleInt()
+ child_allocation.x = int(round(rect.x * _CELL_SIZE))
+ child_allocation.y = int(round(rect.y * _CELL_SIZE))
+ child_allocation.width = child_request.width
+ child_allocation.height = child_request.height
child.size_allocate(child_allocation)
def _get_child_grid_size(self, child):
- width, height = child.size_request()
- width = math.ceil(width / _CELL_SIZE)
- height = math.ceil(height / _CELL_SIZE)
+ request = child.size_request()
+ width = math.ceil(request.width / _CELL_SIZE)
+ height = math.ceil(request.height / _CELL_SIZE)
return int(width), int(height)
def __grid_child_changed_cb(self, grid, child):
- width, height = child.size_request()
+ request = child.size_request()
rect = self._grid.get_child_rect(child)
- child_allocation = (int(round(rect.x * _CELL_SIZE)),
- int(round(rect.y * _CELL_SIZE)),
- width,
- height)
+ child_allocation = cairo.RectangleInt()
+ child_allocation.x = int(round(rect.x * _CELL_SIZE))
+ child_allocation.y = int(round(rect.y * _CELL_SIZE))
+ child_allocation.width = request.width
+ child_allocation.height = request.height
child.size_allocate(child_allocation)
@@ -165,11 +173,13 @@ class SpreadLayout(ViewLayout):
width, height = self._get_child_grid_size(child)
self._grid.add(child, width, height, None, None, locked=False)
- width, height = child.size_request()
+ requisition = child.size_request()
rect = self._grid.get_child_rect(child)
- x = int(round(rect.x * _CELL_SIZE))
- y = int(round(rect.y * _CELL_SIZE)) + allocation.y
- child_allocation = (x, y, width, height)
+ child_allocation = cairo.RectangleInt()
+ child_allocation.x = int(round(rect.x * _CELL_SIZE))
+ child_allocation.y = int(round(rect.y * _CELL_SIZE)) + allocation.y
+ child_allocation.width = requisition.width
+ child_allocation.height = requisition.height
child.size_allocate(child_allocation)
@@ -211,37 +221,38 @@ class RandomLayout(SpreadLayout):
def allocate_children(self, allocation, children):
for child in children:
- child_width, child_height = child.size_request()
+ child_requisition = child.size_request()
if not self._grid.is_in_grid(child):
self._add_fixed_position(child, allocation)
if child in self.fixed_positions:
x, y = self.fixed_positions[child]
- x = min(x, allocation.width - child_width)
- y = min(y, allocation.height - child_height)
+ x = min(x, allocation.width - child_requisition.width)
+ y = min(y, allocation.height - child_requisition.height)
elif hasattr(child, 'get_bundle_id'):
name_hash = hashlib.md5(child.get_bundle_id())
x = int(name_hash.hexdigest()[:5], 16) % \
- (allocation.width - child_width)
+ (allocation.width - child_requisition.width)
y = int(name_hash.hexdigest()[-5:], 16) % \
- (allocation.height - child_height)
+ (allocation.height - child_requisition.height)
else:
x = None
y = None
if x is None or y is None:
- self._grid.add(child, child_width / _CELL_SIZE,
- child_height / _CELL_SIZE)
+ self._grid.add(child, child_requisition.width / _CELL_SIZE,
+ child_requisition.height / _CELL_SIZE)
else:
- self._grid.add(child, child_width / _CELL_SIZE,
- child_height / _CELL_SIZE,
+ self._grid.add(child, child_requisition.width / _CELL_SIZE,
+ child_requisition.height / _CELL_SIZE,
x / _CELL_SIZE, y / _CELL_SIZE)
rect = self._grid.get_child_rect(child)
- x = int(round(rect.x * _CELL_SIZE))
- y = int(round(rect.y * _CELL_SIZE)) + allocation.y
- child_allocation = (x, y,
- child_width, child_height)
+ child_allocation = cairo.RectangleInt()
+ child_allocation.x = int(round(rect.x * _CELL_SIZE))
+ child_allocation.y = int(round(rect.y * _CELL_SIZE)) + allocation.y
+ child_allocation.width = child_requisition.width
+ child_allocation.height = child_requisition.height
child.size_allocate(child_allocation)
def move_icon(self, child, x, y, allocation):
@@ -369,9 +380,11 @@ class RingLayout(ViewLayout):
allocation.height)
child.size_request()
child.set_size(icon_size)
- child_allocation = (allocation.x + x,
- allocation.y + y,
- icon_size, icon_size)
+ child_allocation = cairo.RectangleInt()
+ child_allocation.x = allocation.x + x
+ child_allocation.y = allocation.y + y
+ child_allocation.width = icon_size
+ child_allocation.height = icon_size
child.size_allocate(child_allocation)
def compare_activities(self, icon_a, icon_b):