diff --git a/gramps/plugins/gramplet/ancestor.py b/gramps/plugins/gramplet/ancestor.py index 8ddc57fd8..7c75cb90d 100644 --- a/gramps/plugins/gramplet/ancestor.py +++ b/gramps/plugins/gramplet/ancestor.py @@ -73,8 +73,8 @@ class Ancestor(Gramplet): """ if active_handle: person = self.dbstate.db.get_person_from_handle(active_handle) - if person: - family_handle = person.get_main_parents_family_handle() + family_handle = person.get_main_parents_family_handle() + if family_handle: family = self.dbstate.db.get_family_from_handle(family_handle) if family and (family.get_father_handle() or family.get_mother_handle()): diff --git a/gramps/plugins/gramplet/children.py b/gramps/plugins/gramplet/children.py index 78e37d0fc..31daf7101 100644 --- a/gramps/plugins/gramplet/children.py +++ b/gramps/plugins/gramplet/children.py @@ -20,6 +20,7 @@ from gramps.gui.editors import EditPerson from gramps.gui.listmodel import ListModel, NOSORT from gramps.gen.plug import Gramplet +from gramps.gen.plug.report.utils import find_spouse from gramps.gen.const import GRAMPS_LOCALE as glocale _ = glocale.translation.gettext from gramps.gen.display.name import displayer as name_displayer @@ -128,19 +129,18 @@ class PersonChildren(Children): active_person = self.dbstate.db.get_person_from_handle(active_handle) for family_handle in active_person.get_family_handle_list(): family = self.dbstate.db.get_family_from_handle(family_handle) - self.display_family(family, active_handle) + self.display_family(family, active_person) self.set_has_data(self.model.count > 0) - def display_family(self, family, active_handle): + def display_family(self, family, active_person): """ Display the children of given family. """ - father_handle = family.get_father_handle() - mother_handle = family.get_mother_handle() - if father_handle == active_handle: - spouse = self.dbstate.db.get_person_from_handle(mother_handle) + spouse_handle = find_spouse(active_person, family) + if spouse_handle: + spouse = self.dbstate.db.get_person_from_handle(spouse_handle) else: - spouse = self.dbstate.db.get_person_from_handle(father_handle) + spouse = None for child_ref in family.get_child_ref_list(): child = self.dbstate.db.get_person_from_handle(child_ref.ref) diff --git a/gramps/plugins/gramplet/events.py b/gramps/plugins/gramplet/events.py index 398e9d84f..de24e90fa 100644 --- a/gramps/plugins/gramplet/events.py +++ b/gramps/plugins/gramplet/events.py @@ -21,6 +21,7 @@ from gramps.gui.editors import EditEvent from gramps.gen.lib import EventRoleType from gramps.gui.listmodel import ListModel, NOSORT from gramps.gen.plug import Gramplet +from gramps.gen.plug.report.utils import find_spouse from gramps.gui.dbguielement import DbGUIElement from gramps.gen.const import GRAMPS_LOCALE as glocale _ = glocale.translation.gettext @@ -199,16 +200,22 @@ class PersonEvents(Events): self.add_event_ref(event_ref) for family_handle in active_person.get_family_handle_list(): family = self.dbstate.db.get_family_from_handle(family_handle) - father_handle = family.get_father_handle() - mother_handle = family.get_mother_handle() - if father_handle == active_handle: - spouse = self.dbstate.db.get_person_from_handle(mother_handle) - else: - spouse = self.dbstate.db.get_person_from_handle(father_handle) - for event_ref in family.get_event_ref_list(): - self.add_event_ref(event_ref, spouse) + self.display_family(family, active_person) self.set_has_data(self.model.count > 0) + def display_family(self, family, active_person): + """ + Display the events for the given family. + """ + spouse_handle = find_spouse(active_person, family) + if spouse_handle: + spouse = self.dbstate.db.get_person_from_handle(spouse_handle) + else: + spouse = None + + for event_ref in family.get_event_ref_list(): + self.add_event_ref(event_ref, spouse) + def get_start_date(self): """ Get the start date for a person, usually a birth date, or