* various: Add undo functionality

svn: r3065
This commit is contained in:
Don Allingham 2004-03-30 04:50:24 +00:00
parent feef42099d
commit 8592fa2cc9
25 changed files with 854 additions and 809 deletions

View File

@ -1,3 +1,6 @@
2004-03-29 Don Allingham <dallingham@users.sourceforge.net>
* various: Add undo functionality
2004-03-27 Alex Roitman <shura@alex.neuro.umn.edu>
* src/plugins/rel_it.py: Convert to class.

View File

@ -129,7 +129,9 @@ class AddMediaObject:
if self.update:
self.update()
self.object = mobj
self.db.commit_media_object(mobj)
trans = self.db.start_transaction()
self.db.commit_media_object(mobj,trans)
self.db.add_transaction(trans)
def on_name_changed(self,obj):
"""

View File

@ -217,7 +217,6 @@ class AddSpouse:
self.db.add_person(person)
else:
self.db.add_person_no_map(person,person.get_id())
self.db.build_person_display(person.get_id())
self.addperson(person)
self.update_data(person.get_id())
#self.slist.center_selected()
@ -241,12 +240,14 @@ class AddSpouse:
Utils.destroy_passed_object(obj)
return
trans = self.db.start_transaction()
if not self.active_family:
self.active_family = self.db.new_family()
self.person.add_family_id(self.active_family.get_id())
self.db.commit_person(self.person)
self.db.commit_person(self.person,trans)
spouse.add_family_id(self.active_family.get_id())
self.db.commit_person(spouse)
self.db.commit_person(spouse,trans)
if self.person.get_gender() == RelLib.Person.male:
self.active_family.set_mother_id(spouse.get_id())
@ -255,8 +256,10 @@ class AddSpouse:
self.active_family.set_father_id(spouse.get_id())
self.active_family.set_mother_id(self.person.get_id())
self.active_family.set_relationship(const.save_frel(unicode(self.relation_type.get_text())))
self.db.commit_family(self.active_family)
rtype = const.save_frel(unicode(self.relation_type.get_text()))
self.active_family.set_relationship(rtype)
self.db.commit_family(self.active_family,trans)
self.db.add_transaction(trans)
Utils.destroy_passed_object(obj)
self.update(self.active_family)

View File

@ -293,7 +293,8 @@ class ChooseParents:
def redrawf(self):
"""Redraws the potential father list"""
self.father_model = gtk.TreeModelSort(PeopleModel.PeopleModel(self.db, self.father_filter))
self.father_nsort = PeopleModel.PeopleModel(self.db, self.father_filter)
self.father_model = gtk.TreeModelSort(self.father_nsort)
self.father_list.set_model(self.father_model)
if self.type == "Partners":
self.flabel.set_label("<b>%s</b>" % _("Par_ent"))
@ -302,7 +303,8 @@ class ChooseParents:
def redrawm(self):
"""Redraws the potential mother list"""
self.mother_model = gtk.TreeModelSort(PeopleModel.PeopleModel(self.db, self.mother_filter))
self.mother_nsort = PeopleModel.PeopleModel(self.db, self.mother_filter)
self.mother_model = gtk.TreeModelSort(self.mother_nsort)
self.mother_list.set_model(self.mother_model)
if self.type == "Partners":
self.mlabel.set_label("<b>%s</b>" % _("Pa_rent"))
@ -351,16 +353,18 @@ class ChooseParents:
family.set_mother_id(mother_id)
family.add_child_id(self.person.get_id())
trans = self.db.start_transaction()
if father_id:
father = self.db.find_person_from_id(father_id)
father.add_family_id(family.get_id())
self.db.commit_person(father)
self.db.commit_person(father,trans)
if mother_id:
mother = self.db.find_person_from_id(mother_id)
mother.add_family_id(family.get_id())
self.db.commit_person(mother)
self.db.commit_person(mother,trans)
self.db.commit_family(family)
self.db.commit_family(family,trans)
self.db.add_transaction(trans)
return family
def mother_list_select_row(self,obj):
@ -414,8 +418,13 @@ class ChooseParents:
if len(family_id_list) >= 1:
family = self.db.find_family_from_id(family_id_list[0])
mother_id = family.get_mother_id()
self.mother_selection.select(mother_id)
#self.mother_model.center_selected()
mother = self.db.find_person_from_id(mother_id)
sname = mother.get_primary_name().get_surname()
tpath = self.mother_nsort.on_get_path(sname)
self.mother_list.expand_row(tpath,0)
path = self.mother_nsort.on_get_path(mother_id)
self.mother_selection.select_path(path)
self.mother_list.scroll_to_cell(path,None,1,0.5,0)
def mother_list_select_row(self,obj):
"""Called when a row is selected in the father list. Sets the
@ -432,9 +441,14 @@ class ChooseParents:
family_id_list = self.mother.get_family_id_list()
if len(family_id_list) >= 1:
family = self.db.find_family_from_id(family_id_list[0])
father_id = family.get_father_id()
self.father_selection.select(father_id)
#self.father_model.center_selected()
father_id = family.get_mother_id()
father = self.db.find_person_from_id(father_id)
sname = father.get_primary_name().get_surname()
tpath = self.father_nsort.on_get_path(sname)
self.father_list.expand_row(tpath,0)
path = self.father_nsort.on_get_path(father_id)
self.father_selection.select_path(path)
self.father_list.scroll_to_cell(path,None,1,0.5,0)
def save_parents_clicked(self,obj):
"""
@ -491,7 +505,6 @@ class ChooseParents:
id = self.db.add_person(person)
else:
self.db.add_person_no_map(person,id)
self.db.build_person_display(id)
self.type = const.save_frel(unicode(self.prel.get_text()))
dinfo = self.db.get_person_display(id)
@ -538,12 +551,15 @@ class ChooseParents:
break
else:
self.person.add_parent_family_id(family.get_id(),mother_rel,father_rel)
self.db.commit_person(self.person)
self.db.commit_family(family)
trans = self.db.start_transaction()
self.db.commit_person(self.person,trans)
self.db.commit_family(family,trans)
if self.father:
self.db.commit_person(self.father)
self.db.commit_person(self.father,trans)
if self.mother:
self.db.commit_person(self.mother)
self.db.commit_person(self.mother,trans)
self.db.add_transaction(trans)
class ModifyParents:
def __init__(self,db,person,family_id,family_update,full_update,parent_window=None):

View File

@ -92,7 +92,8 @@ class DbPrompter:
"on_ok_button1_clicked": self.save_ok_button_clicked,
"destroy_passed_object": self.cancel_button_clicked,
})
wFs.get_widget('fileselection').set_title('%s - GRAMPS' % _('Create database'))
filesel = wFs.get_widget('fileselection')
filesel.set_title('%s - GRAMPS' % _('Create database'))
def save_ok_button_clicked(self,obj):
filename = obj.get_filename().encode('iso8859-1')
@ -101,6 +102,18 @@ class DbPrompter:
self.db.read_file(filename)
def open_activate(self):
wFs = gtk.glade.XML (const.gladeFile, "fileselection","gramps")
wFs.signal_autoconnect({
"on_ok_button1_clicked": self.ok_button_clicked,
"destroy_passed_object": self.cancel_button_clicked,
})
self.filesel = wFs.get_widget('fileselection')
self.filesel.set_title('%s - GRAMPS' % _('Open database'))
if GrampsCfg.lastfile:
self.filesel.set_filename(GrampsCfg.lastfile)
return
wFs = gtk.glade.XML(const.revisionFile, "dbopen","gramps")
wFs.signal_autoconnect({
"on_ok_button1_clicked": self.ok_button_clicked,
@ -130,7 +143,7 @@ class DbPrompter:
self.show()
def ok_button_clicked(self,obj):
filename = self.dbname.get_full_path(0)
filename = self.filesel.get_filename()
if not filename:
return

View File

@ -1409,6 +1409,9 @@ class EditPerson:
self.person.set_death_id(self.death.get_id())
def on_apply_person_clicked(self,obj):
trans = self.db.start_transaction()
surname = unicode(self.surname_field.get_text())
suffix = unicode(self.suffix.get_text())
prefix = unicode(self.prefix.get_text())
@ -1424,7 +1427,7 @@ class EditPerson:
self.birth.set_place_id(self.get_place(self.bplace,1))
if idval != self.person.get_id():
m = self.db.get_person_id_map()
m = self.db.get_person_keys()
if not m.has_key(idval):
if m.has_key(self.person.get_id()):
del m[self.person.get_id()]
@ -1476,20 +1479,20 @@ class EditPerson:
self.pdmap[p[0]] = key
if self.orig_birth == None:
self.db.add_event(self.birth)
self.db.add_event(self.birth,trans)
self.person.set_birth_id(self.birth.get_id())
elif not self.orig_birth.are_equal(self.birth):
self.db.commit_event(self.birth)
self.db.commit_event(self.birth,trans)
# Update each of the families child lists to reflect any
# change in ordering due to the new birth date
family = self.person.get_main_parents_family_id()
if (family):
f = self.db.find_family_no_map(family)
f = self.db.find_family_no_map(family,trans)
new_order = self.reorder_child_list(self.person,f.get_child_id_list())
f.set_child_id_list(new_order)
for (family, rel1, rel2) in self.person.get_parent_family_id_list():
f = self.db.find_family_no_map(family)
f = self.db.find_family_no_map(family,trans)
new_order = self.reorder_child_list(self.person,f.get_child_id_list())
f.set_child_id_list(new_order)
@ -1497,10 +1500,10 @@ class EditPerson:
self.death.set_place_id(self.get_place(self.dplace,1))
if self.orig_death == None:
self.db.add_event(self.death)
self.db.add_event(self.death,trans)
self.person.set_death_id(self.death.get_id())
elif not self.orig_death.are_equal(self.death):
self.db.commit_event(self.death)
self.db.commit_event(self.death,trans)
male = self.is_male.get_active()
female = self.is_female.get_active()
@ -1580,10 +1583,10 @@ class EditPerson:
self.update_lists()
if self.callback:
change = (self.orig_surname != surname) or (self.orig_id != idval)
self.callback(self,change)
self.db.commit_person(self.person)
self.callback(self,trans)
self.db.commit_person(self.person, trans)
self.db.add_transaction(trans)
self.close(1)
def get_place(self,field,makenew=0):

View File

@ -369,7 +369,10 @@ class EditPlace:
self.gallery_ok = 1
self.update_lists()
self.db.commit_place(self.place)
trans = self.db.start_transaction()
self.db.commit_place(self.place,trans)
self.db.add_transaction(trans)
if self.callback:
self.callback(self.place)
@ -553,16 +556,25 @@ class DeletePlaceQuery:
self.update = update
def query_response(self):
self.db.remove_place(self.place.get_id())
trans = self.db.start_transaction()
self.db.remove_place(self.place.get_id(),trans)
for key in self.db.get_person_keys():
p = self.db.get_person(key)
for event in [p.get_birth(), p.get_death()] + p.get_event_list():
if event.get_place_id() == self.place:
event.set_place_id(None)
for f in self.db.get_family_id_map().values():
for event in f.get_event_list():
if event.get_place_id() == self.place:
for event_id in [p.get_birth_id(), p.get_death_id()] + p.get_event_list():
event = self.db.find_event_from_id(event_id)
if event and event.get_place_id() == self.place.get_id():
event.set_place_id(None)
self.db.commit_event(event,trans)
for fid in self.db.get_family_keys():
f = self.db.find_family_from_id(fid)
for event_id in f.get_event_list():
event = self.db.find_event_from_id(event_id)
if event and event.get_place_id() == self.place.get_id():
event.set_place_id(None)
self.db.commit_event(event,trans)
self.db.add_transaction(trans)
self.update(None)

View File

@ -326,7 +326,10 @@ class EditSource:
self.gallery_ok = 1
self.db.commit_source(self.source)
trans = self.db.start_transaction()
self.db.commit_source(self.source,trans)
self.db.add_transaction(trans)
if self.callback:
self.callback(self.source)
self.close(obj)
@ -362,42 +365,53 @@ class DelSrcQuery:
m = 1
if m:
object.set_source_reference_list(l)
return m
def query_response(self):
self.db.remove_source_id(self.source.get_id())
trans = self.db.start_transaction()
for key in self.db.get_person_keys():
commit = 0
p = self.db.get_person(key)
for v_id in p.get_event_list() + [p.get_birth_id(), p.get_death_id()]:
v = self.db.find_event_from_id(v_id)
if v:
self.delete_source(v)
commit += self.delete_source(v)
for v in p.get_attribute_list():
self.delete_source(v)
commit += self.delete_source(v)
for v in p.get_alternate_names() + [p.get_primary_name()]:
self.delete_source(v)
commit += self.delete_source(v)
for v in p.get_address_list():
self.delete_source(v)
commit += self.delete_source(v)
if commit > 0:
self.db.commit_person(p,trans)
for p_id in self.db.get_family_keys():
commit = 0
p = self.db.find_family_from_id(p_id)
for v_id in p.get_event_list():
v = self.db.find_event_from_id(v_id)
if v:
self.delete_source(v)
commit += self.delete_source(v)
for v in p.get_attribute_list():
self.delete_source(v)
commit += self.delete_source(v)
if commit > 0:
self.db.commit_family(p,trans)
for p_id in self.db.get_object_keys():
p = self.db.find_object_from_id(p_id)
self.delete_source(p)
if self.delete_source(p):
self.db.commit_media_object(p,trans)
for key in self.db.get_place_id_keys():
p = self.db.find_place_from_id(key)
self.delete_source(self.db.find_place_from_id(key))
if self.delete_source(self.db.find_place_from_id(key)):
self.db.commit_place(p,trans)
self.update(0)
self.db.remove_source_id(self.source.get_id(),trans)
self.db.add_transaction(trans)
self.update()

View File

@ -356,7 +356,9 @@ class EventEditor:
if self.event.get_privacy() != priv:
self.event.set_privacy(priv)
self.parent.lists_changed = 1
self.db.commit_event(self.event)
trans = self.db.start_transaction()
self.db.commit_event(self.event,trans)
self.db.add_transaction(trans)
def on_switch_page(self,obj,a,page):
buf = self.note_field.get_buffer()

View File

@ -87,16 +87,26 @@ class FamilyView:
self.sp_par_arrow = "Down"
self.child_arrow = "Up"
if not already_init:
self.top.get_widget('add_parents2').connect('clicked',self.add_parents_clicked)
self.top.get_widget('del_parents2').connect('clicked',self.del_parents_clicked)
self.top.get_widget('add_spparents2').connect('clicked',self.add_sp_parents)
self.top.get_widget('del_spparents2').connect('clicked',self.del_sp_parents)
self.top.get_widget('fam_back2').connect('clicked',self.child_back)
self.top.get_widget('del_child_btn2').connect('clicked',self.remove_child_clicked)
self.top.get_widget('add_child_btn2').connect('clicked',self.add_child_clicked)
self.top.get_widget('select_child2').connect('clicked',self.select_child_clicked)
self.top.get_widget('ap_parents_btn2').connect('clicked',self.ap_parents_clicked)
self.top.get_widget('sp_parents_btn2').connect('clicked',self.sp_parents_clicked)
self.top.get_widget('add_parents2').connect('clicked',
self.add_parents_clicked)
self.top.get_widget('del_parents2').connect('clicked',
self.del_parents_clicked)
self.top.get_widget('add_spparents2').connect('clicked',
self.add_sp_parents)
self.top.get_widget('del_spparents2').connect('clicked',
self.del_sp_parents)
self.top.get_widget('fam_back2').connect('clicked',
self.child_back)
self.top.get_widget('del_child_btn2').connect('clicked',
self.remove_child_clicked)
self.top.get_widget('add_child_btn2').connect('clicked',
self.add_child_clicked)
self.top.get_widget('select_child2').connect('clicked',
self.select_child_clicked)
self.top.get_widget('ap_parents_btn2').connect('clicked',
self.ap_parents_clicked)
self.top.get_widget('sp_parents_btn2').connect('clicked',
self.sp_parents_clicked)
self.parent.views.get_nth_page(2).show_all()
if self.parent.views.get_current_page() == 1:
self.parent.views.set_current_page(2)
@ -117,16 +127,26 @@ class FamilyView:
self.sp_par_arrow = "Right"
self.child_arrow = "Left"
if not already_init:
self.top.get_widget('add_parents').connect('clicked',self.add_parents_clicked)
self.top.get_widget('del_parents').connect('clicked',self.del_parents_clicked)
self.top.get_widget('add_spparents').connect('clicked',self.add_sp_parents)
self.top.get_widget('del_spparents').connect('clicked',self.del_sp_parents)
self.top.get_widget('fam_back').connect('clicked',self.child_back)
self.top.get_widget('del_child_btn').connect('clicked',self.remove_child_clicked)
self.top.get_widget('add_child_btn').connect('clicked',self.add_child_clicked)
self.top.get_widget('select_child').connect('clicked',self.select_child_clicked)
self.top.get_widget('ap_parents_btn').connect('clicked',self.ap_parents_clicked)
self.top.get_widget('sp_parents_btn').connect('clicked',self.sp_parents_clicked)
self.top.get_widget('add_parents').connect('clicked',
self.add_parents_clicked)
self.top.get_widget('del_parents').connect('clicked',
self.del_parents_clicked)
self.top.get_widget('add_spparents').connect('clicked',
self.add_sp_parents)
self.top.get_widget('del_spparents').connect('clicked',
self.del_sp_parents)
self.top.get_widget('fam_back').connect('clicked',
self.child_back)
self.top.get_widget('del_child_btn').connect('clicked',
self.remove_child_clicked)
self.top.get_widget('add_child_btn').connect('clicked',
self.add_child_clicked)
self.top.get_widget('select_child').connect('clicked',
self.select_child_clicked)
self.top.get_widget('ap_parents_btn').connect('clicked',
self.ap_parents_clicked)
self.top.get_widget('sp_parents_btn').connect('clicked',
self.sp_parents_clicked)
self.parent.views.get_nth_page(1).show_all()
if self.parent.views.get_current_page() == 2:
self.parent.views.set_current_page(1)
@ -234,7 +254,7 @@ class FamilyView:
and event.state == gtk.gdk.CONTROL_MASK:
self.spouse_swap(obj)
elif event.keyval == gtk.gdk.keyval_from_name("Delete") and not event.state:
self.remove_spouse(obj)
self.remove_spouse(obj,trans)
elif event.keyval == gtk.gdk.keyval_from_name("Insert") and not event.state:
self.select_spouse(obj)
elif event.keyval == gtk.gdk.keyval_from_name("Insert") \
@ -530,7 +550,9 @@ class FamilyView:
def set_preferred_spouse(self,obj):
if self.selected_spouse:
self.person.set_preferred_family_id(self.family)
self.parent.db.commit_person(self.person)
trans = self.parent.db.start_transaction()
self.parent.db.commit_person(self.person,trans)
self.parent.db.add_transaction(trans)
self.load_family()
def edit_spouse_callback(self,obj):
@ -597,28 +619,30 @@ class FamilyView:
def spouse_after_edit(self,epo):
ap = self.parent.active_person
if epo:
self.parent.db.build_person_display(epo.person.get_id(),epo.original_id)
self.parent.db.commit_person(epo.person)
trans = self.parent.db.start_transaction()
self.parent.db.commit_person(epo.person,trans)
self.parent.db.add_transaction(trans)
self.parent.people_view.remove_from_person_list(epo.person,epo.original_id)
self.parent.people_view.redisplay_person_list(epo.person)
self.parent.active_person = ap
self.load_family(self.family)
def new_spouse_after_edit(self,epo,change):
def new_spouse_after_edit(self,epo,trans):
if epo.person.get_id() == "":
self.parent.db.add_person(epo.person)
self.parent.db.add_person(epo.person,trans)
else:
self.parent.db.add_person_no_map(epo.person,epo.person.get_id())
self.parent.db.add_person_no_map(epo.person,epo.person.get_id(),trans)
self.family = self.parent.db.new_family(trans)
self.parent.people_view.add_to_person_list(epo.person,0)
self.family = self.parent.db.new_family()
self.person.add_family_id(self.family.get_id())
epo.person.add_family_id(self.family.get_id())
self.parent.db.commit_person(epo.person)
self.parent.db.commit_person(self.person)
self.parent.db.commit_person(epo.person,trans)
self.parent.db.commit_person(self.person,trans)
if self.person.get_gender() == RelLib.Person.male:
self.family.set_mother_id(epo.person.get_id())
@ -627,7 +651,7 @@ class FamilyView:
self.family.set_father_id(epo.person.get_id())
self.family.set_mother_id(self.person.get_id())
self.parent.db.commit_family(self.family)
self.parent.db.commit_family(self.family,trans)
self.load_family(self.family)
Marriage.Marriage(self.parent,self.family,self.parent.db,
@ -671,14 +695,13 @@ class FamilyView:
self.parent.update_person_list(person)
self.load_family(self.family)
def new_child_after_edit(self,epo):
def new_child_after_edit(self,epo,trans):
if epo.person.get_id() == "":
self.parent.db.add_person(epo.person)
self.parent.db.add_person(epo.person,trans)
else:
self.parent.db.add_person_no_map(epo.person,epo.person.get_id())
self.parent.db.add_person_no_map(epo.person,epo.person.get_id(),trans)
self.parent.db.build_person_display(epo.person.get_id())
self.parent.people_view.add_to_person_list(epo.person,0)
if not self.family:
@ -691,8 +714,8 @@ class FamilyView:
self.family.add_child_id(epo.person.get_id())
epo.person.add_parent_family_id(self.family.get_id(),"Birth","Birth")
self.parent.db.commit_person(epo.person)
self.parent.db.commit_family(self.family)
self.parent.db.commit_person(epo.person,trans)
self.parent.db.commit_family(self.family,trans)
self.display_marriage(self.family)
def select_child_clicked(self,obj):
@ -716,6 +739,8 @@ class FamilyView:
id = self.child_model.get_value(iter,2)
child = self.parent.db.get_person(id)
trans = self.parent.db.start_transaction()
self.family.remove_child_id(child.get_id())
child.remove_parent_family_id(self.family.get_id())
@ -725,8 +750,10 @@ class FamilyView:
elif self.family.get_mother_id() == None:
self.delete_family_from(self.family.get_father_id())
self.parent.db.commit_person(child)
self.parent.db.commit_family(self.family)
self.parent.db.commit_person(child,trans)
self.parent.db.commit_family(self.family,trans)
self.parent.db.add_transaction(trans)
self.load_family()
def remove_spouse(self,obj):
@ -752,16 +779,18 @@ class FamilyView:
else:
self.family.set_mother_id(None)
trans = self.parent.db.start_transaction()
if self.selected_spouse:
self.selected_spouse.remove_family_id(self.family.get_id())
self.parent.db.commit_person(self.selected_spouse)
self.selected_spouse.remove_family_id(self.family.get_id(),trans)
self.parent.db.commit_person(self.selected_spouse,trans)
self.parent.db.commit_family(self.family)
self.parent.db.commit_family(self.family,trans)
if len(self.family.get_child_id_list()) == 0:
self.person.remove_family_id(self.family.get_id())
self.parent.db.commit_person(self.person)
self.parent.db.delete_family(self.family.get_id())
self.person.remove_family_id(self.family.get_id(),trans)
self.parent.db.commit_person(self.person,trans)
self.parent.db.delete_family(self.family.get_id(),trans)
if len(self.person.get_family_id_list()) > 0:
family_id = self.person.get_family_id_list()[0]
self.load_family(self.parent.db.find_family_from_id(family_id))
@ -769,6 +798,7 @@ class FamilyView:
self.load_family(self.family)
else:
self.load_family(self.family)
self.parent.db.add_transaction(trans)
if len(self.person.get_family_id_list()) <= 1:
self.spouse_selection.set_mode(gtk.SELECTION_NONE)
@ -806,7 +836,9 @@ class FamilyView:
person = self.parent.db.find_person_from_id(person_id)
self.parent.change_active_person(person)
self.parent.db.commit_family(family)
trans = self.parent.db.start_transaction()
self.parent.db.commit_family(family,trans)
self.parent.db.add_transaction(trans)
self.load_family(family)
def clear(self):
@ -938,13 +970,15 @@ class FamilyView:
return _("%s: unknown") % (l)
def delete_family_from(self,person):
person.remove_family_id(self.family.get_id())
self.parent.db.delete_family(self.family.get_id())
trans = self.parent.db.start_transaction()
person.remove_family_id(self.family.get_id(),trans)
self.parent.db.delete_family(self.family.get_id(),trans)
flist = self.person.get_family_id_list()
if len(flist) > 0:
self.family = flist[0]
else:
self.family = None
self.parent.db.add_transaction(trans)
def display_marriage(self,family):
self.child_model.clear()
@ -1228,7 +1262,10 @@ class FamilyView:
fam = person.get_parent_family_id_list()[row[0]]
person.remove_parent_family_id(fam[0])
self.parent.db.commit_person(person)
trans = self.parent.db.start_transaction()
self.parent.db.commit_person(person,trans)
self.parent.db.add_transaction(trans)
self.load_family()
def drag_data_received(self,widget,context,x,y,sel_data,info,time):

View File

@ -235,7 +235,7 @@ def loadConfig(call):
global familyview
_callback = call
lastfile = get_string("/apps/gramps/last-file")
lastfile = get_string("/apps/gramps/recent-file")
uselds = get_bool("/apps/gramps/use-lds")
ac = get_bool("/apps/gramps/disable-auto-complete",0)
mediaref = get_bool("/apps/gramps/make-reference",1)
@ -372,7 +372,7 @@ def sync():
#
#-------------------------------------------------------------------------
def save_last_file(file):
set_string("/apps/gramps/last-file",file)
set_string("/apps/gramps/recent-file",file)
sync()
#-------------------------------------------------------------------------

View File

@ -705,7 +705,6 @@ class GrampsParser:
self.family = None
def stop_person(self,tag):
self.db.build_person_display(self.person.get_id())
self.db.commit_person(self.person)
self.person = None

View File

@ -525,7 +525,7 @@ class Gallery(ImageSelect):
if GrampsCfg.globalprop:
GlobalMediaProperties(self.db,photo,None)
else:
if self.db.get_object_map().has_key(data.data):
if self.db.has_object_id(data.data):
icon_index = self.get_index(w,x,y)
index = 0
for p in self.dataobj.get_media_list():
@ -822,7 +822,10 @@ class LocalMediaProperties:
if self.lists_changed:
self.photo.set_attribute_list(self.alist)
self.parent.lists_changed = 1
self.db.commit_media_object(self.object)
trans = self.db.start_transaction()
self.db.commit_media_object(self.object,trans)
self.db.add_transaction(trans)
def on_help_clicked(self, obj):
"""Display the relevant portion of GRAMPS manual"""
@ -1061,7 +1064,9 @@ class GlobalMediaProperties:
self.object.set_attribute_list(self.alist)
if self.update != None:
self.update()
self.db.commit_media_object(self.object)
trans = self.db.start_transaction()
self.db.commit_media_object(self.object,trans)
self.db.add_transaction(trans)
def on_help_clicked(self, obj):
"""Display the relevant portion of GRAMPS manual"""
@ -1115,8 +1120,8 @@ class DeleteMediaQuery:
self.update = update
def query_response(self):
del self.db.get_object_map()[self.media.get_id()]
trans = self.db.start_transaction()
for key in self.db.get_person_keys():
p = self.db.get_person(key)
nl = []
@ -1128,8 +1133,10 @@ class DeleteMediaQuery:
change = 1
if change:
p.set_media_list(nl)
self.db.commit_person(p,trans)
for p in self.db.get_family_id_map().values():
for fid in self.db.get_family_keys():
p = self.db.find_family_from_id(fid)
nl = []
change = 0
for photo in p.get_media_list():
@ -1139,9 +1146,10 @@ class DeleteMediaQuery:
change = 1
if change:
p.set_media_list(nl)
self.db.commit_family(p,trans)
for key in self.db.get_source_keys():
p = self.db.get_source(key)
sid = self.db.find_source_from_id(key,trans)
nl = []
change = 0
for photo in p.get_media_list():
@ -1151,9 +1159,10 @@ class DeleteMediaQuery:
change = 1
if change:
p.set_media_list(nl)
self.db.commit_source(p,trans)
for key in self.db.get_place_id_keys():
p = self.db.get_place_id(key)
p = self.db.find_place_from_id(key)
nl = []
change = 0
for photo in p.get_media_list():
@ -1163,6 +1172,9 @@ class DeleteMediaQuery:
change = 1
if change:
p.set_media_list(nl)
self.db.commit_place(p,trans)
self.db.remove_object(self.media.get_id(),trans)
self.db.add_transaction(trans)
if self.update:
self.update(0)
self.update()

View File

@ -635,7 +635,9 @@ class Marriage:
self.update_lists()
self.update_fv(self.family)
self.db.commit_family(self.family)
trans = self.db.start_transaction()
self.db.commit_family(self.family,trans)
self.db.add_transaction(trans)
self.close(1)

View File

@ -150,14 +150,6 @@ class MediaView:
self.build_columns()
self.build_tree()
def goto(self,id):
self.selection.unselect_all()
iter = self.id2col[id]
self.selection.select_iter(iter)
itpath = self.model.get_path (iter)
col = self.list.get_column (0)
self.list.scroll_to_cell (itpath, col, gtk.TRUE, 0.5, 0)
def build_tree(self):
self.list.set_model(None)
self.model = gtk.TreeModelSort(DisplayModels.MediaModel(self.parent.db))
@ -295,7 +287,7 @@ class MediaView:
id = store.get_value(iter,1)
mobj = self.db.find_object_from_id(id)
if self.is_object_used(mobj):
ans = ImageSelect.DeleteMediaQuery(mobj,self.db,self.update)
ans = ImageSelect.DeleteMediaQuery(mobj,self.db,self.build_tree)
QuestionDialog(_('Delete Media Object?'),
_('This media object is currently being used. '
'If you delete this object, it will be removed '
@ -304,8 +296,10 @@ class MediaView:
_('_Delete Media Object'),
ans.query_response)
else:
self.db.remove_object(mobj.get_id())
self.update(0)
trans = self.db.start_transaction()
self.db.remove_object(mobj.get_id(),trans)
self.db.add_transaction(trans)
self.build_tree()
def is_object_used(self,mobj):
for family_id in self.db.get_family_keys():
@ -366,7 +360,8 @@ class MediaView:
photo.set_thumbnail(RelImage.build_thumbnail(name))
description = os.path.basename(name)
photo.set_description(description)
self.db.add_object(photo)
trans = self.db.start_transaction()
self.db.add_object(photo,trans)
self.load_media()
if GrampsCfg.mediaref == 0:
name = RelImage.import_media_object(name,
@ -375,7 +370,10 @@ class MediaView:
if name:
photo.set_path(name)
photo.setLocal(1)
self.db.commit_media_object(photo)
self.db.commit_media_object(photo,trans)
self.db.add_transaction(trans)
if GrampsCfg.globalprop:
ImageSelect.GlobalMediaProperties(self.db,photo,self.load_media)
elif protocol != "":
@ -394,7 +392,8 @@ class MediaView:
photo.set_description(d)
photo.setLocal(1)
photo.set_path(tfile)
self.db.add_object(photo)
trans = self.db.start_transaction()
self.db.add_object(photo,trans)
oref = RelLib.MediaRef()
oref.set_reference(photo)
try:
@ -407,7 +406,10 @@ class MediaView:
except:
photo.set_path(tfile)
return
self.db.commit_media_object(photo)
self.db.commit_media_object(photo,trans)
self.db.add_transaction(trans)
if GrampsCfg.globalprop:
ImageSelect.GlobalMediaProperties(self.db,photo,None)

View File

@ -307,7 +307,7 @@ class MergePeople:
event = self.p2.get_death()
event.set_name("Alternate Death")
self.p1.add_event(event)
if self.glade.get_widget("bfather2").get_active():
orig_family = self.p1.get_main_parents_family_id()
if orig_family:
@ -347,7 +347,6 @@ class MergePeople:
try:
self.db.remove_person_id(self.p2.get_id())
self.db.personMap[self.p1.get_id()] = self.p1
self.db.build_person_display(self.p1.get_id(),old_id)
except:
print "%s is not in the person map!" % (GrampsCfg.nameof(self.p2))
self.update(self.p1,self.p2,old_id)

View File

@ -62,7 +62,7 @@ class PeopleModel(gtk.GenericTreeModel):
if not self.db.is_open():
return
for person_id in self.db.get_person_keys():
person = self.db.find_person_from_id(person_id)
@ -141,7 +141,8 @@ class PeopleModel(gtk.GenericTreeModel):
else:
return u''
else:
return self.fmap[col](self.db.person_map[str(iter)])
val = self.fmap[col](self.db.person_map[str(iter)])
return val
def on_iter_next(self, node):
'''returns the next node at this level of the tree'''

View File

@ -1,325 +0,0 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000 Donald N. Allingham
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#-------------------------------------------------------------------------
#
# GNOME
#
#-------------------------------------------------------------------------
from gobject import TYPE_STRING, TYPE_INT
import gtk
import pango
#-------------------------------------------------------------------------
#
# internationalization
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# constants
#
#-------------------------------------------------------------------------
_BCOL = 8
_IDCOL = 1
_TOP_FONT=pango.WEIGHT_ULTRABOLD
_TEXT_FONT=pango.WEIGHT_NORMAL
#-------------------------------------------------------------------------
#
# PeopleStore
#
#-------------------------------------------------------------------------
class PeopleStore:
def __init__(self,tree,parent,select_func=None,event_func=None,
mode=gtk.SELECTION_SINGLE):
self.titles = [
(_('Name'),5,250), (_('ID'),1,50),(_('Gender'),2,70),
(_('Birth date'),6,150),(_('Death date'),7,150)
]
ncols = len(self.titles) + 3
self.tree = tree
self.parent = parent
self.tree.connect('row-expanded',self.on_row_expanded)
self.mylist = [TYPE_STRING]*ncols + [TYPE_INT]
self.tree.set_rules_hint(gtk.TRUE)
self.model = None
self.tree_roots = {}
self.tree_open = {}
self.tree_list = {}
self.selection = None
self.mode = mode
self.new_model()
self.count = 0
self.cid = None
self.cids = []
cnum = 0
for name in self.titles:
renderer = gtk.CellRendererText()
renderer.set_fixed_height_from_font(1)
if name[0] != '':
column = gtk.TreeViewColumn(name[0],renderer,text=cnum)
column.set_min_width(name[2])
column.set_resizable(gtk.TRUE)
column.set_clickable(gtk.TRUE)
column.set_sort_column_id(name[1])
cnum += 1
self.cids.append(name[1])
self.tree.append_column(column)
self.connect_model()
if select_func:
self.selection.connect('changed',select_func)
if event_func:
self.double_click = event_func
self.tree.connect('row_activated', self.row_activated)
def row_activated (self, treeview, path, column):
self.double_click (treeview)
def enable_sort(self):
if self.cids[0] != -1:
self.model.set_sort_column_id(self.cids[0],gtk.SORT_ASCENDING)
def unselect(self):
self.selection.unselect_all()
def set_reorderable(self,order):
self.tree.set_reorderable(order)
def new_model(self):
if self.model:
self.cid = self.model.get_sort_column_id()
del self.model
del self.selection
self.count = 0
self.model = gtk.TreeStore(*self.mylist)
self.selection = self.tree.get_selection()
self.selection.set_mode(self.mode)
self.sel_iter = None
def connect_model(self):
self.tree.set_model(self.model)
if self.sel_iter:
self.selection.select_iter(self.sel_iter)
if self.cid:
self.model.set_sort_column_id(self.cid[0],self.cid[1])
self.sort()
def sort(self):
val = self.model.get_sort_column_id()
col = val[0]
if col < 0:
return
if col > 0:
self.model.set_sort_column_id(col,val[1])
else:
self.model.set_sort_column_id(self.cids[0],val[1])
self.model.sort_column_changed()
def get_selected(self):
return self.selection.get_selected()
def get_row_at(self,x,y):
path = self.tree.get_path_at_pos(x,y)
if path == None:
return self.count -1
else:
return path[0][0]-1
def get_selected_row(self):
store, iter = self.selection.get_selected()
if iter:
rows = store.get_path(iter)
return rows[0]
else:
return -1
def get_selected_objects(self):
if self.count == 0:
return []
elif self.mode == gtk.SELECTION_SINGLE:
store,iter = self.selection.get_selected()
if iter:
return [self.model.get_value(iter,_IDCOL)]
else:
return []
else:
mlist = []
self.selection.selected_foreach(self.blist,mlist)
return mlist
def get_icon(self):
if self.mode == gtk.SELECTION_SINGLE:
store,iter = self.selection.get_selected()
path = self.model.get_path(iter)
else:
mlist = []
self.selection.selected_foreach(self.blist,mlist)
path = self.model.get_path(mlist[0])
return self.tree.create_row_drag_icon(path)
def blist(self,store,path,iter,id_list):
id_list.append(self.model.get_value(iter,_IDCOL))
def clear(self):
self.count = 0
self.tree_roots = {}
self.tree_open = {}
self.model.clear()
def remove(self,iter):
try:
iter_parent = self.model.iter_parent (iter)
self.model.remove(iter)
if iter_parent and not self.model.iter_has_child (iter_parent):
name = unicode(self.model.get_value(iter_parent,0))
self.model.remove (iter_parent)
if self.tree_roots.has_key(name):
del self.tree_roots[name]
if self.tree_open.has_key(name):
del self.tree_open[name]
if self.tree_list.has_key(name):
del self.tree_list[name]
self.count = self.count - 1
except:
pass
def get_row(self,iter):
row = self.model.get_path(iter)
return row[0]
def select_row(self,row):
self.selection.select_path((row))
def select_iter(self,iter):
self.selection.select_iter(iter)
def get_object(self,iter):
return self.model.get_value(iter,_IDCOL)
def insert(self,position,data,info=None,select=0):
self.count = self.count + 1
iter = self.model.insert(position)
col = 0
for object in data:
self.model.set_value(iter,col,object)
col = col + 1
self.model.set_value(iter,_IDCOL,info)
self.model.set_value(iter,_BCOL,_TOP_FONT)
if select:
self.selection.select_iter(iter)
return iter
def get_data(self,iter,cols):
return [ self.model.get_value(iter,c) for c in cols ]
def on_row_expanded(self, view, iter, path):
name = self.model.get_value(iter,0)
self.fill_row(name,iter)
def expand_row(self,name,iter=None):
path = self.model.get_path(self.tree_roots[name])
self.parent.parent.status_text(_('Updating display...'))
self.tree.expand_row(path,1)
self.parent.parent.modify_statusbar()
def fill_row(self,name,iter=None):
name = unicode(name)
if not iter:
iter = self.tree_roots[name]
child = self.model.iter_children(iter)
if self.model.get_value(child,0) is None:
self.model.remove(child)
for d in self.tree_list[name]:
new_iter = self.model.append(iter)
self.model.set(new_iter,0,d[0],1,d[1],2,d[2],3,d[3],4,d[4],
5,d[5],6,d[6],7,d[7])
self.parent.id2col[d[1]] = (self,new_iter)
self.expand_row (name, iter)
def add(self,data,select=0):
self.count = self.count + 1
name = data[-1]
if self.tree_roots.has_key(name):
top = self.tree_roots[name]
else:
top = self.model.append(None)
self.model.append(top)
self.tree_open[name] = 0
self.tree_list[name] = []
self.model.set_value(top,0,name)
self.model.set_value(top,5,name.upper())
self.model.set_value(top,_BCOL,_TOP_FONT)
self.tree_roots[name] = top
if self.tree_open[name] or select:
iter = self.model.append(top)
col = 0
for object in data[:-1]:
self.model.set_value(iter,col,object)
col = col + 1
self.model.set_value(iter,_BCOL,_TEXT_FONT)
if select:
self.sel_iter = iter
self.selection.select_iter(self.sel_iter)
return iter
else:
self.tree_list[name].append(data)
return None
def set(self,iter,data,select=0):
col = 0
for object in data:
self.model.set_value(iter,col,object)
col = col + 1
self.model.set_value(iter,_BCOL,_TEXT_FONT)
if select:
self.sel_iter = iter
return iter
def add_and_select(self,data):
self.count = self.count + 1
iter = self.model.append()
col = 0
for object in data:
self.model.set_value(iter,col,object)
col = col + 1
self.model.set_value(iter,_BCOL,_TEXT_FONT)
self.selection.select_iter(iter)
def center_selected(self):
model,iter = self.selection.get_selected()
if iter:
path = model.get_path(iter)
self.tree.scroll_to_cell(path,None,gtk.TRUE,0.5,0.5)

View File

@ -151,11 +151,7 @@ class PeopleView:
def remove_from_person_list(self,person,old_id=None):
"""Remove the selected person from the list. A person object is expected,
not an ID"""
if old_id == None or person.get_id() == old_id:
path = self.person_model.on_get_path(person.get_id())
self.person_model.row_deleted(path)
else:
self.person_model.rebuild_data()
self.build_tree()
def remove_from_history(self,person,old_id=None):
"""Removes a person from the history list"""
@ -187,8 +183,8 @@ class PeopleView:
self.apply_filter(self.person_tree)
self.goto_active_person()
def add_to_person_list(self,person,change):
self.rebuild_data()
def add_to_person_list(self,person,change=0):
self.build_tree()
def goto_active_person(self,first=0):
if not self.parent.active_person:
@ -253,4 +249,7 @@ class PeopleView:
menu.popup(None,None,None,event.button,event.time)
def redisplay_person_list(self,person):
self.person_model.rebuild_data()
self.person_model = PeopleModel.PeopleModel(self.parent.db)
self.sort_model = gtk.TreeModelSort(self.person_model)
self.person_tree.set_model(self.sort_model)

View File

@ -68,21 +68,18 @@ class PlaceView:
def __init__(self,parent,db,glade,update):
self.parent = parent
self.db = db
self.glade = glade
self.db = db
self.list = glade.get_widget("place_list")
self.update = update
self.list.connect('button-press-event',self.button_press)
self.list.connect('key-press-event',self.key_press)
self.selection = self.list.get_selection()
self.selection.set_mode(gtk.SELECTION_MULTIPLE)
self.renderer = gtk.CellRendererText()
self.active = None
self.model = gtk.TreeModelSort(DisplayModels.PlaceModel(self.db))
self.list.set_model(self.model)
self.selection = self.list.get_selection()
self.selection.set_mode(gtk.SELECTION_MULTIPLE)
self.list.connect('button-press-event',self.button_press)
self.list.connect('key-press-event',self.key_press)
self.topWindow = self.glade.get_widget("gramps")
self.columns = []
@ -127,35 +124,6 @@ class PlaceView:
self.list.set_model(self.model)
self.selection = self.list.get_selection()
def load_places(self,id=None):
"""Rebuilds the entire place view. This can be very time consuming
on large databases, and should only be called when absolutely
necessary"""
pass
#self.build_tree()
def goto(self,id):
self.selection.unselect_all()
iter = self.id2col[id]
self.selection.select_iter(iter)
itpath = self.model.get_path (iter)
col = self.list.get_column (0)
self.list.scroll_to_cell (itpath, col, gtk.TRUE, 0.5, 0)
def merge(self):
mlist = []
self.selection.selected_foreach(self.blist,mlist)
if len(mlist) != 2:
msg = _("Cannot merge places.")
msg2 = _("Exactly two places must be selected to perform a merge. "
"A second place can be selected by holding down the "
"control key while clicking on the desired place.")
ErrorDialog(msg,msg2)
else:
import MergeData
MergeData.MergePlaces(self.db,mlist[0],mlist[1],self.load_places)
def button_press(self,obj,event):
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
mlist = []
@ -201,26 +169,25 @@ class PlaceView:
menu.append(item)
menu.popup(None,None,None,event.button,event.time)
def new_place_after_edit(self,place):
self.db.add_place(place)
self.update(0)
def update_display(self,place):
if place:
self.db.build_place_display(place.get_id())
self.update(0)
def on_add_place_clicked(self,obj):
EditPlace.EditPlace(self.parent,RelLib.Place(),self.new_place_after_edit)
def new_place_after_edit(self,place):
self.db.add_place(place)
def update_display(self,place):
self.build_tree()
def on_delete_clicked(self,obj):
mlist = []
self.selection.selected_foreach(self.blist,mlist)
trans = self.db.start_transaction()
for place in mlist:
used = 0
for key in self.db.get_person_keys():
p = self.db.get_person(key)
p = self.db.find_person_from_id(key)
event_list = []
for e in [p.get_birth_id(),p.get_death_id()] + p.get_event_list():
event = self.db.find_event_from_id(e)
@ -233,7 +200,8 @@ class PlaceView:
if p.get_lds_sealing():
event_list.append(p.get_lds_sealing())
for event in event_list:
if event.get_place_id() == place:
if event.get_place_id() == place.get_id():
print event.get_id()
used = 1
for fid in self.db.get_family_keys():
@ -246,7 +214,8 @@ class PlaceView:
if f.get_lds_sealing():
event_list.append(f.get_lds_sealing())
for event in event_list:
if event.get_place_id() == place:
if event.get_place_id() == place.get_id():
print event.get_id()
used = 1
if used == 1:
@ -259,8 +228,10 @@ class PlaceView:
_('_Delete Place'),
ans.query_response)
else:
self.db.remove_place(place.get_id())
self.update(0)
trans = self.db.start_transaction()
self.db.remove_place(place.get_id(),trans)
self.db.add_transaction(trans)
self.build_tree()
def on_edit_clicked(self,obj):
"""Display the selected places in the EditPlace display"""
@ -273,3 +244,18 @@ class PlaceView:
def blist(self,store,path,iter,list):
id = self.db.get_place_id(store.get_value(iter,1))
list.append(id)
def merge(self):
mlist = []
self.selection.selected_foreach(self.blist,mlist)
if len(mlist) != 2:
msg = _("Cannot merge places.")
msg2 = _("Exactly two places must be selected to perform a merge. "
"A second place can be selected by holding down the "
"control key while clicking on the desired place.")
ErrorDialog(msg,msg2)
else:
import MergeData
MergeData.MergePlaces(self.db,mlist[0],mlist[1],self.build_tree)

File diff suppressed because it is too large Load Diff

View File

@ -300,7 +300,10 @@ class SelectChild:
select_child.add_parent_family_id(self.family.get_id(),mrel,frel)
self.db.commit_person(select_child)
trans = self.db.start_transaction()
self.db.commit_person(select_child,trans)
self.db.add_transaction(trans)
self.redraw(self.family)
self.close(obj)
@ -430,6 +433,9 @@ class EditRel:
frel = "Unknown"
self.child.change_parent_family_id(self.family.get_id(),mrel,frel)
self.db.commit_person(self.child)
trans = self.start_transaction()
self.db.commit_person(self.child,trans)
self.db.add_transaction(trans)
self.update()
self.top.destroy()

View File

@ -68,8 +68,8 @@ class SourceView:
self.db = db
self.update = update
self.list = glade.get_widget("source_list")
self.list.connect('button-press-event',self.button_press)
self.selection = self.list.get_selection()
colno = 0
self.renderer = gtk.CellRendererText()
@ -80,12 +80,6 @@ class SourceView:
self.columns = []
self.build_columns()
def load_sources(self,id=None):
pass
def on_click(self,column):
self.click_col = column
def build_columns(self):
for column in self.columns:
self.list.remove_column(column)
@ -112,25 +106,18 @@ class SourceView:
self.list.append_column(column)
index += 1
def on_click(self,column):
self.click_col = column
def change_db(self,db):
self.build_columns()
self.build_tree()
def goto(self,id):
iter = self.map[id]
self.list.get_selection().select_iter(iter)
itpath = self.model.get_path (iter)
col = self.list.get_column (0)
self.list.scroll_to_cell (itpath, col, gtk.TRUE, 0.5, 0)
def build_tree(self):
self.list.set_model(None)
self.model = gtk.TreeModelSort(DisplayModels.SourceModel(self.parent.db))
self.list.set_model(self.model)
self.selection = self.list.get_selection()
self.list.connect('button-press-event',self.button_press)
def button_press(self,obj,event):
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
@ -182,7 +169,6 @@ class SourceView:
self.topWindow,self.new_after_edit)
def on_delete_clicked(self,obj):
store,iter = self.selection.get_selected()
if not iter:
return
@ -191,7 +177,7 @@ class SourceView:
source = self.db.get_source(id)
if self.is_used(source):
ans = EditSource.DelSrcQuery(source,self.db,self.update)
ans = EditSource.DelSrcQuery(source,self.db,self.build_tree)
QuestionDialog(_('Delete %s?') % source.get_title(),
_('This source is currently being used. Deleting it '
@ -200,8 +186,10 @@ class SourceView:
_('_Delete Source'),
ans.query_response,self.topWindow)
else:
self.db.remove_source_id(source.get_id())
self.update(0)
trans = self.db.start_transaction()
self.db.remove_source_id(source.get_id(),trans)
self.db.add_transaction(trans)
self.build_tree()
def is_used(self,source):
for key in self.db.get_place_id_keys():
@ -258,8 +246,7 @@ class SourceView:
def new_after_edit(self,source):
self.db.add_source(source)
self.update(0)
self.build_tree()
def update_display(self,place):
self.db.build_source_display(place.get_id())
self.update(0)
self.build_tree()

View File

@ -51,7 +51,7 @@
<accelerator key="N" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1865">
<widget class="GtkImage" id="image1882">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
@ -73,7 +73,7 @@
<accelerator key="O" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1866">
<widget class="GtkImage" id="image1883">
<property name="visible">True</property>
<property name="stock">gtk-open</property>
<property name="icon_size">1</property>
@ -107,7 +107,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image1867">
<widget class="GtkImage" id="image1884">
<property name="visible">True</property>
<property name="stock">gtk-convert</property>
<property name="icon_size">1</property>
@ -135,7 +135,7 @@
<accelerator key="Q" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1868">
<widget class="GtkImage" id="image1885">
<property name="visible">True</property>
<property name="stock">gtk-quit</property>
<property name="icon_size">1</property>
@ -171,7 +171,7 @@
<accelerator key="Insert" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1869">
<widget class="GtkImage" id="image1886">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
@ -194,7 +194,7 @@
<accelerator key="Delete" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1870">
<widget class="GtkImage" id="image1887">
<property name="visible">True</property>
<property name="stock">gtk-remove</property>
<property name="icon_size">1</property>
@ -207,6 +207,14 @@
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="undo1">
<property name="visible">True</property>
<property name="stock_item">GNOMEUIINFO_MENU_UNDO_ITEM</property>
<signal name="activate" handler="on_undo_activate" last_modification_time="Fri, 26 Mar 2004 00:07:15 GMT"/>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="edit_item">
<property name="visible">True</property>
@ -232,7 +240,7 @@
<accelerator key="F" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1871">
<widget class="GtkImage" id="image1888">
<property name="visible">True</property>
<property name="stock">gtk-find</property>
<property name="icon_size">1</property>
@ -254,7 +262,7 @@
<accelerator key="M" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1872">
<widget class="GtkImage" id="image1889">
<property name="visible">True</property>
<property name="stock">gtk-convert</property>
<property name="icon_size">1</property>
@ -281,7 +289,7 @@
<signal name="activate" handler="on_preferences1_activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1873">
<widget class="GtkImage" id="image1890">
<property name="visible">True</property>
<property name="stock">gtk-preferences</property>
<property name="icon_size">1</property>
@ -302,7 +310,7 @@
<signal name="activate" handler="on_column_order_activate" last_modification_time="Wed, 10 Mar 2004 04:36:07 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1874">
<widget class="GtkImage" id="image1891">
<property name="visible">True</property>
<property name="stock">gtk-properties</property>
<property name="icon_size">1</property>
@ -323,7 +331,7 @@
<signal name="activate" handler="on_default_person_activate" last_modification_time="Sat, 16 Aug 2003 01:58:26 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1875">
<widget class="GtkImage" id="image1892">
<property name="visible">True</property>
<property name="stock">gtk-home</property>
<property name="icon_size">1</property>
@ -409,7 +417,7 @@
<accelerator key="D" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1876">
<widget class="GtkImage" id="image1893">
<property name="visible">True</property>
<property name="stock">gtk-index</property>
<property name="icon_size">1</property>
@ -431,7 +439,7 @@
<accelerator key="B" modifiers="GDK_CONTROL_MASK" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1877">
<widget class="GtkImage" id="image1894">
<property name="visible">True</property>
<property name="stock">gnome-stock-book-open</property>
<property name="icon_size">1</property>
@ -504,7 +512,7 @@
<accelerator key="F1" modifiers="0" signal="activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1878">
<widget class="GtkImage" id="image1895">
<property name="visible">True</property>
<property name="stock">gtk-help</property>
<property name="icon_size">1</property>
@ -525,7 +533,7 @@
<signal name="activate" handler="on_faq_activate" last_modification_time="Wed, 26 Nov 2003 17:59:23 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1879">
<widget class="GtkImage" id="image1896">
<property name="visible">True</property>
<property name="stock">gnome-stock-book-open</property>
<property name="icon_size">1</property>
@ -552,7 +560,7 @@
<signal name="activate" handler="on_gramps_home_page_activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1880">
<widget class="GtkImage" id="image1897">
<property name="visible">True</property>
<property name="stock">gtk-jump-to</property>
<property name="icon_size">1</property>
@ -573,7 +581,7 @@
<signal name="activate" handler="on_gramps_mailing_lists_activate"/>
<child internal-child="image">
<widget class="GtkImage" id="image1881">
<widget class="GtkImage" id="image1898">
<property name="visible">True</property>
<property name="stock">gnome-stock-mail</property>
<property name="icon_size">1</property>
@ -627,7 +635,7 @@
<signal name="activate" handler="on_about_activate" last_modification_time="Tue, 01 Apr 2003 03:44:24 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1882">
<widget class="GtkImage" id="image1899">
<property name="visible">True</property>
<property name="stock">gnome-stock-about</property>
<property name="icon_size">1</property>

View File

@ -148,7 +148,6 @@ class Gramps:
self.db.set_researcher(GrampsCfg.get_researcher())
def pref_callback(self,val):
self.db.rebuild_person_table()
self.modify_statusbar()
self.family_view.init_interface()
self.update_display(1)
@ -259,6 +258,7 @@ class Gramps:
self.child_windows = {}
self.gtop.signal_autoconnect({
"on_undo_activate" : self.undo,
"on_column_order_activate": self.column_order,
"on_back_clicked" : self.back_clicked,
"on_back_pressed" : self.back_pressed,
@ -346,6 +346,16 @@ class Gramps:
self.topWindow.show()
self.enable_toolbar(self.use_toolbar)
def undo(self,*args):
self.db.undo()
p = self.db.try_to_find_person_from_id(self.active_person.get_id())
self.change_active_person(p)
self.place_view.change_db(self.db)
self.people_view.change_db(self.db)
self.source_view.change_db(self.db)
self.media_view.change_db(self.db)
self.family_view.load_family()
def set_column_order(self,list):
self.db.set_column_order(list)
self.people_view.build_columns()
@ -894,8 +904,6 @@ class Gramps:
self.family_view.clear()
self.family_view.load_family()
self.pedigree_view.clear()
self.source_view.load_sources()
self.place_view.load_places()
self.media_view.load_media()
def tool_callback(self,val):
@ -931,17 +939,12 @@ class Gramps:
self.family_view.load_family()
elif page == PEDIGREE_VIEW:
self.pedigree_view.load_canvas(self.active_person)
elif page == SOURCE_VIEW:
self.source_view.load_sources()
elif page == PLACE_VIEW:
if len(self.db.get_place_id_keys()) > 2000:
self.status_text(_('Updating display - this may take a few seconds...'))
else:
self.status_text(_('Updating display...'))
self.place_view.load_places()
self.modify_statusbar()
else:
self.media_view.load_media()
def on_tools_clicked(self,obj):
if self.active_person:
@ -953,23 +956,13 @@ class Gramps:
Plugins.ReportPlugins(self,self.db,self.active_person)
def on_ok_button1_clicked(self,obj):
dbname = obj.get_data("dbname")
getoldrev = obj.get_data("getoldrev")
filename = dbname.get_full_path(0)
filename = self.filesel.get_filename()
if filename == "" or filename == None:
return
filename = os.path.normpath(os.path.abspath(filename))
self.filesel.destroy()
self.clear_database()
if getoldrev.get_active():
vc = VersionControl.RcsVersionControl(filename)
VersionControl.RevisionSelect(self.db,filename,vc,
self.load_revision)
else:
self.auto_save_load(filename)
self.auto_save_load(filename)
def on_help_dbopen_clicked(self,obj):
"""Display the relevant portion of GRAMPS manual"""
@ -1053,7 +1046,10 @@ class Gramps:
if o.get_reference_id() == ObjectId:
nl.remove(o)
p.set_media_list(nl)
self.db.remove_object(ObjectId)
trans = self.db.start_transaction()
self.db.remove_object(ObjectId)
self.db.add_transaction(trans)
def leave_clicked():
# File is lost => do nothing, leave as is
@ -1210,6 +1206,8 @@ class Gramps:
def delete_person_response(self):
trans = self.db.start_transaction()
if self.db.get_default_person() == self.active_person:
self.db.set_default_person(None)
@ -1222,7 +1220,8 @@ class Gramps:
for child_id in family.get_child_id_list():
child = self.db.find_person_from_id(child_id)
child.remove_parent_family_id(family.get_id())
self.db.delete_family(family.get_id())
self.db.commit_person(child,trans)
self.db.delete_family(family.get_id(),trans)
else:
family.set_father_id(None)
else:
@ -1230,23 +1229,27 @@ class Gramps:
for child_id in family.get_child_id_list():
child = self.db.find_person_from_id(child_id)
child.remove_parent_family_id(family)
self.db.delete_family(family)
self.db.commit_person(child,trans)
self.db.delete_family(family,trans)
else:
family.set_mother_id(None)
self.db.commit_family(family,trans)
for (family_id,mrel,frel) in self.active_person.get_parent_family_id_list():
if family_id:
family = self.db.find_family_from_id(family_id)
family.remove_child_id(self.active_person.get_id())
self.db.commit_family(family,trans)
self.people_view.remove_from_history(self.active_person)
self.db.remove_person_id(self.active_person.get_id())
self.db.remove_person_id(self.active_person.get_id(),trans)
self.people_view.remove_from_person_list(self.active_person)
if self.hindex >= 0:
self.active_person = self.db.get_person(self.history[self.hindex])
else:
self.change_active_person(None)
self.db.add_transaction(trans)
self.redraw_histmenu()
def merge_update(self,p1,p2,old_id):
@ -1261,15 +1264,16 @@ class Gramps:
def goto_active_person(self,first=0):
self.people_view.goto_active_person(first)
def change_active_person(self,person):
def change_active_person(self,person,force=0):
self.active_person = person
if person == None:
self.set_buttons(0)
self.active_person = None
self.modify_statusbar()
elif self.active_person == None or \
person.get_id() != self.active_person.get_id():
self.active_person = person
self.modify_statusbar()
self.set_buttons(1)
if person:
if self.hindex+1 < len(self.history):
self.history = self.history[0:self.hindex+1]
@ -1292,6 +1296,7 @@ class Gramps:
else:
self.backbtn.set_sensitive(0)
self.back.set_sensitive(0)
else:
self.set_buttons(1)
def modify_statusbar(self):
@ -1327,31 +1332,19 @@ class Gramps:
DisplayTrace.DisplayTrace()
return ""
def fs_close_window(self,obj):
self.filesel.destroy()
def on_open_activate(self,obj):
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")
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()
top = gtk.glade.XML (const.gladeFile, "fileselection","gramps")
top.signal_autoconnect({
"on_ok_button1_clicked": self.on_ok_button1_clicked,
"destroy_passed_object": self.fs_close_window,
})
self.filesel = top.get_widget('fileselection')
if GrampsCfg.lastfile:
self.filesel.set_filename(GrampsCfg.lastfile)
def on_revert_activate(self,obj):
pass
@ -1429,15 +1422,12 @@ class Gramps:
elif page == SOURCE_VIEW:
self.enable_buttons(1)
self.merge_button.set_sensitive(0)
self.source_view.load_sources()
elif page == PLACE_VIEW:
self.enable_buttons(1)
self.place_view.load_places()
self.merge_button.set_sensitive(1)
elif page == MEDIA_VIEW:
self.enable_buttons(1)
self.merge_button.set_sensitive(0)
self.media_view.load_media()
def on_apply_filter_clicked(self,obj):
self.people_view.apply_filter_clicked()
@ -1455,15 +1445,14 @@ class Gramps:
filter.hide()
filter.set_sensitive(qual)
def new_after_edit(self,epo):
def new_after_edit(self,epo,trans):
if epo:
if epo.person.get_id() == "":
self.db.add_person(epo.person)
self.db.add_person(epo.person,trans)
else:
self.db.add_person_no_map(epo.person,epo.person.get_id())
self.db.build_person_display(epo.person.get_id())
self.db.add_person_no_map(epo.person,epo.person.get_id(),trans)
self.change_active_person(epo.person)
self.people_view.redisplay_person_list(epo.person)
self.people_view.add_to_person_list(epo.person)
if self.views.get_current_page() in [FAMILY_VIEW1,FAMILY_VIEW2]:
self.family_view.load_family()