[pitivi] Timeline: Disable updates when adding/moving objects in the timeline.



commit e71a23d1b051bdf130550e3fc66bf5382af1ead7
Author: Edward Hervey <bilboed bilboed com>
Date:   Thu May 7 18:51:01 2009 +0200

    Timeline: Disable updates when adding/moving objects in the timeline.
    
    This requires current gnonlin git, and might need some more optimisation
    by putting even more timeline modifications between enable/disableUpdates.
---
 pitivi/timeline/timeline.py |    8 ++++++++
 pitivi/timeline/track.py    |    6 ++++++
 pitivi/ui/timeline.py       |    6 ++++++
 pitivi/ui/trackobject.py    |    5 +++++
 4 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 078b946..f66f64a 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -735,3 +735,11 @@ class Timeline(Signallable, Loggable):
             return edge
 
         return start
+
+    def disableUpdates(self):
+        for track in self.tracks:
+            track.disableUpdates()
+
+    def enableUpdates(self):
+        for track in self.tracks:
+            track.enableUpdates()
diff --git a/pitivi/timeline/track.py b/pitivi/timeline/track.py
index 736054e..fef45f4 100644
--- a/pitivi/timeline/track.py
+++ b/pitivi/timeline/track.py
@@ -458,3 +458,9 @@ class Track(Signallable):
 
     def _disconnectFromTrackObject(self, track_object):
         track_object.disconnect_by_function(self._trackObjectPriorityChangedCb)
+
+    def enableUpdates(self):
+        self.composition.props.update = True
+
+    def disableUpdates(self):
+        self.composition.props.update = False
diff --git a/pitivi/ui/timeline.py b/pitivi/ui/timeline.py
index 765ba54..de360e0 100644
--- a/pitivi/ui/timeline.py
+++ b/pitivi/ui/timeline.py
@@ -243,12 +243,17 @@ class Timeline(gtk.Table, Loggable, Zoomable):
 ## Drag and Drop callbacks
 
     def _dragMotionCb(self, unused, context, x, y, timestamp):
+        self.warning("self._factories:%r, self._temp_objects:%r",
+                     not not self._factories,
+                     not not self._temp_objects)
         if not self._factories:
             atom = gtk.gdk.atom_intern(dnd.FILESOURCE_TUPLE[0])
             self.drag_get_data(context, atom, timestamp)
             self.drag_highlight()
         else:
+            # actual drag-and-drop
             if not self._temp_objects:
+                self.timeline.disableUpdates()
                 self._add_temp_source()
             self._move_temp_source(x, y)
         return True
@@ -261,6 +266,7 @@ class Timeline(gtk.Table, Loggable, Zoomable):
             finally:
                 self._temp_objects = None
         self.drag_unhighlight()
+        self.timeline.enableUpdates()
 
     def _dragDropCb(self, widget, context, x, y, timestamp):
         self._add_temp_source()
diff --git a/pitivi/ui/trackobject.py b/pitivi/ui/trackobject.py
index b40b165..0f13f5c 100644
--- a/pitivi/ui/trackobject.py
+++ b/pitivi/ui/trackobject.py
@@ -159,6 +159,7 @@ class TrackObject(View, goocanvas.Group, Zoomable):
 
         def drag_start(self):
             TimelineController.drag_start(self)
+            self._view.timeline.disableUpdates()
             self._view.raise_(None)
             tx = self._view.props.parent.get_transform()
             self._y_offset = tx[5]
@@ -180,6 +181,10 @@ class TrackObject(View, goocanvas.Group, Zoomable):
                     self._offsets[obj] = start, priority
                 del self._offsets[element]
 
+        def drag_end(self):
+            TimelineController.drag_end(self)
+            self._view.timeline.enableUpdates()
+
         def click(self, pos):
             mode = SELECT
             if self._last_event.get_state() & gtk.gdk.SHIFT_MASK:



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