move LaTeX no-PIL-software warning into method which needs it

This commit is contained in:
Paul Franklin 2016-06-11 13:44:44 -07:00
parent ebc88d5f92
commit 4c57c9090d
2 changed files with 14 additions and 8 deletions

View File

@ -215,6 +215,7 @@ register('interface.filter-editor-height', 350)
register('interface.fullscreen', False)
register('interface.grampletbar-close', False)
register('interface.ignore-gexiv2', False)
register('interface.ignore-pil', False)
register('interface.ignore-osmgpsmap', False)
register('interface.lds-height', 450)
register('interface.lds-width', 600)

View File

@ -57,14 +57,7 @@ from gramps.gen.plug.docbackend import DocBackend
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
_LOG = logging.getLogger(".latexdoc")
if not HAVE_PIL:
_LOG.warning(_("PIL (Python Imaging Library) not loaded. "
"Production of jpg images from non-jpg images "
"in LaTeX documents will not be available. "
"Use your package manager to install python-imaging "
"or python-pillow or python3-pillow"))
_CLICKABLE = '\\url{\\1}'
@ -1239,9 +1232,21 @@ class LaTeXDoc(BaseDoc, TextDoc):
'\n *** to ', outfile,
'%\n')))
elif not HAVE_PIL:
from gramps.gen.config import config
if not config.get('interface.ignore-pil'):
from gramps.gen.constfunc import has_display
if has_display():
from gramps.gui.dialog import MessageHideDialog
title = _("PIL (Python Imaging Library) not loaded.")
message = _("Production of jpg images from non-jpg images "
"in LaTeX documents will not be available. "
"Use your package manager to install "
"python-imaging or python-pillow or "
"python3-pillow")
MessageHideDialog(title, message, 'interface.ignore-pil')
self.emit(''.join(('%\n *** Error: cannot convert ', infile,
'\n *** to ', outfile,
'PIL not installed %\n')))
'\n *** PIL not installed %\n')))
if self.in_table:
self.pict_in_table = True