Fix mimetype issues

bzr-revno: 1109
Fixes: https://launchpad.net/bugs/657465
This commit is contained in:
Tim Bentley 2010-10-30 13:56:51 +01:00
commit a1d2e8390b
2 changed files with 26 additions and 19 deletions

View File

@ -602,7 +602,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtCore.QObject.connect(self.FileSaveAsItem, QtCore.QObject.connect(self.FileSaveAsItem,
QtCore.SIGNAL(u'triggered()'), QtCore.SIGNAL(u'triggered()'),
self.ServiceManagerContents.onSaveService) self.ServiceManagerContents.onSaveService)
#i18n set signals for languages # i18n set signals for languages
QtCore.QObject.connect(self.AutoLanguageItem, QtCore.QObject.connect(self.AutoLanguageItem,
QtCore.SIGNAL(u'toggled(bool)'), self.setAutoLanguage) QtCore.SIGNAL(u'toggled(bool)'), self.setAutoLanguage)
self.LanguageGroup.triggered.connect(LanguageManager.set_language) self.LanguageGroup.triggered.connect(LanguageManager.set_language)
@ -622,15 +622,15 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged) QtCore.SIGNAL(u'config_screen_changed'), self.screenChanged)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_status_text'), self.showStatusMessage) QtCore.SIGNAL(u'maindisplay_status_text'), self.showStatusMessage)
#warning cyclic dependency # warning cyclic dependency
#RenderManager needs to call ThemeManager and # RenderManager needs to call ThemeManager and
#ThemeManager needs to call RenderManager # ThemeManager needs to call RenderManager
self.RenderManager = RenderManager( self.RenderManager = RenderManager(
self.ThemeManagerContents, self.screens) self.ThemeManagerContents, self.screens)
#Define the media Dock Manager # Define the media Dock Manager
self.mediaDockManager = MediaDockManager(self.MediaToolBox) self.mediaDockManager = MediaDockManager(self.MediaToolBox)
log.info(u'Load Plugins') log.info(u'Load Plugins')
#make the controllers available to the plugins # make the controllers available to the plugins
self.plugin_helpers[u'preview'] = self.PreviewController self.plugin_helpers[u'preview'] = self.PreviewController
self.plugin_helpers[u'live'] = self.LiveController self.plugin_helpers[u'live'] = self.LiveController
self.plugin_helpers[u'render'] = self.RenderManager self.plugin_helpers[u'render'] = self.RenderManager

View File

@ -25,6 +25,7 @@
############################################################################### ###############################################################################
import logging import logging
import mimetypes
from PyQt4.phonon import Phonon from PyQt4.phonon import Phonon
@ -45,6 +46,7 @@ class MediaPlugin(Plugin):
self.dnd_id = u'Media' self.dnd_id = u'Media'
self.audio_list = u'' self.audio_list = u''
self.video_list = u'' self.video_list = u''
mimetypes.init()
for mimetype in Phonon.BackendCapabilities.availableMimeTypes(): for mimetype in Phonon.BackendCapabilities.availableMimeTypes():
mimetype = unicode(mimetype) mimetype = unicode(mimetype)
type = mimetype.split(u'audio/x-') type = mimetype.split(u'audio/x-')
@ -60,13 +62,18 @@ class MediaPlugin(Plugin):
self.video_list, mimetype = self._addToList(self.video_list, self.video_list, mimetype = self._addToList(self.video_list,
type, mimetype) type, mimetype)
def _addToList(self, list, value, type): def _addToList(self, list, value, mimetype):
# Is it a media type
if len(value) == 2: if len(value) == 2:
if list.find(value[1]) == -1: extensions = mimetypes.guess_all_extensions(unicode(mimetype))
list += u'*.%s ' % value[1] # we have an extension
self.serviceManager.supportedSuffixes(value[1]) if extensions:
type = u'' for extension in extensions:
return list, type if list.find(extension) == -1:
list += u'*%s ' % extension
self.serviceManager.supportedSuffixes(extension[1:])
mimetype = u''
return list, mimetype
def getSettingsTab(self): def getSettingsTab(self):
return MediaTab(self.name) return MediaTab(self.name)