8128: GtkDialog mapped without a transient parent

This commit is contained in:
Paul Franklin 2016-08-03 18:16:48 -07:00
parent 675ae1a8d4
commit f9dbfd9dbd
35 changed files with 184 additions and 142 deletions

View File

@ -222,7 +222,7 @@ class User(user.User):
) % {'gramps_bugtracker_url' : URL_BUGHOME} ) % {'gramps_bugtracker_url' : URL_BUGHOME}
+ error + '\n\n') + error + '\n\n')
def info(self, msg1, infotext, parent=None, monospaced=False): def info(self, msg1, infotext, parent=None, monospaced=False): # parent-OK
""" """
Displays information to the CLI Displays information to the CLI
""" """

View File

@ -27,4 +27,4 @@ gen data specific for output (eg markup in gen/lib) and output where needed
from .docbackend import DocBackendError, DocBackend from .docbackend import DocBackendError, DocBackend
from .cairobackend import CairoBackend from .cairobackend import CairoBackend
#__all__ = [ DocBackend, CairoBackend, LateXBackend ] #__all__ = [ DocBackend, CairoBackend, LaTeXBackend ]

View File

@ -183,7 +183,7 @@ class User(metaclass=ABCMeta):
""" """
@abstractmethod @abstractmethod
def info(self, msg1, infotext, parent=None, monospaced=False): def info(self, msg1, infotext, parent=None, monospaced=False): # parent-OK
""" """
Displays information to the user Displays information to the user
""" """

View File

@ -167,7 +167,10 @@ class AddMedia(ManagedWindow):
pname = str(media_path(self.dbase)) pname = str(media_path(self.dbase))
if not os.path.exists(pname): if not os.path.exists(pname):
msgstr = _("Cannot import %s") msgstr = _("Cannot import %s")
msgstr2 = _("Directory specified in preferences: Base path for relative media paths: %s does not exist. Change preferences or do not use relative path when importing") msgstr2 = _("Directory specified in preferences: "
"Base path for relative media paths: "
"%s does not exist. Change preferences "
"or do not use relative path when importing")
ErrorDialog(msgstr % filename, msgstr2 % pname, # parent-OK ErrorDialog(msgstr % filename, msgstr2 % pname, # parent-OK
parent=self.window) parent=self.window)
return return

View File

@ -24,8 +24,6 @@
# Python classes # Python classes
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -40,6 +38,8 @@ from gi.repository import Gdk
# Gramps classes # Gramps classes
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from ...widgets import SimpleButton from ...widgets import SimpleButton
from .grampstab import GrampsTab from .grampstab import GrampsTab
from gramps.gen.errors import WindowActiveError from gramps.gen.errors import WindowActiveError

View File

@ -24,8 +24,6 @@
# Python classes # Python classes
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
import logging import logging
LOG = logging.getLogger(".citation") LOG = logging.getLogger(".citation")
@ -41,6 +39,8 @@ from gi.repository import GObject, GLib
# Gramps classes # Gramps classes
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.errors import WindowActiveError from gramps.gen.errors import WindowActiveError
from gramps.gen.lib import Citation, Source from gramps.gen.lib import Citation, Source
from ...dbguielement import DbGUIElement from ...dbguielement import DbGUIElement
@ -168,8 +168,9 @@ class CitationEmbedList(EmbeddedList, DbGUIElement):
callertitle=self.callertitle) callertitle=self.callertitle)
except WindowActiveError: except WindowActiveError:
from ...dialog import WarningDialog from ...dialog import WarningDialog
WarningDialog(_("Cannot share this reference"), # no-parent WarningDialog(_("Cannot share this reference"), # parent-OK
self.__blocked_text()) self.__blocked_text(),
parent=self.uistate.window)
elif isinstance(object, Citation): elif isinstance(object, Citation):
try: try:
from .. import EditCitation from .. import EditCitation
@ -178,8 +179,9 @@ class CitationEmbedList(EmbeddedList, DbGUIElement):
callertitle=self.callertitle) callertitle=self.callertitle)
except WindowActiveError: except WindowActiveError:
from ...dialog import WarningDialog from ...dialog import WarningDialog
WarningDialog(_("Cannot share this reference"), # no-parent WarningDialog(_("Cannot share this reference"), # parent-OK
self.__blocked_text()) self.__blocked_text(),
parent=self.uistate.window)
else: else:
raise ValueError("selection must be either source or citation") raise ValueError("selection must be either source or citation")
@ -251,8 +253,9 @@ class CitationEmbedList(EmbeddedList, DbGUIElement):
callertitle=self.callertitle) callertitle=self.callertitle)
except WindowActiveError: except WindowActiveError:
from ...dialog import WarningDialog from ...dialog import WarningDialog
WarningDialog(_("Cannot share this reference"), # no-parent WarningDialog(_("Cannot share this reference"), # parent-OK
self.__blocked_text()) self.__blocked_text(),
parent=self.uistate.window)
else: else:
raise ValueError("selection must be either source or citation") raise ValueError("selection must be either source or citation")
@ -271,7 +274,8 @@ class CitationEmbedList(EmbeddedList, DbGUIElement):
callertitle=self.callertitle) callertitle=self.callertitle)
except WindowActiveError: except WindowActiveError:
from ...dialog import WarningDialog from ...dialog import WarningDialog
WarningDialog(_("Cannot share this reference"), # no-parent WarningDialog(_("Cannot share this reference"), # parent-OK
self.__blocked_text()) self.__blocked_text(),
parent=self.uistate.window)
else: else:
raise ValueError("selection must be either source or citation") raise ValueError("selection must be either source or citation")

