[pitivi] mainwindow: Do not purge clips when an asset is removed



commit 2a5f94f170929562ea14b5a892b2479118a82ffb
Author: Thibault Saunier <tsaunier gnome org>
Date:   Tue Dec 1 16:30:54 2015 +0100

    mainwindow: Do not purge clips when an asset is removed
    
    That does not belong to the main window but to the media library
    that have a much better knowledge of what is going on
    
    Differential Revision: https://phabricator.freedesktop.org/D579

 pitivi/mainwindow.py        |    7 -------
 pitivi/medialibrary.py      |    2 ++
 pitivi/timeline/timeline.py |    8 ++++----
 3 files changed, 6 insertions(+), 11 deletions(-)
---
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index 090d638..5db1837 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -538,11 +538,6 @@ class PitiviMainWindow(Gtk.ApplicationWindow, Loggable):
         self.save_action.set_enabled(True)
         self.updateTitle()
 
-    def _mediaLibrarySourceRemovedCb(self, unused_project, asset):
-        """When a clip is removed from the Media Library, tell the timeline
-        to remove all instances of that clip."""
-        self.timeline_ui.purgeObject(asset.get_id())
-
     def _builderConnectCb(self, builder, gobject, signal_name, handler_name,
                           connect_object, flags, user_data):
         id_ = gobject.connect(signal_name, getattr(self, handler_name))
@@ -1021,7 +1016,6 @@ class PitiviMainWindow(Gtk.ApplicationWindow, Loggable):
     def _connectToProject(self, project):
         # FIXME GES we should re-enable this when possible
         # medialibrary.connect("missing-plugins", self._sourceListMissingPluginsCb)
-        project.connect("asset-removed", self._mediaLibrarySourceRemovedCb)
         project.connect("project-changed", self._projectChangedCb)
         project.connect(
             "rendering-settings-changed", self._renderingSettingsChangedCb)
@@ -1076,7 +1070,6 @@ class PitiviMainWindow(Gtk.ApplicationWindow, Loggable):
             self.settings.lastProjectFolder = folder_path
 
     def _disconnectFromProject(self, project):
-        project.disconnect_by_func(self._mediaLibrarySourceRemovedCb)
         project.disconnect_by_func(self._projectChangedCb)
         project.disconnect_by_func(self._renderingSettingsChangedCb)
 
diff --git a/pitivi/medialibrary.py b/pitivi/medialibrary.py
index 89995c9..5f0058e 100644
--- a/pitivi/medialibrary.py
+++ b/pitivi/medialibrary.py
@@ -379,6 +379,8 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
         for row in rows:
             asset = model[row.get_path()][COL_ASSET]
             self.app.project_manager.current_project.remove_asset(asset)
+            self.app.gui.timeline_ui.purgeAsset(asset.props.id)
+
         self.app.action_log.commit()
 
         # The treeview can make some of the remaining items selected, so
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 3d545d2..a8ebbbb 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -1231,13 +1231,13 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
             return self.bTimeline.props.duration
         return position
 
-    def purgeObject(self, asset_id):
+    def purgeAsset(self, asset_id):
         """Remove all instances of an asset from the timeline."""
         layers = self.bTimeline.get_layers()
         for layer in layers:
-            for tlobj in layer.get_clips():
-                if asset_id == tlobj.get_id():
-                    layer.remove_clip(tlobj)
+            for clip in layer.get_clips():
+                if asset_id == clip.get_id():
+                    layer.remove_clip(clip)
         self._project.pipeline.commit_timeline()
 
     def setProjectManager(self, projectmanager):


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