[pitivi/ges: 282/287] viewer: Update the widgets when seeking while paused



commit e87e7fd1790c6885ae11a876f10d29c7bdc34d67
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date:   Wed Feb 15 21:36:53 2012 -0500

    viewer: Update the widgets when seeking while paused

 pitivi/mainwindow.py |    4 +++-
 pitivi/viewer.py     |   23 +++++++++++++++--------
 2 files changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index 181aab8..8768ed6 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -1205,7 +1205,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
 
     def _timelineSeekCb(self, ruler, position, format):
         """
-        This is the main method used for seeking throughout the app.
+        The app's main seek method used when the user seeks manually.
 
         We clamp the seeker position so that it cannot go past 0 or the
         end of the timeline.
@@ -1222,6 +1222,8 @@ class PitiviMainWindow(gtk.Window, Loggable):
                 self.warning("Could not seek to %s", gst.TIME_ARGS(position))
             else:
                 self._seeker.setPosition(position)
+            # Ensure that the viewer UI is updated when seeking while paused
+            self.viewer.positionCheck()
 
         except Exception, e:
             self.error("seek failed %s %s %s", gst.TIME_ARGS(position), format, e)
diff --git a/pitivi/viewer.py b/pitivi/viewer.py
index 275a734..76ff9a4 100644
--- a/pitivi/viewer.py
+++ b/pitivi/viewer.py
@@ -460,10 +460,12 @@ class PitiviViewer(gtk.VBox, Loggable):
         else:
             self.dock()
 
-    def _positionCheckCb(self):
+    def positionCheck(self):
         """
-        Every 300 ms, check if the timeline position changed.
-        If so, update our viewer UI widgets.
+        If the timeline position changed, update the viewer UI widgets.
+
+        This is meant to be called either by the gobject timer when playing,
+        or by mainwindow's _timelineSeekCb when the timer is disabled.
         """
         try:
             self.current_time = self.pipeline.query_position(gst.FORMAT_TIME)[0]
@@ -473,10 +475,15 @@ class PitiviViewer(gtk.VBox, Loggable):
                 self.seeker.setPosition(self.current_time)
                 self.previous_time = self.current_time
         except:
-            self.debug("could not check timeline position for the viewer")
-        if self.currentState == gst.STATE_PAUSED:
-            return False
-        return True
+            self.debug("Could not check timeline position for the viewer")
+
+    def _positionCheckTimerCb(self):
+        """
+        Every 300 ms, request to check if the timeline position changed.
+        If the pipeline is paused, this returns False to stop the gobject timer.
+        """
+        self.positionCheck()
+        return self.currentState != gst.STATE_PAUSED
 
     def pipelineStateChanged(self, state):
         """
@@ -489,7 +496,7 @@ class PitiviViewer(gtk.VBox, Loggable):
         if int(state) == int(gst.STATE_PLAYING):
             self.playpause_button.setPause()
             self.system.inhibitScreensaver(self.INHIBIT_REASON)
-            gobject.timeout_add(300, self._positionCheckCb)
+            gobject.timeout_add(300, self._positionCheckTimerCb)
         elif int(state) == int(gst.STATE_PAUSED):
             self.playpause_button.setPlay()
             self.system.uninhibitScreensaver(self.INHIBIT_REASON)



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