From 2a665dcdb73176db0abb872b723c1ad901e919a1 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Wed, 21 Jan 2009 11:15:15 +0000 Subject: #213 fix dnd of icons in the favorite view --- (limited to 'src') diff --git a/src/jarabe/desktop/favoriteslayout.py b/src/jarabe/desktop/favoriteslayout.py index a82f6bf..06e799b 100644 --- a/src/jarabe/desktop/favoriteslayout.py +++ b/src/jarabe/desktop/favoriteslayout.py @@ -56,14 +56,20 @@ class FavoritesLayout(gobject.GObject, hippo.CanvasLayout): return 0 def append(self, icon, locked=False): - if hasattr(icon, 'fixed_position'): - relative_x, relative_y = icon.fixed_position - if relative_x >= 0 and relative_y >= 0: - min_width_, width = self.box.get_width_request() - min_height_, height = self.box.get_height_request(width) - self.fixed_positions[icon] = \ - (int(relative_x * _BASE_SCALE / float(width)), - int(relative_y * _BASE_SCALE / float(height))) + if not hasattr(type(icon), 'fixed_position'): + logging.debug('Icon without fixed_position: %r %r' % (icon, dir(icon))) + return + + relative_x, relative_y = icon.fixed_position + if relative_x < 0 or relative_y < 0: + logging.debug('Icon out of bounds: %r' % icon) + return + + min_width_, width = self.box.get_width_request() + min_height_, height = self.box.get_height_request(width) + self.fixed_positions[icon] = \ + (int(relative_x * _BASE_SCALE / float(width)), + int(relative_y * _BASE_SCALE / float(height))) def remove(self, icon): if icon in self.fixed_positions: @@ -73,15 +79,18 @@ class FavoritesLayout(gobject.GObject, hippo.CanvasLayout): if icon not in self.box.get_children(): raise ValueError('Child not in box.') - if hasattr(icon, 'get_bundle_id') and hasattr(icon, 'get_version'): - min_width_, width = self.box.get_width_request() - min_height_, height = self.box.get_height_request(width) - registry = bundleregistry.get_registry() - registry.set_bundle_position( - icon.get_bundle_id(), icon.get_version(), - x * width / float(_BASE_SCALE), - y * height / float(_BASE_SCALE)) - self.fixed_positions[icon] = (x, y) + if not(hasattr(icon, 'get_bundle_id') and hasattr(icon, 'get_version')): + logging.debug('Not an activity icon %r' % icon) + return + + min_width_, width = self.box.get_width_request() + min_height_, height = self.box.get_height_request(width) + registry = bundleregistry.get_registry() + registry.set_bundle_position( + icon.get_bundle_id(), icon.get_version(), + x * width / float(_BASE_SCALE), + y * height / float(_BASE_SCALE)) + self.fixed_positions[icon] = (x, y) def do_allocate(self, x, y, width, height, req_width, req_height, origin_changed): diff --git a/src/jarabe/desktop/favoritesview.py b/src/jarabe/desktop/favoritesview.py index 561b26b..03dd407 100644 --- a/src/jarabe/desktop/favoritesview.py +++ b/src/jarabe/desktop/favoritesview.py @@ -546,7 +546,8 @@ class ActivityIcon(CanvasIcon): installation_time = property(_get_installation_time, None) def _get_fixed_position(self): - return self._activity_info.position + registry = bundleregistry.get_registry() + return registry.get_bundle_position(self.bundle_id, self.version) fixed_position = property(_get_fixed_position, None) class FavoritePalette(ActivityPalette): -- cgit v0.9.1