[pitivi] Cleanup and compact some code



commit b2c7d3fd326a7fcc3b8baf4d159b695a65edb23e
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date:   Fri Feb 8 17:07:30 2013 -0500

    Cleanup and compact some code

 pitivi/application.py    |   33 +++++++++++++--------------------
 pitivi/clipproperties.py |    3 +--
 pitivi/undo/effect.py    |    4 ----
 pitivi/undo/timeline.py  |   26 ++++++++------------------
 4 files changed, 22 insertions(+), 44 deletions(-)
---
diff --git a/pitivi/application.py b/pitivi/application.py
index 8a61e2d..8d2b266 100644
--- a/pitivi/application.py
+++ b/pitivi/application.py
@@ -170,18 +170,13 @@ class Pitivi(Loggable, Signallable):
         return True
 
     def _connectToProjectManager(self, projectManager):
-        projectManager.connect("new-project-loading",
-                self._projectManagerNewProjectLoading)
-        projectManager.connect("new-project-created",
-                self._projectManagerNewProjectCreated)
-        projectManager.connect("new-project-loaded",
-                self._projectManagerNewProjectLoaded)
-        projectManager.connect("new-project-failed",
-                self._projectManagerNewProjectFailed)
-        projectManager.connect("closing-project",
-                self._projectManagerClosingProject)
-        projectManager.connect("project-closed",
-                self._projectManagerProjectClosed)
+        pm = projectManager
+        pm.connect("new-project-loading", self._projectManagerNewProjectLoading)
+        pm.connect("new-project-created", self._projectManagerNewProjectCreated)
+        pm.connect("new-project-loaded", self._projectManagerNewProjectLoaded)
+        pm.connect("new-project-failed", self._projectManagerNewProjectFailed)
+        pm.connect("closing-project", self._projectManagerClosingProject)
+        pm.connect("project-closed", self._projectManagerProjectClosed)
 
     def _projectManagerNewProjectLoading(self, projectManager, uri):
         self.emit("new-project-loading", uri)
@@ -337,14 +332,12 @@ class ProjectCreatorGuiPitivi(GuiPitivi):
         self.projectManager.newBlankProject(False)
         uris = ["file://" + urllib.quote(os.path.abspath(media_filename))
                 for media_filename in media_filenames]
-        self.current.medialibrary.connect("source-added",
-                self._sourceAddedCb, uris, add_to_timeline)
-        self.current.medialibrary.connect("discovery-error",
-                self._discoveryErrorCb, uris)
-        self.current.medialibrary.addUris(uris)
-
-    def _sourceAddedCb(self, medialibrary, info,
-            startup_uris, add_to_timeline):
+        lib = self.current.medialibrary
+        lib.connect("source-added", self._sourceAddedCb, uris, add_to_timeline)
+        lib.connect("discovery-error", self._discoveryErrorCb, uris)
+        lib.addUris(uris)
+
+    def _sourceAddedCb(self, medialibrary, info, startup_uris, add_to_timeline):
         if self._maybePopStartupUri(startup_uris, info.get_uri()) \
                 and add_to_timeline:
             self.action_log.begin("add clip")
diff --git a/pitivi/clipproperties.py b/pitivi/clipproperties.py
index e3f45e2..98d017c 100644
--- a/pitivi/clipproperties.py
+++ b/pitivi/clipproperties.py
@@ -342,8 +342,7 @@ class EffectProperties(Gtk.Expander):
 
                     break
 
-    def _dragDropCb(self, unused, context, unused_x, unused_y,
-             unused_timestamp):
+    def _dragDropCb(self, *unused_arguments):
         self.addEffectToCurrentSelection(self.app.gui.effectlist.getSelectedItems())
 
     def _dragLeaveCb(self, unused_layout, unused_context, unused_tstamp):
diff --git a/pitivi/undo/effect.py b/pitivi/undo/effect.py
index 7e50d78..2f1a4f4 100644
--- a/pitivi/undo/effect.py
+++ b/pitivi/undo/effect.py
@@ -126,7 +126,6 @@ class EffectAdded(UndoableAction):
         for prop_changed in self._props_changed:
             prop_changed.gst_element = self.track_element.getElement()
         self._props_changed = []
-
         self._done()
 
     def undo(self):
@@ -148,7 +147,6 @@ class EffectAdded(UndoableAction):
             self._properties_watcher.getPropChangedFromTrackObj(self.track_element)
         del self.track_element
         self.track_element = None
-
         self._undone()
 
 