View File

@ -24,8 +24,6 @@
# python # python
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
import pickle import pickle
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -44,6 +42,8 @@ from gi.repository import Pango
# Gramps classes # Gramps classes
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from ...utils import is_right_click from ...utils import is_right_click
from .buttontab import ButtonTab from .buttontab import ButtonTab
@ -576,7 +576,7 @@ class EmbeddedList(ButtonTab):
from ...dialog import RunDatabaseRepair from ...dialog import RunDatabaseRepair
import traceback import traceback
traceback.print_exc() traceback.print_exc()
RunDatabaseRepair(str(msg)) # no-parent RunDatabaseRepair(str(msg), parent=self.uistate.window) # parent-OK
return return
self.tree.set_model(self.model) self.tree.set_model(self.model)

View File

@ -24,8 +24,6 @@
# Python classes # Python classes
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gi.repository import Gtk from gi.repository import Gtk
from gi.repository import GObject from gi.repository import GObject
from gi.repository import GLib from gi.repository import GLib
@ -35,6 +33,8 @@ from gi.repository import GLib
# Gramps classes # Gramps classes
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.lib import Event, EventRef, EventRoleType, EventType from gramps.gen.lib import Event, EventRef, EventRoleType, EventType
from gramps.gen.errors import WindowActiveError from gramps.gen.errors import WindowActiveError
from ...ddtargets import DdTargets from ...ddtargets import DdTargets
@ -264,8 +264,9 @@ class EventEmbedList(DbGUIElement, GroupEmbeddedList):
event, ref, self.object_added) event, ref, self.object_added)
except WindowActiveError: except WindowActiveError:
from ...dialog import WarningDialog from ...dialog import WarningDialog
WarningDialog(_("Cannot share this reference"), # no-parent WarningDialog(_("Cannot share this reference"), # parent-OK
self.__blocked_text()) self.__blocked_text(),
parent=self.uistate.window)
def edit_button_clicked(self, obj): def edit_button_clicked(self, obj):
ref = self.get_selected() ref = self.get_selected()
@ -277,8 +278,9 @@ class EventEmbedList(DbGUIElement, GroupEmbeddedList):
event, ref[1], self.object_edited) event, ref[1], self.object_edited)
except WindowActiveError: except WindowActiveError:
from ...dialog import WarningDialog from ...dialog import WarningDialog
WarningDialog(_("Cannot edit this reference"), # no-parent WarningDialog(_("Cannot edit this reference"), # parent-OK
self.__blocked_text()) self.__blocked_text(),
parent=self.uistate.window)
elif ref and ref[0] != self._WORKGROUP: elif ref and ref[0] != self._WORKGROUP:
#bring up family editor #bring up family editor
key = self._groups[ref[0]][0] key = self._groups[ref[0]][0]
@ -318,9 +320,10 @@ class EventEmbedList(DbGUIElement, GroupEmbeddedList):
handle change request of non native data handle change request of non native data
""" """
from ...dialog import WarningDialog from ...dialog import WarningDialog
WarningDialog(_("Cannot change Person"), # no-parent WarningDialog( # parent-OK
_("You cannot change Person events in the Family Editor") _("Cannot change Person"),
) _("You cannot change Person events in the Family Editor"),
parent=self.uistate.window)
def _handle_drag(self, row, obj): def _handle_drag(self, row, obj):
""" """
@ -340,14 +343,14 @@ class EventEmbedList(DbGUIElement, GroupEmbeddedList):
event, obj, self.object_edited) event, obj, self.object_edited)
except WindowActiveError: except WindowActiveError:
from ...dialog import WarningDialog from ...dialog import WarningDialog
WarningDialog( # no-parent WarningDialog( # parent-OK
_("Cannot edit this reference"), _("Cannot edit this reference"),
_("This event reference cannot be edited at this time. " _("This event reference cannot be edited at this time. "
"Either the associated event is already being edited " "Either the associated event is already being edited "
"or another event reference that is associated with " "or another event reference that is associated with "
"the same event is being edited.\n\nTo edit this event " "the same event is being edited.\n\nTo edit this event "
"reference, you need to close the event.") "reference, you need to close the event."),
) parent=self.uistate.window)
else: else:
self.dropnotworkgroup(row, obj) self.dropnotworkgroup(row, obj)

View File

@ -61,6 +61,7 @@ from .buttontab import ButtonTab
from gramps.gen.const import THUMBSCALE from gramps.gen.const import THUMBSCALE
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# #
@ -259,8 +260,9 @@ class GalleryTab(ButtonTab, DbGUIElement):
if obj is None : if obj is None :
#notify user of error #notify user of error
from ...dialog import RunDatabaseRepair from ...dialog import RunDatabaseRepair
RunDatabaseRepair( # no-parent RunDatabaseRepair( # parent-OK
_('Non existing media found in the Gallery')) _('Non existing media found in the Gallery'),
parent=self.uistate.window)
else : else :
pixbuf = get_thumbnail_image( pixbuf = get_thumbnail_image(
media_path_full(self.dbstate.db, media_path_full(self.dbstate.db,
@ -334,8 +336,9 @@ class GalleryTab(ButtonTab, DbGUIElement):
src, sref, self.add_callback) src, sref, self.add_callback)
except WindowActiveError: except WindowActiveError:
from ...dialog import WarningDialog from ...dialog import WarningDialog
WarningDialog(_("Cannot share this reference"), # no-parent WarningDialog(_("Cannot share this reference"), # parent-OK
self.__blocked_text()) self.__blocked_text(),
parent=self.uistate.window)
def del_button_clicked(self, obj): def del_button_clicked(self, obj):
ref = self.get_selected() ref = self.get_selected()
@ -354,8 +357,9 @@ class GalleryTab(ButtonTab, DbGUIElement):
obj, ref, self.edit_callback) obj, ref, self.edit_callback)
except WindowActiveError: except WindowActiveError:
from ...dialog import WarningDialog from ...dialog import WarningDialog
WarningDialog(_("Cannot edit this reference"), # no-parent WarningDialog(_("Cannot edit this reference"), # parent-OK
self.__blocked_text()) self.__blocked_text(),
parent=self.uistate.window)
def edit_callback(self, media_ref, media): def edit_callback(self, media_ref, media):
""" """

