From 2f5aa02120a37ebccc280b636d6c682891f2e9be Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Thu, 20 Apr 2006 03:44:11 +0000 Subject: [PATCH] * src/RelLib/_Family.py: add remove_child_handle svn: r6376 --- ChangeLog | 1 + src/Editors/_EditFamily.py | 8 +++++--- src/RelLib/_Family.py | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9fae7a3ae..d4b1f13cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ 2006-04-19 Don Allingham + * src/RelLib/_Family.py: add remove_child_handle * src/DataViews/_EventView.py: more GrampsTypes changes * src/DataViews/_PedigreeView.py: more GrampsTypes changes * src/RelLib/_ChildRef.py: more GrampsTypes changes diff --git a/src/Editors/_EditFamily.py b/src/Editors/_EditFamily.py index c467bbc71..6ec48df66 100644 --- a/src/Editors/_EditFamily.py +++ b/src/Editors/_EditFamily.py @@ -238,9 +238,11 @@ class ChildEmbedList(EmbeddedList): skip=[ x for x in skip if x]) def del_button_clicked(self,obj): - ref = self.get_selected() - if ref: - self.family.remove_child_ref(ref) + handle = self.get_selected() + if handle: + for ref in self.family.get_child_ref_list(): + if ref.ref == handle: + self.family.remove_child_ref(ref) self.rebuild() def edit_button_clicked(self,obj): diff --git a/src/RelLib/_Family.py b/src/RelLib/_Family.py index 885983d26..0fd4a20bd 100644 --- a/src/RelLib/_Family.py +++ b/src/RelLib/_Family.py @@ -382,6 +382,21 @@ class Family(PrimaryObject,SourceBase,NoteBase,MediaBase,AttributeBase, if ref.ref != child_ref.ref ] self.child_ref_list = new_list + def remove_child_handle(self,child_handle): + """ + Removes the database handle for L{Person} to the Family's list + of children if the L{Person} is already in the list. + + @param person_handle: L{Person} database handle + @type person_handle: str + @return: True if the handle was removed, False if it was not + in the list. + @rtype: bool + """ + new_list = [ref for ref in self.child_ref_list + if ref.ref != child_handle ] + self.child_ref_list = new_list + def get_child_ref_list(self): """ Returns the list of L{Person} handles identifying the children