[pitivi] Re-enables drag and drop from the effect list.
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Re-enables drag and drop from the effect list.
- Date: Sun, 2 Sep 2012 04:03:15 +0000 (UTC)
commit 4fa00a2b2e239dc927ee874aaf5c6cf4159a1831
Author: Mathieu Duponchelle <mathieu duponchelle epitech eu>
Date: Mon Aug 20 17:23:16 2012 +0200
Re-enables drag and drop from the effect list.
pitivi/effects.py | 73 +++++++------------------------------------
pitivi/medialibrary.py | 7 ++++
pitivi/timeline/timeline.py | 10 +++---
3 files changed, 24 insertions(+), 66 deletions(-)
---
diff --git a/pitivi/effects.py b/pitivi/effects.py
index c9e092b..00f8cd7 100644
--- a/pitivi/effects.py
+++ b/pitivi/effects.py
@@ -52,7 +52,7 @@ from pitivi.settings import GlobalSettings
import pitivi.utils.ui as dnd
from pitivi.utils.loggable import Loggable
-from pitivi.utils.ui import SPACING
+from pitivi.utils.ui import SPACING, TYPE_PITIVI_EFFECT
from pitivi.utils.widgets import GstElementSettingsWidget, FractionWidget
@@ -353,11 +353,7 @@ class EffectListWidget(gtk.VBox, Loggable):
self.app = instance
self.settings = instance.settings
- self._dragButton = None
- self._dragStarted = False
- self._dragSelection = False
- self._dragX = 0
- self._dragY = 0
+ self._draggedItems = None
#Searchbox and combobox
hfilters = gtk.HBox()
@@ -431,11 +427,13 @@ class EffectListWidget(gtk.VBox, Loggable):
self.view.connect("button-press-event", self._buttonPressEventCb)
self.view.connect("select-cursor-row", self._enterPressEventCb)
- self.view.connect("motion-notify-event", self._motionNotifyEventCb)
- self.view.connect("button-release-event", self._buttonReleaseCb)
+
self.view.drag_source_set(0, [], gtk.gdk.ACTION_COPY)
+ self.view.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK, [("pitivi/effect", 0, TYPE_PITIVI_EFFECT)], Gdk.DragAction.COPY)
+ self.view.drag_source_set_target_list(None)
+ self.view.drag_source_add_text_targets()
+
self.view.connect("drag_begin", self._dndDragBeginCb)
- self.view.connect("drag_data_get", self._dndDataGetCb)
# Delay the loading of the available effects so the application
# starts faster.
@@ -501,7 +499,6 @@ class EffectListWidget(gtk.VBox, Loggable):
def _dndDragBeginCb(self, view, context):
self.info("tree drag_begin")
-
model, paths = self.view.get_selection().get_selected_rows()
if not paths:
@@ -539,68 +536,22 @@ class EffectListWidget(gtk.VBox, Loggable):
else:
chain_up = not self._rowUnderMouseSelected(view, event)
- self._dragStarted = False
- self._dragSelection = False
- self._dragButton = event.button
- self._dragX = int(event.x)
- self._dragY = int(event.y)
-
if chain_up:
- gtk.TreeView.do_button_press_event(view, event)
+ self._draggedItems = None
else:
- view.grab_focus()
+ self._draggedItems = self.getSelectedItems()
+ gtk.TreeView.do_button_press_event(view, event)
return True
- def _motionNotifyEventCb(self, view, event):
- chain_up = True
-
- if not self._dragButton:
- return True
-
- if self._nothingUnderMouse(view, event):
- return True
-
- if not event.state & (gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK):
- chain_up = not self._rowUnderMouseSelected(view, event)
-
- if view.drag_check_threshold(self._dragX, self._dragY,
- int(event.x), int(event.y)):
- context = view.drag_begin(
- gtk.TargetList.new(self._getTargetEntries()),
- gtk.gdk.ACTION_COPY,
- self._dragButton,
- event)
- self._dragStarted = True
-
- if chain_up:
- gtk.TreeView.do_button_press_event(view, event)
- else:
- view.grab_focus()
-
- return False
-
- def _buttonReleaseCb(self, treeview, event):
- if event.button == self._dragButton:
- self._dragButton = None
- return False
-
def getSelectedItems(self):
+ if self._draggedItems:
+ return self._draggedItems
model, rows = self.view.get_selection().get_selected_rows()
path = self.modelFilter.convert_path_to_child_path(rows[0])
return self.storemodel[path][COL_ELEMENT_NAME]
- def _dndDataGetCb(self, unused_widget, context, selection,
- targettype, unused_eventtime):
- self.info("data get, type:%d", targettype)
- factory = self.getSelectedItems()
- if factory is None or len(factory) < 1:
- return
-
- selection.set(selection.target, 8, factory)
- gtk.drag_set_icon_pixbuf(context, INVISIBLE, 0, 0)
-
def _effectTypeChangedCb(self, combobox):
self.modelFilter.refilter()
self.show_categories(combobox.get_active())
diff --git a/pitivi/medialibrary.py b/pitivi/medialibrary.py
index ac65e38..fd9c9b0 100644
--- a/pitivi/medialibrary.py
+++ b/pitivi/medialibrary.py
@@ -276,6 +276,7 @@ class MediaLibraryWidget(gtk.VBox, Loggable):
self._project = None
self.dummy_selected = []
self._draggedItems = None
+ self.dragged = False
# Store
# icon, infotext, objectfactory, uri, length
@@ -449,6 +450,7 @@ class MediaLibraryWidget(gtk.VBox, Loggable):
self.treeview.drag_source_add_text_targets()
self.treeview.connect("drag_begin", self._dndDragBeginCb)
+ self.treeview.connect("drag-end", self._dndDragEndCb)
self.iconview.drag_source_set(0, [], gtk.gdk.ACTION_COPY)
self.iconview.enable_model_drag_source(Gdk.ModifierType.BUTTON1_MASK, [gtk.TargetEntry.new("pitivi/file-source", 0, TYPE_PITIVI_FILESOURCE)], Gdk.DragAction.COPY)
@@ -457,6 +459,7 @@ class MediaLibraryWidget(gtk.VBox, Loggable):
self.iconview.drag_source_add_text_targets()
self.iconview.connect("drag_begin", self._dndDragBeginCb)
+ self.iconview.connect("drag-end", self._dndDragEndCb)
# Hack so that the views have the same method as self
self.treeview.getSelectedItems = self.getSelectedItems
@@ -1214,6 +1217,7 @@ class MediaLibraryWidget(gtk.VBox, Loggable):
#used with TreeView and IconView
def _dndDragBeginCb(self, view, context):
self.info("tree drag_begin")
+ self.dragged = True
paths = self.getSelectedPaths()
if len(paths) < 1:
@@ -1222,6 +1226,9 @@ class MediaLibraryWidget(gtk.VBox, Loggable):
row = self.modelFilter[paths[0]]
gtk.drag_set_icon_pixbuf(context, row[COL_ICON], 0, 0)
+ def _dndDragEndCb(self, view, context):
+ self.dragged = False
+
def getSelectedPaths(self):
""" Returns a list of selected treeview or iconview items """
if self.clip_view == SHOW_TREEVIEW:
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index d34160d..46a3ca7 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -1173,10 +1173,9 @@ class Timeline(gtk.Table, Loggable, Zoomable):
def _dragMotionCb(self, unused, context, x, y, timestamp):
# Set up the initial data when we first initiate the drag operation
-
if not self._drag_started:
self._drag_started = True
- elif context.list_targets() not in DND_EFFECT_LIST:
+ elif context.list_targets() not in DND_EFFECT_LIST and self.app.gui.medialibrary.dragged:
if not self._temp_objects and not self._creating_tckobjs_sigid:
self._create_temp_source(x, y)
@@ -1234,7 +1233,8 @@ class Timeline(gtk.Table, Loggable, Zoomable):
# Resetting _drag_started will tell _dragCleanUp to not do anything
self._drag_started = False
self.debug("Drag drop")
- if context.list_targets() not in DND_EFFECT_LIST:
+
+ if self.app.gui.medialibrary.dragged:
self._canvas.drag_unhighlight()
self.app.action_log.begin("add clip")
if self._move_context is not None:
@@ -1250,12 +1250,11 @@ class Timeline(gtk.Table, Loggable, Zoomable):
else:
if self.app.current.timeline.props.duration == 0:
return False
- factory = self._factories[0]
timeline_objs = self._getTimelineObjectUnderMouse(x, y)
if timeline_objs:
# FIXME make a util function to add effects
# instead of copy/pasting it from cliproperties
- bin_desc = factory.effectname
+ bin_desc = self.app.gui.effectlist.getSelectedItems()
media_type = self.app.effects.getFactoryFromName(bin_desc).media_type
# Trying to apply effect only on the first object of the selection
@@ -1281,6 +1280,7 @@ class Timeline(gtk.Table, Loggable, Zoomable):
self.timeline.selection.setSelection(timeline_objs, SELECT)
break
+ Gtk.drag_finish(context, True, False, timestamp)
return True
def _getTimelineObjectUnderMouse(self, x, y):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]