Fix Relationship view so ages are according to Preferences (#798)

Fixes #11040
This commit is contained in:
Paul Culley 2019-03-16 23:18:00 -05:00 committed by Sam Manzi
parent 71ad5ffb04
commit aff888a0b5

View File

@ -160,6 +160,8 @@ class RelationshipView(NavigationView):
self.use_shade = self._config.get('preferences.relation-shade') self.use_shade = self._config.get('preferences.relation-shade')
self.theme = self._config.get('preferences.relation-display-theme') self.theme = self._config.get('preferences.relation-display-theme')
self.toolbar_visible = config.get('interface.toolbar-on') self.toolbar_visible = config.get('interface.toolbar-on')
self.age_precision = config.get('preferences.age-display-precision')
def get_handle_from_gramps_id(self, gid): def get_handle_from_gramps_id(self, gid):
""" """
@ -619,29 +621,30 @@ class RelationshipView(NavigationView):
if death: if death:
death_date = death.get_date_object() death_date = death.get_date_object()
if (death_date and death_date.get_valid()): if (death_date and death_date.get_valid()):
age = death_date - birth_date age = (death_date - birth_date).format(
subgrid.attach(widgets.BasicLabel(_("%s:") % death_title), precision=self.age_precision)
1, 2, 1, 1) subgrid.attach(widgets.BasicLabel(
deathwidget = widgets.BasicLabel("%s (%s)" % _("%s:") % death_title), 1, 2, 1, 1)
(self.format_event(death), age), deathwidget = widgets.BasicLabel(
Pango.EllipsizeMode.END) "%s (%s)" % (self.format_event(death), age),
Pango.EllipsizeMode.END)
deathwidget.set_selectable(True) deathwidget.set_selectable(True)
subgrid.attach(deathwidget, subgrid.attach(deathwidget, 2, 2, 1, 1)
2, 2, 1, 1)
showed_death = True showed_death = True
if not showed_death: if not showed_death:
age = Today() - birth_date age = (Today() - birth_date).format(
precision=self.age_precision)
if probably_alive(person, self.dbstate.db): if probably_alive(person, self.dbstate.db):
subgrid.attach(widgets.BasicLabel(_("%s:") % _("Alive")), subgrid.attach(widgets.BasicLabel(
1, 2, 1, 1) _("%s:") % _("Alive")), 1, 2, 1, 1)
subgrid.attach(widgets.BasicLabel("(%s)" % age, Pango.EllipsizeMode.END), subgrid.attach(widgets.BasicLabel(
2, 2, 1, 1) "(%s)" % age, Pango.EllipsizeMode.END), 2, 2, 1, 1)
else: else:
subgrid.attach(widgets.BasicLabel(_("%s:") % _("Death")), subgrid.attach(widgets.BasicLabel(
1, 2, 1, 1) _("%s:") % _("Death")), 1, 2, 1, 1)
subgrid.attach(widgets.BasicLabel("%s (%s)" % (_("unknown"), age), subgrid.attach(widgets.BasicLabel(
Pango.EllipsizeMode.END), "%s (%s)" % (_("unknown"), age),
2, 2, 1, 1) Pango.EllipsizeMode.END), 2, 2, 1, 1)
showed_death = True showed_death = True
if not showed_death: if not showed_death: