* src/EditPerson.py: hide window while closing updating info

* src/FamilyView.py: Fix deleting of spouses and children
* src/GrampsDbBase.py: add remove_family, clear default person
if the person is deleted
* src/PeopleView.py: text clean up
* src/gramps_main.py: disable buttons while deleting a person


svn: r3776
This commit is contained in:
Don Allingham 2004-12-03 01:49:09 +00:00
parent 7b7d9ddac8
commit e25236f85a
6 changed files with 69 additions and 20 deletions

View File

@ -1,3 +1,11 @@
2004-12-02 Don Allingham <dallingham@users.sourceforge.net>
* src/EditPerson.py: hide window while closing updating info
* src/FamilyView.py: Fix deleting of spouses and children
* src/GrampsDbBase.py: add remove_family, clear default person
if the person is deleted
* src/PeopleView.py: text clean up
* src/gramps_main.py: disable buttons while deleting a person
2004-12-01 Alex Roitman <shura@alex.neuro.umn.edu>
* src/Report.py (on_center_person_change_clicked): Typo.

View File

@ -1535,6 +1535,7 @@ class EditPerson:
def on_apply_person_clicked(self,obj):
self.window.hide()
trans = self.db.transaction_begin()
surname = unicode(self.surname.get_text())

View File

@ -778,7 +778,7 @@ class FamilyView:
DisplayTrace.DisplayTrace()
def remove_child_clicked(self,obj):
if not self.family or not self.person:
if self.family == None or self.person == None:
return
model, node = self.child_selection.get_selected()
@ -800,7 +800,8 @@ class FamilyView:
self.delete_family_from(self.family.get_father_handle())
self.parent.db.commit_person(child,trans)
self.parent.db.commit_family(self.family,trans)
if self.family:
self.parent.db.commit_family(self.family,trans)
n = child.get_primary_name().get_regular_name()
self.parent.db.transaction_commit(trans,_("Remove Child (%s)") % n)
@ -838,9 +839,17 @@ class FamilyView:
self.parent.db.commit_family(self.family,trans)
if len(self.family.get_child_handle_list()) == 0:
self.person.remove_family_handle(self.family.get_handle())
self.parent.db.commit_person(self.person,trans)
self.parent.db.delete_family(self.family.get_handle(),trans)
mother_id = self.family.get_mother_handle()
father_id = self.family.get_father_handle()
for id in [father_id, mother_id]:
if id:
print p.get_family_handle_list()
p = self.db.find_person_from_handle(id)
p.remove_family_handle(self.family.get_handle())
self.parent.db.commit_person(p,trans)
print p.get_family_handle_list()
if len(self.person.get_family_handle_list()) > 0:
handle = self.person.get_family_handle_list()[0]
family = self.parent.db.find_family_from_handle(handle,trans)
@ -849,6 +858,9 @@ class FamilyView:
self.load_family(self.family)
else:
self.load_family(self.family)
person_id = self.person.get_handle()
self.person = self.parent.db.get_person_from_handle(person_id)
n = self.person.get_primary_name().get_regular_name()
self.parent.db.transaction_commit(trans,_("Remove Spouse (%s)") % n)
@ -950,9 +962,11 @@ class FamilyView:
flist = {}
print splist
for f in splist:
fm = self.parent.db.get_family_from_handle(f)
if not fm:
continue
if fm.get_father_handle() == self.person.get_handle():
sp_id = fm.get_mother_handle()
else:
@ -1035,13 +1049,14 @@ class FamilyView:
else:
return _("%s: unknown") % (l)
def delete_family_from(self,person):
def delete_family_from(self,person_handle):
trans = self.parent.db.transaction_begin()
person.remove_family_handle(self.family.get_handle(),trans)
self.parent.db.delete_family(self.family.get_handle(),trans)
person = self.parent.db.get_person_from_handle(person_handle)
person.remove_family_handle(self.family.get_handle())
self.parent.db.remove_family(self.family.get_handle(),trans)
flist = self.person.get_family_handle_list()
if len(flist) > 0:
self.family = flist[0]
self.family = self.parent.db.get_family_from_handle(flist[0])
else:
self.family = None
n = person.get_primary_name().get_name()
@ -1316,12 +1331,12 @@ class FamilyView:
mother = self.parent.db.find_person_from_handle(mother_handle)
mother.remove_family_handle(fam)
self.parent.db.commit_person(mother,trans)
self.parent.db.delete_family(fam,trans)
self.parent.db.remove_family(fam,trans)
elif mother_handle == None and father_handle:
father = self.parent.db.find_person_from_handle(father_handle)
father.remove_family_handle(fam,trans)
self.parent.db.commit_person(father,trans)
self.parent.db.delete_family(fam,trans)
self.parent.db.remove_family(fam,trans)
self.parent.db.commit_person(person,trans)
n = person.get_primary_name().get_regular_name()

