* src/DisplayModels/_PeopleModel.py: Make fallbacks for birth and death work again.

* src/DataViews/_RelationView.py (write_title): Display fallbacks in case birth or death is not available
* src/DataViews/_PedigreeView.py: Display fallbacks in case birth or death is not available



svn: r7575
This commit is contained in:
Martin Hawlisch 2006-11-07 12:05:40 +00:00
parent 56e6c22f65
commit b64f5a1332
4 changed files with 88 additions and 15 deletions

View File

@ -1,3 +1,11 @@
2006-11-07 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/DisplayModels/_PeopleModel.py: Make fallbacks for birth and
death work again.
* src/DataViews/_RelationView.py (write_title): Display fallbacks
in case birth or death is not available
* src/DataViews/_PedigreeView.py: Display fallbacks in case birth
or death is not available
2006-11-06 Don Allingham <don@gramps-project.org>
* src/glade/gramps.glade: add tooltips for place buttons
* src/GrampsWidgets.py: provide default instructions for place

View File

@ -133,7 +133,7 @@ class PersonBoxWidget_cairo( gtk.DrawingArea, _PersonWidget_base):
self.connect("realize", self.realize)
self.text = ""
if self.person:
self.text = self.fh.format_person(self.person,self.maxlines)
self.text = self.fh.format_person(self.person,self.maxlines,True)
alive = Utils.probably_alive(self.person,self.fh.dbstate.db)
if alive and self.person.get_gender() == RelLib.Person.MALE:
self.bgcolor = (185/256.0, 207/256.0, 231/256.0)
@ -178,7 +178,7 @@ class PersonBoxWidget_cairo( gtk.DrawingArea, _PersonWidget_base):
self.context = self.window.cairo_create()
self.textlayout = self.context.create_layout()
self.textlayout.set_font_description(self.get_style().font_desc)
self.textlayout.set_text(self.text)
self.textlayout.set_markup(self.text)
s = self.textlayout.get_pixel_size()
xmin = s[0] + 12
ymin = s[1] + 11
@ -383,15 +383,59 @@ class FormattingHelper:
else:
text = place_title
return text
def format_person( self, person, line_count):
def format_person( self, person, line_count, use_markup=False):
if not person:
return ""
name = NameDisplay.displayer.display(person)
if line_count < 3:
return name
bdate,bplace,bdate_full,bdate_mod,ddate,dplace,ddate_full,ddate_mod = \
ReportUtils.get_birth_death_strings(self.dbstate.db,person)
birth_ref = person.get_birth_ref()
birth = None
birth_fallback = False
if birth_ref:
birth = self.dbstate.db.get_event_from_handle(birth_ref.ref)
else:
for event_ref in person.get_event_ref_list():
event = self.dbstate.db.get_event_from_handle(event_ref.ref)
if event.get_type() in [RelLib.EventType.CHRISTEN, RelLib.EventType.BAPTISM]:
birth = event
birth_fallback = True
break
death_ref = person.get_death_ref()
death = None
death_fallback = False
if death_ref:
death = self.dbstate.db.get_event_from_handle(death_ref.ref)
else:
for event_ref in person.get_event_ref_list():
event = self.dbstate.db.get_event_from_handle(event_ref.ref)
if event.get_type() in [RelLib.EventType.BURIAL, RelLib.EventType.CREMATION]:
death = event
death_fallback = True
break
if birth and birth_fallback and use_markup:
bdate = "<i>%s</i>" % birth.get_date_object()
bplace = "<i>%s</i>" % self.get_place_name(birth)
elif birth:
bdate = birth.get_date_object()
bplace = self.get_place_name(birth)
else:
bdate = ""
bplace = ""
if death and death_fallback and use_markup:
ddate = "<i>%s</i>" % death.get_date_object()
dplace = "<i>%s</i>" % self.get_place_name(death)
elif death:
ddate = death.get_date_object()
dplace = self.get_place_name(death)
else:
ddate = ""
dplace = ""
if line_count < 5:
return "%s\n* %s\n+ %s" % (name,bdate,ddate)
else:

