[pitivi/ges: 160/287] undo: move PropertyChangeTracker to undo/undo.py
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi/ges: 160/287] undo: move PropertyChangeTracker to undo/undo.py
- Date: Thu, 15 Mar 2012 16:39:17 +0000 (UTC)
commit 85cfa43acbe33d7d06564e05599c82f57d1e2bf2
Author: Thibault Saunier <thibault saunier collabora com>
Date: Mon Jan 9 14:04:58 2012 -0300
undo: move PropertyChangeTracker to undo/undo.py
All baseclasses related to undo/redo should get into undo/undo.py
pitivi/undo/effect.py | 4 ++++
pitivi/undo/timeline.py | 2 +-
pitivi/undo/undo.py | 45 ++++++++++++++++++++++++++++++++++++++++++++-
pitivi/utils/misc.py | 36 ------------------------------------
4 files changed, 49 insertions(+), 38 deletions(-)
---
diff --git a/pitivi/undo/effect.py b/pitivi/undo/effect.py
index d67ff18..b585eb1 100644
--- a/pitivi/undo/effect.py
+++ b/pitivi/undo/effect.py
@@ -23,6 +23,8 @@
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
+import gobject
+
from pitivi.undo.undo import UndoableAction
@@ -42,6 +44,8 @@ class EffectPropertyChanged(UndoableAction):
self._undone()
+# FIXME We should refactor pitivi.undo.PropertyChangeTracker so we can use it as
+# a baseclass here!
class EffectGstElementPropertyChangeTracker:
"""
Track effect configuration changes in its list of control effects
diff --git a/pitivi/undo/timeline.py b/pitivi/undo/timeline.py
index 933072f..0f7d29d 100644
--- a/pitivi/undo/timeline.py
+++ b/pitivi/undo/timeline.py
@@ -22,7 +22,7 @@
import gobject
from pitivi.signalinterface import Signallable
-from pitivi.utils.misc import PropertyChangeTracker
+from pitivi.undo.undo import PropertyChangeTracker
from pitivi.undo.undo import UndoableAction
from pitivi.ui.effectsconfiguration import PROPS_TO_IGNORE
diff --git a/pitivi/undo/undo.py b/pitivi/undo/undo.py
index f6b14a3..436e85f 100644
--- a/pitivi/undo/undo.py
+++ b/pitivi/undo/undo.py
@@ -1,6 +1,6 @@
# PiTiVi , Non-linear video editor
#
-# pitivi/undo.py
+# pitivi/undo/undo.py
#
# Copyright (c) 2009, Alessandro Decina <alessandro d gmail com>
#
@@ -19,6 +19,10 @@
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
+"""
+Base classes for the undo/redo feature implementation
+"""
+
from pitivi.signalinterface import Signallable
from pitivi.utils.loggable import Loggable
@@ -259,3 +263,42 @@ class DebugActionLogObserver(Loggable):
def _actionLogPushCb(self, log, stack, action):
self.debug("push %s in %s", action, stack.action_group_name)
+
+
+class PropertyChangeTracker(Signallable):
+ """
+ BaseClasse to track a class property, Used for undo/redo
+ """
+
+ __signals__ = {}
+
+ def __init__(self):
+ self.properties = {}
+ self.obj = None
+
+ def connectToObject(self, obj):
+ self.obj = obj
+ self.properties = self._takeCurrentSnapshot(obj)
+ for property_name in self.property_names:
+ signal_name = "notify::" + property_name
+ self.__signals__[signal_name] = []
+ obj.connect(signal_name,
+ self._propertyChangedCb, property_name)
+
+ def _takeCurrentSnapshot(self, obj):
+ properties = {}
+ for property_name in self.property_names:
+ properties[property_name] = \
+ obj.get_property(property_name.replace("-", "_"))
+
+ return properties
+
+ def disconnectFromObject(self, obj):
+ self.obj = None
+ obj.disconnect_by_func(self._propertyChangedCb)
+
+ def _propertyChangedCb(self, object, value, property_name):
+ old_value = self.properties[property_name]
+ self.properties[property_name] = value
+
+ self.emit("notify::" + property_name, object, old_value, value)
diff --git a/pitivi/utils/misc.py b/pitivi/utils/misc.py
index 76b81f7..bd38f92 100644
--- a/pitivi/utils/misc.py
+++ b/pitivi/utils/misc.py
@@ -268,42 +268,6 @@ def uri_is_reachable(uri):
return os.path.isfile(gst.uri_get_location(uri))
-class PropertyChangeTracker(Signallable):
-
- __signals__ = {}
-
- def __init__(self):
- self.properties = {}
- self.obj = None
-
- def connectToObject(self, obj):
- self.obj = obj
- self.properties = self._takeCurrentSnapshot(obj)
- for property_name in self.property_names:
- signal_name = "notify::" + property_name
- self.__signals__[signal_name] = []
- obj.connect(signal_name,
- self._propertyChangedCb, property_name)
-
- def _takeCurrentSnapshot(self, obj):
- properties = {}
- for property_name in self.property_names:
- properties[property_name] = \
- obj.get_property(property_name.replace("-", "_"))
-
- return properties
-
- def disconnectFromObject(self, obj):
- self.obj = None
- obj.disconnect_by_func(self._propertyChangedCb)
-
- def _propertyChangedCb(self, object, value, property_name):
- old_value = self.properties[property_name]
- self.properties[property_name] = value
-
- self.emit("notify::" + property_name, object, old_value, value)
-
-
class Seeker(Signallable):
"""
The Seeker is a singleton helper class to do various seeking
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]