← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~mahfiaz/openlp/fixes_and_improvements into lp:openlp

 

mahfiaz has proposed merging lp:~mahfiaz/openlp/fixes_and_improvements into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~mahfiaz/openlp/fixes_and_improvements/+merge/50521
-- 
https://code.launchpad.net/~mahfiaz/openlp/fixes_and_improvements/+merge/50521
Your team OpenLP Core is requested to review the proposed merge of lp:~mahfiaz/openlp/fixes_and_improvements into lp:openlp.
=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py	2011-02-17 02:33:12 +0000
+++ openlp/plugins/media/lib/mediaitem.py	2011-02-20 18:52:01 +0000
@@ -60,8 +60,9 @@
     def retranslateUi(self):
         self.onNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media')
         self.onNewFileMasks = unicode(translate('MediaPlugin.MediaItem',
-            'Videos (%s);;Audio (%s);;%s (*)')) % (self.parent.video_list,
-            self.parent.audio_list, UiStrings.AllFiles)
+            'Videos (%s);;Audio (%s);;%s (*)')) % (
+            u' '.join(self.parent.video_list), 
+            u' '.join(self.parent.audio_list), UiStrings.AllFiles)
         self.replaceAction.setText(UiStrings.ReplaceBG)
         self.replaceAction.setToolTip(UiStrings.ReplaceLiveBG)
         self.resetAction.setText(UiStrings.ResetBG)

=== modified file 'openlp/plugins/media/mediaplugin.py'
--- openlp/plugins/media/mediaplugin.py	2011-02-20 16:45:58 +0000
+++ openlp/plugins/media/mediaplugin.py	2011-02-20 18:52:01 +0000
@@ -45,38 +45,28 @@
         self.icon = build_icon(self.icon_path)
         # passed with drag and drop messages
         self.dnd_id = u'Media'
-        self.audio_list = u''
-        self.video_list = u''
+        self.audio_list = []
+        self.video_list = []
         mimetypes.init()
         for mimetype in Phonon.BackendCapabilities.availableMimeTypes():
             mimetype = unicode(mimetype)
-            type = mimetype.split(u'audio/x-')
-            self.audio_list, mimetype = self._addToList(self.audio_list,
-                type, mimetype)
-            type = mimetype.split(u'audio/')
-            self.audio_list, mimetype = self._addToList(self.audio_list,
-                type, mimetype)
-            type = mimetype.split(u'video/x-')
-            self.video_list, mimetype = self._addToList(self.video_list,
-                type, mimetype)
-            type = mimetype.split(u'video/')
-            self.video_list, mimetype = self._addToList(self.video_list,
-                type, mimetype)
-        log.info(u'MediaPlugin handles audio extensions: %s', self.audio_list)
-        log.info(u'MediaPlugin handles video extensions: %s', self.video_list)
+            if mimetype.startswith(u'audio/'):
+                self._addToList(self.audio_list, mimetype)
+            elif mimetype.startswith(u'video/'):
+                self._addToList(self.video_list, mimetype)
+        log.info(u'MediaPlugin handles audio extensions: %s',
+            u' '.join(self.audio_list))
+        log.info(u'MediaPlugin handles video extensions: %s',
+            u' '.join(self.video_list))
 
-    def _addToList(self, list, value, mimetype):
+    def _addToList(self, list, mimetype):
         # Is it a media type
-        if len(value) == 2:
-            extensions = mimetypes.guess_all_extensions(unicode(mimetype))
-            # we have an extension
-            if extensions:
-                for extension in extensions:
-                    if list.find(extension) == -1:
-                        list += u'*%s ' % extension
-                        self.serviceManager.supportedSuffixes(extension[1:])
-                mimetype = u''
-        return list, mimetype
+        extensions = mimetypes.guess_all_extensions(unicode(mimetype))
+        for extension in extensions:
+            ext = u'*%s' % extension
+            if ext not in list:
+                list.append(ext)
+                self.serviceManager.supportedSuffixes(extension[1:])
 
     def about(self):
         about_text = translate('MediaPlugin', '<strong>Media Plugin</strong>'


Follow ups