[pitivi: 8/10] sourcelist: only call drag_begin at appropriate time, Finally Fixes 572327



commit 6f623e01b7dce7df52b38b6c855f19059306f669
Author: Brandon Lewis <brandon_lewis berkeley edu>
Date:   Fri Mar 13 18:32:47 2009 -0700

    sourcelist: only call drag_begin at appropriate time, Finally Fixes 572327
---
 pitivi/ui/sourcelist.py |   34 ++++++++++++++++++++++++----------
 1 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/pitivi/ui/sourcelist.py b/pitivi/ui/sourcelist.py
index 65c8d65..ba0d240 100644
--- a/pitivi/ui/sourcelist.py
+++ b/pitivi/ui/sourcelist.py
@@ -541,6 +541,16 @@ class SourceList(gtk.VBox, Loggable):
     _dragY = 0
     _ignoreRelease = False
 
+    def _rowUnderMouseSelected(self, treeview, event):
+        result = treeview.get_path_at_pos(int(event.x), int(event.y))
+        if result:
+            path = result[0]
+            return treeview.get_selection().path_is_selected(path)
+        return False
+
+    def _nothingUnderMouse(self, treeview, event):
+        return not bool(treeview.get_path_at_pos(int(event.x), int(event.y)))
+
     def _treeViewButtonPressEventCb(self, treeview, event):
         chain_up = True
 
@@ -551,7 +561,7 @@ class SourceList(gtk.VBox, Loggable):
         else:
 
             if not event.state & (gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK):
-                chain_up = False
+                chain_up = not self._rowUnderMouseSelected(treeview, event)
 
             self._dragStarted = False
             self._dragButton = event.button 
@@ -568,16 +578,20 @@ class SourceList(gtk.VBox, Loggable):
         return True
 
     def _treeViewMotionNotifyEventCb(self, treeview, event):
-        if self._dragButton:
-            if treeview.drag_check_threshold(self._dragX, self._dragY,
-                int(event.x), int(event.y)):
-                context = treeview.drag_begin(
-                    [dnd.URI_TUPLE, dnd.FILESOURCE_TUPLE],
-                    gtk.gdk.ACTION_COPY,
-                    self._dragButton,
-                    event)
-                self._dragStarted = True
+        if not self._dragButton:
             return True
+
+        if self._nothingUnderMouse(treeview, event):
+            return True
+
+        if treeview.drag_check_threshold(self._dragX, self._dragY,
+            int(event.x), int(event.y)):
+            context = treeview.drag_begin(
+                [dnd.URI_TUPLE, dnd.FILESOURCE_TUPLE],
+                gtk.gdk.ACTION_COPY,
+                self._dragButton,
+                event)
+            self._dragStarted = True
         return False
 
     def _treeViewButtonReleaseCb(self, treeview, event):



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