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() 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,24 +1386,34 @@ class Gramps:
DisplayTrace.DisplayTrace() DisplayTrace.DisplayTrace()
def on_open_activate(self,obj): def on_open_activate(self,obj):
wFs = gtk.glade.XML(const.revisionFile, "dbopen") if Utils.wasModified():
wFs.signal_autoconnect({ self.delobj = obj
"on_ok_button1_clicked": self.on_ok_button1_clicked, SaveDialog(_('Save Changes Made to the Database?'),
"destroy_passed_object": Utils.destroy_passed_object _("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)
fileSelector = wFs.get_widget("dbopen") if not Utils.wasModified():
wFs = gtk.glade.XML(const.revisionFile, "dbopen")
wFs.signal_autoconnect({
"on_ok_button1_clicked": self.on_ok_button1_clicked,
"destroy_passed_object": Utils.destroy_passed_object
})
Utils.set_titles(fileSelector, wFs.get_widget('title'), fileSelector = wFs.get_widget("dbopen")
_('Open a database'))
Utils.set_titles(fileSelector, wFs.get_widget('title'),
_('Open a database'))
dbname = wFs.get_widget("dbname") dbname = wFs.get_widget("dbname")
getoldrev = wFs.get_widget("getoldrev") getoldrev = wFs.get_widget("getoldrev")
fileSelector.set_data("dbname",dbname) fileSelector.set_data("dbname",dbname)
dbname.set_default_path(GrampsCfg.db_dir) dbname.set_default_path(GrampsCfg.db_dir)
fileSelector.set_data("getoldrev",getoldrev) fileSelector.set_data("getoldrev",getoldrev)
getoldrev.set_sensitive(GrampsCfg.usevc) getoldrev.set_sensitive(GrampsCfg.usevc)
fileSelector.show() fileSelector.show()
def on_revert_activate(self,obj): def on_revert_activate(self,obj):
@ -1902,34 +1925,43 @@ class Gramps:
# self.load_new_person(obj) # self.load_new_person(obj)
def open_example(self,obj): def open_example(self,obj):
import shutil if Utils.wasModified():
dest = os.path.expanduser("~/.gramps/example") self.delobj = obj
if not os.path.isdir(dest): SaveDialog(_('Save Changes Made to the Database?'),
try: _("Unsaved changes exist in the current database. If you "
os.mkdir(dest) "close without saving, the changes you have made will "
except IOError,msg: "be lost."),
ErrorDialog(_('Could not create database'), self.close_noquit,
_('The directory ~/.gramps/example could not ' self.save_query_noquit)
'be created.' + '\n' + str(msg) ))
except OSError,msg:
ErrorDialog(_('Could not create database'),
_('The directory ~/.gramps/example could not '
'be created.' + '\n' + str(msg) ))
except:
ErrorDialog(_('Could not create database'),
_('The directory ~/.gramps/example could not '
'be created.'))
try: if not Utils.wasModified():
dir = "%s/share/gramps/example" % const.prefixdir import shutil
for file in os.listdir(dir): dest = os.path.expanduser("~/.gramps/example")
shutil.copy("%s/%s" % (dir,file), dest) if not os.path.isdir(dest):
except IOError,msg: try:
ErrorDialog(_('Example database not created'),str(msg)) os.mkdir(dest)
except OSError,msg: except IOError,msg:
ErrorDialog(_('Example database not created'),str(msg)) ErrorDialog(_('Could not create database'),
_('The directory ~/.gramps/example could not '
self.read_file(dest) 'be created.' + '\n' + str(msg) ))
except OSError,msg:
ErrorDialog(_('Could not create database'),
_('The directory ~/.gramps/example could not '
'be created.' + '\n' + str(msg) ))
except:
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):
shutil.copy("%s/%s" % (dir,file), dest)
except IOError,msg:
ErrorDialog(_('Example database not created'),str(msg))
except OSError,msg:
ErrorDialog(_('Example database not created'),str(msg))
self.read_file(dest)
DARKEN = 1.4 DARKEN = 1.4