View File

@ -24,8 +24,6 @@
# python # python
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gi.repository import GObject from gi.repository import GObject
from gi.repository import GLib from gi.repository import GLib
@ -34,6 +32,8 @@ from gi.repository import GLib
# Gramps classes # Gramps classes
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.lib import EventRoleType, EventType from gramps.gen.lib import EventRoleType, EventType
from gramps.gen.display.name import displayer as name_displayer from gramps.gen.display.name import displayer as name_displayer
from .eventembedlist import EventEmbedList from .eventembedlist import EventEmbedList
@ -126,10 +126,11 @@ class PersonEventEmbedList(EventEmbedList):
handle change request of non native data handle change request of non native data
""" """
from ...dialog import WarningDialog from ...dialog import WarningDialog
WarningDialog( # no-parent WarningDialog( # parent-OK
_("Cannot change Family"), _("Cannot change Family"),
_("You cannot change Family events in the Person Editor") _("You cannot change Family events in the Person Editor"),
) parent=self.uistate.window)
def _move_up_group(self, groupindex): def _move_up_group(self, groupindex):
""" """
move up pressed on the group move up pressed on the group

View File

@ -23,8 +23,6 @@
# Python classes # Python classes
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gi.repository import GObject from gi.repository import GObject
from gi.repository import GLib from gi.repository import GLib
@ -33,6 +31,8 @@ from gi.repository import GLib
# Gramps classes # Gramps classes
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.lib import Place, PlaceRef from gramps.gen.lib import Place, PlaceRef
from gramps.gen.errors import WindowActiveError from gramps.gen.errors import WindowActiveError
from ...dialog import ErrorDialog from ...dialog import ErrorDialog
@ -138,9 +138,10 @@ class PlaceRefEmbedList(EmbeddedList):
def handle_extra_type(self, objtype, obj): def handle_extra_type(self, objtype, obj):
if obj in self.get_skip_list(self.handle): if obj in self.get_skip_list(self.handle):
ErrorDialog(_("Place cycle detected"), # no-parent ErrorDialog(_("Place cycle detected"), # parent-OK
_("The place you are adding is already enclosed by " _("The place you are adding is already enclosed by "
"this place")) "this place"),
parent=self.uistate.window)
return return
place = self.dbstate.db.get_place_from_handle(obj) place = self.dbstate.db.get_place_from_handle(obj)
placeref = PlaceRef() placeref = PlaceRef()

View File

@ -23,8 +23,6 @@
# Python classes # Python classes
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gi.repository import GObject, GLib from gi.repository import GObject, GLib
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -32,6 +30,8 @@ from gi.repository import GObject, GLib
# Gramps classes # Gramps classes
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.lib import RepoRef, Repository from gramps.gen.lib import RepoRef, Repository
from ...dbguielement import DbGUIElement from ...dbguielement import DbGUIElement
from ...selectors import SelectorFactory from ...selectors import SelectorFactory
@ -164,15 +164,15 @@ class RepoEmbedList(EmbeddedList, DbGUIElement):
ref, self.edit_callback) ref, self.edit_callback)
except WindowActiveError: except WindowActiveError:
from ...dialog import WarningDialog from ...dialog import WarningDialog
WarningDialog( # no-parent WarningDialog( # parent-OK
_("Cannot edit this reference"), _("Cannot edit this reference"),
_("This repository reference cannot be edited at this " _("This repository reference cannot be edited at this "
"time. Either the associated repository is already " "time. Either the associated repository is already "
"being edited or another repository reference that is " "being edited or another repository reference that is "
"associated with the same repository is being edited." "associated with the same repository is being edited."
"\n\nTo edit this repository reference, you need to " "\n\nTo edit this repository reference, you need to "
"close the repository.") "close the repository."),
) parent=self.uistate.window)
def edit_callback(self, name): def edit_callback(self, name):

View File

@ -1043,7 +1043,7 @@ class EditFamily(EditPrimary):
#try: #try:
self.__do_save() self.__do_save()
#except bsddb_db.DBRunRecoveryError as msg: #except bsddb_db.DBRunRecoveryError as msg:
# RunDatabaseRepair(msg[1]) # no-parent # RunDatabaseRepair(msg[1], parent=self.window) # parent-OK
def __do_save(self): def __do_save(self):
self.ok_button.set_sensitive(False) self.ok_button.set_sensitive(False)

View File

@ -957,8 +957,9 @@ class EditPerson(EditPrimary):
if obj is None : if obj is None :
#notify user of error #notify user of error
from ..dialog import RunDatabaseRepair from ..dialog import RunDatabaseRepair
RunDatabaseRepair( # no-parent RunDatabaseRepair( # parent-OK
_('Non existing media found in the Gallery')) _('Non existing media found in the Gallery'),
parent=self.window)
else : else :
self.load_photo(ref, obj) self.load_photo(ref, obj)
else: else:
@ -1083,7 +1084,7 @@ class EditPerson(EditPrimary):
#config.save() #config.save()
class GenderDialog(Gtk.MessageDialog): class GenderDialog(Gtk.MessageDialog): # parent-OK
def __init__(self, parent=None): def __init__(self, parent=None):
Gtk.MessageDialog.__init__(self, Gtk.MessageDialog.__init__(self,
parent, parent,

View File

@ -237,7 +237,7 @@ class EditPersonRef(EditSecondary):
else: else:
from ..dialog import ErrorDialog from ..dialog import ErrorDialog
ErrorDialog( # no-parent ErrorDialog( # parent-OK
_('No person selected'), _('No person selected'),
_('You must either select a person or Cancel ' _('You must either select a person or Cancel the edit'),
'the edit')) parent=self.uistate.window)

View File

@ -127,7 +127,7 @@ def _display_welcome_message(parent=None):
Display a welcome message to the user. Display a welcome message to the user.
(This docstring seems very legacy/historical, not accurate.) (This docstring seems very legacy/historical, not accurate.)
""" """
_display_generic_message("master", 'behavior.betawarn', parent) _display_generic_message("master", 'behavior.betawarn', parent=parent)
def _display_generic_message(warning_type, config_key, parent=None): def _display_generic_message(warning_type, config_key, parent=None):
""" """
@ -224,9 +224,9 @@ class Gramps:
if (lin() if (lin()
and glocale.lang != 'C' and glocale.lang != 'C'
and not gettext.find(GTK_GETTEXT_DOMAIN)): and not gettext.find(GTK_GETTEXT_DOMAIN)):
_display_gtk_gettext_message(parent=self._vm.window) _display_gtk_gettext_message(parent=self._vm.window) # parent-OK
_display_welcome_message(parent=self._vm.window) _display_welcome_message(parent=self._vm.window) # parent-OK
self._vm.init_interface() self._vm.init_interface()

View File

@ -662,8 +662,9 @@ class WriterOptionBox:
lambda : self.edit_filter_save(filterdb, namespace)) lambda : self.edit_filter_save(filterdb, namespace))
else: # can't edit this filter else: # can't edit this filter
from ...dialog import ErrorDialog from ...dialog import ErrorDialog
ErrorDialog(_("Cannot edit a system filter"), # no-parent ErrorDialog(_("Cannot edit a system filter"), # parent-OK
_("Please select a different filter to edit")) _("Please select a different filter to edit"),
parent=self.uistate.window)
def edit_filter_save(self, filterdb, namespace): def edit_filter_save(self, filterdb, namespace):
""" """

View File

@ -23,11 +23,12 @@
import os import os
from gi.repository import Gtk from gi.repository import Gtk
from gi.repository import GObject from gi.repository import GObject
from gramps.gen.constfunc import get_curr_dir from gramps.gen.constfunc import get_curr_dir
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
class FileEntry(Gtk.Box): class FileEntry(Gtk.Box): # parent-OK
""" A widget that allows the user to select a file from the file system """ """ A widget that allows the user to select a file from the file system """
def __init__(self, defname, title, parent=None): def __init__(self, defname, title, parent=None):
Gtk.Box.__init__(self) Gtk.Box.__init__(self)

View File

