* src/PedView.py: Show Baptism/Burial as fallback for birth/death; Moved text generation for details view out of DispBox class so that PedigreeView can use the same string for max size calculation.

* src/PeopleModel.py: Show Baptism/Burial as fallback for birth/death. Based on patch from Jim Smart.
* src/PeopleView.py: Enable makup that PeopleModel can render fallback data in italics.


svn: r4299
This commit is contained in:
Martin Hawlisch 2005-04-05 15:02:59 +00:00
parent 0b50042f61
commit 34490376db
4 changed files with 132 additions and 54 deletions

View File

@ -1,3 +1,11 @@
2005-04-05 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/PedView.py: Show Baptism/Burial as fallback for birth/death; Moved text
generation for details view out of DispBox class so that PedigreeView can use the
same string for max size calculation.
* src/PeopleModel.py: Show Baptism/Burial as fallback for birth/death. Based on
patch from Jim Smart.
* src/PeopleView.py: Enable makup that PeopleModel can render fallback data in italics.
2005-04-01 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/GrampsDBCallback.py: added support for disconnecting callbacks,
better test code and lots of logging. Improved the comments.

View File

@ -61,6 +61,11 @@ _CANVASPAD = 3
_PERSON = "p"
_BORN = _('b.')
_DIED = _('d.')
_BAPT = _('bap.')
_CHRI = _('chr.')
_BURI = _('bur.')
_CREM = _('crem.')
#-------------------------------------------------------------------------
#
@ -77,6 +82,7 @@ class DispBox:
shadow = _PAD
xpad = _PAD
self.db = db
self.change = change
self.edit = edit
self.build_menu = build_menu
@ -88,27 +94,8 @@ class DispBox:
self.root = root
self.name = NameDisplay.displayer.display(person)
birth_handle = self.person.get_birth_handle()
death_handle = self.person.get_death_handle()
if birth_handle:
bd = db.get_event_from_handle(birth_handle).get_date()
else:
bd = ""
if death_handle:
dd = db.get_event_from_handle(death_handle).get_date()
else:
dd = ""
if bd and dd:
self.exp = "%s\n%s %s\n%s %s" % (self.name,_BORN,bd,_DIED,dd )
elif bd:
self.exp = "%s\n%s %s" % (self.name,_BORN,bd )
elif dd:
self.exp = "%s\n%s %s" % (self.name,_DIED,dd )
else:
self.exp = "%s" % self.name
self.exp = build_detail_string( db, person)
self.group = self.root.add(CanvasGroup,x=x,y=y)
self.shadow = self.group.add(
@ -130,6 +117,7 @@ class DispBox:
self.group.connect('event',self.group_event)
self.group.set_data(_PERSON,person.get_handle())
def cleanup(self):
self.shadow.destroy()
self.bkgnd.destroy()
@ -229,23 +217,12 @@ class PedigreeView:
for t in lst:
if t:
birth_handle = t[0].get_birth_handle()
death_handle = t[0].get_death_handle()
if birth_handle:
birth = self.parent.db.get_event_from_handle(birth_handle).get_date()
else:
birth = u""
if death_handle:
death = self.parent.db.get_event_from_handle(death_handle).get_date()
else:
death = u""
for n in [NameDisplay.displayer.display(t[0]), u'%s %s' % (_BORN,birth),
u'%s %s' % (_DIED,death)]:
boxtext = build_detail_string(self.parent.db,t[0]).encode("UTF-8")
for line in boxtext.split("\n"):
try:
a.set_text(n,len(n))
a.set_text(line,len(line))
except TypeError:
a.set_text(n)
a.set_text(line)
(w1,h1) = a.get_pixel_size()
h = max(h,h1)
w = max(w,w1)
@ -759,3 +736,56 @@ def find_parents(db,p):
if mother_handle not in parentlist:
parentlist.append(mother_handle)
return parentlist
#-------------------------------------------------------------------------
#
# Functions to build the text displayed in the details view of a DispBox
# aditionally used by PedigreeView to get the largest area covered by a DispBox
#
#-------------------------------------------------------------------------
def build_detail_string(db,person):
detail_text = NameDisplay.displayer.display(person)
def format_event(db, label, event):
if not event:
return u""
ed = event.get_date()
ep = None
place_handle = event.get_place_handle()
if place_handle:
place_title = db.get_place_from_handle(place_handle).get_title()
if place_title != "":
ep = place_title
if ep:
return u"\n%s %s, %s" % (label,ed,ep)
return u"\n%s %s" % (label,ed)
birth_handle = person.get_birth_handle()
if birth_handle:
detail_text += format_event(db, _BORN, db.get_event_from_handle(birth_handle))
else:
for event_handle in person.get_event_list():
event = db.get_event_from_handle(event_handle)
if event.get_name() == "Baptism":
detail_text += format_event(db, _BAPT, event)
break
if event.get_name() == "Christening":
detail_text += format_event(db, _CHRI, event)
break
death_handle = person.get_death_handle()
if death_handle:
detail_text += format_event(db, _DIED, db.get_event_from_handle(death_handle))
else:
for event_handle in person.get_event_list():
event = db.get_event_from_handle(event_handle)
if event.get_name() == "Burial":
detail_text += format_event(db, _BURI, event)
break
if event.get_name() == "Cremation":
detail_text += format_event(db, _CREM, event)
break
return detail_text

View File

@ -28,6 +28,7 @@
from gettext import gettext as _
import time
import locale
import cgi
#-------------------------------------------------------------------------
#
@ -57,6 +58,7 @@ _GENDER_COL= 2
_NAME_COL = 3
_DEATH_COL = 6
_BIRTH_COL = 7
_EVENT_COL = 8
_FAMILY_COL= 9
_CHANGE_COL= 21
@ -282,14 +284,28 @@ class PeopleModel(gtk.GenericTreeModel):
def column_birth_day(self,data,node):
if data[_BIRTH_COL]:
return self.db.get_event_from_handle(data[_BIRTH_COL]).get_date()
else:
birth = self.db.get_event_from_handle(data[_BIRTH_COL])
if birth.get_date() and birth.get_date() != "":
return cgi.escape(birth.get_date())
for event_handle in data[_EVENT_COL]:
event = self.db.get_event_from_handle(event_handle)
if event.name in ["Baptism", "Christening"] and event.get_date() != "":
return "<i>" + cgi.escape(event.get_date()) + "</i>"
return u""
def column_death_day(self,data,node):
if data[_DEATH_COL]:
return self.db.get_event_from_handle(data[_DEATH_COL]).get_date()
else:
death = self.db.get_event_from_handle(data[_DEATH_COL])
if death.get_date() and death.get_date() != "":
return cgi.escape(death.get_date())
for event_handle in data[_EVENT_COL]:
event = self.db.get_event_from_handle(event_handle)
if event.name in ["Burial", "Cremation"] and event.get_date() != "":
return "<i>" + cgi.escape(event.get_date()) + "</i>"
return u""
def column_cause_of_death(self,data,node):
@ -304,7 +320,19 @@ class PeopleModel(gtk.GenericTreeModel):
if event:
place_handle = event.get_place_handle()
if place_handle:
return self.db.get_place_from_handle(place_handle).get_title()
place_title = self.db.get_place_from_handle(place_handle).get_title()
if place_title != "":
return cgi.escape(place_title)
for event_handle in data[_EVENT_COL]:
event = self.db.get_event_from_handle(event_handle)
if event.name in ["Baptism", "Christening"]:
place_handle = event.get_place_handle()
if place_handle:
place_title = self.db.get_place_from_handle(place_handle).get_title()
if place_title != "":
return "<i>" + cgi.escape(place_title) + "</i>"
return u""
def column_death_place(self,data,node):
@ -313,7 +341,19 @@ class PeopleModel(gtk.GenericTreeModel):
if event:
place_handle = event.get_place_handle()
if place_handle:
return self.db.get_place_from_handle(place_handle).get_title()
place_title = self.db.get_place_from_handle(place_handle).get_title()
if place_title != "":
return cgi.escape(place_title)
for event_handle in data[_EVENT_COL]:
event = self.db.get_event_from_handle(event_handle)
if event.name in ["Baptism", "Christening"]:
place_handle = event.get_place_handle()
if place_handle:
place_title = self.db.get_place_from_handle(place_handle).get_title()
if place_title != "":
return "<i>" + cgi.escape(place_title) + "</i>"
return u""
def column_int_id(self,data,node):

View File

@ -127,7 +127,7 @@ class PeopleView:
if not pair[0]:
continue
name = column_names[pair[1]]
column = gtk.TreeViewColumn(name, self.renderer, text=pair[1])
column = gtk.TreeViewColumn(name, self.renderer, markup=pair[1])
column.set_resizable(True)
column.set_min_width(60)
column.set_sizing(gtk.TREE_VIEW_COLUMN_GROW_ONLY)