[pitivi] timeline: Handle drag and dropping effect on clips



commit bfaaecfe7366ca8773fbbc8576daa65ee769bcff
Author: Thibault Saunier <tsaunier gnome org>
Date:   Sun Jul 12 22:40:24 2015 +0200

    timeline: Handle drag and dropping effect on clips
    
    Summary: Depends on D260
    
    Reviewers: Mathieu_Du, aleb
    
    Differential Revision: https://phabricator.freedesktop.org/D261

 pitivi/timeline/elements.py |   26 ++++++++++++++++++++++++++
 pitivi/timeline/timeline.py |   15 ++++++++-------
 2 files changed, 34 insertions(+), 7 deletions(-)
---
diff --git a/pitivi/timeline/elements.py b/pitivi/timeline/elements.py
index 91404f5..52f8de1 100644
--- a/pitivi/timeline/elements.py
+++ b/pitivi/timeline/elements.py
@@ -618,6 +618,32 @@ class Clip(Gtk.EventBox, timelineUtils.Zoomable, Loggable):
         self._connectGES()
         self.get_accessible().set_name(self.bClip.get_name())
 
+        # To be able to receive effects dragged on clips.
+        self.drag_dest_set(0, [ui.EFFECT_TARGET_ENTRY], Gdk.DragAction.COPY)
+
+        self.connect("drag-drop", self.__dragDropCb)
+
+    def __dragDropCb(self, unused_widget, context, x, y, timestamp):
+        success = False
+
+        target = self.drag_dest_find_target(context, None)
+        if not target:
+            return False
+
+        if target.name() == ui.EFFECT_TARGET_ENTRY.target:
+            self.info("Adding effect %s", self.timeline.dropData)
+            self.app.gui.clipconfig.effect_expander.addEffectToClip(self.bClip,
+                                                                    self.timeline.dropData)
+            self.timeline.resetSelectionGroup()
+            self.timeline.selection.setSelection([self.bClip], timelineUtils.SELECT)
+            self.timeline.parent.gui.switchContextTab(self.bClip)
+            self.timeline.cleanDropData()
+            success = True
+
+        Gtk.drag_finish(context, success, True, timestamp)
+
+        return success
+
     def __computeHeightAndY(self):
         parent = self.get_parent()
         parent_height = parent.get_allocated_height()
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 9c3db89..96bf0b7 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -762,16 +762,19 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
             self.__got_dragged = False
             self._createdClips = False
 
+    def cleanDropData(self):
+        self.dropDataReady = False
+        self.dropData = None
+        self._createdClips = False
+
     def __dragDropCb(self, unused_widget, context, x, y, timestamp):
         # Same as in insertEnd: this value changes during insertion, snapshot
         # it
         zoom_was_fitted = self.parent.zoomed_fitted
-        success = True
-        self.dropDataReady = False
-        self.dropData = None
-        self._createdClips = False
 
         target = self.drag_dest_find_target(context, None).name()
+        success = True
+        self.cleanDropData()
         if target == URI_TARGET_ENTRY.target:
             if self.__last_clips_on_leave:
                 self.app.action_log.begin("add clip")
@@ -786,12 +789,10 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
 
                 if zoom_was_fitted:
                     self.parent._setBestZoomRatio()
-
                 self.dragEnd(True)
-        elif target == EFFECT_TARGET_ENTRY.target:
-            self.fixme("TODO Implement effect support")
         else:
             success = False
+
         Gtk.drag_finish(context, success, False, timestamp)
         return success
 


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