give GUI User an optional parent, for when None would otherwise be used
This commit is contained in:
parent
f75618eb2d
commit
66260871dc
@ -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.
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user