Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAgustin Zubiaga <aguz@sugarlabs.org>2012-05-31 02:28:40 (GMT)
committer Agustin Zubiaga <aguz@sugarlabs.org>2012-05-31 02:28:40 (GMT)
commited1b8370a2ddb7035e1982318bf92fcc35b156e2 (patch)
treed5a847014631f67900accbc6c5c9d7386d3c121d
parentdaca53a3139fcc3d5cf06f906d890d169564c43f (diff)
FPS SpinButton added
Signed-off-by: Agustin Zubiaga <aguz@sugarlabs.org>
-rw-r--r--activity.py30
-rw-r--r--animation.py10
2 files changed, 30 insertions, 10 deletions
diff --git a/activity.py b/activity.py
index ba06613..7bd580a 100644
--- a/activity.py
+++ b/activity.py
@@ -54,8 +54,6 @@ class AnimateActivity(activity.Activity):
toolbarbox.toolbar.insert(activity_button, 0)
separator = gtk.SeparatorToolItem()
- separator.set_expand(False)
- separator.set_draw(True)
toolbarbox.toolbar.insert(separator, -1)
add_image = ToolButton('list-add')
@@ -69,8 +67,6 @@ class AnimateActivity(activity.Activity):
toolbarbox.toolbar.insert(remove_frame, -1)
separator = gtk.SeparatorToolItem()
- separator.set_expand(False)
- separator.set_draw(True)
toolbarbox.toolbar.insert(separator, -1)
back_btn = ToolButton('media-seek-backward')
@@ -89,8 +85,6 @@ class AnimateActivity(activity.Activity):
toolbarbox.toolbar.insert(next_btn, -1)
separator = gtk.SeparatorToolItem()
- separator.set_expand(False)
- separator.set_draw(True)
toolbarbox.toolbar.insert(separator, -1)
options_button = ToolbarButton(icon_name='preferences-system')
@@ -114,14 +108,30 @@ class AnimateActivity(activity.Activity):
pingpong.connect("clicked", self._set_pingpong_mode)
options_toolbar.insert(pingpong, -1)
+ separator = gtk.SeparatorToolItem()
+ options_toolbar.insert(separator, -1)
+
+ toollabel = gtk.ToolItem()
+ toollabel.add(gtk.Label(_("Frames per second:")))
+ options_toolbar.insert(toollabel, -1)
+
+ separator = gtk.SeparatorToolItem()
+ separator.set_draw(False)
+ options_toolbar.insert(separator, -1)
+
+ toolspin = gtk.ToolItem()
+ adjustment = gtk.Adjustment(2, 1, 24, 1, 1, 1)
+ fpsbutton = gtk.SpinButton(adjustment, 0, 0)
+ fpsbutton.connect('value-changed', self._fps_changed_cb)
+ toolspin.add(fpsbutton)
+ options_toolbar.insert(toolspin, -1)
+
options_button.props.page = options_toolbar
options_toolbar.show_all()
toolbarbox.toolbar.insert(options_button, -1)
separator = gtk.SeparatorToolItem()
- separator.set_draw(True)
- separator.set_expand(False)
toolbarbox.toolbar.insert(separator, -1)
fullscreen_btn = ToolButton('view-fullscreen')
@@ -171,6 +181,10 @@ class AnimateActivity(activity.Activity):
else:
return
+ def _fps_changed_cb(self, widget):
+ fps = widget.get_adjustment().get_value()
+ self._animation.set_fps(fps)
+
def _set_return_mode(self, widget):
self._animation.set_mode(animation.RETURN_MODE)
diff --git a/animation.py b/animation.py
index dbeb364..9c1b93f 100644
--- a/animation.py
+++ b/animation.py
@@ -39,7 +39,7 @@ class Animation(gtk.Image):
gobject.TYPE_NONE,
(gobject.TYPE_INT,))}
- def __init__(self, width, height, sleep_time=1):
+ def __init__(self, width, height, fps=2):
gtk.Image.__init__(self)
self._current_image = 0
@@ -50,7 +50,7 @@ class Animation(gtk.Image):
self.images_reverse = False
self._size = width, height
- self._sleep_time = int(sleep_time * 1000)
+ self._sleep_time = int(1000 / fps)
def remove_current_frame(self):
del(self.images[self._current_image])
@@ -62,6 +62,12 @@ class Animation(gtk.Image):
self.set_from_pixbuf(None)
self._current_image = 0
+ def set_fps(self, fps):
+ self._sleep_time = int(1000 / fps)
+ if self._running:
+ self.pause()
+ self.run()
+
def set_mode(self, mode):
"""Defines animation mode"""
self._mode = mode