From 4c57c9090d6fb6404c6ca4af6e15f3825c22e1c2 Mon Sep 17 00:00:00 2001 From: Paul Franklin Date: Sat, 11 Jun 2016 13:44:44 -0700 Subject: [PATCH] move LaTeX no-PIL-software warning into method which needs it --- gramps/gen/config.py | 1 + gramps/plugins/docgen/latexdoc.py | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/gramps/gen/config.py b/gramps/gen/config.py index 9eb683cf6..bd2426478 100644 --- a/gramps/gen/config.py +++ b/gramps/gen/config.py @@ -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) diff --git a/gramps/plugins/docgen/latexdoc.py b/gramps/plugins/docgen/latexdoc.py index 56455fecb..9a56b23bd 100644 --- a/gramps/plugins/docgen/latexdoc.py +++ b/gramps/plugins/docgen/latexdoc.py @@ -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