View File

@ -442,23 +442,45 @@ class RelationshipView(PageView.PersonNavView):
# Birth event.
birth_ref = person.get_birth_ref()
birth_title = _('Birth')
birth = None
if birth_ref:
birth = self.dbstate.db.get_event_from_handle(birth_ref.ref)
else:
birth = None
for event_ref in person.get_event_ref_list():
event = self.dbstate.db.get_event_from_handle(event_ref.ref)
if event.get_type() == RelLib.EventType.CHRISTEN:
birth_title = _('Christening')
birth = event
break
if event.get_type() == RelLib.EventType.BAPTISM:
birth_title = _('Baptism')
birth = event
break
subtbl.attach(GrampsWidgets.BasicLabel("%s:" % _('Birth')),
subtbl.attach(GrampsWidgets.BasicLabel("%s:" % birth_title),
1, 2, 1, 2, xoptions=gtk.FILL, yoptions=0)
subtbl.attach(GrampsWidgets.BasicLabel(self.format_event(birth)),
2, 3, 1, 2, yoptions=0)
death_ref = person.get_death_ref()
death_title = _('Death')
death = None
if death_ref:
death = self.dbstate.db.get_event_from_handle(death_ref.ref)
else:
death = None
for event_ref in person.get_event_ref_list():
event = self.dbstate.db.get_event_from_handle(event_ref.ref)
if event.get_type() == RelLib.EventType.BURIAL:
death_title = _('Burial')
death = event
break
if event.get_type() == RelLib.EventType.CREMATION:
death_title = _('Cremation')
death = event
break
subtbl.attach(GrampsWidgets.BasicLabel("%s:" % _('Death')),
subtbl.attach(GrampsWidgets.BasicLabel("%s:" % death_title),
1, 2, 2, 3, xoptions=gtk.FILL, yoptions=0)
subtbl.attach(GrampsWidgets.BasicLabel(self.format_event(death)),
2, 3, 2, 3, yoptions=0)
@ -963,4 +985,3 @@ class RelationshipView(PageView.PersonNavView):
self.dbstate.active.handle)
except Errors.WindowActiveError:
pass

View File

@ -452,7 +452,7 @@ class PeopleModel(gtk.GenericTreeModel):
er = EventRef()
er.unserialize(event_ref)
event = self.db.get_event_from_handle(er.ref)
etype = event.get_type()[0]
etype = event.get_type()
date_str = DateHandler.get_date(event)
if (etype in [EventType.BAPTISM, EventType.CHRISTEN]
and date_str != ""):
@ -478,7 +478,7 @@ class PeopleModel(gtk.GenericTreeModel):
er = EventRef()
er.unserialize(event_ref)
event = self.db.get_event_from_handle(er.ref)
etype = event.get_type()[0]
etype = event.get_type()
date_str = DateHandler.get_date(event)
if (etype in [EventType.BURIAL, EventType.CREMATION]
and date_str != ""):
@ -508,7 +508,7 @@ class PeopleModel(gtk.GenericTreeModel):
er = EventRef()
er.unserialize(event_ref)
event = self.db.get_event_from_handle(er.ref)
etype = event.get_type()[0]
etype = event.get_type()
if etype in [EventType.BAPTISM, EventType.CHRISTEN]:
place_handle = event.get_place_handle()
if place_handle:
@ -541,7 +541,7 @@ class PeopleModel(gtk.GenericTreeModel):
er = EventRef()
er.unserialize(event_ref)
event = self.db.get_event_from_handle(er.ref)
etype = event.get_type()[0]
etype = event.get_type()
if etype in [EventType.BURIAL, EventType.CREMATION]:
place_handle = event.get_place_handle()
if place_handle: