Add parent windows to report dialogs
This commit is contained in:
parent
6100a5b7da
commit
43882165cf
@ -493,8 +493,9 @@ class BookSelector(ManagedWindow):
|
|||||||
'%s.\n\n This makes references to the central person '
|
'%s.\n\n This makes references to the central person '
|
||||||
'saved in the book invalid.\n\n'
|
'saved in the book invalid.\n\n'
|
||||||
'Therefore, the central person for each item is being set '
|
'Therefore, the central person for each item is being set '
|
||||||
'to the active person of the currently opened database.' )
|
'to the active person of the currently opened database.')
|
||||||
% book.get_dbname() )
|
% book.get_dbname(),
|
||||||
|
parent=self.window)
|
||||||
|
|
||||||
self.book.clear()
|
self.book.clear()
|
||||||
self.book_model.clear()
|
self.book_model.clear()
|
||||||
@ -591,8 +592,8 @@ class BookSelector(ManagedWindow):
|
|||||||
store, the_iter = self.book_model.get_selected()
|
store, the_iter = self.book_model.get_selected()
|
||||||
if not the_iter:
|
if not the_iter:
|
||||||
WarningDialog(_('No selected book item'),
|
WarningDialog(_('No selected book item'),
|
||||||
_('Please select a book item to configure.')
|
_('Please select a book item to configure.'),
|
||||||
)
|
parent=self.window)
|
||||||
return
|
return
|
||||||
data = self.book_model.get_data(the_iter, list(range(self.book_nr_cols)))
|
data = self.book_model.get_data(the_iter, list(range(self.book_nr_cols)))
|
||||||
row = self.book_model.get_selected_row()
|
row = self.book_model.get_selected_row()
|
||||||
@ -705,7 +706,8 @@ class BookSelector(ManagedWindow):
|
|||||||
BookDialog(self.dbstate, self.uistate,
|
BookDialog(self.dbstate, self.uistate,
|
||||||
self.book, BookOptions)
|
self.book, BookOptions)
|
||||||
else:
|
else:
|
||||||
WarningDialog(_('No items'), _('This book has no items.'))
|
WarningDialog(_('No items'), _('This book has no items.'),
|
||||||
|
parent=self.window)
|
||||||
return
|
return
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
@ -718,8 +720,8 @@ class BookSelector(ManagedWindow):
|
|||||||
if not name:
|
if not name:
|
||||||
WarningDialog(_('No book name'), _(
|
WarningDialog(_('No book name'), _(
|
||||||
'You are about to save away a book with no name.\n\n'
|
'You are about to save away a book with no name.\n\n'
|
||||||
'Please give it a name before saving it away.')
|
'Please give it a name before saving it away.'),
|
||||||
)
|
parent=self.window)
|
||||||
return
|
return
|
||||||
if name in self.book_list.get_book_names():
|
if name in self.book_list.get_book_names():
|
||||||
from ...dialog import QuestionDialog2
|
from ...dialog import QuestionDialog2
|
||||||
@ -729,7 +731,8 @@ class BookSelector(ManagedWindow):
|
|||||||
'book with a name which already exists.'
|
'book with a name which already exists.'
|
||||||
),
|
),
|
||||||
_('Proceed'),
|
_('Proceed'),
|
||||||
_('Cancel'))
|
_('Cancel'),
|
||||||
|
parent=self.window)
|
||||||
if q.run():
|
if q.run():
|
||||||
self.book.set_name(name)
|
self.book.set_name(name)
|
||||||
else:
|
else:
|
||||||
@ -925,7 +928,7 @@ class BookDialog(DocReportDialog):
|
|||||||
try:
|
try:
|
||||||
self.make_book()
|
self.make_book()
|
||||||
except (IOError, OSError) as msg:
|
except (IOError, OSError) as msg:
|
||||||
ErrorDialog(str(msg))
|
ErrorDialog(str(msg), parent=self.window)
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def setup_style_frame(self): pass
|
def setup_style_frame(self): pass
|
||||||
|
@ -26,10 +26,11 @@ from gi.repository import GObject
|
|||||||
from gramps.gen.constfunc import conv_to_unicode, get_curr_dir
|
from gramps.gen.constfunc import conv_to_unicode, get_curr_dir
|
||||||
class FileEntry(Gtk.Box):
|
class FileEntry(Gtk.Box):
|
||||||
""" 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):
|
def __init__(self, defname, title, parent=None):
|
||||||
Gtk.Box.__init__(self)
|
Gtk.Box.__init__(self)
|
||||||
|
|
||||||
self.title = title
|
self.title = title
|
||||||
|
self.parent = parent
|
||||||
self.dir = False
|
self.dir = False
|
||||||
self.__base_path = ""
|
self.__base_path = ""
|
||||||
self.__file_name = ""
|
self.__file_name = ""
|
||||||
@ -54,6 +55,7 @@ class FileEntry(Gtk.Box):
|
|||||||
my_action = Gtk.FileChooserAction.SAVE
|
my_action = Gtk.FileChooserAction.SAVE
|
||||||
|
|
||||||
dialog = Gtk.FileChooserDialog(self.title,
|
dialog = Gtk.FileChooserDialog(self.title,
|
||||||
|
self.parent,
|
||||||
action=my_action,
|
action=my_action,
|
||||||
buttons=(Gtk.STOCK_CANCEL,
|
buttons=(Gtk.STOCK_CANCEL,
|
||||||
Gtk.ResponseType.CANCEL,
|
Gtk.ResponseType.CANCEL,
|
||||||
|
@ -445,7 +445,7 @@ 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"))
|
self.target_fileentry = FileEntry(hid, _("Save As"), 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:
|
||||||
@ -499,8 +499,8 @@ class ReportDialog(ManagedWindow):
|
|||||||
_("You do not have permission to write "
|
_("You do not have permission to write "
|
||||||
"under the directory %s\n\n"
|
"under the directory %s\n\n"
|
||||||
"Please select another directory or correct "
|
"Please select another directory or correct "
|
||||||
"the permissions.") % self.target_path
|
"the permissions.") % self.target_path,
|
||||||
)
|
parent=self.window)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# selected path is an existing file and we need a file
|
# selected path is an existing file and we need a file
|
||||||
@ -509,7 +509,8 @@ class ReportDialog(ManagedWindow):
|
|||||||
_('You can choose to either overwrite the '
|
_('You can choose to either overwrite the '
|
||||||
'file, or change the selected filename.'),
|
'file, or change the selected filename.'),
|
||||||
_('_Overwrite'), None,
|
_('_Overwrite'), None,
|
||||||
_('_Change filename'), None)
|
_('_Change filename'), None,
|
||||||
|
parent=self.window)
|
||||||
|
|
||||||
if a.get_response() == Gtk.ResponseType.YES:
|
if a.get_response() == Gtk.ResponseType.YES:
|
||||||
return None
|
return None
|
||||||
@ -524,8 +525,8 @@ class ReportDialog(ManagedWindow):
|
|||||||
_("You do not have permission to create "
|
_("You do not have permission to create "
|
||||||
"%s\n\n"
|
"%s\n\n"
|
||||||
"Please select another path or correct "
|
"Please select another path or correct "
|
||||||
"the permissions.") % self.target_path
|
"the permissions.") % self.target_path,
|
||||||
)
|
parent=self.window)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
self.set_default_directory(os.path.dirname(self.target_path) + os.sep)
|
self.set_default_directory(os.path.dirname(self.target_path) + os.sep)
|
||||||
@ -651,7 +652,8 @@ def report(dbstate, uistate, person, report_class, options_class,
|
|||||||
ErrorDialog(
|
ErrorDialog(
|
||||||
_('Active person has not been set'),
|
_('Active person has not been set'),
|
||||||
_('You must select an active person for this report to work '
|
_('You must select an active person for this report to work '
|
||||||
'properly.'))
|
'properly.'),
|
||||||
|
parent=uistate.window)
|
||||||
return
|
return
|
||||||
|
|
||||||
if category == CATEGORY_TEXT:
|
if category == CATEGORY_TEXT:
|
||||||
@ -699,14 +701,16 @@ def report(dbstate, uistate, person, report_class, options_class,
|
|||||||
|
|
||||||
except FilterError as msg:
|
except FilterError as msg:
|
||||||
(m1, m2) = msg.messages()
|
(m1, m2) = msg.messages()
|
||||||
ErrorDialog(m1, m2)
|
ErrorDialog(m1, m2, parent=uistate.window)
|
||||||
except IOError as msg:
|
except IOError as msg:
|
||||||
ErrorDialog(_("Report could not be created"), str(msg))
|
ErrorDialog(_("Report could not be created"), str(msg),
|
||||||
|
parent=uistate.window)
|
||||||
except ReportError as msg:
|
except ReportError as msg:
|
||||||
(m1, m2) = msg.messages()
|
(m1, m2) = msg.messages()
|
||||||
ErrorDialog(m1, m2)
|
ErrorDialog(m1, m2, parent=uistate.window)
|
||||||
except DatabaseError as msg:
|
except DatabaseError as msg:
|
||||||
ErrorDialog(_("Report could not be created"), str(msg))
|
ErrorDialog(_("Report could not be created"), str(msg),
|
||||||
|
parent=uistate.window)
|
||||||
# The following except statement will catch all "NoneType" exceptions.
|
# The following except statement will catch all "NoneType" exceptions.
|
||||||
# This is useful for released code where the exception is most likely
|
# This is useful for released code where the exception is most likely
|
||||||
# a corrupt database. But it is less useful for developing new reports
|
# a corrupt database. But it is less useful for developing new reports
|
||||||
|
Loading…
Reference in New Issue
Block a user