[pitivi] undo: Move ProjectLogObserver to pitivi/undo/
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] undo: Move ProjectLogObserver to pitivi/undo/
- Date: Sat, 16 Apr 2016 14:24:21 +0000 (UTC)
commit 038059647d57a295620cae02f4e3f18943c449d1
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Sun Apr 3 15:44:31 2016 +0200
undo: Move ProjectLogObserver to pitivi/undo/
Differential Revision: https://phabricator.freedesktop.org/D863
pitivi/application.py | 2 +-
pitivi/project.py | 102 ---------------------------------------
pitivi/undo/Makefile.am | 9 ++--
pitivi/undo/project.py | 123 +++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 129 insertions(+), 107 deletions(-)
---
diff --git a/pitivi/application.py b/pitivi/application.py
index f1d3818..7df353e 100644
--- a/pitivi/application.py
+++ b/pitivi/application.py
@@ -35,11 +35,11 @@ from pitivi.configure import VERSION
from pitivi.dialogs.startupwizard import StartUpWizard
from pitivi.effects import EffectsManager
from pitivi.mainwindow import PitiviMainWindow
-from pitivi.project import ProjectLogObserver
from pitivi.project import ProjectManager
from pitivi.settings import get_dir
from pitivi.settings import GlobalSettings
from pitivi.settings import xdg_cache_home
+from pitivi.undo.project import ProjectLogObserver
from pitivi.undo.timeline import TimelineLogObserver
from pitivi.undo.undo import UndoableActionLog
from pitivi.utils import loggable
diff --git a/pitivi/project.py b/pitivi/project.py
index 44c6e45..2800e1d 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -40,7 +40,6 @@ from pitivi.configure import get_ui_dir
from pitivi.preset import AudioPresetManager
from pitivi.preset import VideoPresetManager
from pitivi.render import CachedEncoderList
-from pitivi.undo.undo import UndoableAction
from pitivi.utils.loggable import Loggable
from pitivi.utils.misc import isWritable
from pitivi.utils.misc import path_from_uri
@@ -68,107 +67,6 @@ DEFAULT_MUXER = "oggmux"
DEFAULT_VIDEO_ENCODER = "theoraenc"
DEFAULT_AUDIO_ENCODER = "vorbisenc"
-# ------------------ Backend classes ---------------------------------------- #
-
-
-class AssetRemovedAction(UndoableAction):
-
- def __init__(self, project, asset):
- UndoableAction.__init__(self)
- self.project = project
- self.asset = asset
-
- def undo(self):
- self.project.add_asset(self.asset)
-
- def do(self):
- self.project.remove_asset(self.asset)
-
- def asScenarioAction(self):
- st = Gst.Structure.new_empty("remove-asset")
- st.set_value("id", self.asset.get_id())
- type_string = GObject.type_name(self.asset.get_extractable_type())
- st.set_value("type", type_string)
- return st
-
-
-class AssetAddedAction(UndoableAction):
-
- def __init__(self, project, asset):
- UndoableAction.__init__(self)
- self.project = project
- self.asset = asset
-
- def undo(self):
- self.project.remove_asset(self.asset)
-
- def do(self):
- self.project.add_asset(self.asset)
-
- def asScenarioAction(self):
- st = Gst.Structure.new_empty("add-asset")
- st.set_value("id", self.asset.get_id())
- type_string = GObject.type_name(self.asset.get_extractable_type())
- st.set_value("type", type_string)
- return st
-
-
-class ProjectSettingsChanged(UndoableAction):
-
- def __init__(self, project, old, new):
- UndoableAction.__init__(self)
- self.project = project
- self.oldsettings = old
- self.newsettings = new
-
- def do(self):
- self.project.setSettings(self.newsettings)
- self._done()
-
- def undo(self):
- self.project.setSettings(self.oldsettings)
- self._undone()
-
-
-class ProjectLogObserver(UndoableAction):
-
- def __init__(self, log):
- UndoableAction.__init__(self)
- self.log = log
-
- def startObserving(self, project):
- project.connect("notify-meta", self._settingsChangedCb)
- project.connect("asset-added", self._assetAddedCb)
- project.connect("asset-removed", self._assetRemovedCb)
-
- def stopObserving(self, project):
- try:
- project.disconnect_by_func(self._settingsChangedCb)
- project.disconnect_by_func(self._assetAddedCb)
- project.disconnect_by_func(self._assetRemovedCb)
- except Exception:
- # This can happen when we interrupt the loading of a project,
- # such as in mainwindow's _projectManagerMissingUriCb
- pass
-
- def _settingsChangedCb(self, project, item, value):
- """
- FIXME Renable undo/redo
- action = ProjectSettingsChanged(project, old, new)
- self.log.begin("change project settings")
- self.log.push(action)
- self.log.commit()
- """
- pass
-
- def _assetAddedCb(self, project, asset):
- action = AssetAddedAction(project, asset)
- self.log.push(action)
-
- def _assetRemovedCb(self, project, asset):
- action = AssetRemovedAction(project, asset)
- self.log.push(action)
-
class ProjectManager(GObject.Object, Loggable):
diff --git a/pitivi/undo/Makefile.am b/pitivi/undo/Makefile.am
index c7e67bc..b24b575 100644
--- a/pitivi/undo/Makefile.am
+++ b/pitivi/undo/Makefile.am
@@ -1,9 +1,10 @@
undodir = $(libdir)/pitivi/python/pitivi/undo
-undo_PYTHON = \
- __init__.py \
- undo.py \
- timeline.py
+undo_PYTHON = \
+ __init__.py \
+ project.py \
+ timeline.py \
+ undo.py
clean-local:
rm -rf *.pyc *.pyo
diff --git a/pitivi/undo/project.py b/pitivi/undo/project.py
new file mode 100644
index 0000000..381977b
--- /dev/null
+++ b/pitivi/undo/project.py
@@ -0,0 +1,123 @@
+# Pitivi video editor
+#
+# pitivi/undo/project.py
+#
+# Copyright (c) 2012, Thibault Saunier <tsaunier gnome org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+from gi.repository import GObject
+from gi.repository import Gst
+
+from pitivi.undo.undo import UndoableAction
+
+
+class AssetAddedAction(UndoableAction):
+
+ def __init__(self, project, asset):
+ UndoableAction.__init__(self)
+ self.project = project
+ self.asset = asset
+
+ def undo(self):
+ self.project.remove_asset(self.asset)
+
+ def do(self):
+ self.project.add_asset(self.asset)
+
+ def asScenarioAction(self):
+ st = Gst.Structure.new_empty("add-asset")
+ st.set_value("id", self.asset.get_id())
+ type_string = GObject.type_name(self.asset.get_extractable_type())
+ st.set_value("type", type_string)
+ return st
+
+
+class AssetRemovedAction(UndoableAction):
+
+ def __init__(self, project, asset):
+ UndoableAction.__init__(self)
+ self.project = project
+ self.asset = asset
+
+ def undo(self):
+ self.project.add_asset(self.asset)
+
+ def do(self):
+ self.project.remove_asset(self.asset)
+
+ def asScenarioAction(self):
+ st = Gst.Structure.new_empty("remove-asset")
+ st.set_value("id", self.asset.get_id())
+ type_string = GObject.type_name(self.asset.get_extractable_type())
+ st.set_value("type", type_string)
+ return st
+
+
+class ProjectSettingsChanged(UndoableAction):
+
+ def __init__(self, project, old, new):
+ UndoableAction.__init__(self)
+ self.project = project
+ self.oldsettings = old
+ self.newsettings = new
+
+ def do(self):
+ self.project.setSettings(self.newsettings)
+ self._done()
+
+ def undo(self):
+ self.project.setSettings(self.oldsettings)
+ self._undone()
+
+
+class ProjectLogObserver(UndoableAction):
+
+ def __init__(self, log):
+ UndoableAction.__init__(self)
+ self.log = log
+
+ def startObserving(self, project):
+ project.connect("notify-meta", self._settingsChangedCb)
+ project.connect("asset-added", self._assetAddedCb)
+ project.connect("asset-removed", self._assetRemovedCb)
+
+ def stopObserving(self, project):
+ try:
+ project.disconnect_by_func(self._settingsChangedCb)
+ project.disconnect_by_func(self._assetAddedCb)
+ project.disconnect_by_func(self._assetRemovedCb)
+ except Exception:
+ # This can happen when we interrupt the loading of a project,
+ # such as in mainwindow's _projectManagerMissingUriCb
+ pass
+
+ def _settingsChangedCb(self, project, item, value):
+ """
+ FIXME Renable undo/redo
+ action = ProjectSettingsChanged(project, old, new)
+ self.log.begin("change project settings")
+ self.log.push(action)
+ self.log.commit()
+ """
+ pass
+
+ def _assetAddedCb(self, project, asset):
+ action = AssetAddedAction(project, asset)
+ self.log.push(action)
+
+ def _assetRemovedCb(self, project, asset):
+ action = AssetRemovedAction(project, asset)
+ self.log.push(action)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]