From 66260871dc91629754d5c499f3645ff95091016a Mon Sep 17 00:00:00 2001 From: Paul Franklin Date: Wed, 21 Dec 2016 15:35:45 -0800 Subject: [PATCH] give GUI User an optional parent, for when None would otherwise be used --- gramps/cli/user.py | 3 ++- gramps/gui/dbman.py | 2 +- gramps/gui/plug/export/_exportassistant.py | 3 ++- gramps/gui/user.py | 10 ++++++++-- gramps/gui/viewmanager.py | 1 + 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/gramps/cli/user.py b/gramps/cli/user.py index af1a01914..6076edb05 100644 --- a/gramps/cli/user.py +++ b/gramps/cli/user.py @@ -49,7 +49,8 @@ class User(user.User): This class provides a means to interact with the user via CLI. It implements the interface in :class:`.gen.user.User` """ - def __init__(self, callback=None, error=None, auto_accept=False, quiet=False, + def __init__(self, callback=None, error=None, + auto_accept=False, quiet=False, uistate=None, dbstate=None): """ Init. diff --git a/gramps/gui/dbman.py b/gramps/gui/dbman.py index 956dbadd4..ab0c2eba4 100644 --- a/gramps/gui/dbman.py +++ b/gramps/gui/dbman.py @@ -191,7 +191,7 @@ class DbManager(CLIDbManager): self.before_change = "" self.after_change = "" self._select_default() - self.user = User(error=ErrorDialog, + self.user = User(error=ErrorDialog, parent=self.parent, callback=self.uistate.pulse_progressbar, uistate=self.uistate) diff --git a/gramps/gui/plug/export/_exportassistant.py b/gramps/gui/plug/export/_exportassistant.py index 84c60dcbf..a4cab8acc 100644 --- a/gramps/gui/plug/export/_exportassistant.py +++ b/gramps/gui/plug/export/_exportassistant.py @@ -592,7 +592,8 @@ class ExportAssistant(ManagedWindow, Gtk.Assistant): export_function = self.map_exporters[ix].get_export_function() success = export_function(self.dbstate.db, filename, - User(error=ErrorDialog, callback=self.callback), + User(error=ErrorDialog, parent=self.uistate.window, + callback=self.callback), self.option_box_instance) except: #an error not catched in the export_function itself diff --git a/gramps/gui/user.py b/gramps/gui/user.py index 1612907c9..8fe143fd4 100644 --- a/gramps/gui/user.py +++ b/gramps/gui/user.py @@ -49,9 +49,11 @@ class User(user.User): This class provides a means to interact with the user via GTK. It implements the interface in :class:`.gen.user.User` """ - def __init__(self, callback=None, error=None, uistate=None, dbstate=None): + def __init__(self, callback=None, error=None, parent=None, + uistate=None, dbstate=None): # TODO User API: gen==cli==gui user.User.__init__(self, callback, error, uistate, dbstate) self._progress = None + self.parent = parent def begin_progress(self, title, message, steps): """ @@ -144,10 +146,14 @@ class User(user.User): :type error: str :returns: none """ - if self.error_function: + if self.error_function and self.parent: # if parent is set, use it + self.error_function(title, error, parent=self.parent) + elif self.error_function: self.error_function(title, error) elif self.uistate: ErrorDialog(title, error, parent=self.uistate.window) + elif self.user.uistate: + ErrorDialog(title, error, parent=self.user.uistate.window) else: ErrorDialog(title, error, parent=None) diff --git a/gramps/gui/viewmanager.py b/gramps/gui/viewmanager.py index 2adb98913..4c449ec83 100644 --- a/gramps/gui/viewmanager.py +++ b/gramps/gui/viewmanager.py @@ -298,6 +298,7 @@ class ViewManager(CLIManager): self.__build_main_window() # sets self.uistate if self.user is None: self.user = User(error=ErrorDialog, + parent=self.window, callback=self.uistate.pulse_progressbar, uistate=self.uistate, dbstate=self.dbstate)