@ -446,7 +446,8 @@ class ReportDialog(ManagedWindow):
hid = self.style_name hid = self.style_name
if hid[-4:] == ".xml": if hid[-4:] == ".xml":
hid = hid[0:-4] hid = hid[0:-4]
self.target_fileentry = FileEntry(hid, _("Save As"), parent=self.window) self.target_fileentry = FileEntry(hid, _("Save As"), # parent-OK
parent=self.window)
spath = self.get_default_directory() spath = self.get_default_directory()
self.target_fileentry.set_filename(spath) self.target_fileentry.set_filename(spath)
# need any labels at top: # need any labels at top:
@ -729,7 +730,8 @@ def report(dbstate, uistate, person, report_class, options_class,
# if str(msg).startswith("'NoneType' object has no attribute"): # if str(msg).startswith("'NoneType' object has no attribute"):
# # "'NoneType' object has no attribute ..." usually means # # "'NoneType' object has no attribute ..." usually means
# # database corruption # # database corruption
# RunDatabaseRepair(str(msg)) # no-parent # RunDatabaseRepair(str(msg),
# parent=self.window) # parent-OK
# else: # else:
# raise # raise
raise raise

View File

@ -32,8 +32,6 @@ Paragraph/Font style editor
# Python modules # Python modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
import logging import logging
log = logging.getLogger(".") log = logging.getLogger(".")
import re import re
@ -50,6 +48,8 @@ from gi.repository import Gtk, Gdk
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from gramps.gen.plug.docgen import (StyleSheet, FONT_SERIF, FONT_SANS_SERIF, from gramps.gen.plug.docgen import (StyleSheet, FONT_SERIF, FONT_SANS_SERIF,
PARA_ALIGN_RIGHT, PARA_ALIGN_CENTER, PARA_ALIGN_LEFT, PARA_ALIGN_RIGHT, PARA_ALIGN_CENTER, PARA_ALIGN_LEFT,
PARA_ALIGN_JUSTIFY, ParagraphStyle, TableStyle, TableCellStyle, PARA_ALIGN_JUSTIFY, ParagraphStyle, TableStyle, TableCellStyle,
@ -81,6 +81,8 @@ class StyleListDisplay:
self.sheetlist = stylesheetlist self.sheetlist = stylesheetlist
self.parent_window = parent_window
self.top = Glade(toplevel='styles') self.top = Glade(toplevel='styles')
self.window = self.top.toplevel self.window = self.top.toplevel
@ -136,7 +138,8 @@ class StyleListDisplay:
self.sheetlist.save() self.sheetlist.save()
except IOError as msg: except IOError as msg:
from ...dialog import ErrorDialog from ...dialog import ErrorDialog
ErrorDialog(_("Error saving stylesheet"), str(msg)) # no-parent ErrorDialog(_("Error saving stylesheet"), str(msg), # parent-OK
parent=self.parent_window)
except: except:
log.error("Failed to save stylesheet", exc_info=True) log.error("Failed to save stylesheet", exc_info=True)

View File

@ -27,8 +27,6 @@
# Python modules # Python modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
import logging import logging
log = logging.getLogger(".") log = logging.getLogger(".")
@ -37,6 +35,8 @@ log = logging.getLogger(".")
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.const import TOOL_OPTIONS from gramps.gen.const import TOOL_OPTIONS
from gramps.gen.display.name import displayer as name_displayer from gramps.gen.display.name import displayer as name_displayer
from gramps.gen.errors import WindowActiveError from gramps.gen.errors import WindowActiveError
@ -132,10 +132,10 @@ class ActivePersonTool(Tool):
if not uistate.get_active('Person'): if not uistate.get_active('Person'):
# TODO: should we replace this with a callback? # TODO: should we replace this with a callback?
from ..dialog import ErrorDialog from ..dialog import ErrorDialog
ErrorDialog(_('Active person has not been set'), # parent-OK
ErrorDialog(_('Active person has not been set'), # no-parent
_('You must select an active person for this ' _('You must select an active person for this '
'tool to work properly.')) 'tool to work properly.'),
parent=uistate.window)
self.fail = True self.fail = True
return return

View File

@ -29,8 +29,6 @@ Handles the Tip of the Day dialog
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from xml.parsers.expat import ParserCreate, ExpatError from xml.parsers.expat import ParserCreate, ExpatError
from random import Random from random import Random
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
import os import os
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -44,6 +42,8 @@ import os
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.const import IMAGE_DIR, TIP_DATA from gramps.gen.const import IMAGE_DIR, TIP_DATA
from gramps.gen.config import config from gramps.gen.config import config
from .managedwindow import ManagedWindow from .managedwindow import ManagedWindow
@ -82,9 +82,10 @@ class TipOfDay(ManagedWindow):
tparser = TipParser() tparser = TipParser()
except (IOError,ExpatError) as e: except (IOError,ExpatError) as e:
self.close() self.close()
ErrorDialog( # no-parent ErrorDialog( # parent-OK
_("Failed to display tip of the day"), _("Failed to display tip of the day"),
_("Unable to read the tips from external file.\n\n%s")%e) _("Unable to read the tips from external file.\n\n%s") % e,
parent=uistate.window)
return return
self.tip_list = tparser.get() self.tip_list = tparser.get()

View File

@ -38,6 +38,7 @@ from gramps.gen import user
from .utils import ProgressMeter from .utils import ProgressMeter
from .dialog import (WarningDialog, ErrorDialog, DBErrorDialog, from .dialog import (WarningDialog, ErrorDialog, DBErrorDialog,
RunDatabaseRepair, InfoDialog, QuestionDialog2) RunDatabaseRepair, InfoDialog, QuestionDialog2)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# User class # User class
@ -175,7 +176,7 @@ class User(user.User):
else: else:
RunDatabaseRepair(error, parent=None) # parent-OK RunDatabaseRepair(error, parent=None) # parent-OK
def info(self, msg1, infotext, parent=None, monospaced=False): def info(self, msg1, infotext, parent=None, monospaced=False): # parent-OK
""" """
Calls the GUI InfoDialog Calls the GUI InfoDialog
""" """

View File

@ -31,8 +31,6 @@ import os
import sys import sys
import subprocess import subprocess
import threading import threading
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
# gtk is not included here, because this file is currently imported # gtk is not included here, because this file is currently imported
# by code that needs to run without the DISPLAY variable (eg, in # by code that needs to run without the DISPLAY variable (eg, in
# the cli only). # the cli only).
@ -52,6 +50,8 @@ from gi.repository import GLib
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.lib.person import Person from gramps.gen.lib.person import Person
from gramps.gen.constfunc import has_display, is_quartz, mac, win from gramps.gen.constfunc import has_display, is_quartz, mac, win
from gramps.gen.config import config from gramps.gen.config import config
@ -586,8 +586,9 @@ def edit_object(dbstate, uistate, reftype, ref):
"alone") "alone")
from .dialog import WarningDialog from .dialog import WarningDialog
WarningDialog(_("Cannot open new citation editor"), # no-parent WarningDialog(_("Cannot open new citation editor"), # parent-OK
blocked_text) blocked_text,
parent=uistate.window)
elif reftype == 'Place': elif reftype == 'Place':
try: try:
place = dbstate.db.get_place_from_handle(ref) place = dbstate.db.get_place_from_handle(ref)

