[pitivi/ges: 8/287] Handle timeline object position when adding to timeline



commit 12a9671d8acd38f3c13fa84ee3791b3443c422b8
Author: Mathieu Duponchelle <seeed laposte net>
Date:   Wed Jul 20 05:02:39 2011 +0200

    Handle timeline object position when adding to timeline
    
    Remove ripple editing for the while

 pitivi/timeline/timeline.py      |   60 +++++++++++++++++++-------------------
 pitivi/timeline/timeline_undo.py |   12 ++++----
 pitivi/ui/timeline.py            |   41 ++++++++++++++------------
 pitivi/utils.py                  |    2 +-
 4 files changed, 59 insertions(+), 56 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 6faa8ba..b553db6 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -953,25 +953,25 @@ class EditingContext(object):
         self.other = other
         self.focus = focus
         self.timeline = timeline
-        self._snap = True
+        self._snap = False
         self._mode = self.DEFAULT
-        self._last_position = focus.start
-        self._last_priority = focus.priority
+        self._last_position = focus.get_property("start")
+        self._last_priority = focus.get_property("priority")
 
-        self.timeline.disableUpdates()
+        #self.timeline.disableUpdates()
 
     def _getOffsets(self, start_offset, priority_offset, timeline_objects):
         offsets = {}
         for timeline_object in timeline_objects:
-            offsets[timeline_object] = (timeline_object.start - start_offset,
-                        timeline_object.priority - priority_offset)
+            offsets[timeline_object] = (timeline_object.get_property("start") - start_offset,
+                        timeline_object.get_property("priority") - priority_offset)
 
         return offsets
 
     def _getTimelineObjectValues(self, timeline_object):
