[pitivi] medialibrary: Reuse the code for setting the dragged paths



commit e6525f58af6113e526047dce0bf40db1e58950ae
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Mon Dec 2 23:23:11 2013 +0100

    medialibrary: Reuse the code for setting the dragged paths

 pitivi/medialibrary.py |   45 ++++++++++++++++-----------------------------
 1 files changed, 16 insertions(+), 29 deletions(-)
---
diff --git a/pitivi/medialibrary.py b/pitivi/medialibrary.py
index ca05377..d0f4fab 100644
--- a/pitivi/medialibrary.py
+++ b/pitivi/medialibrary.py
@@ -841,32 +841,35 @@ class MediaLibraryWidget(Gtk.VBox, Loggable):
             self.iconview.unselect_all()
 
     def _treeViewButtonPressEventCb(self, treeview, event):
-        chain_up = True
+        self._updateDraggedPaths(treeview, event)
 
+        Gtk.TreeView.do_button_press_event(treeview, event)
+
+        ts = self.treeview.get_selection()
+        if self._draggedPaths:
+            for path in self._draggedPaths:
+                ts.select_path(path)
+
+        return True
+
+    def _updateDraggedPaths(self, view, event):
         if event.type == getattr(Gdk.EventType, '2BUTTON_PRESS'):
             # It is possible to double-click outside of clips:
-            if self.getSelectedPaths() != []:
+            if self.getSelectedPaths():
                 # Here we used to emit "play", but
                 # this is now handled by _itemOrRowActivatedCb instead.
                 pass
             chain_up = False
         elif not event.get_state() & (Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK):
-            chain_up = not self._rowUnderMouseSelected(treeview, event)
+            chain_up = not self._rowUnderMouseSelected(view, event)
+        else:
+            chain_up = True
 
         if not chain_up:
             self._draggedPaths = self.getSelectedPaths()
         else:
             self._draggedPaths = None
 
-        Gtk.TreeView.do_button_press_event(treeview, event)
-
-        ts = self.treeview.get_selection()
-        if self._draggedPaths:
-            for path in self._draggedPaths:
-                ts.select_path(path)
-
-        return True
-
     def _treeViewButtonReleaseEventCb(self, treeview, event):
         ts = self.treeview.get_selection()
         state = event.get_state() & (Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK)
@@ -903,22 +906,7 @@ class MediaLibraryWidget(Gtk.VBox, Loggable):
         self.emit('play', asset)
 
     def _iconViewButtonPressEventCb(self, iconview, event):
-        chain_up = True
-
-        if event.type == getattr(Gdk.EventType, '2BUTTON_PRESS'):
-            # It is possible to double-click outside of clips:
-            if self.getSelectedPaths() != []:
-                # Here we used to emit "play", but
-                # this is now handled by _itemOrRowActivatedCb instead.
-                pass
-            chain_up = False
-        elif not event.get_state() & (Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.SHIFT_MASK):
-            chain_up = not self._rowUnderMouseSelected(iconview, event)
-
-        if not chain_up:
-            self._draggedPaths = self.getSelectedPaths()
-        else:
-            self._draggedPaths = None
+        self._updateDraggedPaths(iconview, event)
 
         Gtk.IconView.do_button_press_event(iconview, event)
 
@@ -926,7 +914,6 @@ class MediaLibraryWidget(Gtk.VBox, Loggable):
             for path in self._draggedPaths:
                 self.iconview.select_path(path)
 
-        self._ignoreRelease = chain_up
         self.iconview_cursor_pos = self.iconview.get_path_at_pos(event.x, event.y)
 
         return True


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