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"), _("Attempt to force closing the dialog"),
_("Please do not force closing this important dialog.\n" _("Please do not force closing this important dialog.\n"
"Instead select one of the available options"), "Instead select one of the available options"),
self.top) parent=self.top)
return True return True
class MultiSelectDialog(object): class MultiSelectDialog(object):
@@ -409,7 +409,7 @@ class MultiSelectDialog(object):
_("Attempt to force closing the dialog"), _("Attempt to force closing the dialog"),
_("Please do not force closing this important dialog.\n" _("Please do not force closing this important dialog.\n"
"Instead select one of the available options"), "Instead select one of the available options"),
self.top) parent=self.top)
return True return True
class MessageHideDialog(object): class MessageHideDialog(object):
@@ -450,7 +450,9 @@ def main(args):
def test_info(obj): 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) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
win.add(vbox) win.add(vbox)

View File

@@ -97,7 +97,7 @@ class EditTagList(ManagedWindow):
""" """
# pylint: disable-msg=E1101 # pylint: disable-msg=E1101
title = _("%(title)s - Gramps") % {'title': _("Edit Tags")} 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_default_size(360, 400)
top.set_modal(True) top.set_modal(True)
top.vbox.set_spacing(5) top.vbox.set_spacing(5)

View File

@@ -219,6 +219,7 @@ class MergeFamily(ManagedWindow):
phoenix_fh, phoenix_mh) phoenix_fh, phoenix_mh)
query.execute() query.execute()
except MergeError as err: 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.uistate.set_busy_cursor(False)
self.close() self.close()

View File

@@ -325,7 +325,8 @@ class MergePerson(ManagedWindow):
query = MergePersonQuery(self.database, phoenix, titanic) query = MergePersonQuery(self.database, phoenix, titanic)
query.execute() query.execute()
except MergeError as err: 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.uistate.set_busy_cursor(False)
self.close() self.close()
if self.update: if self.update:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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