[pitivi] Add Undo and Redo actions.



commit 8a518d846fc714cf6cbcf363a7d2ccc1249b52ec
Author: Alessandro Decina <alessandro d gmail com>
Date:   Wed Jun 10 13:40:12 2009 +0200

    Add Undo and Redo actions.

 pitivi/ui/mainwindow.py  |   21 +++++++++++++++++++++
 pitivi/ui/mainwindow.xml |    2 ++
 2 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index c3cfd59..152ab03 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -180,6 +180,9 @@ class PitiviMainWindow(gtk.Window, Loggable):
         self.app.projectManager.connect("missing-uri",
                 self._projectManagerMissingUriCb)
 
+        self.app.action_log.connect("can-undo", self._actionLogCanUndo)
+        self.app.action_log.connect("can-redo", self._actionLogCanRedo)
+
         # if no webcams available, hide the webcam action
         self.app.deviceprobe.connect("device-added", self._deviceChangeCb)
         self.app.deviceprobe.connect("device-removed", self._deviceChangeCb)
@@ -231,6 +234,12 @@ class PitiviMainWindow(gtk.Window, Loggable):
              None, _("Edit the project settings"), self._projectSettingsCb),
             ("RenderProject", 'pitivi-render' , _("_Render project"),
              None, _("Render project"), self._recordCb),
+            ("Undo", gtk.STOCK_UNDO,
+             _("_Undo"),
+             None, _("Undo the last operation"), self._undoCb),
+            ("Redo", gtk.STOCK_REDO,
+             _("_Redo"),
+             None, _("Redo the last operation that was undone"), self._redoCb),
             ("PluginManager", gtk.STOCK_PREFERENCES ,
              _("_Plugins..."),
              None, _("Manage plugins"), self._pluginManagerCb),
@@ -587,6 +596,12 @@ class PitiviMainWindow(gtk.Window, Loggable):
         abt.connect("response", self._aboutResponseCb)
         abt.show()
 
+    def _undoCb(self, action):
+        self.app.action_log.undo()
+
+    def _redoCb(self, action):
+        self.app.action_log.redo()
+
     def _pluginManagerCb(self, unused_action):
         from pluginmanagerdialog import PluginManagerDialog
         PluginManagerDialog(self.app.plugin_manager)
@@ -720,6 +735,12 @@ class PitiviMainWindow(gtk.Window, Loggable):
 
         dialog.destroy()
 
+    def _actionLogCanUndo(self, action_log, can_undo):
+        self.actiongroup.get_action("Undo").set_sensitive(can_undo)
+
+    def _actionLogCanRedo(self, action_log, can_redo):
+        self.actiongroup.get_action("Redo").set_sensitive(can_redo)
+
 
 ## PiTiVi current project callbacks
 
diff --git a/pitivi/ui/mainwindow.xml b/pitivi/ui/mainwindow.xml
index 1d244ea..bbd47bf 100644
--- a/pitivi/ui/mainwindow.xml
+++ b/pitivi/ui/mainwindow.xml
@@ -9,6 +9,8 @@
       <menuitem action="Quit" />
     </menu>
     <menu action="Edit">
+      <menuitem action="Undo" />
+      <menuitem action="Redo" />
       <menuitem action="PluginManager" />
       <menuitem action="Preferences" />
     </menu>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]