View File

@ -429,12 +429,15 @@ class CitationBookmarks(ListBookmarks):
# more comprehensive solution is needed in the long term. See also # more comprehensive solution is needed in the long term. See also
# change_active in CitatinTreeView # change_active in CitatinTreeView
from gramps.gui.dialog import WarningDialog from gramps.gui.dialog import WarningDialog
WarningDialog(_("Cannot bookmark this reference"), # no-parent WarningDialog( # parent-OK
"Only Citations can be bookmarked in this view. " _("Cannot bookmark this reference"),
"You are probably trying to bookmark a Source in the " # FIXME should this next string be translated?
"Citation Tree View. In this view, only Citations " "Only Citations can be bookmarked in this view. "
"can be bookmarked. To bookmark a Source, switch to " "You are probably trying to bookmark a Source in the "
"the Source View") "Citation Tree View. In this view, only Citations "
"can be bookmarked. To bookmark a Source, switch to "
"the Source View",
parent=self.uistate.window)
def connect_signals(self): def connect_signals(self):
self.dbstate.db.connect('citation-delete', self.remove_handles) self.dbstate.db.connect('citation-delete', self.remove_handles)

View File

@ -50,6 +50,8 @@ from gi.repository import Pango
# Gramps # Gramps
# #
#---------------------------------------------------------------- #----------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from .pageview import PageView from .pageview import PageView
from .navigationview import NavigationView from .navigationview import NavigationView
from ..actiongroup import ActionGroup from ..actiongroup import ActionGroup
@ -63,8 +65,6 @@ from gramps.gen.utils.debug import profile
from gramps.gen.utils.string import data_recover_msg from gramps.gen.utils.string import data_recover_msg
from ..dialog import QuestionDialog, QuestionDialog2 from ..dialog import QuestionDialog, QuestionDialog2
from ..editors import FilterEditor from ..editors import FilterEditor
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from ..ddtargets import DdTargets from ..ddtargets import DdTargets
from ..plug.quick import create_quickreport_menu, create_web_connect_menu from ..plug.quick import create_quickreport_menu, create_web_connect_menu
from ..utils import is_right_click from ..utils import is_right_click
@ -445,10 +445,10 @@ class ListView(NavigationView):
self.bookmarks.add(mlist[0]) self.bookmarks.add(mlist[0])
else: else:
from ..dialog import WarningDialog from ..dialog import WarningDialog
WarningDialog( # no-parent WarningDialog(_("Could Not Set a Bookmark"), # parent-OK
_("Could Not Set a Bookmark"), _("A bookmark could not be set because "
_("A bookmark could not be set because " "nothing was selected."),
"nothing was selected.")) parent=self.uistate.window)
#################################################################### ####################################################################
# #
@ -537,12 +537,13 @@ class ListView(NavigationView):
""" """
prompt = True prompt = True
if len(self.selected_handles()) > 1: if len(self.selected_handles()) > 1:
q = QuestionDialog2( # no-parent q = QuestionDialog2( # parent-OK
_("Multiple Selection Delete"), _("Multiple Selection Delete"),
_("More than one item has been selected for deletion. " _("More than one item has been selected for deletion. "
"Select the option indicating how to delete the items:"), "Select the option indicating how to delete the items:"),
_("Delete All"), _("Delete All"),
_("Confirm Each Delete")) _("Confirm Each Delete"),
parent=self.uistate.window)
prompt = not q.run() prompt = not q.run()
if not prompt: if not prompt:
@ -563,8 +564,9 @@ class ListView(NavigationView):
#if descr == "": #if descr == "":
descr = object.get_gramps_id() descr = object.get_gramps_id()
self.uistate.set_busy_cursor(True) self.uistate.set_busy_cursor(True)
QuestionDialog(_('Delete %s?') % descr, msg, # no-parent QuestionDialog(_('Delete %s?') % descr, msg, # parent-OK
_('_Delete Item'), query.query_response) _('_Delete Item'), query.query_response,
parent=self.uistate.window)
self.uistate.set_busy_cursor(False) self.uistate.set_busy_cursor(False)
else: else:
query.query_response() query.query_response()

View File

@ -46,10 +46,10 @@ from gi.repository import Gtk
# Gramps # Gramps
# #
#---------------------------------------------------------------- #----------------------------------------------------------------
from .pageview import PageView
from ..actiongroup import ActionGroup
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext _ = glocale.translation.sgettext
from .pageview import PageView
from ..actiongroup import ActionGroup
from gramps.gen.utils.db import navigation_label from gramps.gen.utils.db import navigation_label
from gramps.gen.constfunc import mod_key from gramps.gen.constfunc import mod_key
@ -252,10 +252,11 @@ class NavigationView(PageView):
_("%s has been bookmarked") % name) _("%s has been bookmarked") % name)
else: else:
from ..dialog import WarningDialog from ..dialog import WarningDialog
WarningDialog( # no-parent WarningDialog( # parent-OK
_("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 edit_bookmarks(self, obj): def edit_bookmarks(self, obj):
""" """

View File

@ -486,12 +486,13 @@ class OrganizeTagsDialog:
tag_handle = store.get_value(iter_, 1) tag_handle = store.get_value(iter_, 1)
tag_name = store.get_value(iter_, 2) tag_name = store.get_value(iter_, 2)
yes_no = QuestionDialog2( # no-parent yes_no = QuestionDialog2( # parent-OK
_("Remove tag '%s'?") % tag_name, _("Remove tag '%s'?") % tag_name,
_("The tag definition will be removed. " _("The tag definition will be removed. The tag will be also "
"The tag will be also removed from all objects in the database."), "removed from all objects in the database."),
_("Yes"), _("Yes"),
_("No")) _("No"),
parent=self.parent_window)
prompt = yes_no.run() prompt = yes_no.run()
if prompt: if prompt:
@ -582,9 +583,9 @@ class EditTag:
self.tag.set_color(hexval) self.tag.set_color(hexval)
if not self.tag.get_name(): if not self.tag.get_name():
ErrorDialog( # no-parent ErrorDialog(_("Cannot save tag"), # parent-OK
_("Cannot save tag"), _("The tag name cannot be empty"),
_("The tag name cannot be empty")) parent=self.parent_window)
return return
if not self.tag.get_handle(): if not self.tag.get_handle():

