[pitivi/ges: 158/287] undo: Create a pitivi/undo folder



commit 50d1f34600bcc357dae0a55a6d308c0a0604730e
Author: Thibault Saunier <thibault saunier collabora com>
Date:   Mon Jan 9 12:32:34 2012 -0300

    undo: Create a pitivi/undo folder
    
    Everything that is related to the undo/redo feature should land in it

 configure.ac                                       |    1 +
 pitivi/Makefile.am                                 |    5 +-
 pitivi/application.py                              |    6 +-
 pitivi/effects.py                                  |   69 ---------------
 pitivi/projectmanager.py                           |    2 +-
 pitivi/undo/Makefile.am                            |   12 +++
 pitivi/undo/__init__.py                            |    3 +
 pitivi/undo/effect.py                              |   93 ++++++++++++++++++++
 pitivi/{sourcelist_undo.py => undo/sourcelist.py}  |    2 +-
 .../{utils/timeline_undo.py => undo/timeline.py}   |    4 +-
 pitivi/{ => undo}/undo.py                          |    0
 pitivi/utils/Makefile.am                           |    4 +-
 tests/test_timeline_undo.py                        |    4 +-
 tests/test_undo.py                                 |    2 +-
 14 files changed, 122 insertions(+), 85 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a4854c3..09a1e42 100644
--- a/configure.ac
+++ b/configure.ac
@@ -88,6 +88,7 @@ pitivi/Makefile
 pitivi/configure.py
 pitivi/ui/Makefile
 pitivi/log/Makefile
+pitivi/undo/Makefile
 pitivi/utils/Makefile
 pitivi.spec
 po/Makefile.in
diff --git a/pitivi/Makefile.am b/pitivi/Makefile.am
index 1f03bcc..a4b93a1 100644
--- a/pitivi/Makefile.am
+++ b/pitivi/Makefile.am
@@ -1,6 +1,7 @@
 SUBDIRS = \
 	ui 		\
 	utils	\
+	undo	\
 	log
 
 pitividir = $(libdir)/pitivi/python/pitivi
@@ -21,11 +22,9 @@ pitivi_PYTHON = \
 	signalgroup.py	\
 	signalinterface.py \
 	sourcelist.py 	\
-	sourcelist_undo.py \
 	system.py	\
 	threads.py	\
-	thumbnailcache.py \
-	undo.py
+	thumbnailcache.py
 
 BUILT_SOURCES=configure.py
 
diff --git a/pitivi/application.py b/pitivi/application.py
index 0c393e6..34cc562 100644
--- a/pitivi/application.py
+++ b/pitivi/application.py
@@ -47,10 +47,10 @@ from pitivi.log.loggable import Loggable
 from pitivi.log import log
 from pitivi.ui.mainwindow import PitiviMainWindow
 from pitivi.projectmanager import ProjectManager, ProjectLogObserver
-from pitivi.undo import UndoableActionLog, DebugActionLogObserver
+from pitivi.undo.undo import UndoableActionLog, DebugActionLogObserver
 #FIXME GES port disabled it
-#from pitivi.utils.timeline_undo import TimelineLogObserver
-from pitivi.sourcelist_undo import SourceListLogObserver
+#from pitivi.undo.timeline import TimelineLogObserver
+from pitivi.undo.sourcelist import SourceListLogObserver
 from pitivi.ui.startupwizard import StartUpWizard
 
 # FIXME : Speedup loading time
