8128: GtkDialog mapped without a transient parent -- partial

This commit is contained in:
Paul Franklin 2016-04-09 09:40:37 -07:00
parent f0e9078ee4
commit 3bd585f7f8
15 changed files with 57 additions and 43 deletions

View File

@ -336,7 +336,7 @@ class MissingMediaDialog(object):
_("Attempt to force closing the dialog"),
_("Please do not force closing this important dialog.\n"
"Instead select one of the available options"),
self.top)
parent=self.top)
return True
class MultiSelectDialog(object):
@ -409,7 +409,7 @@ class MultiSelectDialog(object):
_("Attempt to force closing the dialog"),
_("Please do not force closing this important dialog.\n"
"Instead select one of the available options"),
self.top)
parent=self.top)
return True
class MessageHideDialog(object):
@ -450,7 +450,9 @@ def main(args):
def test_info(obj):
InfoDialog('The title', 'This is a lot of info\n to show to all!', parent=win)
InfoDialog('The title',
'This is a lot of info\n to show to all!',
parent=win)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
win.add(vbox)

View File

@ -97,7 +97,7 @@ class EditTagList(ManagedWindow):
"""
# pylint: disable-msg=E1101
title = _("%(title)s - Gramps") % {'title': _("Edit Tags")}
top = Gtk.Dialog(title)
top = Gtk.Dialog(title, self.uistate.window)
top.set_default_size(360, 400)
top.set_modal(True)
top.vbox.set_spacing(5)

View File

@ -219,6 +219,7 @@ class MergeFamily(ManagedWindow):
phoenix_fh, phoenix_mh)
query.execute()
except MergeError as err:
ErrorDialog( _("Cannot merge people"), str(err))
ErrorDialog(_("Cannot merge people"), str(err),
parent=self.uistate.window)
self.uistate.set_busy_cursor(False)
self.close()

View File

@ -325,7 +325,8 @@ class MergePerson(ManagedWindow):
query = MergePersonQuery(self.database, phoenix, titanic)
query.execute()
except MergeError as err:
ErrorDialog( _("Cannot merge people"), str(err))
ErrorDialog(_("Cannot merge people"), str(err),
parent=self.uistate.window)
self.uistate.set_busy_cursor(False)
self.close()
if self.update:

View File

@ -345,7 +345,7 @@ class ViewManager(CLIManager):
Show the error.
In the GUI, the error is shown, and a return happens
"""
ErrorDialog(title, errormessage)
ErrorDialog(title, errormessage, parent=self.uistate.window)
return 1
def __build_main_window(self):
@ -763,7 +763,8 @@ class ViewManager(CLIManager):
try:
self.dbstate.db.backup()
except DbException as msg:
ErrorDialog(_("Error saving backup data"), msg)
ErrorDialog(_("Error saving backup data"), msg,
parent=self.uistate.window)
self.uistate.set_busy_cursor(False)
self.uistate.progress.hide()
@ -778,7 +779,8 @@ class ViewManager(CLIManager):
_("Aborting changes will return the database to the state "
"it was before you started this editing session."),
_("Abort changes"),
_("Cancel"))
_("Cancel"),
parent=self.uistate.window)
if dialog.run():
self.dbstate.db.disable_signals()
@ -790,7 +792,7 @@ class ViewManager(CLIManager):
_("Cannot abandon session's changes"),
_('Changes cannot be completely abandoned because the '
'number of changes made in the session exceeded the '
'limit.'))
'limit.'), parent=self.uistate.window)
def __init_action_group(self, name, actions, sensitive=True, toggles=None):
"""
@ -1083,7 +1085,8 @@ class ViewManager(CLIManager):
self.db_loader.import_file()
infotxt = self.db_loader.import_info_text()
if infotxt:
InfoDialog(_('Import Statistics'), infotxt, self.window)
InfoDialog(_('Import Statistics'), infotxt,
parent=self.window)
self.__post_load()
def __open_activate(self, obj):
@ -1227,7 +1230,6 @@ class ViewManager(CLIManager):
"""
Make a quick XML back with or without media.
"""
from .dialog import QuestionDialog2
window = Gtk.Dialog(_("Gramps XML Backup"),
self.uistate.window,
Gtk.DialogFlags.DESTROY_WITH_PARENT, None)
@ -1625,7 +1627,8 @@ def run_plugin(pdata, dbstate, uistate):
'gramps_bugtracker_url' : URL_BUGHOME,
'firstauthoremail': pdata.authors_email[0] if
pdata.authors_email else '...',
'error_msg': error_msg})
'error_msg': error_msg},
parent=self.uistate.window)
return
if pdata.ptype == REPORT:
@ -1681,7 +1684,8 @@ def get_available_views():
'gramps_bugtracker_url' : URL_BUGHOME,
'firstauthoremail': pdata.authors_email[0] if
pdata.authors_email else '...',
'error_msg': lasterror})
'error_msg': lasterror},
parent=self.uistate.window)
continue
viewclass = getattr(mod, pdata.viewclass)

View File

@ -292,11 +292,12 @@ class BasePersonView(ListView):
msg1 = self._message1_format(person)
msg2 = self._message2_format(person)
msg2 = "%s %s" % (msg2, data_recover_msg)
# This gets person to delete deom self.active_person:
# This gets person to delete self.active_person:
QuestionDialog(msg1,
msg2,
_('_Delete Person'),
self.delete_person_response)
self.delete_person_response,
parent=self.uistate.window)
else:
# Ask to delete; option to cancel, delete rest
# This gets person to delete from parameter
@ -304,7 +305,8 @@ class BasePersonView(ListView):
self._message2_format,
handles,
self._lookup_person,
yes_func=self.delete_person_response) # Yes
yes_func=self.delete_person_response,
parent=self.uistate.window)
def _message1_format(self, person):
return _('Delete %s?') % (name_displayer.display(person) +
@ -413,11 +415,11 @@ class BasePersonView(ListView):
mlist = self.selected_handles()
if len(mlist) != 2:
ErrorDialog(
_("Cannot merge people"),
_("Exactly two people must be selected to perform a merge. "
"A second person can be selected by holding down the "
"control key while clicking on the desired person."))
ErrorDialog(_("Cannot merge people"),
_("Exactly two people must be selected to perform "
"a merge. A second person can be selected by "
"holding down the control key while clicking on "
"the desired person."), parent=self.uistate.window)
else:
MergePerson(self.dbstate, self.uistate, mlist[0], mlist[1])

View File

@ -258,7 +258,7 @@ class PlaceBaseView(ListView):
if not len(self.mapservicedata):
msg = _("No map service is available.")
msg2 = _("Check your installation.")
ErrorDialog(msg, msg2)
ErrorDialog(msg, msg2, parent=self.uistate.window)
return
place_handles = self.selected_handles()
@ -269,7 +269,7 @@ class PlaceBaseView(ListView):
msg2 = _("You need to select a place to be able to view it"
" on a map. Some Map Services might support multiple"
" selections.")
ErrorDialog(msg, msg2)
ErrorDialog(msg, msg2, parent=self.uistate.window)
return
#TODO: support for descriptions in some cases. For now, pass None
@ -363,7 +363,7 @@ class PlaceBaseView(ListView):
msg = _("Cannot delete place.")
msg2 = _("This place is currently referenced by another place. "
"First remove the places it contains.")
ErrorDialog(msg, msg2)
ErrorDialog(msg, msg2, parent=self.uistate.window)
return
self.remove_selected_objects()
@ -406,14 +406,14 @@ class PlaceBaseView(ListView):
msg2 = _("Exactly two places must be selected to perform a merge. "
"A second place can be selected by holding down the "
"control key while clicking on the desired place.")
ErrorDialog(msg, msg2)
ErrorDialog(msg, msg2, parent=self.uistate.window)
else:
if (located_in(self.dbstate.db, mlist[0], mlist[1]) or
located_in(self.dbstate.db, mlist[1], mlist[0])):
msg = _("Cannot merge places.")
msg2 = _("Merging these places would create a cycle in the "
"place hierarchy.")
ErrorDialog(msg, msg2)
ErrorDialog(msg, msg2, parent=self.uistate.window)
else:
MergePlace(self.dbstate, self.uistate, mlist[0], mlist[1],
self.merged)

View File

@ -313,7 +313,7 @@ class CitationListView(ListView):
"merge. A second citation can be selected by holding "
"down the control key while clicking on the desired "
"citation.")
ErrorDialog(msg, msg2)
ErrorDialog(msg, msg2, parent=self.uistate.window)
else:
citation1 = self.dbstate.db.get_citation_from_handle(mlist[0])
citation2 = self.dbstate.db.get_citation_from_handle(mlist[1])
@ -324,7 +324,7 @@ class CitationListView(ListView):
"source to perform a merge. If you want to merge "
"these two citations, then you must merge the "
"sources first.")
ErrorDialog(msg, msg2)
ErrorDialog(msg, msg2, parent=self.uistate.window)
else:
MergeCitation(self.dbstate, self.uistate, mlist[0], mlist[1])

View File

@ -428,7 +428,8 @@ class CitationTreeView(ListView):
except WindowActiveError:
from gramps.gui.dialog import WarningDialog
WarningDialog(_("Cannot share this reference"),
self.__blocked_text())
self.__blocked_text(),
parent=self.uistate.window)
#
def remove(self, obj):
self.remove_selected_objects()
@ -478,7 +479,8 @@ class CitationTreeView(ListView):
except WindowActiveError:
from gramps.gui.dialog import WarningDialog
WarningDialog(_("Cannot share this reference"),
self.__blocked_text2())
self.__blocked_text2(),
parent=self.uistate.window)
def __blocked_text(self):
"""
@ -512,7 +514,7 @@ class CitationTreeView(ListView):
"merge. A second citation can be selected by holding "
"down the control key while clicking on the desired "
"citation.")
ErrorDialog(msg, msg2)
ErrorDialog(msg, msg2, parent=self.uistate.window)
else:
source1 = self.dbstate.db.get_source_from_handle(mlist[0])
citation1 = self.dbstate.db.get_citation_from_handle(mlist[0])
@ -532,7 +534,7 @@ class CitationTreeView(ListView):
"source to perform a merge. If you want to merge "
"these two citations, then you must merge the "
"sources first.")
ErrorDialog(msg, msg2)
ErrorDialog(msg, msg2, parent=self.uistate.window)
else:
MergeCitation(self.dbstate, self.uistate, mlist[0],
mlist[1])
@ -543,7 +545,7 @@ class CitationTreeView(ListView):
msg2 = _("Both objects must be of the same type, either "
"both must be sources, or both must be "
"citations.")
ErrorDialog(msg, msg2)
ErrorDialog(msg, msg2, parent=self.uistate.window)
def get_handle_from_gramps_id(self, gid):
obj = self.dbstate.db.get_citation_from_gramps_id(gid)