View File

@ -37,8 +37,6 @@ LOG = logging.getLogger('.grampletbar')
# Python modules # Python modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
import time import time
import os import os
import configparser import configparser
@ -55,6 +53,8 @@ from gi.repository import Gtk
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.const import URL_MANUAL_PAGE, VERSION_DIR from gramps.gen.const import URL_MANUAL_PAGE, VERSION_DIR
from gramps.gen.config import config from gramps.gen.config import config
from gramps.gen.constfunc import win from gramps.gen.constfunc import win
@ -541,11 +541,13 @@ class GrampletBar(Gtk.Notebook):
""" """
Called when restore defaults is clicked from the context menu. Called when restore defaults is clicked from the context menu.
""" """
QuestionDialog(_("Restore to defaults?"), # no-parent QuestionDialog(
_("Restore to defaults?"), # parent-OK
_("The gramplet bar will be restored to contain its default " _("The gramplet bar will be restored to contain its default "
"gramplets. This action cannot be undone."), "gramplets. This action cannot be undone."),
_("OK"), _("OK"),
self.restore) self.restore,
parent=self.uistate.window)
def get_config_funcs(self): def get_config_funcs(self):
""" """

View File

@ -77,7 +77,7 @@ SEPARATION_PAT = '&&'
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Latex Article Template # LaTeX Article Template
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -407,20 +407,20 @@ _LATEX_TEMPLATE = '''%
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# These tables correlate font sizes to Latex. The first table contains # These tables correlate font sizes to LaTeX. The first table contains
# typical font sizes in points. The second table contains the standard # typical font sizes in points. The second table contains the standard
# Latex font size names. Since we use bisect to map the first table to the # LaTeX font size names. Since we use bisect to map the first table to the
# second, we are guaranteed that any font less than 6 points is 'tiny', fonts # second, we are guaranteed that any font less than 6 points is 'tiny', fonts
# from 6-7 points are 'script', etc. and fonts greater than or equal to 22 # from 6-7 points are 'script', etc. and fonts greater than or equal to 22
# are considered 'Huge'. Note that fonts from 12-13 points are not given a # are considered 'Huge'. Note that fonts from 12-13 points are not given a
# Latex font size name but are considered "normal." # LaTeX font size name but are considered "normal."
_FONT_SIZES = [6, 8, 10, 12, 14, 16, 18, 20, 22] _FONT_SIZES = [6, 8, 10, 12, 14, 16, 18, 20, 22]
_FONT_NAMES = ['tiny', 'scriptsize', 'footnotesize', 'small', '', _FONT_NAMES = ['tiny', 'scriptsize', 'footnotesize', 'small', '',
'large', 'Large', 'LARGE', 'huge', 'Huge'] 'large', 'Large', 'LARGE', 'huge', 'Huge']
def map_font_size(fontsize): def map_font_size(fontsize):
""" Map font size in points to Latex font size """ """ Map font size in points to LaTeX font size """
return _FONT_NAMES[bisect(_FONT_SIZES, fontsize)] return _FONT_NAMES[bisect(_FONT_SIZES, fontsize)]
@ -545,7 +545,7 @@ def latexescapeverbatim(text):
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class LateXBackend(DocBackend): class LaTeXBackend(DocBackend):
""" """
Implementation of docbackend for latex docs. Implementation of docbackend for latex docs.
File and File format management for latex docs File and File format management for latex docs
@ -570,13 +570,13 @@ class LateXBackend(DocBackend):
def setescape(self, preformatted=False): def setescape(self, preformatted=False):
""" """
Latex needs two different escape functions depending on the type. LaTeX needs two different escape functions depending on the type.
This function allows to switch the escape function This function allows to switch the escape function
""" """
if not preformatted: if not preformatted:
LateXBackend.ESCAPE_FUNC = lambda x: latexescape LaTeXBackend.ESCAPE_FUNC = lambda x: latexescape
else: else:
LateXBackend.ESCAPE_FUNC = lambda x: latexescapeverbatim LaTeXBackend.ESCAPE_FUNC = lambda x: latexescapeverbatim
def _create_xmltag(self, type, value): def _create_xmltag(self, type, value):
""" """
@ -949,7 +949,7 @@ class LaTeXDoc(BaseDoc, TextDoc):
def open(self, filename): def open(self, filename):
"""Opens the specified file, making sure that it has the """Opens the specified file, making sure that it has the
extension of .tex""" extension of .tex"""
self._backend = LateXBackend(filename) self._backend = LaTeXBackend(filename)
self._backend.open() self._backend.open()
# Font size control seems to be limited. For now, ignore # Font size control seems to be limited. For now, ignore

View File

@ -2779,7 +2779,7 @@ class GedcomParser(UpdateCallback):
parent_window = self.user.uistate.window parent_window = self.user.uistate.window
else: else:
parent_window = None parent_window = None
self.user.info(message, "".join(self.errors), self.user.info(message, "".join(self.errors), # parent-OK
parent=parent_window, monospaced=True) parent=parent_window, monospaced=True)
def __clean_up(self): def __clean_up(self):

View File

@ -51,7 +51,7 @@ from gramps.gen.db import DbTxn
class PopulateSources(tool.Tool, ManagedWindow): class PopulateSources(tool.Tool, ManagedWindow):
""" """
Gramplet that populates the database with sources and citations. Tool that populates the database with sources and citations.
""" """
def __init__(self, dbstate, user, options_class, name, callback=None): def __init__(self, dbstate, user, options_class, name, callback=None):
@ -67,8 +67,9 @@ class PopulateSources(tool.Tool, ManagedWindow):
if response == Gtk.ResponseType.ACCEPT: if response == Gtk.ResponseType.ACCEPT:
self.on_ok_clicked() self.on_ok_clicked()
OkDialog('Data generated', # no-parent OkDialog('Data generated', # parent-OK
"The requested sources and citations were generated") "The requested sources and citations were generated",
parent=uistate.window)
self.close() self.close()

View File

@ -28,8 +28,6 @@
# Standard python modules # Standard python modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -44,6 +42,8 @@ from gi.repository import Gtk
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from gramps.gen.display.name import displayer as name_displayer from gramps.gen.display.name import displayer as name_displayer
from gramps.gui.managedwindow import ManagedWindow from gramps.gui.managedwindow import ManagedWindow
from gramps.gui.views.treemodels import PeopleBaseModel, PersonTreeModel from gramps.gui.views.treemodels import PeopleBaseModel, PersonTreeModel
@ -146,9 +146,10 @@ class RelCalc(tool.Tool, ManagedWindow):
if not self.person: if not self.person:
self.window.hide() self.window.hide()
ErrorDialog(_('Active person has not been set'), # no-parent ErrorDialog(_('Active person has not been set'), # parent-OK
_('You must select an active person for this ' _('You must select an active person for this '
'tool to work properly.')) 'tool to work properly.'),
parent=uistate.window)
self.close() self.close()
return return

View File

@ -689,7 +689,8 @@ class PedigreeView(NavigationView):
else: else:
self.rebuild_trees(None) self.rebuild_trees(None)
except AttributeError as msg: except AttributeError as msg:
RunDatabaseRepair(str(msg)) # no-parent RunDatabaseRepair(str(msg), # parent-OK
parent=self.uistate.window)
def _connect_db_signals(self): def _connect_db_signals(self):
""" """
@ -1496,8 +1497,9 @@ class PedigreeView(NavigationView):
try: try:
alive = probably_alive(person, self.dbstate.db) alive = probably_alive(person, self.dbstate.db)
except RuntimeError: except RuntimeError:
ErrorDialog(_('Relationship loop detected'), # no-parent ErrorDialog(_('Relationship loop detected'), # parent-OK
_('A person was found to be his/her own ancestor.')) _('A person was found to be his/her own ancestor.'),
parent=self.uistate.window)
alive = False alive = False
lst[index] = [person, val, None, alive, None] lst[index] = [person, val, None, alive, None]

View File

@ -27,9 +27,6 @@ Relationship View
# Python modules # Python modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
ngettext = glocale.translation.ngettext # else "nearby" comments are ignored
from html import escape from html import escape
import pickle import pickle
@ -55,6 +52,9 @@ from gi.repository import Pango
# Gramps Modules # Gramps Modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
ngettext = glocale.translation.ngettext # else "nearby" comments are ignored
from gramps.gen.lib import (ChildRef, EventRoleType, EventType, Family, from gramps.gen.lib import (ChildRef, EventRoleType, EventType, Family,
FamilyRelType, Name, Person, Surname) FamilyRelType, Name, Person, Surname)
from gramps.gen.lib.date import Today from gramps.gen.lib.date import Today
@ -473,7 +473,8 @@ class RelationshipView(NavigationView):
exc = traceback.format_exc() exc = traceback.format_exc()
_LOG.error(str(msg) +"\n" + exc) _LOG.error(str(msg) +"\n" + exc)
from gramps.gui.dialog import RunDatabaseRepair from gramps.gui.dialog import RunDatabaseRepair
RunDatabaseRepair(str(msg)) # no-parent RunDatabaseRepair(str(msg), # parent-OK
parent=self.uistate.window)
self.redrawing = False self.redrawing = False
return True return True
@ -1350,9 +1351,10 @@ class RelationshipView(NavigationView):
family = self.dbstate.db.get_family_from_handle(family_handle) family = self.dbstate.db.get_family_from_handle(family_handle)
if family is None: if family is None:
from gramps.gui.dialog import WarningDialog from gramps.gui.dialog import WarningDialog
WarningDialog( # no-parent WarningDialog( # parent-OK
_('Broken family detected'), _('Broken family detected'),
_('Please run the Check and Repair Database tool')) _('Please run the Check and Repair Database tool'),
parent=self.uistate.window)
return return
father_handle = family.get_father_handle() father_handle = family.get_father_handle()