Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2009-01-21 11:15:15 (GMT)
committer Tomeu Vizoso <tomeu@sugarlabs.org>2009-01-21 11:15:15 (GMT)
commit2a665dcdb73176db0abb872b723c1ad901e919a1 (patch)
tree4c4e14699f1bc7486a5105414b5faa42e4d61b8f /src
parent072887fd1861c48da7713ba1f53cf646c76f977a (diff)
#213 fix dnd of icons in the favorite view
Diffstat (limited to 'src')
-rw-r--r--src/jarabe/desktop/favoriteslayout.py43
-rw-r--r--src/jarabe/desktop/favoritesview.py3
2 files changed, 28 insertions, 18 deletions
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):