7258: A consequence of forcing paths to unicode is that we sometimes need to explicitly decode a path to utf8 to pass to Gtk
Only in Py2, of course, since the Py3 version of PyGObject knows what to do.
This commit is contained in:
parent
74336a7ca8
commit
8f4aebe4c6
@ -64,6 +64,15 @@ cuni = conv_to_unicode_direct
|
|||||||
def conv_to_unicode(x, y='utf8'):
|
def conv_to_unicode(x, y='utf8'):
|
||||||
return x if x is None or isinstance(x, UNITYPE) else cuni(x, y)
|
return x if x is None or isinstance(x, UNITYPE) else cuni(x, y)
|
||||||
|
|
||||||
|
def uni_to_gui(x):
|
||||||
|
'''
|
||||||
|
In Py2 we need to convert strings to utf8 before passing them to
|
||||||
|
Gtk functions.
|
||||||
|
'''
|
||||||
|
if sys.version_info[0] < 3 and isinstance(x, UNITYPE):
|
||||||
|
return x.encode('utf8')
|
||||||
|
else:
|
||||||
|
return x
|
||||||
|
|
||||||
# handle in database is bytes, while internally Gramps wants unicode for py3
|
# handle in database is bytes, while internally Gramps wants unicode for py3
|
||||||
if sys.version_info[0] < 3:
|
if sys.version_info[0] < 3:
|
||||||
|
@ -47,7 +47,7 @@ from gi.repository import Gtk
|
|||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
from gramps.gen.const import GLADE_DIR, GRAMPS_LOCALE as glocale
|
from gramps.gen.const import GLADE_DIR, GRAMPS_LOCALE as glocale
|
||||||
from gramps.gen.constfunc import STRTYPE
|
from gramps.gen.constfunc import STRTYPE, uni_to_gui
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -122,7 +122,7 @@ class Glade(Gtk.Builder):
|
|||||||
|
|
||||||
# try to build Gtk objects from glade file. Let exceptions happen
|
# try to build Gtk objects from glade file. Let exceptions happen
|
||||||
|
|
||||||
self.add_from_file(path)
|
self.add_from_file(uni_to_gui(path))
|
||||||
self.__dirname, self.__filename = os.path.split(path)
|
self.__dirname, self.__filename = os.path.split(path)
|
||||||
|
|
||||||
# try to find the toplevel widget
|
# try to find the toplevel widget
|
||||||
|
Loading…
Reference in New Issue
Block a user