Fix 'References' Gramplet for issue when activated during an import (#584)

* Fix 'References' Gramplet for issue when activated during an import

Fixes #10507

* disable Application Menu during import
This commit is contained in:
Paul Culley 2018-04-30 18:36:23 -05:00 committed by Sam Manzi
parent 67dcffee20
commit ebc0f25bc7
3 changed files with 47 additions and 9 deletions

View File

@ -506,10 +506,9 @@ class GrampsImportFileDialog(ManagedWindow):
for plugin in pmgr.get_import_plugins():
if extension == plugin.get_extension():
self.do_import(import_dialog,
plugin.get_import_function(),
filename)
self.close()
self.do_import(plugin.get_import_function(),
filename)
if callback is not None:
callback(self.import_info)
return
@ -565,12 +564,11 @@ class GrampsImportFileDialog(ManagedWindow):
return False
def do_import(self, dialog, importer, filename):
def do_import(self, importer, filename):
self.import_info = None
position = self.window.get_position() # crock
dialog.hide()
self.window.move(position[0], position[1])
self._begin_progress()
self.uistate.set_sensitive(False)
self.uistate.viewmanager.enable_menu(False)
try:
#an importer can return an object with info, object.info_text()
@ -590,6 +588,8 @@ class GrampsImportFileDialog(ManagedWindow):
parent=self.uistate.window)
except Exception:
_LOG.error("Failed to import database.", exc_info=True)
self.uistate.set_sensitive(True)
self.uistate.viewmanager.enable_menu(True)
self._end_progress()
def build_menu_names(self, obj): # this is meaningless since it's modal

View File

@ -1279,6 +1279,44 @@ class ViewManager(CLIManager):
config.set('paths.recent-file', '')
config.save()
def enable_menu(self, enable):
""" Enable/disable the menues. Used by the dbloader for import to
prevent other operations during import. Needed because simpler methods
don't work under Gnome with application menus at top of screen (instead
of Gramps window).
Note: enable must be set to False on first call.
"""
if not enable:
self.action_st = (
self.actiongroup.get_sensitive(),
self.readonlygroup.get_sensitive(),
self.undoactions.get_sensitive(),
self.redoactions.get_sensitive(),
self.undohistoryactions.get_sensitive(),
self.fileactions.get_sensitive(),
self.toolactions.get_sensitive(),
self.reportactions.get_sensitive(),
self.recent_manager.action_group.get_sensitive())
self.actiongroup.set_sensitive(enable)
self.readonlygroup.set_sensitive(enable)
self.undoactions.set_sensitive(enable)
self.redoactions.set_sensitive(enable)
self.undohistoryactions.set_sensitive(enable)
self.fileactions.set_sensitive(enable)
self.toolactions.set_sensitive(enable)
self.reportactions.set_sensitive(enable)
self.recent_manager.action_group.set_sensitive(enable)
else:
self.actiongroup.set_sensitive(self.action_st[0])
self.readonlygroup.set_sensitive(self.action_st[1])
self.undoactions.set_sensitive(self.action_st[2])
self.redoactions.set_sensitive(self.action_st[3])
self.undohistoryactions.set_sensitive(self.action_st[4])
self.fileactions.set_sensitive(self.action_st[5])
self.toolactions.set_sensitive(self.action_st[6])
self.reportactions.set_sensitive(self.action_st[7])
self.recent_manager.action_group.set_sensitive(self.action_st[8])
def __change_undo_label(self, label):
"""
Change the UNDO label

View File

@ -73,7 +73,7 @@ class Backlinks(Gramplet):
"""
Return True if the gramplet has data, else return False.
"""
if active_handle is None:
if not active_handle:
return False
for handle in self.dbstate.db.find_backlink_handles(active_handle):
return True