[pitivi] project: Rename timeline field



commit 0bd6f29eead402c6fe6a30055f4b6229386b8c42
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Wed Jun 8 07:11:51 2016 +0200

    project: Rename timeline field
    
    Differential Revision: https://phabricator.freedesktop.org/D1076

 pitivi/application.py       |    2 +-
 pitivi/clipproperties.py    |   12 +++---
 pitivi/mainwindow.py        |    8 ++--
 pitivi/medialibrary.py      |    2 +-
 pitivi/project.py           |   81 ++++++++++++++++++++++---------------------
 pitivi/render.py            |    6 ++--
 pitivi/timeline/timeline.py |    4 +-
 pitivi/titleeditor.py       |    2 +-
 tests/test_media_library.py |    6 ++--
 tests/test_project.py       |    2 +-
 tests/test_undo_timeline.py |    2 +-
 11 files changed, 64 insertions(+), 63 deletions(-)
---
diff --git a/pitivi/application.py b/pitivi/application.py
index 3e9bb40..ed93a33 100644
--- a/pitivi/application.py
+++ b/pitivi/application.py
@@ -283,7 +283,7 @@ class Pitivi(Gtk.Application, Loggable):
         self.action_log.connect("move", self._action_log_move_cb)
 
         timeline_observer = TimelineObserver(self.action_log)
-        timeline_observer.startObserving(project.timeline)
+        timeline_observer.startObserving(project.ges_timeline)
 
         project_observer = ProjectObserver(project, self.action_log)
 
diff --git a/pitivi/clipproperties.py b/pitivi/clipproperties.py
index d748f25..0c269a2 100644
--- a/pitivi/clipproperties.py
+++ b/pitivi/clipproperties.py
@@ -259,7 +259,7 @@ class EffectProperties(Gtk.Expander, Loggable):
             self._selection = None
         self._project = project
         if project:
-            self._selection = project.timeline.ui.selection
+            self._selection = project.ges_timeline.ui.selection
             self._selection.connect('selection-changed', self._selectionChangedCb)
             self.selected_effects = self._selection.getSelectedEffects()
         self.__updateAll()
@@ -307,7 +307,7 @@ class EffectProperties(Gtk.Expander, Loggable):
         self._removeEffect(effect)
 
     def _removeEffect(self, effect):
-        pipeline = self._project.timeline.get_parent()
+        pipeline = self._project.ges_timeline.get_parent()
         with self.app.action_log.started("remove effect", CommitTimelineFinalizingAction(pipeline)):
             self.__remove_configuration_widget()
             self.effects_properties_manager.cleanCache(effect)
@@ -325,7 +325,7 @@ class EffectProperties(Gtk.Expander, Loggable):
             if track_type == GES.TrackType.AUDIO and media_type == AUDIO_EFFECT or \
                     track_type == GES.TrackType.VIDEO and media_type == VIDEO_EFFECT:
                 # Actually add the effect
-                pipeline = self._project.timeline.get_parent()
+                pipeline = self._project.ges_timeline.get_parent()
                 with self.app.action_log.started("add effect",
                                                  CommitTimelineFinalizingAction(pipeline)):
                     effect = GES.Effect.new(bin_description=factory_name)
@@ -421,7 +421,7 @@ class EffectProperties(Gtk.Expander, Loggable):
         # The paths are different.
         effects = clip.get_top_effects()
         effect = effects[source_index]
-        pipeline = self._project.timeline.get_parent()
+        pipeline = self._project.ges_timeline.get_parent()
         with self.app.action_log.started("move effect",
                                          CommitTimelineFinalizingAction(pipeline)):
             clip.set_top_effect_priority(effect, drop_index)
@@ -453,7 +453,7 @@ class EffectProperties(Gtk.Expander, Loggable):
             tck_effect.set_active(not tck_effect.is_active())
             cellrenderertoggle.set_active(tck_effect.is_active())
             self._updateTreeview()
-            self._project.timeline.commit()
+            self._project.ges_timeline.commit()
 
     def _expandedCb(self, unused_expander, unused_params):
         self.__updateAll()
@@ -576,7 +576,7 @@ class TransformationProperties(Gtk.Expander, Loggable):
             self._selection = None
         self._project = project
         if project:
