[pitivi/ges: 66/287] Cleanup all around



commit eb23dbe07b6d1840ff83ca89fec803a62ff1c364
Author: Thibault Saunier <thibault saunier collabora com>
Date:   Mon Oct 24 16:33:39 2011 +0200

    Cleanup all around

 pitivi/ui/mainwindow.py  |   13 ++++++-------
 pitivi/ui/timeline.py    |   12 +++++++-----
 pitivi/ui/trackobject.py |    4 ----
 pitivi/ui/viewer.py      |   17 ++++++-----------
 4 files changed, 19 insertions(+), 27 deletions(-)
---
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index 8346f7c..f41841a 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -27,11 +27,10 @@ Main GTK+ window
 import os
 import gtk
 import gst
-from urllib import unquote
-import webbrowser
-import gobject
 import ges
+import webbrowser
 
+from urllib import unquote
 from gettext import gettext as _
 from gtk import RecentManager
 
@@ -709,9 +708,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
         ruler_width = self.timeline.ruler.get_allocation()[2]
         # Add gst.SECOND - 1 to the timeline duration to make sure the
         # last second of the timeline will be in view.
-        tracks = self.project.timeline.get_tracks()
-        duration = max(tracks[0].get_property("duration"), tracks[1].get_property("duration"))
-        self.project.timeline.duration = duration
+        duration = self.timeline.duration
         timeline_duration = duration + gst.SECOND - 1
         timeline_duration_s = int(timeline_duration / gst.SECOND)
 
@@ -977,11 +974,13 @@ class PitiviMainWindow(gtk.Window, Loggable):
 ## Project Timeline (not to be confused with UI timeline)
 
     def _timelineDurationChangedCb(self, timeline, duration):
-        if duration > 0:
+        if timeline.duration > 0:
             sensitive = True
             if self._zoom_duration_changed:
                 self.setBestZoomRatio()
                 self._zoom_duration_changed = False
+            else:
+                self.timeline.updateScrollAdjustments()
         else:
             sensitive = False
         self.render_button.set_sensitive(sensitive)
diff --git a/pitivi/ui/timeline.py b/pitivi/ui/timeline.py
index a5c7e87..a72529c 100644
--- a/pitivi/ui/timeline.py
+++ b/pitivi/ui/timeline.py
@@ -614,7 +614,7 @@ class Timeline(gtk.Table, Loggable, Zoomable):
             self.hadj.props.value
         new_pos = Zoomable.nsToPixel(self._position) - cur_playhead_offset
 
-        self._updateScrollAdjustments()
+        self.updateScrollAdjustments()
         self._scrollToPosition(new_pos)
         self.ruler.queue_resize()
         self.ruler.queue_draw()
@@ -705,9 +705,9 @@ class Timeline(gtk.Table, Loggable, Zoomable):
     timeline = property(getTimeline, setTimeline, delTimeline,
             "The GESTimeline")
 
-    def _updateScrollAdjustments(self):
+    def updateScrollAdjustments(self):
         a = self.get_allocation()
-        size = Zoomable.nsToPixel(self.timeline.duration)
+        size = Zoomable.nsToPixel(self.duration)
         self.hadj.props.lower = 0
         self.hadj.props.upper = size + 200  # why is this necessary???
         self.hadj.props.page_size = a.width
@@ -783,9 +783,11 @@ class Timeline(gtk.Table, Loggable, Zoomable):
         self.timeline.enable_update(False)
         tl_objs_dict = {}
         for track in self.timeline.get_tracks():
-            tck_objects = track.get_track_objects_at_position(long(self._position))
+            tck_objects = \
+                track.get_track_objects_at_position(long(self._position))
             for tck_obj in tck_objects:
-                if isinstance(tck_obj, ges.TrackAudioTestSource) or isinstance(tck_obj, ges.TrackVideoTestSource):
+                if isinstance(tck_obj, ges.TrackAudioTestSource) or \
+                    isinstance(tck_obj, ges.TrackVideoTestSource):
                     continue
                 obj = tck_obj.get_timeline_object()
                 if obj in tl_objs_dict.keys():
