diff options
Diffstat (limited to 'src/jarabe/desktop/favoriteslayout.py')
-rw-r--r-- | src/jarabe/desktop/favoriteslayout.py | 68 |
1 files changed, 11 insertions, 57 deletions
diff --git a/src/jarabe/desktop/favoriteslayout.py b/src/jarabe/desktop/favoriteslayout.py index 7b847ac..b3e9848 100644 --- a/src/jarabe/desktop/favoriteslayout.py +++ b/src/jarabe/desktop/favoriteslayout.py @@ -213,27 +213,8 @@ class RingLayout(FavoritesLayout): def __init__(self): FavoritesLayout.__init__(self) - self._locked_children = {} self._spiral_mode = False - def append(self, icon, locked=False): - FavoritesLayout.append(self, icon, locked) - if locked: - child = self.box.find_box_child(icon) - self._locked_children[child] = (0, 0) - - def remove(self, icon): - child = self.box.find_box_child(icon) - if child in self._locked_children: - del self._locked_children[child] - FavoritesLayout.remove(self, icon) - - def move_icon(self, icon, x, y, locked=False): - FavoritesLayout.move_icon(self, icon, x, y, locked) - if locked: - child = self.box.find_box_child(icon) - self._locked_children[child] = (x, y) - def _calculate_radius_and_icon_size(self, children_count): """ Adjust the ring or spiral radius and icon size as needed. """ self._spiral_mode = False @@ -264,12 +245,9 @@ class RingLayout(FavoritesLayout): return radius, icon_size def _calculate_position(self, radius, icon_size, icon_index, children_count, - sin=math.sin, cos=math.cos): + width, height, sin=math.sin, cos=math.cos): """ Calculate an icon position on a circle or a spiral. """ - width, height = self.box.get_allocation() if self._spiral_mode: - min_width_, box_width = self.box.get_width_request() - min_height_, box_height = self.box.get_height_request(box_width) angle, radius = self._calculate_angle_and_radius(icon_index, icon_size) x, y = self._convert_from_polar_to_cartesian(angle, radius, @@ -305,44 +283,20 @@ class RingLayout(FavoritesLayout): radius += (float(icon_spacing) * spiral_spacing / n) return angle, radius - def _get_children_in_ring(self): - children_in_ring = [child for child in self.box.get_layout_children() \ - if child not in self._locked_children] - return children_in_ring + def allocate_icons(self, children, width, height): + radius, icon_size = self._calculate_radius_and_icon_size(len(children)) - def do_allocate(self, x, y, width, height, req_width, req_height, - origin_changed): - children_in_ring = self._get_children_in_ring() - if children_in_ring: - radius, icon_size = \ - self._calculate_radius_and_icon_size(len(children_in_ring)) - - for n in range(len(children_in_ring)): - child = children_in_ring[n] - - x, y = self._calculate_position(radius, icon_size, n, - len(children_in_ring)) - - # We need to always get requests to not confuse hippo - min_w_, child_width = child.get_width_request() - min_h_, child_height = child.get_height_request(child_width) + allocations = [] + for n in range(len(children)): + child = children[n] - child.allocate(int(x), int(y), child_width, child_height, - origin_changed) - child.item.props.size = icon_size - - for child in self._locked_children.keys(): - x, y = self._locked_children[child] - - # We need to always get requests to not confuse hippo - min_w_, child_width = child.get_width_request() - min_h_, child_height = child.get_height_request(child_width) + x, y = self._calculate_position(radius, icon_size, n, len(children), + width, height) - if child_width <= 0 or child_height <= 0: - return + allocation = gtk.gdk.Rectangle(int(x), int(y), icon_size, icon_size) + allocations.append(allocation) - child.allocate(int(x), int(y), child_width, child_height, - origin_changed) + return allocations def compare_activities(self, icon_a, icon_b): if hasattr(icon_a, 'installation_time') and \ |