diff options
author | Tomeu Vizoso <tomeu@tomeu-asus.(none)> | 2008-06-11 15:38:17 (GMT) |
---|---|---|
committer | Tomeu Vizoso <tomeu@tomeu-laptop.(none)> | 2008-06-20 10:24:58 (GMT) |
commit | 8653d936ef59916a6c3f4b56f17161e5a61afdfc (patch) | |
tree | 5e2fa7f92bb9570a6f3dd8c1d63f15e87bbb3429 /src | |
parent | 3cc77d917005e5c6ae8728bbc6eab38db45708ed (diff) |
Persist position of favorite icons
Diffstat (limited to 'src')
-rw-r--r-- | src/view/home/activitiesring.py | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/src/view/home/activitiesring.py b/src/view/home/activitiesring.py index 5d66ec3..a250c1d 100644 --- a/src/view/home/activitiesring.py +++ b/src/view/home/activitiesring.py @@ -203,7 +203,9 @@ class ActivitiesRing(hippo.Canvas): icon_file_name = self._last_clicked_icon.props.file_name # TODO: we should get the pixbuf from the widget, so it has colors, etc pixbuf = gtk.gdk.pixbuf_new_from_file(icon_file_name) - context.set_icon_pixbuf(pixbuf, 0, 0) + + hot_spot = style.zoom(10) + context.set_icon_pixbuf(pixbuf, hot_spot, hot_spot) def __drag_motion_cb(self, widget, context, x, y, time): if self._last_clicked_icon is not None: @@ -266,6 +268,10 @@ class ActivityIcon(CanvasIcon): return self._activity_info.installation_time installation_time = property(_get_installation_time, None) + def _get_fixed_position(self): + return self._activity_info.position + fixed_position = property(_get_fixed_position, None) + class CurrentActivityIcon(CanvasIcon, hippo.CanvasItem): def __init__(self): CanvasIcon.__init__(self, cache=True) @@ -389,18 +395,32 @@ class RingLayout(gobject.GObject, hippo.CanvasLayout): else: return 0 - def append(self, child): - self._box.insert_sorted(child, 0, self._compare_activities) + def append(self, icon): + self._box.insert_sorted(icon, 0, self._compare_activities) + relative_x, relative_y = icon.fixed_position + if relative_x >= 0 and relative_y >= 0: + width = gtk.gdk.screen_width() + height = gtk.gdk.screen_height() - style.GRID_CELL_SIZE + self._fixed_positions[icon] = (relative_x * 1000 / width, + relative_y * 1000 / height) self._update_icon_sizes() - def remove(self, child): - self._box.remove(child) + def remove(self, icon): + del self._fixed_positions[icon] + self._box.remove(icon) self._update_icon_sizes() - def move_icon(self, child, x, y): - if child not in self._box.get_children(): + def move_icon(self, icon, x, y): + if icon not in self._box.get_children(): raise ValueError('Child not in box.') - self._fixed_positions[child] = (x, y) + + width = gtk.gdk.screen_width() + height = gtk.gdk.screen_height() - style.GRID_CELL_SIZE + registry = activity.get_registry() + registry.set_activity_position(icon.get_bundle_id(), icon.get_version(), + x * width / 1000, y * height / 1000) + + self._fixed_positions[icon] = (x, y) self._box.emit_request_changed() def do_allocate(self, x, y, width, height, req_width, req_height, |