[pitivi] Make PropertyChangeTracker reusable.
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Subject: [pitivi] Make PropertyChangeTracker reusable.
- Date: Thu, 11 Jun 2009 12:38:43 -0400 (EDT)
commit 4b26229ba420cca49b94cfaea05378bba19a22a3
Author: Alessandro Decina <alessandro d gmail com>
Date: Tue Jun 9 18:50:53 2009 +0200
Make PropertyChangeTracker reusable.
pitivi/timeline/timeline.py | 4 +++-
pitivi/utils.py | 15 ++++++++++-----
2 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 1438193..56d1daf 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -558,7 +558,8 @@ class Link(object):
self.timeline_objects.add(timeline_object)
- tracker = LinkPropertyChangeTracker(timeline_object)
+ tracker = LinkPropertyChangeTracker()
+ tracker.connectToObject(timeline_object)
self.property_trackers[timeline_object] = tracker
tracker.connect('start-changed', self._startChangedCb)
@@ -579,6 +580,7 @@ class Link(object):
raise TimelineError()
tracker = self.property_trackers.pop(timeline_object)
+ tracker.disconnectFromObject(timeline_object)
tracker.disconnect_by_function(self._startChangedCb)
timeline_object.link = None
diff --git a/pitivi/utils.py b/pitivi/utils.py
index 72328f8..b1c067a 100644
--- a/pitivi/utils.py
+++ b/pitivi/utils.py
@@ -237,21 +237,26 @@ def uri_is_reachable(uri):
return os.path.isfile(gst.uri_get_location(uri))
class PropertyChangeTracker(Signallable):
- def __init__(self, timeline_object):
+ def __init__(self):
self.properties = {}
+ def connectToObject(self, obj):
for property_name in self.property_names:
self.properties[property_name] = \
- getattr(timeline_object, property_name)
+ getattr(obj, property_name)
- timeline_object.connect(property_name + '-changed',
+ obj.connect(property_name + '-changed',
self._propertyChangedCb, property_name)
- def _propertyChangedCb(self, timeline_object, value, property_name):
+
+ def disconnectFromObject(self, obj):
+ 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(property_name + '-changed', timeline_object, old_value, value)
+ self.emit(property_name + '-changed', object, old_value, value)
class Seeker(Signallable):
__signals__ = {'seek': ['position', 'format']}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]