diff --git a/shell/view/home/FriendsBox.py b/shell/view/home/FriendsBox.py index ed722f47..32d1e30c 100644 --- a/shell/view/home/FriendsBox.py +++ b/shell/view/home/FriendsBox.py @@ -29,8 +29,6 @@ class FriendsBox(SpreadBox, hippo.CanvasItem): friends.connect('friend-added', self._friend_added_cb) friends.connect('friend-removed', self._friend_removed_cb) - gobject.idle_add(self.spread) - def add_friend(self, buddy_info): icon = FriendView(self._shell, self._menu_shell, buddy_info) self.add(icon) diff --git a/shell/view/home/HomeWindow.py b/shell/view/home/HomeWindow.py index 6cd2c404..af38fd09 100644 --- a/shell/view/home/HomeWindow.py +++ b/shell/view/home/HomeWindow.py @@ -13,6 +13,9 @@ class HomeWindow(gtk.Window): gtk.Window.__init__(self) self._shell = shell + self.set_default_size(gtk.gdk.screen_width(), + gtk.gdk.screen_height()) + self.realize() self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DESKTOP) diff --git a/shell/view/home/MeshBox.py b/shell/view/home/MeshBox.py index be47f7e9..b7a13c4b 100644 --- a/shell/view/home/MeshBox.py +++ b/shell/view/home/MeshBox.py @@ -65,8 +65,6 @@ class MeshBox(SpreadBox): self._model.connect('activity-added', self._activity_added_cb) self._model.connect('activity-removed', self._activity_removed_cb) - gobject.idle_add(self.spread) - def _buddy_added_cb(self, model, buddy_model): self._add_alone_buddy(buddy_model) diff --git a/sugar/graphics/spreadbox.py b/sugar/graphics/spreadbox.py index b9d07d45..6e96e532 100644 --- a/sugar/graphics/spreadbox.py +++ b/sugar/graphics/spreadbox.py @@ -19,21 +19,6 @@ class SpreadBox(hippo.CanvasBox, hippo.CanvasItem): def add(self, item): self._items_to_position.append(item) self.append(item, hippo.PACK_FIXED) - if self._spread_on_add: - self.spread() - - def spread(self): - self._spread_on_add = True - - [width, height] = self.get_allocation() - for item in self._items_to_position: - x = int(random.random() * width) - y = int(random.random() * height) - - [x, y] = self._clamp_position(item, x, y) - self.move(item, x, y) - - self._items_to_position = [] def _get_distance(self, icon1, icon2): [icon1_x, icon1_y] = self.get_position(icon1) @@ -57,8 +42,7 @@ class SpreadBox(hippo.CanvasBox, hippo.CanvasItem): x = max(0, x) y = max(0, y) - item_w = icon.get_width_request() - item_h = icon.get_height_request(item_w) + [item_w, item_h] = icon.get_request() [box_w, box_h] = self.get_allocation() x = min(box_w - item_w, x) @@ -94,6 +78,17 @@ class SpreadBox(hippo.CanvasBox, hippo.CanvasItem): def do_allocate(self, width, height): hippo.CanvasBox.do_allocate(self, width, height) + for item in self._items_to_position: + [item_w, item_h] = item.get_request() + + x = int(random.random() * width - item_w) + y = int(random.random() * height - item_h) + + [x, y] = self._clamp_position(item, x, y) + self.move(item, x, y) + + self._items_to_position = [] + tries = 10 self._spread_icons() while not self._stable and tries > 0: diff --git a/tests/test-spread-box.py b/tests/test-spread-box.py index 6a81834b..e503a451 100755 --- a/tests/test-spread-box.py +++ b/tests/test-spread-box.py @@ -25,7 +25,7 @@ def _create_icon(): icon_name='stock-buddy') box.add(icon) - return (len(box.get_children()) < 20) + return (len(box.get_children()) < 15) window = gtk.Window() window.connect("destroy", lambda w: gtk.main_quit()) @@ -35,10 +35,9 @@ canvas = hippo.Canvas() box = SpreadBox(background_color=0xe2e2e2ff) canvas.set_root(box) -box.spread() -canvas.show() window.add(canvas) +canvas.show() gobject.timeout_add(500, _create_icon)