[pitivi/ges: 92/287] utils: Add a setPosition method to Seeker
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi/ges: 92/287] utils: Add a setPosition method to Seeker
- Date: Thu, 15 Mar 2012 16:33:33 +0000 (UTC)
commit feec1917726d40748d13d904c7401e12d99bc721
Author: Thibault Saunier <thibault saunier collabora com>
Date: Wed Dec 14 11:24:22 2011 -0300
utils: Add a setPosition method to Seeker
It basically only send "position-changed" so then the application reacts
accordingly. This avoids each piece to have to handle everything.
pitivi/ui/mainwindow.py | 15 ++++++++-------
pitivi/ui/ruler.py | 8 ++++++--
pitivi/ui/timeline.py | 8 +++++---
pitivi/ui/viewer.py | 2 +-
pitivi/utils.py | 8 ++++++--
5 files changed, 26 insertions(+), 15 deletions(-)
---
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index 9da31a7..5c98a20 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -698,12 +698,13 @@ class PitiviMainWindow(gtk.Window, Loggable):
else:
self._zoom_duration_changed = True
- self.project.seeker.connect("seek", self._timelineSeekCb)
- self.project.seeker.connect("seek-relative", self._timelineSeekRelativeCb)
- self.project.seeker.connect("flush", self._timelineSeekFlushCb)
+ self._seeker = self.project.seeker
+ self._seeker.connect("seek", self._timelineSeekCb)
+ self._seeker.connect("seek-relative", self._timelineSeekRelativeCb)
+ self._seeker.connect("flush", self._timelineSeekFlushCb)
# preliminary seek to ensure the project pipeline is configured
- self.project.seeker.seek(0)
+ self._seeker.seek(0)
def setBestZoomRatio(self, p=0):
"""Set the zoom level so that the entire timeline is in view."""
@@ -1082,7 +1083,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
self.project_pipeline.seek(1.0, gst.FORMAT_TIME, gst.SEEK_FLAG_FLUSH,
gst.SEEK_TYPE_SET, position, gst.SEEK_TYPE_NONE, -1)
- self.timeline.timelinePositionChanged(position)
+ self._seeker.setPosition(position)
except Exception, e:
self.error("seek failed %s %s %s", gst.TIME_ARGS(position), format, e)
@@ -1092,7 +1093,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
position = self.project_pipeline.query_position(gst.FORMAT_TIME)[0]
self.project_pipeline.seek(1.0, gst.FORMAT_TIME, gst.SEEK_FLAG_FLUSH,
gst.SEEK_TYPE_SET, position, gst.SEEK_TYPE_NONE, -1)
- self.timeline.timelinePositionChanged(position)
+ self._seeker.setPosition(position)
except Exception, e:
self.error("seek failed %s %s %s", gst.TIME_ARGS(position), format, e)
@@ -1107,7 +1108,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
self.project_pipeline.seek(1.0, format, gst.SEEK_FLAG_FLUSH,
gst.SEEK_TYPE_SET, position, gst.SEEK_TYPE_NONE, -1)
- self.timeline.timelinePositionChanged(position)
+ self._seeker.setPosition(position)
except Exception, e:
self.error("seek failed %s %s %s", gst.TIME_ARGS(position), format, e)
diff --git a/pitivi/ui/ruler.py b/pitivi/ui/ruler.py
index 19c958b..48cc772 100644
--- a/pitivi/ui/ruler.py
+++ b/pitivi/ui/ruler.py
@@ -26,7 +26,9 @@ Widget for the complex view ruler
import gobject
import gtk
import gst
-import cairo
+
+from pitivi.utils import Seeker
+
from pitivi.ui.zoominterface import Zoomable
from pitivi.log.loggable import Loggable
from pitivi.utils import time_to_string
@@ -80,6 +82,8 @@ class ScaleRuler(gtk.DrawingArea, Zoomable, Loggable):
self.app = instance
self.need_update = True
+ self._seeker = Seeker(80)
+
def _hadjValueChangedCb(self, hadj):
self.pixmap_offset = self.hadj.get_value()
self.need_update = True
@@ -181,7 +185,7 @@ class ScaleRuler(gtk.DrawingArea, Zoomable, Loggable):
return False
def _doSeek(self, value, format=gst.FORMAT_TIME, on_idle=False):
- self.app.current.seeker.seek(value, format, on_idle)
+ self._seeker.seek(value, format, on_idle)
## Drawing methods
diff --git a/pitivi/ui/timeline.py b/pitivi/ui/timeline.py
index 3c5458a..06ea508 100644
--- a/pitivi/ui/timeline.py
+++ b/pitivi/ui/timeline.py
@@ -473,7 +473,7 @@ class Timeline(gtk.Table, Loggable, Zoomable):
track.add_object(effect)
self.app.action_log.commit()
self._factories = None
- self.app.current.seeker.seek(self._position)
+ self.seeker.seek(self._position)
context.drop_finish(True, timestamp)
self.timeline.selection.setSelection(timeline_objs, SELECT)
@@ -660,7 +660,7 @@ class Timeline(gtk.Table, Loggable, Zoomable):
self.ruler.queue_resize()
self.ruler.queue_draw()
- def timelinePositionChanged(self, position):
+ def positionChangedCb(self, seeker, position):
self._position = position
self.ruler.timelinePositionChanged(position)
self._canvas.timelinePositionChanged(position)
@@ -705,6 +705,7 @@ class Timeline(gtk.Table, Loggable, Zoomable):
self.debug("Setting project %s", project)
if self._project:
self._project.disconnect_by_function(self._settingsChangedCb)
+ self.seeker.disconnect_by_function(self.positionChangedCb)
self._project = project
if self._project:
@@ -714,7 +715,8 @@ class Timeline(gtk.Table, Loggable, Zoomable):
self.ruler.setProjectFrameRate(self._project.getSettings().videorate)
self.ruler.zoomChanged()
self._settingsChangedCb(self._project, None, self._project.getSettings())
- self._seeker = self._project.seeker
+ self.seeker = self._project.seeker
+ self.seeker.connect("position-changed", self.positionChangedCb)
self._project.connect("settings-changed", self._settingsChangedCb)
def _settingsChangedCb(self, project, old, new):
diff --git a/pitivi/ui/viewer.py b/pitivi/ui/viewer.py
index e3240d2..7668d0c 100644
--- a/pitivi/ui/viewer.py
+++ b/pitivi/ui/viewer.py
@@ -442,7 +442,7 @@ class PitiviViewer(gtk.VBox, Loggable):
self.timecode_entry.setWidgetValue(value, False)
position = self.pipeline.query_position(gst.FORMAT_TIME)[0]
- self.app.gui.timeline.timelinePositionChanged(position)
+ self.seeker.setPosition(position)
if not self.moving_slider:
self.posadjust.set_value(float(value))
diff --git a/pitivi/utils.py b/pitivi/utils.py
index 8e67fca..80223dd 100644
--- a/pitivi/utils.py
+++ b/pitivi/utils.py
@@ -313,7 +313,8 @@ class Seeker(Signallable):
__signals__ = {
'seek': ['position', 'format'],
'flush': [],
- 'seek-relative': ['time']
+ 'seek-relative': ['time'],
+ 'position-changed': ['position']
}
_instance = None
@@ -331,8 +332,8 @@ class Seeker(Signallable):
self._time = None
def seek(self, position, format=gst.FORMAT_TIME, on_idle=False):
- self.position = position
self.format = format
+ self.position = position
if self.pending_seek_id is None:
if on_idle:
@@ -387,6 +388,9 @@ class Seeker(Signallable):
return False
return False
+ def setPosition(self, position):
+ self.emit("position-changed", position)
+
def get_filesystem_encoding():
return sys.getfilesystemencoding() or "utf-8"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]