From 49817c40dcbb0e1327d279a499fb7ad596de997e Mon Sep 17 00:00:00 2001 From: Martin Hawlisch Date: Thu, 29 Dec 2005 18:09:06 +0000 Subject: [PATCH] * src/PedView.py: Add new submenu showing people that share the same event. This for example lists witnesses. svn: r5638 --- ChangeLog | 4 +++ src/PedView.py | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9506668eb..9c21540ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2005-12-29 Martin Hawlisch + * src/PedView.py: Add new submenu showing people that share + the same event. This for example lists witnesses. + 2005-12-28 Don Allingham * src/Makefile.am: add PythonMime and GnomeMime * src/GnomeMime.py: GNOME based mime handling diff --git a/src/PedView.py b/src/PedView.py index 228912b83..f285a53c6 100644 --- a/src/PedView.py +++ b/src/PedView.py @@ -621,6 +621,9 @@ class PedView(PageView.PersonNavView): edit_item.show() menu.append(edit_item) + # collect all spouses, parents and children + linked_persons = [] + # Go over spouses and build their menu item = gtk.MenuItem(_("Spouses")) fam_list = person.get_family_handle_list() @@ -645,6 +648,7 @@ class PedView(PageView.PersonNavView): sp_item = gtk.ImageMenuItem(NameDisplay.displayer.display(spouse)) sp_item.set_image(go_image) sp_item.set_data(_PERSON,sp_id) + linked_persons.append(sp_id) sp_item.connect("activate",self.on_childmenu_changed) sp_item.show() sp_menu.append(sp_item) @@ -679,6 +683,7 @@ class PedView(PageView.PersonNavView): sib_item = gtk.ImageMenuItem(NameDisplay.displayer.display(sib)) sib_item.set_image(go_image) sib_item.set_data(_PERSON,sib_id) + linked_persons.append(sib_id) sib_item.connect("activate",self.on_childmenu_changed) sib_item.show() sib_menu.append(sib_item) @@ -716,6 +721,7 @@ class PedView(PageView.PersonNavView): label.set_alignment(0,0) child_item.add(label) child_item.set_data(_PERSON,child_handle) + linked_persons.append(child_handle) child_item.connect("activate",self.on_childmenu_changed) child_item.show() child_menu.append(child_item) @@ -753,6 +759,7 @@ class PedView(PageView.PersonNavView): label.set_alignment(0,0) par_item.add(label) par_item.set_data(_PERSON,par_id) + linked_persons.append(par_id) par_item.connect("activate",self.on_childmenu_changed) par_item.show() par_menu.append(par_item) @@ -762,6 +769,43 @@ class PedView(PageView.PersonNavView): item.show() menu.append(item) + # Go over parents and build their menu + item = gtk.MenuItem(_("Related")) + no_related = 1 + for p_id in find_witnessed_people(self.db,person): + #if p_id in linked_persons: + # continue # skip already listed family members + + per = self.db.get_person_from_handle(p_id) + if not per: + continue + + if no_related: + no_related = 0 + item.set_submenu(gtk.Menu()) + per_menu = item.get_submenu() + + label = gtk.Label(escape(NameDisplay.displayer.display(per))) + + go_image = gtk.image_new_from_stock(gtk.STOCK_JUMP_TO,gtk.ICON_SIZE_MENU) + go_image.show() + per_item = gtk.ImageMenuItem(None) + per_item.set_image(go_image) + label.set_use_markup(True) + label.show() + label.set_alignment(0,0) + per_item.add(label) + per_item.set_data(_PERSON,p_id) + per_item.connect("activate",self.on_childmenu_changed) + per_item.show() + per_menu.append(per_item) + + if no_related: + item.set_sensitive(0) + item.show() + menu.append(item) + + # Add separator item = gtk.MenuItem(None) item.show() @@ -867,6 +911,35 @@ def find_parents(db,p): parentlist.append(mother_handle) return parentlist +#------------------------------------------------------------------------- +# +# Function to return persons, that share the same event. +# This for example links witnesses to the tree +# +#------------------------------------------------------------------------- +def find_witnessed_people(db,p): + people = [] + for event_ref in p.get_event_ref_list(): + for l in db.find_backlink_handles( event_ref.ref): + if l[0] == 'Person' and l[1] != p.get_handle(): + people.append(l[1]) + if l[0] == 'Family': + fam = db.get_family_from_handle(l[1]) + if fam: + father_handle = fam.get_father_handle() + if father_handle and father_handle != p.get_handle(): + people.append(father_handle) + mother_handle = fam.get_mother_handle() + if mother_handle and mother_handle != p.get_handle(): + people.append(mother_handle) + for f in p.get_family_handle_list(): + family = db.get_family_from_handle(f) + for event_ref in family.get_event_ref_list(): + for l in db.find_backlink_handles( event_ref.ref): + if l[0] == 'Person' and l[1] != p.get_handle(): + people.append(l[1]) + return people + #------------------------------------------------------------------------- # # Functions to build the text displayed in the details view of a DispBox