-        return (timeline_object.start, timeline_object.duration,
-                timeline_object.in_point, timeline_object.media_duration,
-                timeline_object.priority)
+        return (timeline_object.get_property("start"), timeline_object.get_property("duration"),
+                timeline_object.get_property("in_point"),
+                timeline_object.get_property("priority"))
 
     def _saveValues(self, timeline_objects):
         return dict(((timeline_object,
@@ -1093,7 +1093,7 @@ class MoveContext(EditingContext):
             else:
                 timeline_object = obj
                 timeline_object_tracks = set(track_object.track for track_object
-                        in timeline_object.track_objects)
+                        in timeline_object.get_track_objects())
                 self.tracks.update(timeline_object_tracks)
 
             self.timeline_objects.add(timeline_object)
@@ -1101,35 +1101,35 @@ class MoveContext(EditingContext):
             self.default_originals[timeline_object] = \
                     self._getTimelineObjectValues(timeline_object)
 
-            earliest = min(earliest, timeline_object.start)
+            earliest = min(earliest, timeline_object.get_property("start"))
             latest = max(latest,
-                    timeline_object.start + timeline_object.duration)
-            min_priority = min(min_priority, timeline_object.priority)
+                    timeline_object.get_property("start") + timeline_object.get_property("duration"))
+            min_priority = min(min_priority, timeline_object.get_property("priority"))
 
-        self.offsets = self._getOffsets(self.focus.start, self.focus.priority,
+        self.offsets = self._getOffsets(self.focus.get_property("start"), self.focus.get_property("priority"),
                 self.timeline_objects)
 
-        self.min_priority = focus.priority - min_priority
-        self.min_position = focus.start - earliest
+        self.min_priority = focus.get_property("priority") - min_priority
+        self.min_position = focus.get_property("start") - earliest
 
         # get the span over all clips for edge snapping
         self.default_span = latest - earliest
 
-        ripple = timeline.getObjsAfterTime(latest)
-        self.ripple_offsets = self._getOffsets(self.focus.start,
-            self.focus.priority, ripple)
+        #ripple = timeline.getObjsAfterTime(latest)
+        #self.ripple_offsets = self._getOffsets(self.focus.get_property("start"),
+            #self.focus.get_property("priority"), ripple)
 
         # get the span over all clips for ripple editing
-        for timeline_object in ripple:
-            latest = max(latest, timeline_object.start +
-                timeline_object.duration)
-        self.ripple_span = latest - earliest
+        #for timeline_object in ripple:
+            #latest = max(latest, timeline_object.get_property("start") +
+                #timeline_object.get_property("duration"))
+        #self.ripple_span = latest - earliest
 
         # save default values
-        self.ripple_originals = self._saveValues(ripple)
+        #self.ripple_originals = self._saveValues(ripple)
 
-        self.timeline_objects_plus_ripple = set(self.timeline_objects)
-        self.timeline_objects_plus_ripple.update(ripple)
+        #self.timeline_objects_plus_ripple = set(self.timeline_objects)
+        #self.timeline_objects_plus_ripple.update(ripple)
 
     def _getGapsAtPriority(self, priority):
         if self._mode == self.RIPPLE:
@@ -1265,12 +1265,12 @@ class MoveContext(EditingContext):
         priority = max(self.min_priority, priority)
         position = max(self.min_position, position)
 
-        self.focus.priority = priority
-        self.focus.setStart(position, snap=self._snap)
+        self.focus.set_property ("priority", priority)
+        self.focus.set_property("start", position)
 
         for obj, (s_offset, p_offset) in self.offsets.iteritems():
-            obj.setStart(position + s_offset)
-            obj.priority = priority + p_offset
+            obj.set_property("start", position + s_offset)
+            obj.set_property ("priority", priority + p_offset)
 
         return position, priority
 
diff --git a/pitivi/timeline/timeline_undo.py b/pitivi/timeline/timeline_undo.py
index 33b5cb2..e2020c4 100644
--- a/pitivi/timeline/timeline_undo.py
+++ b/pitivi/timeline/timeline_undo.py
@@ -131,7 +131,7 @@ class TimelineObjectAdded(UndoableAction):
         self.timeline = timeline
         self.timeline_object = timeline_object
         self.tracks = dict((track_object, track_object.track)
-                for track_object in timeline_object.track_objects)
+                for track_object in timeline_object.get_track_objects())
 
     def do(self):
         for track_object, track in self.tracks.iteritems():
@@ -395,13 +395,13 @@ class TimelineLogObserver(object):
         tracker = TimelineObjectPropertyChangeTracker()
         tracker.connectToObject(timeline_object)
         for property_name in tracker.property_names:
-            tracker.connect(property_name + "-changed",
+            tracker.connect("notify::" +property_name,
                     self._timelineObjectPropertyChangedCb, property_name)
         self.timeline_object_property_trackers[timeline_object] = tracker
 
         timeline_object.connect("track-object-added", self._timelineObjectTrackObjectAddedCb)
-        timeline_object.connect("track-object-removed", self._timelineObjectTrackObjectRemovedCb)
-        for obj in timeline_object.track_objects:
+        #timeline_object.connect("track-object-removed", self._timelineObjectTrackObjectRemovedCb)
+        for obj in timeline_object.get_track_objects():
             self._connectToTrackObject(obj)
 
     def _disconnectFromTimelineObject(self, timeline_object):
@@ -410,8 +410,8 @@ class TimelineLogObserver(object):
         tracker.disconnect_by_func(self._timelineObjectPropertyChangedCb)
 
     def _connectToTrackObject(self, track_object):
-        for prop, interpolator in track_object.getInterpolators().itervalues():
-            self._connectToInterpolator(interpolator)
+        #for prop, interpolator in track_object.getInterpolators().itervalues():
+            #self._connectToInterpolator(interpolator)
         if isinstance(track_object, TrackEffect):
             self.effect_properties_tracker.addEffectElement(track_object.getElement())
 
diff --git a/pitivi/ui/timeline.py b/pitivi/ui/timeline.py
index 39c3dfc..7537bda 100644
--- a/pitivi/ui/timeline.py
+++ b/pitivi/ui/timeline.py
@@ -200,6 +200,8 @@ class Timeline(gtk.Table, Loggable, Zoomable):
         self._prev_duration = 0
         self.rate = gst.Fraction(1, 1)
 
+        self._temp_objects = []
+
     def _createUI(self):
         self.leftSizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
         self.props.row_spacing = 2
@@ -392,28 +394,25 @@ class Timeline(gtk.Table, Loggable, Zoomable):
 
     def _dragMotionCb(self, unused, context, x, y, timestamp):
 
-        if self._factories is None:
-            if  context.targets in DND_EFFECT_LIST:
-                atom = gtk.gdk.atom_intern(dnd.EFFECT_TUPLE[0])
-            else:
-                atom = gtk.gdk.atom_intern(dnd.FILESOURCE_TUPLE[0])
+        atom = gtk.gdk.atom_intern(dnd.FILESOURCE_TUPLE[0])
 
-            self.drag_get_data(context, atom, timestamp)
-            self.drag_highlight()
-        else:
-            if  context.targets not in DND_EFFECT_LIST:
-                if not self._temp_objects:
-                    #GES break,FIXME
-                    pass
+        self.drag_get_data(context, atom, timestamp)
+        self.drag_highlight()
+        if  context.targets not in DND_EFFECT_LIST:
+            if not self._temp_objects:
+                #GES break, FIXME
+                pass
+                self.timeline.disableUpdates()
+                self._add_temp_source()
+                focus = self._temp_objects[0]
+                self._move_context = MoveContext(self.timeline,
+                        focus, set(self._temp_objects[1:]))
+            self._move_temp_source(self.hadj.props.value + x, y)
         return True
 
     def _dragLeaveCb(self, unused_layout, context, unused_tstamp):
         if self._temp_objects:
-            try:
-                for obj in self._temp_objects:
-                    self.timeline.removeTimelineObject(obj, deep=True)
-            finally:
-                self._temp_objects = None
+            self._temp_objects = []
 
         self.drag_unhighlight()
         #FIXME, GES break, temporary hack
@@ -490,8 +489,12 @@ class Timeline(gtk.Table, Loggable, Zoomable):
         return timeline_objs
 
     def _add_temp_source(self):
-        self._temp_objects = [self.timeline.addSourceFactory(factory)
-            for factory in self._factories]
+        uris = self.selection_data.split("\n")
+        layer = self.app.projectManager.current.timeline.get_layers()[0]
+        for uri in uris :
+            src = ges.TimelineFileSource(uri)
+            layer.add_object(src)
+            self._temp_objects.insert(0, src)
 
     def _move_temp_source(self, x, y):
         x1, y1, x2, y2 = self._controls.get_allocation()
diff --git a/pitivi/utils.py b/pitivi/utils.py
index 95df0f9..95e91d6 100644
--- a/pitivi/utils.py
+++ b/pitivi/utils.py
@@ -353,7 +353,7 @@ class PropertyChangeTracker(Signallable):
         old_value = self.properties[property_name]
         self.properties[property_name] = value
 
-        self.emit(property_name + '-changed', object, old_value, value)
+        self.emit("notify::" + property_name, object, old_value, value)
 
 
 class Seeker(Signallable):



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