Database saving
svn: r2927
This commit is contained in:
parent
9b0827745c
commit
f60a720646
@ -369,6 +369,7 @@ class EditPlace:
|
||||
self.gallery_ok = 1
|
||||
self.update_lists()
|
||||
|
||||
self.db.commit_place(self.place)
|
||||
if self.callback:
|
||||
self.callback(self.place)
|
||||
|
||||
|
@ -324,6 +324,7 @@ class EditSource:
|
||||
|
||||
self.gallery_ok = 1
|
||||
|
||||
self.db.commit_source(self.source)
|
||||
if self.callback:
|
||||
self.callback(self.source)
|
||||
self.close(obj)
|
||||
|
@ -944,6 +944,7 @@ class GlobalMediaProperties:
|
||||
"on_update_attr_clicked" : self.on_update_attr_clicked,
|
||||
"on_help_clicked" : self.on_help_clicked,
|
||||
})
|
||||
|
||||
self.redraw_attr_list()
|
||||
self.display_refs()
|
||||
|
||||
@ -1012,7 +1013,8 @@ class GlobalMediaProperties:
|
||||
if o.get_reference_id() == self.object.get_id():
|
||||
self.refmodel.add([_("Person"),p.get_id(),GrampsCfg.nameof(p)])
|
||||
any = 1
|
||||
for p in self.db.get_family_id_map().values():
|
||||
for key in self.db.get_family_keys():
|
||||
p = self.db.find_family_from_id(key)
|
||||
for o in p.get_media_list():
|
||||
if o.get_reference_get_id() == self.object.get_id():
|
||||
self.refmodel.add([_("Family"),p.get_id(),Utils.family_name(p,self.db)])
|
||||
|
@ -281,7 +281,7 @@ class MediaView:
|
||||
list_store, iter = self.selection.get_selected()
|
||||
if iter:
|
||||
id = list_store.get_value(iter,1)
|
||||
object = self.db.get_object(id)
|
||||
object = self.db.find_object_from_id(id)
|
||||
ImageSelect.GlobalMediaProperties(self.db,object,self.load_media)
|
||||
|
||||
def on_delete_clicked(self,obj):
|
||||
|
@ -61,8 +61,8 @@ def import_media_object(filename,path,base):
|
||||
|
||||
type = Utils.get_mime_type(filename)
|
||||
if type[0:5] == "image":
|
||||
name = "%s/%s%s" % (path,base,ext)
|
||||
thumb = "%s/.thumb" % (path)
|
||||
name = "%s/%s%s" % (os.path.dirname(path),base,ext)
|
||||
thumb = "%s/.thumb" % (os.path.dirname(path))
|
||||
|
||||
try:
|
||||
if not os.path.exists(thumb):
|
||||
|
@ -428,13 +428,13 @@ def find_icon(mtype):
|
||||
return const.icon
|
||||
|
||||
def get_mime_type(file):
|
||||
type = gnome.vfs.get_mime_type(file)
|
||||
type = grampslib.gnome_vfs_mime_type_from_name(file)
|
||||
if type:
|
||||
return type
|
||||
return "unknown"
|
||||
|
||||
def get_mime_description(type):
|
||||
value = gnome.vfs.mime_get_description(type)
|
||||
value = grampslib.gnome_vfs_mime_get_description(type)
|
||||
if value:
|
||||
return value
|
||||
return ""
|
||||
@ -455,7 +455,7 @@ def thumb_path(dir,mobj):
|
||||
type = mobj.get_mime_type()
|
||||
|
||||
if type[0:5] == "image":
|
||||
thumb = "%s/.thumb/%s.jpg" % (dir,mobj.get_id())
|
||||
thumb = "%s/.thumb/%s.jpg" % (os.path.dirname(dir),mobj.get_id())
|
||||
try:
|
||||
if RelImage.check_thumb(mobj.get_path(),thumb,const.thumbScale):
|
||||
return thumb
|
||||
|
@ -756,18 +756,9 @@ class Gramps:
|
||||
|
||||
def on_exit_activate(self,obj):
|
||||
"""Prompt to save on exit if needed"""
|
||||
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.quit,
|
||||
self.save_query)
|
||||
else:
|
||||
self.delete_abandoned_photos()
|
||||
self.db.close()
|
||||
gtk.mainquit()
|
||||
self.delete_abandoned_photos()
|
||||
self.db.close()
|
||||
gtk.mainquit()
|
||||
|
||||
def save_query(self):
|
||||
"""Catch the reponse to the save on exit question"""
|
||||
@ -781,14 +772,11 @@ class Gramps:
|
||||
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()
|
||||
if GrampsCfg.lastfile:
|
||||
self.delete_autosave(GrampsCfg.lastfile)
|
||||
gtk.mainquit()
|
||||
|
||||
def close_noquit(self):
|
||||
@ -797,7 +785,6 @@ class Gramps:
|
||||
self.db.close()
|
||||
if GrampsCfg.lastfile:
|
||||
self.delete_autosave(GrampsCfg.lastfile)
|
||||
Utils.clearModified()
|
||||
|
||||
def delete_abandoned_photos(self):
|
||||
"""
|
||||
@ -888,7 +875,6 @@ class Gramps:
|
||||
self.topWindow.set_title("GRAMPS")
|
||||
self.active_person = None
|
||||
|
||||
Utils.clearModified()
|
||||
Utils.clear_timer()
|
||||
self.change_active_person(None)
|
||||
self.people_view.clear()
|
||||
@ -1145,7 +1131,6 @@ class Gramps:
|
||||
filename = os.path.normpath(os.path.abspath(filename))
|
||||
self.status_text(_("Saving %s ...") % filename)
|
||||
|
||||
Utils.clearModified()
|
||||
Utils.clear_timer()
|
||||
|
||||
if os.path.exists(filename):
|
||||
@ -1386,69 +1371,33 @@ class Gramps:
|
||||
return ""
|
||||
|
||||
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","gramps")
|
||||
|
||||
self.dbopen_fs = wFs.get_widget("dbopen")
|
||||
|
||||
Utils.set_titles(self.dbopen_fs, wFs.get_widget('title'),
|
||||
_('Open a database'))
|
||||
wFs = gtk.glade.XML(const.revisionFile, "dbopen","gramps")
|
||||
|
||||
dbname = wFs.get_widget("dbname")
|
||||
getoldrev = wFs.get_widget("getoldrev")
|
||||
self.dbopen_fs.set_data("dbname",dbname)
|
||||
dbname.set_default_path(GrampsCfg.db_dir)
|
||||
dbname.set_filename(GrampsCfg.db_dir)
|
||||
dbname.gtk_entry().set_position(len(GrampsCfg.db_dir))
|
||||
|
||||
self.dbopen_fs.set_data("getoldrev",getoldrev)
|
||||
getoldrev.set_sensitive(GrampsCfg.usevc)
|
||||
self.dbopen_fs.set_transient_for(self.topWindow)
|
||||
self.dbopen_fs.show()
|
||||
self.dbopen_button = self.dbopen_fs.run()
|
||||
if self.dbopen_button == gtk.RESPONSE_OK:
|
||||
self.on_ok_button1_clicked(self.dbopen_fs)
|
||||
elif self.dbopen_button == gtk.RESPONSE_HELP:
|
||||
self.on_help_dbopen_clicked(obj)
|
||||
self.dbopen_fs.destroy()
|
||||
self.dbopen_fs = wFs.get_widget("dbopen")
|
||||
|
||||
Utils.set_titles(self.dbopen_fs, wFs.get_widget('title'),
|
||||
_('Open a database'))
|
||||
|
||||
dbname = wFs.get_widget("dbname")
|
||||
getoldrev = wFs.get_widget("getoldrev")
|
||||
self.dbopen_fs.set_data("dbname",dbname)
|
||||
dbname.set_default_path(GrampsCfg.db_dir)
|
||||
dbname.set_filename(GrampsCfg.db_dir)
|
||||
dbname.gtk_entry().set_position(len(GrampsCfg.db_dir))
|
||||
|
||||
self.dbopen_fs.set_data("getoldrev",getoldrev)
|
||||
getoldrev.set_sensitive(GrampsCfg.usevc)
|
||||
self.dbopen_fs.set_transient_for(self.topWindow)
|
||||
self.dbopen_fs.show()
|
||||
self.dbopen_button = self.dbopen_fs.run()
|
||||
if self.dbopen_button == gtk.RESPONSE_OK:
|
||||
self.on_ok_button1_clicked(self.dbopen_fs)
|
||||
elif self.dbopen_button == gtk.RESPONSE_HELP:
|
||||
self.on_help_dbopen_clicked(obj)
|
||||
self.dbopen_fs.destroy()
|
||||
|
||||
def on_revert_activate(self,obj):
|
||||
|
||||
if self.db.get_save_path() != "":
|
||||
QuestionDialog(_('Revert to last saved database?'),
|
||||
_('Reverting to the last saved database '
|
||||
'will cause all unsaved changes to be lost, and '
|
||||
'the last saved database will be loaded.'),
|
||||
_('_Revert'),
|
||||
self.revert_query)
|
||||
else:
|
||||
WarningDialog(_('Could Not Revert to the Previous Database.'),
|
||||
_('GRAMPS could not find a previous version of '
|
||||
'the database'))
|
||||
|
||||
def revert_query(self):
|
||||
const.personalEvents = const.init_personal_event_list()
|
||||
const.personalAttributes = const.init_personal_attribute_list()
|
||||
const.marriageEvents = const.init_marriage_event_list()
|
||||
const.familyAttributes = const.init_family_attribute_list()
|
||||
const.familyRelations = const.init_family_relation_list()
|
||||
|
||||
file = self.db.get_save_path()
|
||||
self.db.new()
|
||||
self.active_person = None
|
||||
self.place_loaded = 0
|
||||
self.read_file(file)
|
||||
Utils.clearModified()
|
||||
Utils.clear_timer()
|
||||
pass
|
||||
|
||||
def on_save_as_activate(self,obj):
|
||||
wFs = gtk.glade.XML (const.gladeFile, "fileselection","gramps")
|
||||
|
Loading…
Reference in New Issue
Block a user