Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorGuillaume Desmottes <cassidy@cass-wks.(none)>2007-04-16 14:52:16 (GMT)
committer Guillaume Desmottes <cassidy@cass-wks.(none)>2007-04-16 14:52:16 (GMT)
commit9bc3edabb87511a3ae12852cb9a232081db4fc1b (patch)
tree4212e818abde8c8128a74e0e9dce28a059ec2a4d /sugar
parenta4e18cf9c5b3a27b52ee7d96530660d75056ae98 (diff)
parentf67a2436538b4fee4747f6d9f41b174801d7ef64 (diff)
Merge branch 'master' of git+ssh://guillaume@dev.laptop.org/git/sugar
Diffstat (limited to 'sugar')
-rw-r--r--sugar/graphics/animator.py8
-rw-r--r--sugar/graphics/spreadbox.py25
2 files changed, 28 insertions, 5 deletions
diff --git a/sugar/graphics/animator.py b/sugar/graphics/animator.py
index 60ff9f3..459851b 100644
--- a/sugar/graphics/animator.py
+++ b/sugar/graphics/animator.py
@@ -28,7 +28,7 @@ class Animator(gobject.GObject):
gobject.TYPE_NONE, ([])),
}
- def __init__(self, time, fps, easing=EASE_OUT_EXPO):
+ def __init__(self, time, fps=20, easing=EASE_OUT_EXPO):
gobject.GObject.__init__(self)
self._animations = []
self._time = time
@@ -39,6 +39,10 @@ class Animator(gobject.GObject):
def add(self, animation):
self._animations.append(animation)
+ def remove_all(self):
+ self.stop()
+ self._animations = []
+
def start(self):
if self._timeout_sid:
self.stop()
@@ -51,7 +55,7 @@ class Animator(gobject.GObject):
if self._timeout_sid:
gobject.source_remove(self._timeout_sid)
self._timeout_sid = 0
- self.emit('completed')
+ self.emit('completed')
def _next_frame_cb(self):
current_time = min(self._time, time.time() - self._start_time)
diff --git a/sugar/graphics/spreadbox.py b/sugar/graphics/spreadbox.py
index 24e12f3..ff50f71 100644
--- a/sugar/graphics/spreadbox.py
+++ b/sugar/graphics/spreadbox.py
@@ -22,20 +22,31 @@ import gtk
from sugar.graphics import units
+_WIDTH = gtk.gdk.screen_width()
+_HEIGHT = gtk.gdk.screen_height()
_CELL_WIDTH = units.grid_to_pixels(1)
_CELL_HEIGHT = units.grid_to_pixels(1)
-_GRID_WIDTH = gtk.gdk.screen_width() / _CELL_WIDTH
-_GRID_HEIGHT = gtk.gdk.screen_height() / _CELL_HEIGHT
+_GRID_WIDTH = _WIDTH / _CELL_WIDTH
+_GRID_HEIGHT = _HEIGHT / _CELL_HEIGHT
-class SpreadBox(hippo.CanvasBox):
+class SpreadBox(hippo.CanvasBox, hippo.CanvasItem):
+ __gtype_name__ = 'SugarSpreadBox'
def __init__(self, **kwargs):
hippo.CanvasBox.__init__(self, **kwargs)
self._grid = []
+ self._center = None
for i in range(0, _GRID_WIDTH * _GRID_HEIGHT):
self._grid.append(None)
+ def set_center_item(self, item):
+ if self._center:
+ self.remove(self._center)
+
+ self._center = item
+ self.append(item, hippo.PACK_FIXED)
+
def add_item(self, item):
start_pos = int(random.random() * len(self._grid))
@@ -60,3 +71,11 @@ class SpreadBox(hippo.CanvasBox):
if self._grid[i] == item:
self._grid[i] = None
self.remove(item)
+
+ def do_allocate(self, width, height, origin_changed):
+ hippo.CanvasBox.do_allocate(self, width, height, origin_changed)
+
+ if self._center:
+ [icon_width, icon_height] = self._center.get_allocation()
+ self.set_position(self._center, (width - icon_width) / 2,
+ (height - icon_height) / 2)