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 f3971932bd
commit c4e62d273a

View File

@ -632,12 +632,25 @@ class Gramps:
self.db.close()
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):
"""Catch the reponse to the save on exit question"""
self.delete_abandoned_photos()
self.db.close()
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):
"""
We only want to delete local objects, not external objects, however, we
@ -1373,6 +1386,16 @@ class Gramps:
DisplayTrace.DisplayTrace()
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.signal_autoconnect({
"on_ok_button1_clicked": self.on_ok_button1_clicked,
@ -1902,6 +1925,16 @@ class Gramps:
# self.load_new_person(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
dest = os.path.expanduser("~/.gramps/example")
if not os.path.isdir(dest):
@ -1919,7 +1952,6 @@ class Gramps:
ErrorDialog(_('Could not create database'),
_('The directory ~/.gramps/example could not '
'be created.'))
try:
dir = "%s/share/gramps/example" % const.prefixdir
for file in os.listdir(dir):