-            self._selection = project.timeline.ui.selection
+            self._selection = project.ges_timeline.ui.selection
             self._selection.connect('selection-changed', self._selectionChangedCb)
 
     def _initButtons(self):
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index 9a77d93..b56d705 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -740,7 +740,7 @@ class MainWindow(Gtk.ApplicationWindow, Loggable):
             # redirects to it if needed, so we still want it to be enabled:
             self.save_action.set_enabled(True)
 
-        if project.timeline.props.duration != 0:
+        if project.ges_timeline.props.duration != 0:
             self.render_button.set_sensitive(True)
 
     def _projectManagerNewProjectLoadingCb(self, unused_project_manager, project):
@@ -1025,8 +1025,8 @@ class MainWindow(Gtk.ApplicationWindow, Loggable):
         project.connect("project-changed", self._projectChangedCb)
         project.connect(
             "rendering-settings-changed", self._renderingSettingsChangedCb)
-        project.timeline.connect("notify::duration",
-                                 self._timelineDurationChangedCb)
+        project.ges_timeline.connect("notify::duration",
+                                     self._timelineDurationChangedCb)
 
 # Missing Plugins Support
 
@@ -1069,7 +1069,7 @@ class MainWindow(Gtk.ApplicationWindow, Loggable):
     def _disconnectFromProject(self, project):
         project.disconnect_by_func(self._projectChangedCb)
         project.disconnect_by_func(self._renderingSettingsChangedCb)
-        project.timeline.disconnect_by_func(self._timelineDurationChangedCb)
+        project.ges_timeline.disconnect_by_func(self._timelineDurationChangedCb)
 
 # Pitivi current project callbacks
 
diff --git a/pitivi/medialibrary.py b/pitivi/medialibrary.py
index 232e9da..f6b5595 100644
--- a/pitivi/medialibrary.py
+++ b/pitivi/medialibrary.py
@@ -1057,7 +1057,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
 
     def _sourceIsUsed(self, asset):
         """Check if a given URI is present in the timeline"""
-        layers = self._project.timeline.get_layers()
+        layers = self._project.ges_timeline.get_layers()
         for layer in layers:
             for clip in layer.get_clips():
                 if clip.get_asset() == asset:
diff --git a/pitivi/project.py b/pitivi/project.py
index 0a0f99a..8c4ec51 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -67,11 +67,15 @@ DEFAULT_AUDIO_ENCODER = "vorbisenc"
 
 
 class ProjectManager(GObject.Object, Loggable):
+    """The project manager.
 
-    """
-    @type app: L{Pitivi}
-    @type current_project: L{Project}
-    @param disable_save: Whether saving is disabled to enforce using save-as.
+    Allows the app to close and then load a different project, handle failures,
+    make automatic backups.
+
+    Attributes:
+        app (Pitivi): The app.
+        current_project (Project): The current project displayed by the app.
+        disable_save (bool): Whether save-as is enforced when saving.
     """
 
     __gsignals__ = {
@@ -348,7 +352,7 @@ class ProjectManager(GObject.Object, Loggable):
             # set to always ask the user on our behalf about overwriting, so
             # if saveProject is actually called, that means overwriting is OK.
             saved = self.current_project.save(
-                self.current_project.timeline, uri,
+                self.current_project.ges_timeline, uri,
                 formatter_type, overwrite=True)
         except Exception as e:
             saved = False
@@ -591,24 +595,19 @@ class ProjectManager(GObject.Object, Loggable):
 
 
 class Project(Loggable, GES.Project):
+    """A Pitivi project.
 