diff --git a/pitivi/ui/trackobject.py b/pitivi/ui/trackobject.py
index 840a245..72bee54 100644
--- a/pitivi/ui/trackobject.py
+++ b/pitivi/ui/trackobject.py
@@ -13,10 +13,8 @@ import controller
 from zoominterface import Zoomable
 from pitivi.timeline.timeline import SELECT, SELECT_ADD, UNSELECT, \
     SELECT_BETWEEN, MoveContext, TrimStartContext, TrimEndContext
-import gst
 from common import LAYER_HEIGHT_EXPANDED, LAYER_HEIGHT_COLLAPSED
 from common import LAYER_SPACING, unpack_cairo_pattern, unpack_cairo_gradient
-from pitivi.ui.point import Point
 from pitivi.ui.prefs import PreferencesDialog
 from pitivi.settings import GlobalSettings
 
@@ -32,8 +30,6 @@ NAME_VOFFSET = 5
 NAME_PADDING = 2
 NAME_PADDING2X = 2 * NAME_PADDING
 
-import gst
-
 GlobalSettings.addConfigOption('videoClipBg',
     section='user-interface',
     key='videoclip-background',
diff --git a/pitivi/ui/viewer.py b/pitivi/ui/viewer.py
index 7b2a5e2..97e060f 100644
--- a/pitivi/ui/viewer.py
+++ b/pitivi/ui/viewer.py
@@ -74,7 +74,6 @@ class ViewerError(Exception):
     pass
 
 
-# TODO : Switch to using Pipeline and Action
 class PitiviViewer(gtk.VBox, Loggable):
 
     __gtype_name__ = 'PitiviViewer'
@@ -182,10 +181,7 @@ class PitiviViewer(gtk.VBox, Loggable):
             if message.src == self.pipeline:
                 self.debug("Pipeline change state prev:%r, new:%r, pending:%r", prev, new, pending)
 
-                state_change = pending == gst.STATE_VOID_PENDING
-
-                if state_change:
-                    self._currentStateCb(new)
+                self._currentStateCb(new)
 
     def _disconnectFromPipeline(self):
         self.debug("pipeline:%r", self.pipeline)
@@ -199,12 +195,9 @@ class PitiviViewer(gtk.VBox, Loggable):
                 self.action.deactivate()
             self.pipeline.removeAction(self.action)
 
-        self.pipeline.disconnect_by_function(self._posCb)
-        self.pipeline.disconnect_by_function(self._currentStateCb)
         self.pipeline.disconnect_by_function(self._elementMessageCb)
         self.pipeline.disconnect_by_function(self._durationChangedCb)
         self.pipeline.disconnect_by_function(self._eosCb)
-        self.pipeline.disconnect_by_function(self.internal.currentStateCb)
         self.pipeline.stop()
 
         self.pipeline = None
@@ -620,6 +613,7 @@ class PitiviViewer(gtk.VBox, Loggable):
             self.playpause_button.setPlay()
         else:
             self.sink = None
+        self.internal._currentStateCb(self.pipeline, state)
         self.currentState = state
 
     def _eosCb(self, unused_pipeline):
@@ -995,7 +989,8 @@ class ViewerWidget(gtk.DrawingArea, Loggable):
     def _sizeCb(self, widget, area):
         # TODO: box is cleared when using regular rendering
         # so we need to flush the pipeline
-        self.pipeline.flushSeekVideo()
+        #self.pipeline.flushSeekVideo()
+        self.pipeline.set_state()
 
     def hide_box(self):
         if self.box:
@@ -1003,7 +998,7 @@ class ViewerWidget(gtk.DrawingArea, Loggable):
             self.disconnect_by_func(self.button_press_event)
             self.disconnect_by_func(self.button_release_event)
             self.disconnect_by_func(self.motion_notify_event)
-            self.pipeline.flushSeekVideo()
+            #self.pipeline.flushSeekVideo()
             self.zoom = 1.0
             if self.sink:
                 self.sink.set_render_rectangle(*self.area)
@@ -1045,7 +1040,7 @@ class ViewerWidget(gtk.DrawingArea, Loggable):
             self.box.select_point(event)
         return True
 
-    def currentStateCb(self, pipeline, state):
+    def _currentStateCb(self, pipeline, state):
         self.pipeline = pipeline
         if state == gst.STATE_PAUSED:
             self._store_pixbuf()



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