diff --git a/src/DisplayTabs/_BackRefModel.py b/src/DisplayTabs/_BackRefModel.py index d0ecc00ba..18039b406 100644 --- a/src/DisplayTabs/_BackRefModel.py +++ b/src/DisplayTabs/_BackRefModel.py @@ -44,6 +44,8 @@ import Utils # #------------------------------------------------------------------------- class BackRefModel(gtk.ListStore): + + dispstr = _('%(part1)s - %(part2)s') def __init__(self, sref_list, db): gtk.ListStore.__init__(self, str, str, str, str, str) @@ -78,10 +80,17 @@ class BackRefModel(gtk.ListStore): elif dtype == 'Event': p = self.db.get_event_from_handle(ref[1]) gid = p.gramps_id - name = p.get_description() handle = p.handle - if not name: + name = p.get_description() + if name: + name = self.dispstr % {'part1': str(p.get_type()), + 'part2': name} + else: name = str(p.get_type()) + part = Utils.get_participant_from_event(self.db, ref[1]) + if part : + name = self.dispstr % {'part1': name, + 'part2': part} elif dtype == 'Place': p = self.db.get_place_from_handle(ref[1]) name = p.get_title() diff --git a/src/Utils.py b/src/Utils.py index c39fc092d..0d980a074 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -1002,4 +1002,43 @@ def update_constants(): _MIN_GENERATION_YEARS = Config.get(Config.MIN_GENERATION_YEARS) _AVG_GENERATION_GAP = Config.get(Config.AVG_GENERATION_GAP) +#------------------------------------------------------------------------- +# +# Function to return the name of the main participant of an event +# +#------------------------------------------------------------------------- +def get_participant_from_event(db, event_handle): + """ + Obtain the first primary or family participant to an event we find in the + database. Note that an event can have more than one primary or + family participant, only one is returned. + """ + participant = "" + result_list = [i for i in db.find_backlink_handles(event_handle, + include_classes=['Person', 'Family'])] + people = [x[1] for x in result_list if x[0] == 'Person'] + families = [x[1] for x in result_list if x[0] == 'Family'] + for personhandle in people: + person = db.get_person_from_handle(personhandle) + for event_ref in person.get_event_ref_list(): + if event_handle == event_ref.ref and \ + event_ref.get_role() == gen.lib.EventRoleType.PRIMARY: + participant = name_displayer.display(person) + break + if participant: + break + if participant: + return participant + + for familyhandle in families: + family = db.get_family_from_handle(familyhandle) + for event_ref in family.get_event_ref_list(): + if event_handle == event_ref.ref and \ + event_ref.get_role() == gen.lib.EventRoleType.FAMILY: + participant = family_name(family, db) + break + if participant: + break + + return participant