[pitivi] autoaligner: Make the auto-alignment feature slightly more robust



commit 8769b74a13413c456443d9f4ffaaf91f58326e9f
Author: Jean-François Fortin Tam <nekohayo gmail com>
Date:   Tue Aug 6 12:04:00 2013 +0200

    autoaligner: Make the auto-alignment feature slightly more robust
    
    - Don't stay stuck with a modal progress window when something fails
    - Remove the check for numpy, as it is now a hard dependency for waveforms
    - Use a larger default window width (like the render progress dialog)
    - Remove the window title icon and give the window a proper modal look

 data/ui/alignmentprogress.ui |    3 ++-
 pitivi/autoaligner.py        |   19 +++++--------------
 pitivi/timeline/timeline.py  |   27 +++++++++++++++------------
 3 files changed, 22 insertions(+), 27 deletions(-)
---
diff --git a/data/ui/alignmentprogress.ui b/data/ui/alignmentprogress.ui
index 219f7c9..cce1afe 100644
--- a/data/ui/alignmentprogress.ui
+++ b/data/ui/alignmentprogress.ui
@@ -4,9 +4,10 @@
   <object class="GtkWindow" id="align-progress">
     <property name="border_width">12</property>
     <property name="title" translatable="yes">Auto-Alignment Starting</property>
-    <property name="resizable">False</property>
     <property name="modal">True</property>
     <property name="window_position">center-on-parent</property>
+    <property name="default_width">400</property>
+    <property name="type_hint">dialog</property>
     <property name="deletable">False</property>
     <child>
       <object class="GtkVBox" id="vbox1">
diff --git a/pitivi/autoaligner.py b/pitivi/autoaligner.py
index 2edac8f..1bf7dc9 100644
--- a/pitivi/autoaligner.py
+++ b/pitivi/autoaligner.py
@@ -299,15 +299,13 @@ def affinealign(reference, targets, max_drift=0.02):
 
 
 def getAudioTrack(clip):
-    """Helper function for getting an audio track from a Clip
+    """
+    Helper function for getting an audio track from a Clip
 
-    @param clip: The Clip from which to locate an
-        audio track
+    @param clip: The Clip from which to locate an audio track
     @type clip: L{Clip}
-    @returns: An audio track from clip, or None if
-        clip has no audio track
+    @returns: An audio track from clip, or None if clip has no audio track
     @rtype: audio L{TrackElement} or L{NoneType}
-
     """
     for track in clip.track_elements:
         if track.stream_type == AudioStream:
@@ -655,8 +653,7 @@ class AlignmentProgressDialog:
 
     def __init__(self, app):
         self.builder = Gtk.Builder()
-        self.builder.add_from_file(os.path.join(configure.get_ui_dir(),
-                                   "alignmentprogress.ui"))
+        self.builder.add_from_file(os.path.join(configure.get_ui_dir(), "alignmentprogress.ui"))
         self.builder.connect_signals(self)
 
         self.window = self.builder.get_object("align-progress")
@@ -669,12 +666,6 @@ class AlignmentProgressDialog:
         # RenderingProgressDialog (bug #652917)
         self.window.set_transient_for(app.gui)
 
-        # UI widgets
-        # We currently reuse the render icon for this dialog.
-        icon_path = os.path.join(configure.get_pixmap_dir(),
-                                 "pitivi-render-16.png")
-        self.window.set_icon_from_file(icon_path)
-
         # FIXME: Add a cancel button
 
     def updatePosition(self, fraction, estimated):
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 8f4dedb..cd7af7b 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -1134,23 +1134,26 @@ class Timeline(Gtk.VBox, Zoomable, Loggable):
             self.app.action_log.commit()
 
     def _alignSelected(self, unused_action):
-        if "NumPy" in missing_soft_deps:
-            DepsManager(self.app)
-
-        elif self.bTimeline:
-            progress_dialog = AlignmentProgressDialog(self.app)
+        if not self.bTimeline:
+            self.error("Trying to use the autoalign feature with an empty timeline")
+            return
 
-            progress_dialog.window.show()
-            self.app.action_log.begin("align")
+        progress_dialog = AlignmentProgressDialog(self.app)
+        progress_dialog.window.show()
+        self.app.action_log.begin("align")
 
-            def alignedCb():  # Called when alignment is complete
-                self.app.action_log.commit()
-                self.bTimeline.commit()
-                progress_dialog.window.destroy()
+        def alignedCb():  # Called when alignment is complete
+            self.app.action_log.commit()
+            self.bTimeline.commit()
+            progress_dialog.window.destroy()
 
-            auto_aligner = AutoAligner(self.timeline.selection, alignedCb)
+        auto_aligner = AutoAligner(self.timeline.selection, alignedCb)
+        try:
             progress_meter = auto_aligner.start()
             progress_meter.addWatcher(progress_dialog.updatePosition)
+        except Exception, e:
+            self.error("Could not start the autoaligner: %s" % e)
+            progress_dialog.window.destroy()
 
     def _split(self, action):
         """


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