diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 3644f1a9e..8bf77b5ed 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,11 @@ +2006-11-07 Martin Hawlisch + * 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 * src/glade/gramps.glade: add tooltips for place buttons * src/GrampsWidgets.py: provide default instructions for place diff --git a/gramps2/src/DataViews/_PedigreeView.py b/gramps2/src/DataViews/_PedigreeView.py index 39cf0d958..89b05b170 100644 --- a/gramps2/src/DataViews/_PedigreeView.py +++ b/gramps2/src/DataViews/_PedigreeView.py @@ -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 = "%s" % birth.get_date_object() + bplace = "%s" % 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 = "%s" % death.get_date_object() + dplace = "%s" % 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: diff --git a/gramps2/src/DataViews/_RelationView.py b/gramps2/src/DataViews/_RelationView.py index 8d420901e..3c45f6077 100644 --- a/gramps2/src/DataViews/_RelationView.py +++ b/gramps2/src/DataViews/_RelationView.py @@ -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 - diff --git a/gramps2/src/DisplayModels/_PeopleModel.py b/gramps2/src/DisplayModels/_PeopleModel.py index aaf4c1697..e702112cd 100644 --- a/gramps2/src/DisplayModels/_PeopleModel.py +++ b/gramps2/src/DisplayModels/_PeopleModel.py @@ -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: