[pitivi] Seeker: make seeking in a idle handler optional.



commit e68f1514328e1ae7abaf9f86f3072e3cf7521239
Author: Alessandro Decina <alessandro d gmail com>
Date:   Tue May 19 17:26:55 2009 +0200

    Seeker: make seeking in a idle handler optional.
---
 pitivi/ui/ruler.py   |    4 ++--
 pitivi/utils.py      |   10 +++++-----
 tests/test_seeker.py |    3 ---
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/pitivi/ui/ruler.py b/pitivi/ui/ruler.py
index 71fb7ab..a06bcf8 100644
--- a/pitivi/ui/ruler.py
+++ b/pitivi/ui/ruler.py
@@ -180,7 +180,7 @@ class ScaleRuler(gtk.Layout, Zoomable, Loggable):
 
         return False
 
-    def _doSeek(self, value, format=gst.FORMAT_TIME):
+    def _doSeek(self, value, format=gst.FORMAT_TIME, on_idle=False):
         self.seeker.seek(value, format)
 
 ## Drawing methods
@@ -235,7 +235,7 @@ class ScaleRuler(gtk.Layout, Zoomable, Loggable):
         else:
             position = self.position
 
-        self._doSeek(position, gst.FORMAT_TIME)
+        self._doSeek(position, gst.FORMAT_TIME, on_idle=True)
 
     def getShadedDuration(self):
         return self.shaded_duration
diff --git a/pitivi/utils.py b/pitivi/utils.py
index cd4bf71..c9419d5 100644
--- a/pitivi/utils.py
+++ b/pitivi/utils.py
@@ -260,20 +260,20 @@ class Seeker(Signallable):
         self.position = None
         self.format = None
 
-    def seek(self, position, format=gst.FORMAT_TIME):
+    def seek(self, position, format=gst.FORMAT_TIME, on_idle=False):
         if self.pending_seek_id is None:
             self.position = position
             self.format = format
-            self._doFirstSeek()
+            if on_idle:
+                gobject.idle_add(self._seekTimeoutCb)
+            else:
+                self._seekTimeoutCb()
             self.pending_seek_id = self._scheduleSeek(self.timeout,
                     self._seekTimeoutCb)
         else:
             self.position = position
             self.format = format
 
-    def _doFirstSeek(self):
-        gobject.idle_add(self._seekTimeoutCb)
-
     def _scheduleSeek(self, timeout, callback):
         return gobject.timeout_add(timeout, callback)
 
diff --git a/tests/test_seeker.py b/tests/test_seeker.py
index ffce449..b8a1a13 100644
--- a/tests/test_seeker.py
+++ b/tests/test_seeker.py
@@ -26,9 +26,6 @@ import gst
 class StubSeeker(Seeker):
     seek_id = 0
 
-    def _doFirstSeek(self):
-        self._seekTimeoutCb()
-
     def _scheduleSeek(self, position, format):
         # mock Seeker._scheduleSeek so that we don't need a mainloop
         seek_id = self.seek_id



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