From 63ffd830210f7db82a0cdacbff12fb56e56530a9 Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Sat, 14 Mar 2015 21:30:19 +0000 Subject: [PATCH] Remove uni_to_gui function We no longer need to convert strings to utf8 before passing them to Gtk functions. --- gramps/gen/constfunc.py | 7 ------- gramps/gui/glade.py | 4 ++-- gramps/gui/plug/_guioptions.py | 5 ++--- gramps/gui/plug/report/_fileentry.py | 5 ++--- gramps/gui/viewmanager.py | 4 ++-- gramps/plugins/tool/eventcmp.py | 2 +- 6 files changed, 9 insertions(+), 18 deletions(-) diff --git a/gramps/gen/constfunc.py b/gramps/gen/constfunc.py index 39fa08170..fae5aa75c 100644 --- a/gramps/gen/constfunc.py +++ b/gramps/gen/constfunc.py @@ -58,13 +58,6 @@ cuni = conv_to_unicode_direct def conv_to_unicode(x, y='utf8'): return x if x is None or isinstance(x, UNITYPE) else cuni(x, y) if y else cuni(x) -def uni_to_gui(x): - ''' - In Py2 we need to convert strings to utf8 before passing them to - Gtk functions. - ''' - return x - # handle in database is bytes, while internally Gramps wants unicode for py3 handle2internal = lambda x: conv_to_unicode(x, 'utf-8') diff --git a/gramps/gui/glade.py b/gramps/gui/glade.py index 90a1a09a9..ff4f7a2c3 100644 --- a/gramps/gui/glade.py +++ b/gramps/gui/glade.py @@ -47,7 +47,7 @@ from gi.repository import Gtk # #------------------------------------------------------------------------ from gramps.gen.const import GLADE_DIR, GRAMPS_LOCALE as glocale -from gramps.gen.constfunc import STRTYPE, uni_to_gui +from gramps.gen.constfunc import STRTYPE #------------------------------------------------------------------------ # @@ -122,7 +122,7 @@ class Glade(Gtk.Builder): # try to build Gtk objects from glade file. Let exceptions happen - self.add_from_file(uni_to_gui(path)) + self.add_from_file(path) self.__dirname, self.__filename = os.path.split(path) # try to find the toplevel widget diff --git a/gramps/gui/plug/_guioptions.py b/gramps/gui/plug/_guioptions.py index b24325d67..5c0804034 100644 --- a/gramps/gui/plug/_guioptions.py +++ b/gramps/gui/plug/_guioptions.py @@ -59,8 +59,7 @@ from ..selectors import SelectorFactory from gramps.gen.display.name import displayer as _nd from gramps.gen.display.place import displayer as _pd from gramps.gen.filters import GenericFilterFactory, GenericFilter, rules -from gramps.gen.constfunc import (conv_to_unicode, uni_to_gui, get_curr_dir, - STRTYPE, cuni) +from gramps.gen.constfunc import (conv_to_unicode, get_curr_dir, STRTYPE, cuni) from gramps.gen.const import GRAMPS_LOCALE as glocale _ = glocale.translation.gettext @@ -1708,7 +1707,7 @@ class GuiDestinationOption(Gtk.Box): if not self.__option.get_directory_entry() and \ not path.endswith(self.__option.get_extension()): path = path + self.__option.get_extension() - self.__entry.set_text(uni_to_gui(path)) + self.__entry.set_text(path) self.__option.set_value(path) fcd.destroy() diff --git a/gramps/gui/plug/report/_fileentry.py b/gramps/gui/plug/report/_fileentry.py index 0a7f215ad..42902bf05 100644 --- a/gramps/gui/plug/report/_fileentry.py +++ b/gramps/gui/plug/report/_fileentry.py @@ -23,7 +23,7 @@ import os from gi.repository import Gtk from gi.repository import GObject -from gramps.gen.constfunc import conv_to_unicode, get_curr_dir, uni_to_gui +from gramps.gen.constfunc import conv_to_unicode, get_curr_dir class FileEntry(Gtk.Box): """ A widget that allows the user to select a file from the file system """ def __init__(self, defname, title): @@ -85,8 +85,7 @@ class FileEntry(Gtk.Box): else: self.__base_path = get_curr_dir() self.__file_name = path - self.entry.set_text(uni_to_gui(os.path.join(self.__base_path, - self.__file_name))) + self.entry.set_text(os.path.join(self.__base_path, self.__file_name)) def get_full_path(self, val): """ Get the full path of the currently selected file. """ diff --git a/gramps/gui/viewmanager.py b/gramps/gui/viewmanager.py index 7210b5482..38a977442 100644 --- a/gramps/gui/viewmanager.py +++ b/gramps/gui/viewmanager.py @@ -77,7 +77,7 @@ from .displaystate import DisplayState, RecentDocsMenu from gramps.gen.const import (HOME_DIR, ICON, URL_BUGTRACKER, URL_HOMEPAGE, URL_MAILINGLIST, URL_MANUAL_PAGE, URL_WIKISTRING, WIKI_EXTRAPLUGINS, URL_BUGHOME) -from gramps.gen.constfunc import is_quartz, conv_to_unicode, uni_to_gui +from gramps.gen.constfunc import is_quartz, conv_to_unicode from gramps.gen.config import config from gramps.gen.errors import WindowActiveError from .dialog import ErrorDialog, WarningDialog, QuestionDialog2, InfoDialog @@ -1341,7 +1341,7 @@ class ViewManager(CLIManager): if not mpath: mpath = HOME_DIR f.set_current_folder(os.path.dirname(mpath)) - f.set_filename(uni_to_gui(os.path.join(mpath, "."))) + f.set_filename(os.path.join(mpath, ".")) status = f.run() if status == Gtk.ResponseType.OK: filename = f.get_filename() diff --git a/gramps/plugins/tool/eventcmp.py b/gramps/plugins/tool/eventcmp.py index 7fe45d747..2b649c006 100644 --- a/gramps/plugins/tool/eventcmp.py +++ b/gramps/plugins/tool/eventcmp.py @@ -59,7 +59,7 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale _ = glocale.translation.sgettext from gramps.gui.glade import Glade from gramps.gui.editors import FilterEditor -from gramps.gen.constfunc import conv_to_unicode, uni_to_gui, get_curr_dir +from gramps.gen.constfunc import conv_to_unicode, get_curr_dir #------------------------------------------------------------------------- #