Prompt to save on Open and Open Example

svn: r1543
This commit is contained in:
Alex Roitman 2003-05-19 18:17:35 +00:00
parent f9ba4fe966
commit 5c7c278e48

View File

@ -632,12 +632,25 @@ class Gramps:
self.db.close() self.db.close()
gtk.mainquit() gtk.mainquit()
def save_query_noquit(self):
"""Catch the reponse to the save question, no quitting"""
self.on_save_activate_quit()
self.delete_abandoned_photos()
self.db.close()
Utils.clearModified()
def quit(self): def quit(self):
"""Catch the reponse to the save on exit question""" """Catch the reponse to the save on exit question"""
self.delete_abandoned_photos() self.delete_abandoned_photos()
self.db.close() self.db.close()
gtk.mainquit() gtk.mainquit()
def close_noquit(self):
"""Close database and delete abandoned photos, no quit"""
self.delete_abandoned_photos()
self.db.close()
Utils.clearModified()
def delete_abandoned_photos(self): def delete_abandoned_photos(self):
""" """
We only want to delete local objects, not external objects, however, we We only want to delete local objects, not external objects, however, we
@ -1373,6 +1386,16 @@ class Gramps:
DisplayTrace.DisplayTrace() DisplayTrace.DisplayTrace()
def on_open_activate(self,obj): def on_open_activate(self,obj):
if Utils.wasModified():
self.delobj = obj
SaveDialog(_('Save Changes Made to the Database?'),
_("Unsaved changes exist in the current database. If you "
"close without saving, the changes you have made will "
"be lost."),
self.close_noquit,
self.save_query_noquit)
if not Utils.wasModified():
wFs = gtk.glade.XML(const.revisionFile, "dbopen") wFs = gtk.glade.XML(const.revisionFile, "dbopen")
wFs.signal_autoconnect({ wFs.signal_autoconnect({
"on_ok_button1_clicked": self.on_ok_button1_clicked, "on_ok_button1_clicked": self.on_ok_button1_clicked,
@ -1902,6 +1925,16 @@ class Gramps:
# self.load_new_person(obj) # self.load_new_person(obj)
def open_example(self,obj): def open_example(self,obj):
if Utils.wasModified():
self.delobj = obj
SaveDialog(_('Save Changes Made to the Database?'),
_("Unsaved changes exist in the current database. If you "
"close without saving, the changes you have made will "
"be lost."),
self.close_noquit,
self.save_query_noquit)
if not Utils.wasModified():
import shutil import shutil
dest = os.path.expanduser("~/.gramps/example") dest = os.path.expanduser("~/.gramps/example")
if not os.path.isdir(dest): if not os.path.isdir(dest):
@ -1919,7 +1952,6 @@ class Gramps:
ErrorDialog(_('Could not create database'), ErrorDialog(_('Could not create database'),
_('The directory ~/.gramps/example could not ' _('The directory ~/.gramps/example could not '
'be created.')) 'be created.'))
try: try:
dir = "%s/share/gramps/example" % const.prefixdir dir = "%s/share/gramps/example" % const.prefixdir
for file in os.listdir(dir): for file in os.listdir(dir):