diff --git a/pitivi/effects.py b/pitivi/effects.py
index 7a2ac0d..8d6001c 100644
--- a/pitivi/effects.py
+++ b/pitivi/effects.py
@@ -25,14 +25,12 @@ Effects global handling
 """
 import gst
 import gtk
-import gobject
 import re
 import os
 
 from gettext import gettext as _
 
 from pitivi.configure import get_pixmap_dir
-from pitivi.undo import UndoableAction
 
 # Note: Some effects are available through the frei0r
 # library and the libavfilter0 library
@@ -312,70 +310,3 @@ class EffectsHandler(object):
                 return None
 
         return icon
-
-
-class EffectPropertyChanged(UndoableAction):
-    def __init__(self, gst_element, property_name, old_value, new_value):
-        self.gst_element = gst_element
-        self.property_name = property_name
-        self.old_value = old_value
-        self.new_value = new_value
-
-    def do(self):
-        self.gst_element.set_property(self.property_name, self.new_value)
-        self._done()
-
-    def undo(self):
-        self.gst_element.set_property(self.property_name, self.old_value)
-        self._undone()
-
-
-class EffectGstElementPropertyChangeTracker:
-    """
-    Track effect configuration changes in its list of control effects
-    """
-    def __init__(self, action_log):
-        self._tracked_effects = {}
-        self.action_log = action_log
-        self.pipeline = None
-
-    def addEffectElement(self, gst_element):
-        properties = {}
-
-        if gst_element in self._tracked_effects:
-            return
-
-        for prop in gobject.list_properties(gst_element):
-            gst_element.connect('notify::' + prop.name,
-                                self._propertyChangedCb,
-                                gst_element)
-            if prop.flags & gobject.PARAM_READABLE:
-                properties[prop.name] = gst_element.get_property(prop.name)
-        self._tracked_effects[gst_element] = properties
-
-    def getPropChangedFromTrackObj(self, track_effect):
-        prop_changed = []
-
-        for undo_stack in self.action_log.undo_stacks:
-            for done_prop_change in undo_stack.done_actions:
-                if isinstance(done_prop_change, EffectPropertyChanged):
-                    if done_prop_change.gst_element is\
-                                        track_effect.getElement():
-                        prop_changed.append(done_prop_change)
-
-        for redo_stack in self.action_log.redo_stacks:
-            for done_prop_change in redo_stack.done_actions:
-                if isinstance(done_prop_change, EffectPropertyChanged):
-                    if done_prop_change.gst_element is\
-                                        track_effect.getElement():
-                        prop_changed.append(done_prop_change)
-
-        return prop_changed
-
-    def _propertyChangedCb(self, gst_element, pspec, unused):
-        old_value = self._tracked_effects[gst_element][pspec.name]
-        new_value = gst_element.get_property(pspec.name)
-        action = EffectPropertyChanged(gst_element, pspec.name, old_value,
-                                       new_value)
-        self._tracked_effects[gst_element][pspec.name] = new_value
-        self.action_log.push(action)
diff --git a/pitivi/projectmanager.py b/pitivi/projectmanager.py
index 2d64a5b..c7bfb3d 100644
--- a/pitivi/projectmanager.py
+++ b/pitivi/projectmanager.py
@@ -31,7 +31,7 @@ from pwd import getpwuid
 from pitivi.project import Project
 from pitivi.signalinterface import Signallable
 from pitivi.log.loggable import Loggable
-from pitivi.undo import UndoableAction
+from pitivi.undo.undo import UndoableAction
 
 
 class ProjectSettingsChanged(UndoableAction):
diff --git a/pitivi/undo/Makefile.am b/pitivi/undo/Makefile.am
new file mode 100644
index 0000000..4303b76
--- /dev/null
+++ b/pitivi/undo/Makefile.am
@@ -0,0 +1,12 @@
+undodir = $(libdir)/pitivi/python/pitivi/undo
+
+undo_PYTHON =    \
+	__init__.py  \
+	undo.py      \
+	timeline.py  \
+	effect.py    \
+	sourcelist.py
+
+clean-local:
+	rm -rf *.pyc *.pyo
+
diff --git a/pitivi/undo/__init__.py b/pitivi/undo/__init__.py
new file mode 100644
index 0000000..d8a2ccd
--- /dev/null
+++ b/pitivi/undo/__init__.py
@@ -0,0 +1,3 @@
+"""
+Undo classes and functions
+"""
diff --git a/pitivi/undo/effect.py b/pitivi/undo/effect.py
new file mode 100644
index 0000000..d67ff18
--- /dev/null
+++ b/pitivi/undo/effect.py
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+#
+#       effect.py
+#
+# Copyright (C) 2012 Thibault Saunier <thibaul saunier collabora com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+# 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, or (at your option)
+# any later version.
+
+from pitivi.undo.undo import UndoableAction
+
+
+class EffectPropertyChanged(UndoableAction):
+    def __init__(self, gst_element, property_name, old_value, new_value):
+        self.gst_element = gst_element
+        self.property_name = property_name
+        self.old_value = old_value
+        self.new_value = new_value
+
+    def do(self):
+        self.gst_element.set_property(self.property_name, self.new_value)
+        self._done()
+
+    def undo(self):
+        self.gst_element.set_property(self.property_name, self.old_value)
+        self._undone()
+
+
+class EffectGstElementPropertyChangeTracker:
+    """
+    Track effect configuration changes in its list of control effects
+    """
+    def __init__(self, action_log):
+        self._tracked_effects = {}
+        self.action_log = action_log
+        self.pipeline = None
+
+    def addEffectElement(self, gst_element):
+        properties = {}
+
+        if gst_element in self._tracked_effects:
+            return
+
+        for prop in gobject.list_properties(gst_element):
+            gst_element.connect('notify::' + prop.name,
+                                self._propertyChangedCb,
+                                gst_element)
+            if prop.flags & gobject.PARAM_READABLE:
+                properties[prop.name] = gst_element.get_property(prop.name)
+        self._tracked_effects[gst_element] = properties
+
+    def getPropChangedFromTrackObj(self, track_effect):
+        prop_changed = []
+
+        for undo_stack in self.action_log.undo_stacks:
+            for done_prop_change in undo_stack.done_actions:
+                if isinstance(done_prop_change, EffectPropertyChanged):
+                    if done_prop_change.gst_element is\
+                                        track_effect.getElement():
+                        prop_changed.append(done_prop_change)
+
+        for redo_stack in self.action_log.redo_stacks:
+            for done_prop_change in redo_stack.done_actions:
+                if isinstance(done_prop_change, EffectPropertyChanged):
+                    if done_prop_change.gst_element is\
+                                        track_effect.getElement():
+                        prop_changed.append(done_prop_change)
+
+        return prop_changed
+
+    def _propertyChangedCb(self, gst_element, pspec, unused):
+        old_value = self._tracked_effects[gst_element][pspec.name]
+        new_value = gst_element.get_property(pspec.name)
+        action = EffectPropertyChanged(gst_element, pspec.name, old_value,
+                                       new_value)
+        self._tracked_effects[gst_element][pspec.name] = new_value
+        self.action_log.push(action)
diff --git a/pitivi/sourcelist_undo.py b/pitivi/undo/sourcelist.py
similarity index 98%
rename from pitivi/sourcelist_undo.py
rename to pitivi/undo/sourcelist.py
index efbef16..d595824 100644
--- a/pitivi/sourcelist_undo.py
+++ b/pitivi/undo/sourcelist.py
@@ -19,7 +19,7 @@
 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 # Boston, MA 02110-1301, USA.
 
-from pitivi.undo import UndoableAction
+from pitivi.undo.undo import UndoableAction
 
 
 class SourceListSourceAddedAction(UndoableAction):
diff --git a/pitivi/utils/timeline_undo.py b/pitivi/undo/timeline.py
similarity index 99%
rename from pitivi/utils/timeline_undo.py
rename to pitivi/undo/timeline.py
index 750aaec..933072f 100644
--- a/pitivi/utils/timeline_undo.py
+++ b/pitivi/undo/timeline.py
@@ -23,10 +23,10 @@ import gobject
 
 from pitivi.signalinterface import Signallable
 from pitivi.utils.misc import PropertyChangeTracker
-from pitivi.undo import UndoableAction
+from pitivi.undo.undo import UndoableAction
 
 from pitivi.ui.effectsconfiguration import PROPS_TO_IGNORE
-from pitivi.effects import EffectGstElementPropertyChangeTracker
+from pitivi.undo.effects import EffectGstElementPropertyChangeTracker
 
 
 class TimelineObjectPropertyChangeTracker(PropertyChangeTracker):
diff --git a/pitivi/undo.py b/pitivi/undo/undo.py
similarity index 100%
rename from pitivi/undo.py
rename to pitivi/undo/undo.py
diff --git a/pitivi/utils/Makefile.am b/pitivi/utils/Makefile.am
index c94d5ac..1d1f076 100644
--- a/pitivi/utils/Makefile.am
+++ b/pitivi/utils/Makefile.am
@@ -6,9 +6,7 @@ utils_PYTHON = 	\
 	alignalgs.py    \
 	extract.py      \
 	timeline.py     \
-	gap.py     \
-	misc.py     \
-	timeline_undo.py
+	misc.py
 
 clean-local:
 	rm -rf *.pyc *.pyo
diff --git a/tests/test_timeline_undo.py b/tests/test_timeline_undo.py
index 9cf7556..b523150 100644
--- a/tests/test_timeline_undo.py
+++ b/tests/test_timeline_undo.py
@@ -35,10 +35,10 @@
 #from pitivi.utils.track import Track, SourceTrackObject, TrackEffect
 #from pitivi.factories.test import VideoTestSourceFactory, TestEffectFactory
 #from pitivi.stream import VideoStream
-#from pitivi.utils.timeline_undo import TimelineLogObserver, \
+#from pitivi.undo.timeline import TimelineLogObserver, \
         #TimelineObjectAdded, TimelineObjectRemoved, \
         #TimelineObjectPropertyChanged, TrackEffectAdded
-#from pitivi.undo import UndoableActionLog
+#from pitivi.undo.undo import UndoableActionLog
 
 #class TestTimelineLogObserver(TimelineLogObserver):
     #def _connectToTimeline(self, timeline):
diff --git a/tests/test_undo.py b/tests/test_undo.py
index 4dd1f75..c4aca20 100644
--- a/tests/test_undo.py
+++ b/tests/test_undo.py
@@ -21,7 +21,7 @@
 
 from unittest import TestCase
 
-from pitivi.undo import UndoError, UndoWrongStateError, UndoableAction, \
+from pitivi.undo.undo import UndoError, UndoWrongStateError, UndoableAction, \
         UndoableActionStack, UndoableActionLog
 
 



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