From 5b3eeb0a9c0baa359fc63798f454be634be42273 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Mon, 25 Sep 2006 20:01:35 +0000 Subject: Keep the icon layout updated when adding buddies to the snow flake --- diff --git a/shell/view/home/IconLayout.py b/shell/view/home/IconLayout.py index 3c8cb1e..0ce2ea7 100644 --- a/shell/view/home/IconLayout.py +++ b/shell/view/home/IconLayout.py @@ -17,10 +17,12 @@ class IconLayout: def add_icon(self, icon): self._icons.append(icon) self._layout_icon(icon) + self.update() def remove_icon(self, icon): self._icons.remove(icon) del self._constraints[icon] + self.update() def _get_distance(self, icon1, icon2): [icon1_x, icon1_y] = self._constraints[icon1] @@ -74,15 +76,16 @@ class IconLayout: matrix.translate(new_x, new_y) icon1.set_transform(matrix) + def update(self): + tries = 10 + self._spread_icons() + while not self._stable and tries > 0: + self._spread_icons() + tries -= 1 + def _layout_icon(self, icon): [width, height] = icon.get_size_request() x = random.random() * (self._x2 - self._x1 - width) y = random.random() * (self._y2 - self._y1 - height) self._constraints[icon] = [x, y] - - tries = 10 - self._spread_icons() - while not self._stable and tries > 0: - self._spread_icons() - tries -= 1 diff --git a/shell/view/home/MeshGroup.py b/shell/view/home/MeshGroup.py index a95605d..aed4303 100644 --- a/shell/view/home/MeshGroup.py +++ b/shell/view/home/MeshGroup.py @@ -110,6 +110,7 @@ class MeshGroup(goocanvas.Group): for activity in self._activities.values(): if activity.has_buddy_icon(name): activity.remove_buddy_icon(name) + self._layout.update() def _move_buddy(self, buddy_model, activity_model): name = buddy_model.get_name() @@ -125,6 +126,8 @@ class MeshGroup(goocanvas.Group): icon.props.size = 60 activity.add_buddy_icon(buddy_model.get_name(), icon) + self._layout.update() + def _add_activity(self, activity_model): icon = ActivityView(self._shell, self._menu_shell, activity_model) self.add_child(icon) -- cgit v0.9.1