Make the PdfController reload backend if setting changes.

This commit is contained in:
Tomas Groth 2014-01-06 12:06:22 +00:00
parent d02377f74f
commit e958c04659
2 changed files with 38 additions and 31 deletions

View File

@ -138,6 +138,9 @@ class PresentationMediaItem(MediaManagerItem):
"""
self.display_type_combo_box.clear()
for item in self.controllers:
# For PDF reload backend, since it can have changed
if self.controllers[item].name == 'Pdf':
self.controllers[item].check_available()
# load the drop down selection
if self.controllers[item].enabled():
self.display_type_combo_box.addItem(item)

View File

@ -57,10 +57,9 @@ class PdfController(PresentationController):
self.process = None
PresentationController.__init__(self, plugin, 'Pdf', PdfDocument)
self.supports = ['pdf']
self.mudrawbin = ''
self.gsbin = ''
if self.check_installed() and self.mudrawbin:
self.also_supports = ['xps']
self.also_supports = []
# Determine whether mudraw or ghostscript is used
self.check_installed()
@staticmethod
def check_binary(program_path):
@ -110,16 +109,18 @@ class PdfController(PresentationController):
:return: True if program to open PDF-files was found, otherwise False.
"""
log.debug('check_installed Pdf')
self.mudrawbin = ''
self.gsbin = ''
self.also_supports = []
# Use the user defined program if given
if (Settings().value('presentations/enable_pdf_program')):
pdf_program = Settings().value('presentations/pdf_program')
program_type = self.check_binary(pdf_program)
if program_type == 'gs':
self.gsbin = pdf_program
return True
elif program_type == 'mudraw':
self.mudrawbin = pdf_program
return True
else:
# Fallback to autodetection
application_path = AppLocation.get_directory(AppLocation.AppDir)
if os.name == 'nt':
@ -144,10 +145,13 @@ class PdfController(PresentationController):
application_path = AppLocation.get_directory(AppLocation.AppDir)
if os.path.isfile(application_path + '/../mudraw'):
self.mudrawbin = application_path + '/../mudraw'
if not self.mudrawbin and not self.gsbin:
return False
else:
if self.mudrawbin:
self.also_supports = ['xps']
return True
elif self.gsbin:
return True
else:
return False
def kill(self):
"""