[pitivi] Simplified encodingdialog.extension_for_muxer()



commit b0ff1dadd412f40323ed2c3e34dd6462b5088f17
Author: Alex BÄ?luÈ? <alexandru balut gmail com>
Date:   Mon May 2 09:51:38 2011 +0200

    Simplified encodingdialog.extension_for_muxer()

 pitivi/ui/encodingdialog.py |   49 ++++++++++++++++++++++++++----------------
 1 files changed, 30 insertions(+), 19 deletions(-)
---
diff --git a/pitivi/ui/encodingdialog.py b/pitivi/ui/encodingdialog.py
index 8e64c7e..51b62bb 100644
--- a/pitivi/ui/encodingdialog.py
+++ b/pitivi/ui/encodingdialog.py
@@ -61,6 +61,7 @@ def filter_recommended(muxers):
     return [m for m in muxers if m.get_rank() > 0]
 
 def extension_for_muxer(muxer):
+    """Returns the file extension appropriate for the specified muxer."""
     exts = {
         "asfmux": "asf",
         "avimux" : "avi",
@@ -88,12 +89,8 @@ def extension_for_muxer(muxer):
         "mxfmux" : "mxf",
         "oggmux" : "ogv",
         "qtmux"  : "mov",
-        "webmmux": "webm",
-    }
-
-    if muxer in exts:
-        return os.path.extsep + exts[muxer]
-    return ""
+        "webmmux": "webm"}
+    return exts.get(muxer)
 
 def factorylist(factories):
     """ Given a sequence of factories, returns a gtk.ListStore()
@@ -179,24 +176,38 @@ class EncodingDialog(GladeWindow, Renderer, Loggable):
         # Summary
         self._updateSummary()
 
-    def updateFilename(self, name):
-        self.fileentry.set_text(name + extension_for_muxer(self.settings.muxer))
+    def updateFilename(self, basename):
+        """Updates the filename UI element to show the specified file name."""
+        extension = extension_for_muxer(self.settings.muxer)
+        if extension:
+            name = "%s%s%s" % (basename, os.path.extsep, extension)
+        else:
+            name = basename
+        self.fileentry.set_text(name)
+
+    def _muxerComboChangedCb(self, muxer_combo):
+        muxer = get_combo_value(muxer_combo).get_name()
+        self.settings.setEncoders(muxer=muxer)
 
-    def _muxerComboChangedCb(self, muxer):
+		# Update the extension of the filename.
         basename = os.path.splitext(self.fileentry.get_text())[0]
-        muxer = get_combo_value(muxer).get_name()
-
-        self.settings.setEncoders(muxer=muxer)
         self.updateFilename(basename)
 
-        # update muxer-dependent video widgets
-        self.video_encoder_combo.set_model(factorylist(
-            self.settings.getVideoEncoders()))
-        self.video_encoder_combo.set_active(0)
+        # Update muxer-dependent widgets.
+        self.updateAvailableEncoders()
+
+    def updateAvailableEncoders(self):
+        """Update the encoder comboboxes to show the available encoders."""
+        video_encoders = self.settings.getVideoEncoders()
+        video_encoder_model = factorylist(video_encoders)
+        self.video_encoder_combo.set_model(video_encoder_model)
 
-        # update muxer-dependent audio widgets
-        self.audio_encoder_combo.set_model(factorylist(
-            self.settings.getAudioEncoders()))
+        audio_encoders = self.settings.getAudioEncoders()
+        audio_encoder_model = factorylist(audio_encoders)
+        self.audio_encoder_combo.set_model(audio_encoder_model)
+
+        # TODO: Set active the preferred audio and video encoders.
+        self.video_encoder_combo.set_active(0)
         self.audio_encoder_combo.set_active(0)
 
     # TODO: selected-only changed



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