From eb26495611bbc8d38637d822343689af1c8bf1a4 Mon Sep 17 00:00:00 2001 From: Daniel Francis Date: Sat, 09 Jun 2012 01:07:19 +0000 Subject: Code review reintegrating toolbars --- diff --git a/activity.py b/activity.py index 7b9bec3..21f836e 100644 --- a/activity.py +++ b/activity.py @@ -49,17 +49,17 @@ class AnimateActivity(activity.Activity): self.max_participants = 1 - toolbarbox = AnimateToolbarBox(self) + self._toolbarbox = AnimateToolbarBox(self) - self.set_toolbar_box(toolbarbox) - toolbarbox.show_all() + self.set_toolbar_box(self._toolbarbox) + self._toolbarbox.show_all() canvas = gtk.HBox() self._animation = None self._animation_frames = [] self.animation_mode = animation.MODE_RETURN - self.modes_buttons = toolbarbox.modes_buttons + self.modes_buttons = self._toolbarbox.modes_buttons self._frames_list = FramesList() self._frames_list.connect("current-frame-changed", @@ -73,6 +73,8 @@ class AnimateActivity(activity.Activity): vbox.pack_start(self._frames_list, True, True, 0) frames_toolbar = FramesToolbar() + frames_toolbar.connect('go-up', self._frames_list.move_up) + frames_toolbar.connect('go-down', self._frames_list.move_down) vbox.pack_end(frames_toolbar, False, True, 0) canvas.pack_end(vbox, False, True, 0) @@ -83,7 +85,7 @@ class AnimateActivity(activity.Activity): self.show() - def _move_cb(self, index, new_index): + def _move_cb(self, widget, index, new_index): self._animation.move(index, new_index) def _current_frame_changed_cb(self, index): @@ -95,7 +97,7 @@ class AnimateActivity(activity.Activity): temp_file_path = tempfile.mktemp() temp_file = open(temp_file_path, "w") temp_file_content = {"mode": self._animation.get_mode(), - "framerate": self._fpsbutton.get_value()} + "framerate": self._toolbarbox.get_fps()} try: json.dump(temp_file_content, temp_file) finally: @@ -134,7 +136,7 @@ class AnimateActivity(activity.Activity): mode = options['mode'] self._animation_mode = mode self.modes_buttons[mode].set_active(True) - self._fpsbutton.set_value(options['framerate']) + self._toolbarbox.set_fps(options['framerate']) def _remove_frame(self, widget): self._frames_list.remove_selected_frame() @@ -200,7 +202,7 @@ class AnimateActivity(activity.Activity): for pixbuf in self._animation_frames: self._animation.add_frame(pixbuf) self._frames_list.add_frame(pixbuf) - self._animation.set_fps(self._fpsbutton.get_value()) + self._animation.set_fps(self._toolbarbox.get_fps()) self._animation.connect("current-frame-updated", self._current_frame_updated_cb) self._animation.show_all() diff --git a/toolbars.py b/toolbars.py index b349e6f..0c0b8cb 100644 --- a/toolbars.py +++ b/toolbars.py @@ -35,9 +35,6 @@ from gettext import gettext as _ class AnimateToolbarBox(ToolbarBox): - __gsignals__ = {'add-frame': (gobject.SIGNAL_RUN_LAST, - gobject.TYPE_NONE, - tuple())} def __init__(self, activity): super(AnimateToolbarBox, self).__init__() @@ -142,18 +139,30 @@ class AnimateToolbarBox(ToolbarBox): stopbtn = StopButton(activity) self.toolbar.insert(stopbtn, -1) + def get_fps(self): + return self._fpsbutton.get_value() + + def set_fps(self, fps): + self._fpsbutton.set_value(fps) + class FramesToolbar(gtk.Toolbar): + __gsignals__ = {'go-up': (gobject.SIGNAL_RUN_LAST, + gobject.TYPE_NONE, + tuple()), + 'go-down': (gobject.SIGNAL_RUN_LAST, + gobject.TYPE_NONE, + tuple())} 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) + move_up.connect('clicked', lambda w: self.emit('go-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) + move_down.connect('clicked', lambda w: self.emit('go-down')) self.insert(move_down, -1) -- cgit v0.9.1