@@ -182,7 +180,6 @@ class EffectRemoved(UndoableAction):
             self._properties_watcher.getPropChangedFromTrackObj(self.track_element)
         del self.track_element
         self.track_element = None
-
         self._done()
 
     def undo(self):
@@ -199,5 +196,4 @@ class EffectRemoved(UndoableAction):
         for prop_changed in self._props_changed:
             prop_changed.gst_element = self.track_element.getElement()
         self._props_changed = []
-
         self._undone()
diff --git a/pitivi/undo/timeline.py b/pitivi/undo/timeline.py
index 4739d62..47b2cbd 100644
--- a/pitivi/undo/timeline.py
+++ b/pitivi/undo/timeline.py
@@ -1,6 +1,6 @@
 # PiTiVi , Non-linear video editor
 #
-#       pitivi/timeline/timeline_undo.py
+#       pitivi/undo/timeline.py
 #
 # Copyright (c) 2009, Alessandro Decina <alessandro d gmail com>
 #
@@ -22,7 +22,6 @@
 from pitivi.utils.signal import Signallable
 from pitivi.undo.undo import PropertyChangeTracker, UndoableAction
 from pitivi.undo.effect import EffectAdded, EffectRemoved
-
 from pitivi.undo.effects import EffectGstElementPropertyChangeTracker
 
 
@@ -56,8 +55,7 @@ class ClipPropertyChangeTracker(PropertyChangeTracker):
 
     def _propertyChangedCb(self, clip, value, property_name):
         if not self._disabled:
-            PropertyChangeTracker._propertyChangedCb(self,
-                    clip, value, property_name)
+            PropertyChangeTracker._propertyChangedCb(self, clip, value, property_name)
 
 
 class KeyframeChangeTracker(Signallable):
@@ -91,15 +89,13 @@ class KeyframeChangeTracker(Signallable):
         self.keyframes[keyframe] = self._getKeyframeSnapshot(keyframe)
 
     def _keyframeRemovedCb(self, interpolator, keyframe, old_value=None):
-        pass
+        pass  # FIXME: this has not been implemented
 
     def _keyframeMovedCb(self, interpolator, keyframe, old_value=None):
         old_snapshot = self.keyframes[keyframe]
         new_snapshot = self._getKeyframeSnapshot(keyframe)
         self.keyframes[keyframe] = new_snapshot
-
-        self.emit("keyframe-moved", interpolator,
-                keyframe, old_snapshot, new_snapshot)
+        self.emit("keyframe-moved", interpolator, keyframe, old_snapshot, new_snapshot)
 
     def _getKeyframeSnapshot(self, keyframe):
         return (keyframe.mode, keyframe.time, keyframe.value)
@@ -113,13 +109,11 @@ class ClipPropertyChanged(UndoableAction):
         self.new_value = new_value
 
     def do(self):
-        setattr(self.clip,
-                self.property_name.replace("-", "_"), self.new_value)
+        setattr(self.clip, self.property_name.replace("-", "_"), self.new_value)
         self._done()
 
     def undo(self):
-        setattr(self.clip,
-                self.property_name.replace("-", "_"), self.old_value)
+        setattr(self.clip, self.property_name.replace("-", "_"), self.old_value)
         self._undone()
 
 
@@ -158,7 +152,6 @@ class ClipRemoved(UndoableAction):
             track.addTrackElement(track_element)
 
         self.timeline.addClip(self.clip)
-
         self._undone()
 
 
@@ -311,9 +304,7 @@ class TimelineLogObserver(object):
 
     def _connectToInterpolator(self, interpolator):
         interpolator.connect("keyframe-added", self._interpolatorKeyframeAddedCb)
-        interpolator.connect("keyframe-removed",
-                self._interpolatorKeyframeRemovedCb)
-
+        interpolator.connect("keyframe-removed", self._interpolatorKeyframeRemovedCb)
         tracker = KeyframeChangeTracker()
         tracker.connectToObject(interpolator)
         tracker.connect("keyframe-moved", self._interpolatorKeyframeMovedCb)
@@ -368,8 +359,7 @@ class TimelineLogObserver(object):
         action = self.interpolatorKeyframeAddedAction(track_element, keyframe)
         self.log.push(action)
 
-    def _interpolatorKeyframeRemovedCb(self, track_element, keyframe,
-            old_value=None):
+    def _interpolatorKeyframeRemovedCb(self, track_element, keyframe, old_value=None):
         action = self.interpolatorKeyframeRemovedAction(track_element, keyframe)
         self.log.push(action)
 


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