Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/jarabe/desktop/favoriteslayout.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/jarabe/desktop/favoriteslayout.py')
-rw-r--r--src/jarabe/desktop/favoriteslayout.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/jarabe/desktop/favoriteslayout.py b/src/jarabe/desktop/favoriteslayout.py
index 3dfa472..db0ff8a 100644
--- a/src/jarabe/desktop/favoriteslayout.py
+++ b/src/jarabe/desktop/favoriteslayout.py
@@ -19,10 +19,10 @@ import logging
import math
import hashlib
from gettext import gettext as _
+import random
import gobject
import gtk
-import hippo
from sugar.graphics import style
@@ -175,6 +175,26 @@ class RandomLayout(FavoritesLayout):
self._grid.move(icon, x / _CELL_SIZE, y / _CELL_SIZE, locked)
FavoritesLayout.move_icon(self, icon, x, y, locked)
+ def allocate_icons(self, children, width, height):
+ icon_size = style.STANDARD_ICON_SIZE
+
+ allocations = []
+ for n in range(len(children)):
+ child = children[n]
+ x, y = self._calculate_position(icon_size, n, len(children),
+ width, height)
+
+ allocation = gtk.gdk.Rectangle(int(x), int(y), icon_size, icon_size)
+ allocations.append(allocation)
+
+ return allocations
+
+ def _calculate_position(self, icon_size, child_n, child_total,
+ width, height):
+ x = random.randint(0, width)
+ y = random.randint(0, height)
+ return x,y
+
def do_allocate(self, x, y, width, height, req_width, req_height,
origin_changed):
for child in self.box.get_layout_children():