-    """
-    The base class for Pitivi projects
-
-    @ivar name: The name of the project
-    @type name: C{str}
-    @ivar description: A description of the project
-    @type description: C{str}
-    @ivar timeline: The timeline
-    @type timeline: L{GES.Timeline}
-    @ivar pipeline: The timeline's pipeline
-    @type pipeline: L{Pipeline}
-    @ivar loaded: Whether the project is fully loaded or not.
-    @type loaded: C{bool}
+    Attributes:
+        app (Pitivi): The app.
+        name (str): The name of the project.
+        description (str): The description of the project.
+        ges_timeline (GES.Timeline): The timeline.
+        pipeline (Pipeline): The timeline's pipeline.
+        loaded (bool): Whether the project is fully loaded.
 
     Signals:
-     - C{project-changed}: Modifications were made to the project
-     - C{start-importing}: Started to import files
+        project-changed: Modifications were made to the project
+        start-importing: Started to import files
     """
 
     __gsignals__ = {
@@ -629,14 +628,16 @@ class Project(Loggable, GES.Project):
 
     def __init__(self, app, name="", uri=None, scenario=None, **unused_kwargs):
         """
-        @param name: The name of the project, if it's a new empty project.
-        @param uri: The URI of the project it will be loaded from.
+        Args:
+            name (Optional[str]): The name of the new empty project.
+            uri (Optional[str]): The URI of the file where the project should
+                be loaded from.
         """
         Loggable.__init__(self)
         GES.Project.__init__(self, uri=uri, extractable_type=GES.Timeline)
         self.log("name:%s, uri:%s", name, uri)
         self.pipeline = None
-        self.timeline = None
+        self.ges_timeline = None
         self.uri = uri
         self.loaded = False
         self.at_least_one_asset_missing = False
@@ -1116,11 +1117,11 @@ class Project(Loggable, GES.Project):
     def do_loaded(self, unused_timeline):
         """ vmethod, get called on "loaded" """
 
-        if not self.timeline:
+        if not self.ges_timeline:
             return
 
         self._ensureTracks()
-        self.timeline.props.auto_transition = True
+        self.ges_timeline.props.auto_transition = True
         self._ensureLayer()
         self.loaded = True
 
@@ -1220,7 +1221,7 @@ class Project(Loggable, GES.Project):
         scenarialize the action in the scenarios.
         """
         self.app.write_action("commit")
-        GES.Timeline.commit(self.timeline)
+        GES.Timeline.commit(self.ges_timeline)
 
     def createTimeline(self):
         """
@@ -1228,18 +1229,18 @@ class Project(Loggable, GES.Project):
         """
         try:
             # The project is loaded from the file in this call.
-            self.timeline = self.extract()
+            self.ges_timeline = self.extract()
         except GLib.Error as e:
             self.warning("Failed to extract the timeline: %s", e)
-            self.timeline = None
+            self.ges_timeline = None
 
-        if self.timeline is None:
+        if self.ges_timeline is None:
             return False
 
-        self.timeline.commit = self._commit
+        self.ges_timeline.commit = self._commit
         self.pipeline = Pipeline(self.app)
         try:
-            self.pipeline.set_timeline(self.timeline)
+            self.pipeline.set_timeline(self.ges_timeline)
         except PipelineError as e:
             self.warning("Failed to set the pipeline's timeline: %s", e)
             return False
@@ -1254,7 +1255,7 @@ class Project(Loggable, GES.Project):
         caps.set_value("width", width)
         caps.set_value("height", height)
         caps.set_value("framerate", self.videorate)
-        for track in self.timeline.get_tracks():
+        for track in self.ges_timeline.get_tracks():
             if isinstance(track, GES.VideoTrack):
                 track.set_restriction_caps(caps)
 
@@ -1302,7 +1303,7 @@ class Project(Loggable, GES.Project):
             self.monitor = None
 
         self.pipeline = None
-        self.timeline = None
+        self.ges_timeline = None
 
         return res
 
@@ -1405,24 +1406,24 @@ class Project(Loggable, GES.Project):
     # ------------------------------------------ #
 
     def _ensureTracks(self):
-        if self.timeline is None:
+        if self.ges_timeline is None:
             self.warning("Can't ensure tracks if no timeline set")
             return
 
         track_types = [track.get_property("track-type")
-                       for track in self.timeline.get_tracks()]
+                       for track in self.ges_timeline.get_tracks()]
 
         if GES.TrackType.VIDEO not in track_types:
-            self.timeline.add_track(GES.VideoTrack.new())
+            self.ges_timeline.add_track(GES.VideoTrack.new())
         if GES.TrackType.AUDIO not in track_types:
-            self.timeline.add_track(GES.AudioTrack.new())
+            self.ges_timeline.add_track(GES.AudioTrack.new())
 
     def _ensureLayer(self):
-        if self.timeline is None:
+        if self.ges_timeline is None:
             self.warning("Can't ensure tracks if no timeline set")
             return
-        if not self.timeline.get_layers():
-            self.timeline.append_layer()
+        if not self.ges_timeline.get_layers():
+            self.ges_timeline.append_layer()
 
     def _ensureVideoRestrictions(self):
         if self.videowidth is None:
diff --git a/pitivi/render.py b/pitivi/render.py
index 6d1f832..c611c63 100644
--- a/pitivi/render.py
+++ b/pitivi/render.py
@@ -588,7 +588,7 @@ class RenderDialog(Loggable):
             return None
 
         current_filesize = os.stat(path_from_uri(self.outfile)).st_size
-        length = self.project.timeline.props.duration
+        length = self.project.ges_timeline.props.duration
         estimated_size = float(
             current_filesize * float(length) / self.current_position)
         # Now let's make it human-readable (instead of octets).
@@ -852,7 +852,7 @@ class RenderDialog(Loggable):
         elif self._is_rendering:
             timediff = time.time() - \
                 self._time_started - self._time_spent_paused
-            length = self.project.timeline.props.duration
+            length = self.project.ges_timeline.props.duration
             totaltime = (timediff * float(length) /
                          float(self.current_position)) - timediff
             time_estimate = beautify_ETA(int(totaltime * Gst.SECOND))
@@ -926,7 +926,7 @@ class RenderDialog(Loggable):
         if not self.progress or not position:
             return
 
-        length = self.project.timeline.props.duration
+        length = self.project.ges_timeline.props.duration
         fraction = float(min(position, length)) / float(length)
         self.progress.updatePosition(fraction)
 
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index ee254b4..ba1e4d0 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -360,7 +360,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
         self._project = project
         if self._project:
             self._project.pipeline.connect('position', self._positionCb)
-            self.ges_timeline = self._project.timeline
+            self.ges_timeline = self._project.ges_timeline
 
         if self.ges_timeline is None:
             return
@@ -1301,7 +1301,7 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
         if self._project:
             self._project.connect("rendering-settings-changed",
                                   self._renderingSettingsChangedCb)
-            self.ges_timeline = project.timeline
+            self.ges_timeline = project.ges_timeline
         else:
             self.ges_timeline = None
 
diff --git a/pitivi/titleeditor.py b/pitivi/titleeditor.py
index 50378ee..4b27759 100644
--- a/pitivi/titleeditor.py
+++ b/pitivi/titleeditor.py
@@ -271,7 +271,7 @@ class TitleEditor(Loggable):
             self._selection.disconnect_by_func(self._selectionChangedCb)
             self._selection = None
         if project:
-            self._selection = project.timeline.ui.selection
+            self._selection = project.ges_timeline.ui.selection
             self._selection.connect('selection-changed', self._selectionChangedCb)
         self._project = project
 
diff --git a/tests/test_media_library.py b/tests/test_media_library.py
index 45ff2e3..8002b81 100644
--- a/tests/test_media_library.py
+++ b/tests/test_media_library.py
@@ -169,12 +169,12 @@ class TestMediaLibrary(BaseTestMediaLibrary):
         # Save the project and reload it, making sure there is no asset
         # in that new project
         project_uri = Gst.filename_to_uri(tempfile.NamedTemporaryFile().name)
-        project.save(project.timeline, project_uri, None, True)
+        project.save(project.ges_timeline, project_uri, None, True)
 
         self._customSetUp(project_uri)
         self.assertNotEqual(project, self.app.project_manager.current_project)
-        self.assertEqual(self.app.project_manager.current_project.list_assets(
-            GES.Extractable), [])
+        project = self.app.project_manager.current_project
+        self.assertEqual(project.list_assets(GES.Extractable), [])
 
     def testNewlyImportedAssetSelected(self):
         self.runCheckImport(["30fps_numeroted_frames_red.mkv",
diff --git a/tests/test_project.py b/tests/test_project.py
index ee491a8..b6f0abb 100644
--- a/tests/test_project.py
+++ b/tests/test_project.py
@@ -303,7 +303,7 @@ class TestProjectLoading(common.TestCase):
         unused, xges_path = tempfile.mkstemp()
         uri = "file://%s" % xges_path
         try:
-            project.save(project.timeline, uri, None, overwrite=True)
+            project.save(project.ges_timeline, uri, None, overwrite=True)
 
             project2 = common.create_project()
             self.assertTrue(project2.createTimeline())
diff --git a/tests/test_undo_timeline.py b/tests/test_undo_timeline.py
index 76bac13..4a1418b 100644
--- a/tests/test_undo_timeline.py
+++ b/tests/test_undo_timeline.py
@@ -96,7 +96,7 @@ class TestTimelineUndo(TestCase):
         self.app = common.create_pitivi()
         self.app.project_manager.newBlankProject()
 
-        self.timeline = self.app.project_manager.current_project.timeline
+        self.timeline = self.app.project_manager.current_project.ges_timeline
         self.layer = self.timeline.append_layer()
         self.action_log = self.app.action_log
 


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