Database saving
svn: r2927
This commit is contained in:
parent
9b0827745c
commit
f60a720646
@ -369,6 +369,7 @@ class EditPlace:
|
|||||||
self.gallery_ok = 1
|
self.gallery_ok = 1
|
||||||
self.update_lists()
|
self.update_lists()
|
||||||
|
|
||||||
|
self.db.commit_place(self.place)
|
||||||
if self.callback:
|
if self.callback:
|
||||||
self.callback(self.place)
|
self.callback(self.place)
|
||||||
|
|
||||||
|
@ -324,6 +324,7 @@ class EditSource:
|
|||||||
|
|
||||||
self.gallery_ok = 1
|
self.gallery_ok = 1
|
||||||
|
|
||||||
|
self.db.commit_source(self.source)
|
||||||
if self.callback:
|
if self.callback:
|
||||||
self.callback(self.source)
|
self.callback(self.source)
|
||||||
self.close(obj)
|
self.close(obj)
|
||||||
|
@ -944,6 +944,7 @@ class GlobalMediaProperties:
|
|||||||
"on_update_attr_clicked" : self.on_update_attr_clicked,
|
"on_update_attr_clicked" : self.on_update_attr_clicked,
|
||||||
"on_help_clicked" : self.on_help_clicked,
|
"on_help_clicked" : self.on_help_clicked,
|
||||||
})
|
})
|
||||||
|
|
||||||
self.redraw_attr_list()
|
self.redraw_attr_list()
|
||||||
self.display_refs()
|
self.display_refs()
|
||||||
|
|
||||||
@ -1012,7 +1013,8 @@ class GlobalMediaProperties:
|
|||||||
if o.get_reference_id() == self.object.get_id():
|
if o.get_reference_id() == self.object.get_id():
|
||||||
self.refmodel.add([_("Person"),p.get_id(),GrampsCfg.nameof(p)])
|
self.refmodel.add([_("Person"),p.get_id(),GrampsCfg.nameof(p)])
|
||||||
any = 1
|
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():
|
for o in p.get_media_list():
|
||||||
if o.get_reference_get_id() == self.object.get_id():
|
if o.get_reference_get_id() == self.object.get_id():
|
||||||
self.refmodel.add([_("Family"),p.get_id(),Utils.family_name(p,self.db)])
|
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()
|
list_store, iter = self.selection.get_selected()
|
||||||
if iter:
|
if iter:
|
||||||
id = list_store.get_value(iter,1)
|
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)
|
ImageSelect.GlobalMediaProperties(self.db,object,self.load_media)
|
||||||
|
|
||||||
def on_delete_clicked(self,obj):
|
def on_delete_clicked(self,obj):
|
||||||
|
@ -61,8 +61,8 @@ def import_media_object(filename,path,base):
|
|||||||
|
|
||||||
type = Utils.get_mime_type(filename)
|
type = Utils.get_mime_type(filename)
|
||||||
if type[0:5] == "image":
|
if type[0:5] == "image":
|
||||||
name = "%s/%s%s" % (path,base,ext)
|
name = "%s/%s%s" % (os.path.dirname(path),base,ext)
|
||||||
thumb = "%s/.thumb" % (path)
|
thumb = "%s/.thumb" % (os.path.dirname(path))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not os.path.exists(thumb):
|
if not os.path.exists(thumb):
|
||||||
|
@ -428,13 +428,13 @@ def find_icon(mtype):
|
|||||||
return const.icon
|
return const.icon
|
||||||
|
|
||||||
def get_mime_type(file):
|
def get_mime_type(file):
|
||||||
type = gnome.vfs.get_mime_type(file)
|
type = grampslib.gnome_vfs_mime_type_from_name(file)
|
||||||
if type:
|
if type:
|
||||||
return type
|
return type
|
||||||
return "unknown"
|
return "unknown"
|
||||||
|
|
||||||
def get_mime_description(type):
|
def get_mime_description(type):
|
||||||
value = gnome.vfs.mime_get_description(type)
|
value = grampslib.gnome_vfs_mime_get_description(type)
|
||||||
if value:
|
if value:
|
||||||
return value
|
return value
|
||||||
return ""
|
return ""
|
||||||
@ -455,7 +455,7 @@ def thumb_path(dir,mobj):
|
|||||||
type = mobj.get_mime_type()
|
type = mobj.get_mime_type()
|
||||||
|
|
||||||
if type[0:5] == "image":
|
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:
|
try:
|
||||||
if RelImage.check_thumb(mobj.get_path(),thumb,const.thumbScale):
|
if RelImage.check_thumb(mobj.get_path(),thumb,const.thumbScale):
|
||||||
return thumb
|
return thumb
|
||||||
|
@ -756,18 +756,9 @@ class Gramps:
|
|||||||
|
|
||||||
def on_exit_activate(self,obj):
|
def on_exit_activate(self,obj):
|
||||||
"""Prompt to save on exit if needed"""
|
"""Prompt to save on exit if needed"""
|
||||||
if Utils.wasModified():
|
self.delete_abandoned_photos()
|
||||||
self.delobj = obj
|
self.db.close()
|
||||||
SaveDialog(_('Save Changes Made to the Database?'),
|
gtk.mainquit()
|
||||||
_("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()
|
|
||||||
|
|
||||||
def save_query(self):
|
def save_query(self):
|
||||||
"""Catch the reponse to the save on exit question"""
|
"""Catch the reponse to the save on exit question"""
|
||||||
@ -781,14 +772,11 @@ class Gramps:
|
|||||||
self.on_save_activate_quit()
|
self.on_save_activate_quit()
|
||||||
self.delete_abandoned_photos()
|
self.delete_abandoned_photos()
|
||||||
self.db.close()
|
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()
|
||||||
if GrampsCfg.lastfile:
|
|
||||||
self.delete_autosave(GrampsCfg.lastfile)
|
|
||||||
gtk.mainquit()
|
gtk.mainquit()
|
||||||
|
|
||||||
def close_noquit(self):
|
def close_noquit(self):
|
||||||
@ -797,7 +785,6 @@ class Gramps:
|
|||||||
self.db.close()
|
self.db.close()
|
||||||
if GrampsCfg.lastfile:
|
if GrampsCfg.lastfile:
|
||||||
self.delete_autosave(GrampsCfg.lastfile)
|
self.delete_autosave(GrampsCfg.lastfile)
|
||||||
Utils.clearModified()
|
|
||||||
|
|
||||||
def delete_abandoned_photos(self):
|
def delete_abandoned_photos(self):
|
||||||
"""
|
"""
|
||||||
@ -888,7 +875,6 @@ class Gramps:
|
|||||||
self.topWindow.set_title("GRAMPS")
|
self.topWindow.set_title("GRAMPS")
|
||||||
self.active_person = None
|
self.active_person = None
|
||||||
|
|
||||||
Utils.clearModified()
|
|
||||||
Utils.clear_timer()
|
Utils.clear_timer()
|
||||||
self.change_active_person(None)
|
self.change_active_person(None)
|
||||||
self.people_view.clear()
|
self.people_view.clear()
|
||||||
@ -1145,7 +1131,6 @@ class Gramps:
|
|||||||
filename = os.path.normpath(os.path.abspath(filename))
|
filename = os.path.normpath(os.path.abspath(filename))
|
||||||
self.status_text(_("Saving %s ...") % filename)
|
self.status_text(_("Saving %s ...") % filename)
|
||||||
|
|
||||||
Utils.clearModified()
|
|
||||||
Utils.clear_timer()
|
Utils.clear_timer()
|
||||||
|
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
@ -1386,69 +1371,33 @@ class Gramps:
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
def on_open_activate(self,obj):
|
def on_open_activate(self,obj):
|
||||||
if Utils.wasModified():
|
wFs = gtk.glade.XML(const.revisionFile, "dbopen","gramps")
|
||||||
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'))
|
|
||||||
|
|
||||||
dbname = wFs.get_widget("dbname")
|
self.dbopen_fs = wFs.get_widget("dbopen")
|
||||||
getoldrev = wFs.get_widget("getoldrev")
|
|
||||||
self.dbopen_fs.set_data("dbname",dbname)
|
Utils.set_titles(self.dbopen_fs, wFs.get_widget('title'),
|
||||||
dbname.set_default_path(GrampsCfg.db_dir)
|
_('Open a database'))
|
||||||
dbname.set_filename(GrampsCfg.db_dir)
|
|
||||||
dbname.gtk_entry().set_position(len(GrampsCfg.db_dir))
|
dbname = wFs.get_widget("dbname")
|
||||||
|
getoldrev = wFs.get_widget("getoldrev")
|
||||||
self.dbopen_fs.set_data("getoldrev",getoldrev)
|
self.dbopen_fs.set_data("dbname",dbname)
|
||||||
getoldrev.set_sensitive(GrampsCfg.usevc)
|
dbname.set_default_path(GrampsCfg.db_dir)
|
||||||
self.dbopen_fs.set_transient_for(self.topWindow)
|
dbname.set_filename(GrampsCfg.db_dir)
|
||||||
self.dbopen_fs.show()
|
dbname.gtk_entry().set_position(len(GrampsCfg.db_dir))
|
||||||
self.dbopen_button = self.dbopen_fs.run()
|
|
||||||
if self.dbopen_button == gtk.RESPONSE_OK:
|
self.dbopen_fs.set_data("getoldrev",getoldrev)
|
||||||
self.on_ok_button1_clicked(self.dbopen_fs)
|
getoldrev.set_sensitive(GrampsCfg.usevc)
|
||||||
elif self.dbopen_button == gtk.RESPONSE_HELP:
|
self.dbopen_fs.set_transient_for(self.topWindow)
|
||||||
self.on_help_dbopen_clicked(obj)
|
self.dbopen_fs.show()
|
||||||
self.dbopen_fs.destroy()
|
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):
|
def on_revert_activate(self,obj):
|
||||||
|
pass
|
||||||
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()
|
|
||||||
|
|
||||||
def on_save_as_activate(self,obj):
|
def on_save_as_activate(self,obj):
|
||||||
wFs = gtk.glade.XML (const.gladeFile, "fileselection","gramps")
|
wFs = gtk.glade.XML (const.gladeFile, "fileselection","gramps")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user