Use correct parent window for export filter progress

This commit is contained in:
Nick Hall 2017-01-27 18:17:50 +00:00
parent 5fead50446
commit 544e3dbcc4
2 changed files with 15 additions and 29 deletions

View File

@ -617,7 +617,7 @@ class WriterOptionBox:
progress.update(progress.progress_cnt) progress.update(progress.progress_cnt)
progress.progress_cnt += 1 progress.progress_cnt += 1
dbase = FilterProxyDb(dbase, self.cfilter, dbase = FilterProxyDb(dbase, self.cfilter,
user=User()) user=User(parent=self.window))
# Apply the Note Filter # Apply the Note Filter
elif proxy_name == "note": elif proxy_name == "note":
@ -627,7 +627,7 @@ class WriterOptionBox:
progress.update(progress.progress_cnt) progress.update(progress.progress_cnt)
progress.progress_cnt += 1 progress.progress_cnt += 1
dbase = FilterProxyDb(dbase, note_filter=self.nfilter, dbase = FilterProxyDb(dbase, note_filter=self.nfilter,
user=User()) user=User(parent=self.window))
# Apply the ReferencedBySelection # Apply the ReferencedBySelection
elif proxy_name == "reference": elif proxy_name == "reference":

View File

@ -53,7 +53,13 @@ class User(user.User):
uistate=None, dbstate=None): # TODO User API: gen==cli==gui uistate=None, dbstate=None): # TODO User API: gen==cli==gui
user.User.__init__(self, callback, error, uistate, dbstate) user.User.__init__(self, callback, error, uistate, dbstate)
self._progress = None self._progress = None
self.parent = parent
if parent:
self.parent = parent
elif uistate:
self.parent = uistate.window
else:
self.parent = None
def begin_progress(self, title, message, steps): def begin_progress(self, title, message, steps):
""" """
@ -69,11 +75,7 @@ class User(user.User):
:type steps: int :type steps: int
:returns: none :returns: none
""" """
if self.uistate: self._progress = ProgressMeter(title, parent=self.parent)
self._progress = ProgressMeter(title,
parent=self.uistate.window)
else:
self._progress = ProgressMeter(title)
if steps > 0: if steps > 0:
self._progress.set_pass(message, steps, ProgressMeter.MODE_FRACTION) self._progress.set_pass(message, steps, ProgressMeter.MODE_FRACTION)
else: else:
@ -130,11 +132,7 @@ class User(user.User):
:type warning: str :type warning: str
:returns: none :returns: none
""" """
if self.uistate: WarningDialog(title, warning, parent=self.parent)
WarningDialog(title, warning,
parent=self.uistate.window)
else:
WarningDialog(title, warning, parent=None)
def notify_error(self, title, error=""): def notify_error(self, title, error=""):
""" """
@ -146,16 +144,10 @@ class User(user.User):
:type error: str :type error: str
:returns: none :returns: none
""" """
if self.error_function and self.parent: # if parent is set, use it if self.error_function:
self.error_function(title, error, parent=self.parent) 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: else:
ErrorDialog(title, error, parent=None) ErrorDialog(title, error, parent=self.parent)
def notify_db_error(self, error): def notify_db_error(self, error):
""" """
@ -165,10 +157,7 @@ class User(user.User):
:type error: str :type error: str
:returns: none :returns: none
""" """
if self.uistate: DBErrorDialog(error, parent=self.parent)
DBErrorDialog(error, parent=self.uistate.window)
else:
DBErrorDialog(error, parent=None)
def notify_db_repair(self, error): def notify_db_repair(self, error):
""" """
@ -178,10 +167,7 @@ class User(user.User):
:type error: str :type error: str
:returns: none :returns: none
""" """
if self.uistate: RunDatabaseRepair(error, parent=self.parent)
RunDatabaseRepair(error, parent=self.uistate.window)
else:
RunDatabaseRepair(error, parent=None)
def info(self, msg1, infotext, parent=None, monospaced=False): def info(self, msg1, infotext, parent=None, monospaced=False):
""" """