8128: GtkDialog mapped without a transient parent

In the process of searching for uses of ErrorDialog which
did not have a "parent" argument, I stumbled on this module
-- and noticed something different in it.

Benny changed the original "ErrorDialog" calls to a
"ERROR = ErrorDialog" variant in
9a2fd50642
on 30 January 2011, "to allow a QML interface" (which by the
way has subsequently been removed from the mainline gramps
code).

In the same commit, in cli/clidbman.py, he added an
_errordialog function and an "ERROR = _errordialog" line,
evidently so all DB errors, no matter whether in GUI or CLI
code, could be changed to things like:

ERROR(_("Could not rename family tree"), str(msg))

But then in 16 February 2011 MDNauta, in
7c1b26d969
changed the generic ERROR to either DbManager.ERROR or else
CLIDbManager.ERROR, depending on whether it was in GUI code
or CLI code.

Which of course defeated the purpose of the change to the
generic call, so I have changed it back to the original
ErrorDialog call, directly.

The decision was made even easier by noticing lots of
more-recent error-handling code which used the ErrorDialog
form as opposed to Benny's variant.
This commit is contained in:
Paul Franklin
2016-07-31 18:32:33 -07:00
parent ea82fc981d
commit b40c92465a

View File

@@ -153,8 +153,6 @@ class DbManager(CLIDbManager):
CLIDbManager.ICON_OPEN : 'document-open', CLIDbManager.ICON_OPEN : 'document-open',
} }
ERROR = ErrorDialog
BUSY_CURSOR = Gdk.Cursor.new_for_display(Gdk.Display.get_default(), BUSY_CURSOR = Gdk.Cursor.new_for_display(Gdk.Display.get_default(),
Gdk.CursorType.WATCH) Gdk.CursorType.WATCH)
@@ -490,7 +488,7 @@ class DbManager(CLIDbManager):
path = store.get_path(node) path = store.get_path(node)
self.lock_file = store[path][PATH_COL] self.lock_file = store[path][PATH_COL]
QuestionDialog( QuestionDialog( # parent-OK
_("Break the lock on the '%s' database?") % store[path][0], _("Break the lock on the '%s' database?") % store[path][0],
_("Gramps believes that someone else is actively editing " _("Gramps believes that someone else is actively editing "
"this database. You cannot edit this database while it " "this database. You cannot edit this database while it "
@@ -499,7 +497,7 @@ class DbManager(CLIDbManager):
"the database and you break the lock, you may corrupt the " "the database and you break the lock, you may corrupt the "
"database."), "database."),
_("Break lock"), _("Break lock"),
self.__really_break_lock, self.top) self.__really_break_lock, parent=self.top)
def __really_break_lock(self): def __really_break_lock(self):
""" """
@@ -588,11 +586,10 @@ class DbManager(CLIDbManager):
del proc del proc
if status != 0: if status != 0:
DbManager.ERROR( ErrorDialog(_("Rename failed"), # parent-OK
_("Rename failed"),
_("An attempt to rename a version failed " _("An attempt to rename a version failed "
"with the following message:\n\n%s") % message "with the following message:\n\n%s") % message,
) parent=self.top)
else: else:
self.model.set_value(node, NAME_COL, new_text) self.model.set_value(node, NAME_COL, new_text)
#scroll to new position #scroll to new position
@@ -608,9 +605,9 @@ class DbManager(CLIDbManager):
node = self.model.get_iter(path) node = self.model.get_iter(path)
filename = self.model.get_value(node, FILE_COL) filename = self.model.get_value(node, FILE_COL)
if self.existing_name(new_text, skippath=path): if self.existing_name(new_text, skippath=path):
DbManager.ERROR( ErrorDialog(_("Could not rename the Family Tree."), # parent-OK
_("Could not rename the Family Tree."), _("Family Tree already exists, choose a unique name."),
_("Family Tree already exists, choose a unique name.")) parent=self.top)
return return
old_text, new_text = self.rename_database(filename, new_text) old_text, new_text = self.rename_database(filename, new_text)
if old_text is not None: if old_text is not None:
@@ -673,7 +670,7 @@ class DbManager(CLIDbManager):
self.data_to_delete = store[path] self.data_to_delete = store[path]
if len(path.get_indices()) == 1: if len(path.get_indices()) == 1:
QuestionDialog( QuestionDialog( # parent-OK
_("Remove the '%s' Family Tree?") % self.data_to_delete[0], _("Remove the '%s' Family Tree?") % self.data_to_delete[0],
_("Removing this Family Tree will permanently destroy " _("Removing this Family Tree will permanently destroy "
"the data."), "the data."),
@@ -682,11 +679,10 @@ class DbManager(CLIDbManager):
else: else:
rev = self.data_to_delete[0] rev = self.data_to_delete[0]
parent = store[(path[0],)][0] parent = store[(path[0],)][0]
QuestionDialog( QuestionDialog(_("Remove the '%(revision)s' version " # parent-OK
_("Remove the '%(revision)s' version of '%(database)s'") % { "of '%(database)s'"
'revision' : rev, ) % {'revision' : rev,
'database' : parent 'database' : parent},
},
_("Removing this version will prevent you from " _("Removing this version will prevent you from "
"extracting it in the future."), "extracting it in the future."),
_("Remove version"), _("Remove version"),
@@ -718,8 +714,9 @@ class DbManager(CLIDbManager):
os.unlink(os.path.join(top, filename)) os.unlink(os.path.join(top, filename))
os.rmdir(directory) os.rmdir(directory)
except (IOError, OSError) as msg: except (IOError, OSError) as msg:
DbManager.ERROR(_("Could not delete Family Tree"), ErrorDialog(_("Could not delete Family Tree"), # parent-OK
str(msg)) str(msg),
parent=self.top)
# rebuild the display # rebuild the display
self.__populate() self.__populate()
self._select_default() self._select_default()
@@ -743,11 +740,10 @@ class DbManager(CLIDbManager):
del proc del proc
if status != 0: if status != 0:
DbManager.ERROR( ErrorDialog(_("Deletion failed"), # parent-OK
_("Deletion failed"),
_("An attempt to delete a version failed " _("An attempt to delete a version failed "
"with the following message:\n\n%s") % message "with the following message:\n\n%s") % message,
) parent=self.top)
# rebuild the display # rebuild the display
self.__populate() self.__populate()
@@ -761,11 +757,11 @@ class DbManager(CLIDbManager):
store, node = self.selection.get_selected() store, node = self.selection.get_selected()
name = store[node][0] name = store[node][0]
dirname = store[node][1] dirname = store[node][1]
QuestionDialog( QuestionDialog( # parent-OK
_("Convert the '%s' database?") % name, _("Convert the '%s' database?") % name,
_("You wish to convert this database into the new DB-API format?"), _("You wish to convert this database into the new DB-API format?"),
_("Convert"), _("Convert"),
lambda: self.__convert_db(name, dirname), self.top) lambda: self.__convert_db(name, dirname), parent=self.top)
def __convert_db(self, name, dirname): def __convert_db(self, name, dirname):
""" """
@@ -774,10 +770,9 @@ class DbManager(CLIDbManager):
try: try:
db = self.dbstate.open_database(name) db = self.dbstate.open_database(name)
except: except:
ErrorDialog( ErrorDialog(_("Opening the '%s' database") % name, # parent-OK
_("Opening the '%s' database") % name,
_("An attempt to convert the database failed. " _("An attempt to convert the database failed. "
"Perhaps it needs updating.")) "Perhaps it needs updating."), parent=self.top)
return return
plugin_manager = GuiPluginManager.get_instance() plugin_manager = GuiPluginManager.get_instance()
export_function = None export_function = None
@@ -787,9 +782,9 @@ class DbManager(CLIDbManager):
break break
## Next, get an XML dump: ## Next, get an XML dump:
if export_function is None: if export_function is None:
ErrorDialog( ErrorDialog(_("Converting the '%s' database") % name, # parent-OK
_("Converting the '%s' database") % name, _("An attempt to export the database failed."),
_("An attempt to export the database failed.")) parent=self.top)
db.close(user=self.user) db.close(user=self.user)
return return
self.__start_cursor(_("Converting data...")) self.__start_cursor(_("Converting data..."))
@@ -812,9 +807,9 @@ class DbManager(CLIDbManager):
if plugin.get_extension() == "gramps": if plugin.get_extension() == "gramps":
import_function = plugin.get_import_function() import_function = plugin.get_import_function()
if import_function is None: if import_function is None:
ErrorDialog( ErrorDialog(_("Converting the '%s' database") % name, # parent-OK
_("Converting the '%s' database") % name, _("An attempt to import into the database failed."),
_("An attempt to import into the database failed.")) parent=self.top)
else: else:
import_function(dbase, xml_file, self.user) import_function(dbase, xml_file, self.user)
self.__end_cursor() self.__end_cursor()
@@ -869,7 +864,7 @@ class DbManager(CLIDbManager):
dirname = store[node][1] dirname = store[node][1]
#First ask user if he is really sure :-) #First ask user if he is really sure :-)
yes_no = QuestionDialog2( yes_no = QuestionDialog2( # parent-OK
_("Repair Family Tree?"), _("Repair Family Tree?"),
_("If you click %(bold_start)sProceed%(bold_end)s, Gramps will " _("If you click %(bold_start)sProceed%(bold_end)s, Gramps will "
"attempt to recover your Family Tree from the last good " "attempt to recover your Family Tree from the last good "
@@ -903,7 +898,8 @@ class DbManager(CLIDbManager):
URL_WIKISTRING + 'Recover_corrupted_family_tree', URL_WIKISTRING + 'Recover_corrupted_family_tree',
'dirname': dirname}, 'dirname': dirname},
_("Proceed, I have taken a backup"), _("Proceed, I have taken a backup"),
_("Stop")) _("Stop"),
parent=self.top)
prompt = yes_no.run() prompt = yes_no.run()
if not prompt: if not prompt:
return return
@@ -930,7 +926,8 @@ class DbManager(CLIDbManager):
try: try:
dbase.restore() dbase.restore()
except DbException as msg: except DbException as msg:
DbManager.ERROR(_("Error restoring backup data"), msg) ErrorDialog(_("Error restoring backup data"), msg, # parent-OK
parent=self.top)
self.__end_cursor() self.__end_cursor()
@@ -968,8 +965,9 @@ class DbManager(CLIDbManager):
try: try:
self._create_new_db(dbid=dbid) self._create_new_db(dbid=dbid)
except (OSError, IOError) as msg: except (OSError, IOError) as msg:
DbManager.ERROR(_("Could not create Family Tree"), ErrorDialog(_("Could not create Family Tree"), # parent-OK
str(msg)) str(msg),
parent=self.top)
self.new.set_sensitive(True) self.new.set_sensitive(True)
def get_backend_name_from_dbid(self, dbid): def get_backend_name_from_dbid(self, dbid):
@@ -1134,11 +1132,10 @@ def check_in(dbase, filename, user, cursor_func=None):
del proc del proc
if status != 0: if status != 0:
ErrorDialog( ErrorDialog(_("Archiving failed"), # parent-OK
_("Archiving failed"),
_("An attempt to create the archive failed " _("An attempt to create the archive failed "
"with the following message:\n\n%s") % message "with the following message:\n\n%s") % message,
) parent=self.top)
if cursor_func: if cursor_func:
cursor_func(_("Creating data to be archived...")) cursor_func(_("Creating data to be archived..."))
@@ -1161,11 +1158,10 @@ def check_in(dbase, filename, user, cursor_func=None):
del proc del proc
if status != 0: if status != 0:
ErrorDialog( ErrorDialog(_("Archiving failed"), # parent-OK
_("Archiving failed"),
_("An attempt to archive the data failed " _("An attempt to archive the data failed "
"with the following message:\n\n%s") % message "with the following message:\n\n%s") % message,
) parent=self.top)
def bug_fix(column, renderer, model, iter_, data): def bug_fix(column, renderer, model, iter_, data):
""" """