From 117fbe2810d8bf28919315ec978bd1cde366bd61 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Tue, 15 Apr 2014 11:46:16 -0700 Subject: [PATCH] Bug 7258: Work around bug in Py2Cairo 1.8.10 and earlier on Linux --- gramps/plugins/docgen/cairodoc.py | 10 +++++++--- gramps/plugins/view/pedigreeview.py | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/gramps/plugins/docgen/cairodoc.py b/gramps/plugins/docgen/cairodoc.py index f5f501420..429ecfb85 100644 --- a/gramps/plugins/docgen/cairodoc.py +++ b/gramps/plugins/docgen/cairodoc.py @@ -30,8 +30,6 @@ # Python modules # #------------------------------------------------------------------------ -from gramps.gen.const import GRAMPS_LOCALE as glocale -_ = glocale.translation.gettext import sys #------------------------------------------------------------------------ @@ -42,7 +40,9 @@ import sys import gramps.plugins.lib.libcairodoc as libcairodoc from gramps.gen.plug.docgen import INDEX_TYPE_ALP, INDEX_TYPE_TOC from gramps.gen.errors import ReportError - +from gramps.gen.const import GRAMPS_LOCALE as glocale +_ = glocale.translation.gettext +from gramps.gen.constfunc import lin #------------------------------------------------------------------------ # # Set up logging @@ -96,6 +96,10 @@ class CairoDocgen(libcairodoc.CairoDoc): # create cairo context and pango layout filename = self._backend.filename + # Work around a bug in pycairo 1.8.10 and earlier. OSX and + # Win32 AIOs use pycairo 1.10.0, in which the bug is fixed. + if (sys.version_info[0] < 3 and lin()): + filename = filename.encode(glocale.getfilesystemencoding()) try: surface = self.create_cairo_surface(filename, paper_width, paper_height) except IOError as msg: diff --git a/gramps/plugins/view/pedigreeview.py b/gramps/plugins/view/pedigreeview.py index 14916f00a..b8035af29 100644 --- a/gramps/plugins/view/pedigreeview.py +++ b/gramps/plugins/view/pedigreeview.py @@ -31,8 +31,6 @@ #------------------------------------------------------------------------- from __future__ import unicode_literals, division -from gramps.gen.const import GRAMPS_LOCALE as glocale -_ = glocale.translation.sgettext from cgi import escape import math import sys @@ -77,7 +75,9 @@ from gramps.gen.const import CUSTOM_FILTERS from gramps.gen.constfunc import is_quartz, win from gramps.gui.dialog import RunDatabaseRepair, ErrorDialog from gramps.gui.utils import color_graph_box, hex_to_rgb_float, is_right_click -from gramps.gen.constfunc import STRTYPE +from gramps.gen.constfunc import STRTYPE, lin +from gramps.gen.const import GRAMPS_LOCALE as glocale +_ = glocale.translation.sgettext #------------------------------------------------------------------------- # @@ -209,6 +209,10 @@ class PersonBoxWidgetCairo(_PersonWidgetBase): if image: image_path = self.get_image(dbstate, person) if image_path and os.path.exists(image_path): + # Work around a bug in pycairo 1.8.10 and earlier. OSX and + # Win32 AIOs use pycairo 1.10.0, in which the bug is fixed. + if (sys.version_info[0] < 3 and lin()): + image_path = image_path.encode(glocale.getfilesystemencoding()) self.img_surf = cairo.ImageSurface.create_from_png(image_path) # enable mouse-over