[pitivi] Add dnd to the clip properties



commit 003d1d9fc84da8c1dc454f8863cc789c7f8044a1
Author: Thibault Saunier <tsaunier gnome org>
Date:   Mon Jul 19 17:44:33 2010 -0400

    Add dnd to the clip properties

 pitivi/timeline/timeline.py |    7 +++++--
 pitivi/ui/clipproperties.py |   21 +++++++++++++--------
 2 files changed, 18 insertions(+), 10 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 6884628..a390e23 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -1687,7 +1687,7 @@ class Timeline(Signallable, Loggable):
         self.addTimelineObject(timeline_object)
         return timeline_object
 
-    def addEffectFactoryOnObject(self, factory, time, priority):
+    def addEffectFactoryOnObject(self, factory, time=0, priority=0, timeline_objects=None):
         """
         Add effectTraks corresponding to the effect from the factory to the corresponding
         L{TimelineObject}s on the timeline
@@ -1722,7 +1722,10 @@ class Timeline(Signallable, Loggable):
         listTimelineObjectTrackObject = []
         track_object = TrackEffect(factory, input_stream)
         track_object.makeBin()
-        timeline_objects = self.getObjsToAddEffectTo(time, priority)
+
+        if not timeline_objects:
+            timeline_objects = self.getObjsToAddEffectTo(time, priority)
+
         for obj in timeline_objects:
             copy_track_obj = track_object.copy()
             track.addTrackObject(copy_track_obj)
diff --git a/pitivi/ui/clipproperties.py b/pitivi/ui/clipproperties.py
index 5806a91..29d185b 100644
--- a/pitivi/ui/clipproperties.py
+++ b/pitivi/ui/clipproperties.py
@@ -83,6 +83,7 @@ class EffectProperties(gtk.Expander):
 
         self.selected_effects = []
         self.timeline_object = None
+        self._factory = None
         self.app = instance
         self.effectsHandler = self.app.effects
         self._effect_config_ui = None
@@ -183,7 +184,7 @@ class EffectProperties(gtk.Expander):
         self.selection.connect("changed", self._treeviewSelectionChangedCb)
         self.removeEffectBt.connect("clicked", self._removeEffectClicked)
 
-        self.treeview.connect("drag-data-received", self._dragDataReceivedCb)
+        self.connect("drag-data-received", self._dragDataReceivedCb)
         self.treeview.connect("drag-leave", self._dragLeaveCb)
         self.treeview.connect("drag-drop", self._dragDropCb)
         self.treeview.connect("drag-motion", self._dragMotionCb)
@@ -240,22 +241,26 @@ class EffectProperties(gtk.Expander):
         self.timeline_object.removeTrackObject(effect)
         track.removeTrackObject(effect)
 
-    def _dragDataReceivedCb(self, unused, context, x, y, timestamp):
-        # I am waiting for effects to work again before implementing DND here
-        print "Receive"
+    def _dragDataReceivedCb(self, unused_layout, context, x, y,
+        selection, targetType, timestamp):
+        self._factory = self.app.effects.getEffect(selection.data)
 
     def _dragDropCb(self, unused, context, x, y, timestamp):
-        print "Drop"
+        if self._factory:
+            self.timeline.addEffectFactoryOnObject(self._factory,
+                                                   timeline_objects = [self.timeline_object])
+        self._factory = None
 
     def _dragLeaveCb(self, unused_layout, unused_context, unused_tstamp):
+        self.factory = None
         self.drag_unhighlight()
 
     def _dragMotionCb(self, unused, context, x, y, timestamp):
+        atom = gtk.gdk.atom_intern(dnd.EFFECT_TUPLE[0])
+        if not self._factory:
+            self.drag_get_data(context, atom, timestamp)
         self.drag_highlight()
 
-    def _timelineWatcherCb(self, timeline):
-        print timeline.selection
-
     def _effectActiveToggleCb(self, cellrenderertoggle, path):
         iter = self.storemodel.get_iter(path)
         track_effect = self.storemodel.get_value(iter, COL_TRACK_EFFECT)



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