View File

@ -264,7 +264,7 @@ class EventView(ListView):
msg2 = _("Exactly two events must be selected to perform a merge. "
"A second object can be selected by holding down the "
"control key while clicking on the desired event.")
ErrorDialog(msg, msg2)
ErrorDialog(msg, msg2, parent=self.uistate.window)
else:
MergeEvent(self.dbstate, self.uistate, mlist[0], mlist[1])

View File

@ -219,7 +219,7 @@ class FamilyView(ListView):
WarningDialog(
_("Could Not Set a Bookmark"),
_("A bookmark could not be set because "
"no one was selected."))
"no one was selected."), parent=self.uistate.window)
def add(self, obj):
family = Family()
@ -243,13 +243,15 @@ class FamilyView(ListView):
QuestionDialog(msg1,
msg2,
_('_Delete Family'),
lambda: self.delete_family_response(family))
lambda: self.delete_family_response(family),
parent=self.uistate.window)
else:
MultiSelectDialog(self._message1_format,
self._message2_format,
handles,
self.dbstate.db.get_family_from_handle,
yes_func=self.delete_family_response)
yes_func=self.delete_family_response,
parent=self.uistate.window)
def _message1_format(self, family):
"""
@ -298,7 +300,7 @@ class FamilyView(ListView):
msg2 = _("Exactly two families must be selected to perform a merge."
" A second family can be selected by holding down the "
"control key while clicking on the desired family.")
ErrorDialog(msg, msg2)
ErrorDialog(msg, msg2, parent=self.uistate.window)
else:
MergeFamily(self.dbstate, self.uistate, mlist[0], mlist[1])

View File

@ -350,7 +350,7 @@ class MediaView(ListView):
msg2 = _("Exactly two media objects must be selected to perform a "
"merge. A second object can be selected by holding down the "
"control key while clicking on the desired object.")
ErrorDialog(msg, msg2)
ErrorDialog(msg, msg2, parent=self.uistate.window)
else:
MergeMedia(self.dbstate, self.uistate, mlist[0], mlist[1])

View File

@ -242,7 +242,7 @@ class NoteView(ListView):
msg2 = _("Exactly two notes must be selected to perform a merge. "
"A second note can be selected by holding down the "
"control key while clicking on the desired note.")
ErrorDialog(msg, msg2)
ErrorDialog(msg, msg2, parent=self.uistate.window)
else:
MergeNote(self.dbstate, self.uistate, mlist[0], mlist[1])

View File

@ -247,7 +247,7 @@ class RepositoryView(ListView):
"merge. A second repository can be selected by holding "
"down the control key while clicking on the desired "
"repository.")
ErrorDialog(msg, msg2)
ErrorDialog(msg, msg2, parent=self.uistate.window)
else:
MergeRepository(self.dbstate, self.uistate, mlist[0], mlist[1])

View File

@ -230,7 +230,7 @@ class SourceView(ListView):
msg2 = _("Exactly two sources must be selected to perform a merge. "
"A second source can be selected by holding down the "
"control key while clicking on the desired source.")
ErrorDialog(msg, msg2)
ErrorDialog(msg, msg2, parent=self.uistate.window)
else:
MergeSource(self.dbstate, self.uistate, mlist[0], mlist[1])