diff options
author | Manuel QuiƱones <manuq@laptop.org> | 2012-09-04 07:37:52 (GMT) |
---|---|---|
committer | Simon Schampijer <simon@laptop.org> | 2012-09-07 09:14:25 (GMT) |
commit | 8c267d5130914288a1eacfa32c97a9c4f30ff8f4 (patch) | |
tree | 6987f619aea27029ce9b17a416ad8fbc89ae9325 /src | |
parent | 48b068b8bceecdd4bcba091dd9d7a355ae41b3ff (diff) |
Grid: compute_weight needs a cairo.RectangleInt
- compute_weight needs a cairo.RectangleInt, the RectangleInt is
only available in the dynamic cairo bindings that is why we use
those here instead of the more complete static bindings
- width and height are now set in the setup() method
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/grid.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/jarabe/desktop/grid.py b/src/jarabe/desktop/grid.py index b7381c9..aa7dce2 100644 --- a/src/jarabe/desktop/grid.py +++ b/src/jarabe/desktop/grid.py @@ -19,6 +19,7 @@ import random from gi.repository import GObject from gi.repository import Gtk +from gi.repository import cairo from gi.repository import SugarExt @@ -38,28 +39,31 @@ class Grid(SugarExt.Grid): def __init__(self, width, height): GObject.GObject.__init__(self) - self.width = width - self.height = height self._children = [] self._child_rects = {} self._locked_children = set() self._collisions = [] self._collisions_sid = 0 - self.setup(self.width, self.height) + self.setup(width, height) def add(self, child, width, height, x=None, y=None, locked=False): if x is not None and y is not None: - rect = (x, y, width, height) + rect = cairo.RectangleInt() + rect.x = x + rect.y = y + rect.width = width + rect.height = height weight = self.compute_weight(rect) else: trials = _PLACE_TRIALS weight = _MAX_WEIGHT while trials > 0 and weight: - x = int(random.random() * (self.width - width)) - y = int(random.random() * (self.height - height)) - - rect = (x, y, width, height) + rect = cairo.RectangleInt() + rect.x = int(random.random() * (self.width - width)) + rect.y = int(random.random() * (self.height - height)) + rect.width = width + rect.height = height new_weight = self.compute_weight(rect) if weight > new_weight: weight = new_weight |