View File

@ -893,9 +893,13 @@ class GrampsDbBase:
if self.metadata and self.metadata.has_key('default'):
person = Person()
handle = self.metadata['default']
data = self.person_map.get(str(handle))
person.unserialize(data)
return person
data = self.person_map.get(str(handle),None)
if data:
person.unserialize(data)
return person
else:
self.metadata['default'] = None
return None
return None
def get_save_path(self):
@ -976,6 +980,14 @@ class GrampsDbBase:
"""
assert False, "Needs to be overridden in the derived class"
def remove_family(self,handle,transaction):
"""
Removes the Family specified by the database handle from the
database, preserving the change in the passed transaction. This
method must be overridden in the derived class.
"""
assert False, "Needs to be overridden in the derived class"
def has_person_handle(self,handle):
"""
returns True if the handle exists in the current Person database.

View File

@ -190,7 +190,8 @@ class PeopleView:
return
p = self.parent.active_person
path = self.person_model.on_get_path(p.get_handle())
top_name = self.parent.db.get_name_group_mapping(p.get_primary_name().get_group_name())
group_name = p.get_primary_name().get_group_name()
top_name = self.parent.db.get_name_group_mapping(group_name)
top_path = self.person_model.on_get_path(top_name)
self.person_tree.expand_row(top_path,0)
self.person_selection.select_path(path)
@ -262,8 +263,8 @@ class PeopleView:
def add_person(self,person):
node = person.get_handle()
top = person.get_primary_name().get_group_name()
if not self.person_model.sname_sub.has_key(top) or \
len(self.person_model.sname_sub[top]) == 1:
if (not self.person_model.sname_sub.has_key(top) or
len(self.person_model.sname_sub[top]) == 1):
path = self.person_model.on_get_path(top)
pnode = self.person_model.get_iter(path)
self.person_model.row_inserted(path,pnode)

View File

@ -1253,7 +1253,18 @@ class Gramps:
_('_Delete Person'),
self.delete_person_response)
def disable_interface(self):
self.remove_button.set_sensitive(False)
self.edit_button.set_sensitive(False)
self.add_button.set_sensitive(False)
def enable_interface(self):
self.remove_button.set_sensitive(True)
self.edit_button.set_sensitive(True)
self.add_button.set_sensitive(True)
def delete_person_response(self):
self.disable_interface()
trans = self.db.transaction_begin()
n = self.active_person.get_primary_name().get_regular_name()
@ -1307,6 +1318,7 @@ class Gramps:
self.goto_active_person()
self.db.transaction_commit(trans,_("Delete Person (%s)") % n)
self.redraw_histmenu()
self.enable_interface()
def merge_update(self,p1,p2,old_id):
self.people_view.remove_from_person_list(p1,old_id)
@ -1325,8 +1337,8 @@ class Gramps:
self.set_buttons(0)
self.active_person = None
self.modify_statusbar()
elif self.active_person == None or \
person.get_handle() != self.active_person.get_handle():
elif (self.active_person == None or
person.get_handle() != self.active_person.get_handle()):
self.active_person = self.db.get_person_from_handle(person.get_handle())
self.modify_statusbar()
self.set_buttons(1)