From d3215c17a42c30243f46e50804fb9d742579d970 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sat, 3 Feb 2007 04:51:52 +0000 Subject: [PATCH] 2007-01-30 Don Allingham * src/Editors/_EditFamily.py: catch family-delete signal svn: r8030 --- gramps2/ChangeLog | 3 +++ gramps2/src/Editors/_EditFamily.py | 9 +++++++++ gramps2/src/GrampsDb/_DbUtils.py | 13 ++++++------- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index d744412ec..335c91fa1 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -10,6 +10,9 @@ 2007-02-01 Alex Roitman * src/plugins/ChangeNames.py: Typo. +2007-01-30 Don Allingham + * src/Editors/_EditFamily.py: catch family-delete signal + 2007-01-30 Brian Matherly * src/docgen/ODFDoc.py: add start_superscript and stop_superscript * src/docgen/KwordDoc.py: add start_superscript and stop_superscript diff --git a/gramps2/src/Editors/_EditFamily.py b/gramps2/src/Editors/_EditFamily.py index eb78096f9..d03835071 100644 --- a/gramps2/src/Editors/_EditFamily.py +++ b/gramps2/src/Editors/_EditFamily.py @@ -396,6 +396,8 @@ class EditFamily(EditPrimary): self._add_db_signal('person-update', self.check_for_change) self._add_db_signal('person-delete', self.check_for_change) self._add_db_signal('person-rebuild', self.reload_people) + self._add_db_signal('family-update', self.check_for_family_change) + self._add_db_signal('family-delete', self.check_for_close) self.added = self.obj.handle == None if self.added: @@ -403,6 +405,13 @@ class EditFamily(EditPrimary): self.load_data() + def check_for_close(self, handles): + if self.obj.get_handle() in handles: + self._do_close() + + def check_for_change(self, handles): + print self.obj.get_handle() in handles + def check_for_change(self,handles): chandles = set([ c.ref for c in self.obj.get_child_ref_list() if c ]) diff --git a/gramps2/src/GrampsDb/_DbUtils.py b/gramps2/src/GrampsDb/_DbUtils.py index 166dad7c5..f5f02bb00 100644 --- a/gramps2/src/GrampsDb/_DbUtils.py +++ b/gramps2/src/GrampsDb/_DbUtils.py @@ -45,17 +45,16 @@ def delete_person_from_database(db, person, trans): else: family.set_mother_handle(None) - if not family.get_father_handle() and not family.get_mother_handle() and \ - not family.get_child_ref_list(): + if ( not family.get_father_handle() and not family.get_mother_handle() and + not family.get_child_ref_list()): db.remove_family(family_handle, trans) else: db.commit_family(family, trans) - for family_handle in person.get_parent_family_handle_list(): - if family_handle: - family = db.get_family_from_handle(family_handle) - family.remove_child_handle(person.get_handle()) - db.commit_family(family, trans) + for family_handle in [fh for fh in person.get_parent_family_handle_list() if fh]: + family = db.get_family_from_handle(family_handle) + family.remove_child_handle(person.get_handle()) + db.commit_family(family, trans) handle = person.get_handle()