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-06-06 01:11:25 (GMT)
committer Agustin Zubiaga <aguz@sugarlabs.org>2012-06-06 01:42:59 (GMT)
commitc10c2849efc8a9ea9e5a5e8e54c4b3a3f6030b00 (patch)
tree070d789eb8181190df8591a803cc5609e1211cec
parente1fb1d8e8a031d9692b444fc82a264124bb9c145 (diff)
Toolbars moved to toolbars.py
Signed-off-by: Agustin Zubiaga <aguz@sugarlabs.org>
-rw-r--r--activity.py131
-rw-r--r--toolbars.py155
2 files changed, 162 insertions, 124 deletions
diff --git a/activity.py b/activity.py
index 1295f2d..851e627 100644
--- a/activity.py
+++ b/activity.py
@@ -30,22 +30,16 @@ import gtk
import gobject
from sugar.activity import activity
-from sugar.activity.widgets import StopButton
-from sugar.activity.widgets import ToolbarButton
-from sugar.activity.widgets import ActivityToolbarButton
from sugar.graphics.objectchooser import ObjectChooser
-from sugar.graphics.toolbarbox import ToolbarBox
-from sugar.graphics.toolbutton import ToolButton
-from sugar.graphics.radiotoolbutton import RadioToolButton
-
from sugar import mime
-from gettext import gettext as _
+from gettext import gettext as _
from StringIO import StringIO
import animation
-
from frames_list import FramesList
+from toolbars import AnimateToolbarbox
+from toolbars import FramesToolbar
class AnimateActivity(activity.Activity):
@@ -55,108 +49,7 @@ class AnimateActivity(activity.Activity):
self.max_participants = 1
- toolbarbox = ToolbarBox()
-
- activity_button = ActivityToolbarButton(self)
- toolbarbox.toolbar.insert(activity_button, 0)
-
- separator = gtk.SeparatorToolItem()
- toolbarbox.toolbar.insert(separator, -1)
-
- add_frame = ToolButton('list-add')
- add_frame.set_tooltip(_('Add a frame'))
- add_frame.connect('clicked', self._add_frame)
- toolbarbox.toolbar.insert(add_frame, -1)
-
- remove_frame = ToolButton('list-remove')
- remove_frame.set_tooltip(_('Remove the selected frame'))
- remove_frame.connect('clicked', self._remove_frame)
- toolbarbox.toolbar.insert(remove_frame, -1)
-
- separator = gtk.SeparatorToolItem()
- toolbarbox.toolbar.insert(separator, -1)
-
- back_btn = ToolButton('media-seek-backward')
- back_btn.set_tooltip(_('Previous Frame'))
- back_btn.connect('clicked', self._previous_frame)
- toolbarbox.toolbar.insert(back_btn, -1)
-
- run_btn = ToolButton('media-playback-start')
- run_btn.set_tooltip(_('Run animation'))
- run_btn.connect('clicked', self._run_pause_animation)
- toolbarbox.toolbar.insert(run_btn, -1)
-
- next_btn = ToolButton('media-seek-forward')
- next_btn.set_tooltip(_('Next Frame'))
- next_btn.connect('clicked', self._next_frame)
- toolbarbox.toolbar.insert(next_btn, -1)
-
- separator = gtk.SeparatorToolItem()
- toolbarbox.toolbar.insert(separator, -1)
-
- options_button = ToolbarButton(icon_name='preferences-system')
- options_toolbar = gtk.Toolbar()
-
- returnbutton = RadioToolButton(icon_name="media-playlist-repeat")
- returnbutton.set_tooltip(_("Repeat Mode"))
- returnbutton.set_active(True)
- returnbutton.connect("clicked", self._set_return_mode)
- options_toolbar.insert(returnbutton, -1)
-
- normalmode = RadioToolButton(icon_name='normal-mode')
- normalmode.props.group = returnbutton
- normalmode.set_tooltip(_('Normal Mode'))
- normalmode.connect("clicked", self._set_normal_mode)
- options_toolbar.insert(normalmode, -1)
-
- pingpong = RadioToolButton(icon_name='ping-pong')
- pingpong.props.group = returnbutton
- pingpong.set_tooltip(_("Ping Pong Mode"))
- pingpong.connect("clicked", self._set_pingpong_mode)
- options_toolbar.insert(pingpong, -1)
-
- self.modes_buttons = [normalmode, returnbutton, pingpong]
- self.animation_mode = animation.MODE_RETURN
-
- 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)
- self._fpsbutton = gtk.SpinButton(adjustment, 0, 0)
- self._fpsbutton.connect('value-changed', self._fps_changed_cb)
- toolspin.add(self._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()
- toolbarbox.toolbar.insert(separator, -1)
-
- fullscreen_btn = ToolButton('view-fullscreen')
- fullscreen_btn.set_tooltip(_('Fullscreen'))
- fullscreen_btn.connect("clicked", self._view_fullscreen)
-
- toolbarbox.toolbar.insert(fullscreen_btn, -1)
-
- separator = gtk.SeparatorToolItem()
- separator.set_expand(True)
- separator.set_draw(False)
- toolbarbox.toolbar.insert(separator, -1)
-
- stopbtn = StopButton(self)
- toolbarbox.toolbar.insert(stopbtn, -1)
+ toolbarbox = AnimateToolbarbox()
self.set_toolbar_box(toolbarbox)
toolbarbox.show_all()
@@ -165,6 +58,8 @@ class AnimateActivity(activity.Activity):
self._animation = None
self._animation_frames = []
+ self.animation_mode = animation.RETURN_MODE
+ self.modes_buttons = toolbarbox.modes_buttons
self._frames_list = FramesList()
self._frames_list.show()
@@ -172,20 +67,8 @@ class AnimateActivity(activity.Activity):
vbox = gtk.VBox()
vbox.pack_start(self._frames_list, True, True, 0)
- frames_toolbar = gtk.Toolbar()
-
- move_up = ToolButton("go-up")
- move_up.set_tooltip(_("Move up"))
- move_up.connect('clicked', self._frames_list.move_up)
- frames_toolbar.insert(move_up, -1)
-
- move_down = ToolButton("go-down")
- move_down.set_tooltip(_("Move down"))
- move_down.connect('clicked', self._frames_list.move_down)
- frames_toolbar.insert(move_down, -1)
-
+ frames_toolbar = FramesToolbar()
vbox.pack_end(frames_toolbar, False, True, 0)
-
canvas.pack_end(vbox, False, True, 0)
canvas.connect("expose-event", self.__canvas_expose_cb)
diff --git a/toolbars.py b/toolbars.py
new file mode 100644
index 0000000..9b2c2d4
--- /dev/null
+++ b/toolbars.py
@@ -0,0 +1,155 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# toolbars.py
+#
+# Copyright 2012 S. Daniel Francis <francis@sugarlabs.org>,
+# Agustin Zubiaga <aguz@sugarlabs.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+import gtk
+
+from sugar.activity.widgets import StopButton
+from sugar.activity.widgets import ToolbarButton
+from sugar.activity.widgets import ActivityToolbarButton
+from sugar.graphics.toolbarbox import Toolbarbox
+from sugar.graphics.toolbutton import ToolButton
+from sugar.graphics.radiotoolbutton import RadioToolButton
+
+from gettext import gettext as _
+
+
+class AnimateToolbarbox(Toolbarbox):
+
+ def __init__(self):
+ super(AnimateToolbarbox, self).__init__()
+
+ activity_button = ActivityToolbarButton(self)
+ self.toolbar.insert(activity_button, 0)
+
+ separator = gtk.SeparatorToolItem()
+ self.toolbar.insert(separator, -1)
+
+ add_frame = ToolButton('list-add')
+ add_frame.set_tooltip(_('Add a frame'))
+ add_frame.connect('clicked', self._add_frame)
+ self.toolbar.insert(add_frame, -1)
+
+ remove_frame = ToolButton('list-remove')
+ remove_frame.set_tooltip(_('Remove the selected frame'))
+ remove_frame.connect('clicked', self._remove_frame)
+ self.toolbar.insert(remove_frame, -1)
+
+ separator = gtk.SeparatorToolItem()
+ self.toolbar.insert(separator, -1)
+
+ back_btn = ToolButton('media-seek-backward')
+ back_btn.set_tooltip(_('Previous Frame'))
+ back_btn.connect('clicked', self._previous_frame)
+ self.toolbar.insert(back_btn, -1)
+
+ run_btn = ToolButton('media-playback-start')
+ run_btn.set_tooltip(_('Run animation'))
+ run_btn.connect('clicked', self._run_pause_animation)
+ self.toolbar.insert(run_btn, -1)
+
+ next_btn = ToolButton('media-seek-forward')
+ next_btn.set_tooltip(_('Next Frame'))
+ next_btn.connect('clicked', self._next_frame)
+ self.toolbar.insert(next_btn, -1)
+
+ separator = gtk.SeparatorToolItem()
+ self.toolbar.insert(separator, -1)
+
+ options_button = ToolbarButton(icon_name='preferences-system')
+ options_toolbar = gtk.Toolbar()
+
+ returnbutton = RadioToolButton(icon_name="media-playlist-repeat")
+ returnbutton.set_tooltip(_("Repeat Mode"))
+ returnbutton.set_active(True)
+ returnbutton.connect("clicked", self._set_return_mode)
+ options_toolbar.insert(returnbutton, -1)
+
+ normalmode = RadioToolButton(icon_name='normal-mode')
+ normalmode.props.group = returnbutton
+ normalmode.set_tooltip(_('Normal Mode'))
+ normalmode.connect("clicked", self._set_normal_mode)
+ options_toolbar.insert(normalmode, -1)
+
+ pingpong = RadioToolButton(icon_name='ping-pong')
+ pingpong.props.group = returnbutton
+ pingpong.set_tooltip(_("Ping Pong Mode"))
+ pingpong.connect("clicked", self._set_pingpong_mode)
+ options_toolbar.insert(pingpong, -1)
+
+ self.modes_buttons = [normalmode, returnbutton, pingpong]
+
+ 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)
+ self._fpsbutton = gtk.SpinButton(adjustment, 0, 0)
+ self._fpsbutton.connect('value-changed', self._fps_changed_cb)
+ toolspin.add(self._fpsbutton)
+ options_toolbar.insert(toolspin, -1)
+
+ options_button.props.page = options_toolbar
+ options_toolbar.show_all()
+
+ self.toolbar.insert(options_button, -1)
+
+ separator = gtk.SeparatorToolItem()
+ self.toolbar.insert(separator, -1)
+
+ fullscreen_btn = ToolButton('view-fullscreen')
+ fullscreen_btn.set_tooltip(_('Fullscreen'))
+ fullscreen_btn.connect("clicked", self._view_fullscreen)
+
+ self.toolbar.insert(fullscreen_btn, -1)
+
+ separator = gtk.SeparatorToolItem()
+ separator.set_expand(True)
+ separator.set_draw(False)
+ self.toolbar.insert(separator, -1)
+
+ stopbtn = StopButton(self)
+ self.toolbar.insert(stopbtn, -1)
+
+
+class FramesToolbar(gtk.Toolbar):
+
+ def __init__(self):
+ super(FramesToolbar, self).__init__()
+
+ move_up = ToolButton("go-up")
+ move_up.set_tooltip(_("Move up"))
+ move_up.connect('clicked', self._frames_list.move_up)
+ self.insert(move_up, -1)
+
+ move_down = ToolButton("go-down")
+ move_down.set_tooltip(_("Move down"))
+ move_down.connect('clicked', self._frames_list.move_down)
+ self.insert(move_down, -1)