* 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,28 +94,9 @@ 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(
CanvasRect, x1=shadow, y1=shadow, x2=w+shadow, y2=h+shadow,
@ -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
@ -141,15 +143,15 @@ class PeopleModel(gtk.GenericTreeModel):
return locale.strcoll(f[0],s[0])
def on_get_flags(self):
'''returns the GtkTreeModelFlags for this particular type of model'''
return gtk.TREE_MODEL_ITERS_PERSIST
'''returns the GtkTreeModelFlags for this particular type of model'''
return gtk.TREE_MODEL_ITERS_PERSIST
def on_get_n_columns(self):
return len(COLUMN_DEFS)
def on_get_path(self, node):
'''returns the tree path (a tuple of indices at the various
levels) for a particular node.'''
'''returns the tree path (a tuple of indices at the various
levels) for a particular node.'''
try:
return (self.top_path2iter.index(node),)
except:
@ -198,7 +200,7 @@ class PeopleModel(gtk.GenericTreeModel):
pass
def on_iter_next(self, node):
'''returns the next node at this level of the tree'''
'''returns the next node at this level of the tree'''
try:
path = self.top_path2iter.index(node)
if path+1 == len(self.top_path2iter):
@ -216,7 +218,7 @@ class PeopleModel(gtk.GenericTreeModel):
return self.path2iter.get((node,0))
def on_iter_has_child(self, node):
'''returns true if this node has children'''
'''returns true if this node has children'''
if node == None:
return len(self.sname_sub)
if self.sname_sub.has_key(node) and len(self.sname_sub[node]) > 0:
@ -243,7 +245,7 @@ class PeopleModel(gtk.GenericTreeModel):
return None
def on_iter_parent(self, node):
'''returns the parent of this node'''
'''returns the parent of this node'''
path = self.iter2path.get(node)
if path:
return path[0]
@ -253,7 +255,7 @@ class PeopleModel(gtk.GenericTreeModel):
return data[_NAME_COL].get_sort_name()
def column_spouse(self,data,node):
spouses_names = u""
spouses_names = u""
handle = data[0]
for family_handle in data[_FAMILY_COL]:
family = self.db.get_family_from_handle(family_handle)
@ -266,7 +268,7 @@ class PeopleModel(gtk.GenericTreeModel):
if len(spouses_names) > 0:
spouses_names += ", "
spouses_names += NameDisplay.displayer.display(spouse)
return spouses_names
return spouses_names
def column_name(self,data,node):
return NameDisplay.displayer.sorted_name(data[_NAME_COL])
@ -282,15 +284,29 @@ 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:
return u""
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:
return u""
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):
if data[_DEATH_COL]:
@ -302,18 +318,42 @@ class PeopleModel(gtk.GenericTreeModel):
if data[_BIRTH_COL]:
event = self.db.get_event_from_handle(data[_BIRTH_COL])
if event:
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 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:
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 "<i>" + cgi.escape(place_title) + "</i>"
return u""
def column_death_place(self,data,node):
if data[_DEATH_COL]:
event = self.db.get_event_from_handle(data[_DEATH_COL])
if event:
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 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:
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 "<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)