2006-05-23 Don Allingham <don@gramps-project.org>

* src/DataViews/_RelationView.py: finish shading
	* src/GrampsDb/_DbUtils.py: add birth/death index set funcion
	* src/Editors/_EditPerson.py: birth/death index fixes
	* src/DisplayTabs/_PersonEventEmbedList.py: birth/death index fixes
	* src/GrampsWidgets.py: shading fixes
	* src/DisplayModels/_PeopleModel.py: birth/death index fixes



svn: r6764
This commit is contained in:
Don Allingham 2006-05-23 21:07:26 +00:00
parent d1d1c2fb5b
commit 74b55ce32a
7 changed files with 101 additions and 71 deletions

View File

@ -1,3 +1,11 @@
2006-05-23 Don Allingham <don@gramps-project.org>
* src/DataViews/_RelationView.py: finish shading
* src/GrampsDb/_DbUtils.py: add birth/death index set funcion
* src/Editors/_EditPerson.py: birth/death index fixes
* src/DisplayTabs/_PersonEventEmbedList.py: birth/death index fixes
* src/GrampsWidgets.py: shading fixes
* src/DisplayModels/_PeopleModel.py: birth/death index fixes
2006-05-23 Alex Roitman <shura@gramps-project.org> 2006-05-23 Alex Roitman <shura@gramps-project.org>
* src/Utils.py (probably_alive): Adapt to new birth/death refs. * src/Utils.py (probably_alive): Adapt to new birth/death refs.

View File

@ -566,6 +566,7 @@ class RelationshipView(PageView.PersonNavView):
label = GrampsWidgets.MarkupLabel(format % cgi.escape(title)) label = GrampsWidgets.MarkupLabel(format % cgi.escape(title))
label.set_alignment(0,0) label.set_alignment(0,0)
label.set_padding(0,3)
self.attach.attach(label, _PLABEL_START, _PLABEL_STOP, self.row, self.attach.attach(label, _PLABEL_START, _PLABEL_STOP, self.row,
self.row+1, xoptions=gtk.FILL|gtk.SHRINK, self.row+1, xoptions=gtk.FILL|gtk.SHRINK,
yoptions=gtk.FILL|gtk.SHRINK) yoptions=gtk.FILL|gtk.SHRINK)
@ -610,13 +611,16 @@ class RelationshipView(PageView.PersonNavView):
link_label = GrampsWidgets.LinkLabel(self.get_name(handle, True), link_label = GrampsWidgets.LinkLabel(self.get_name(handle, True),
self.button_press, handle) self.button_press, handle)
link_label.modify_bg(gtk.STATE_NORMAL, self.color) link_label.modify_bg(gtk.STATE_NORMAL, self.color)
link_label.set_padding(3, 0)
button = GrampsWidgets.IconButton(self.edit_button_press, handle) button = GrampsWidgets.IconButton(self.edit_button_press, handle)
vbox.pack_start(GrampsWidgets.LinkBox(link_label, button)) vbox.pack_start(GrampsWidgets.LinkBox(link_label, button))
if self.show_details: if self.show_details:
value = self.info_string(handle) value = self.info_string(handle)
if value: if value:
vbox.add(GrampsWidgets.BasicLabel(value)) l = GrampsWidgets.BasicLabel(value)
l.set_padding(3, 0)
vbox.add(l)
def write_data(self, box, title, start_col=_SDATA_START, def write_data(self, box, title, start_col=_SDATA_START,
stop_col=_SDATA_STOP): stop_col=_SDATA_STOP):
@ -710,7 +714,6 @@ class RelationshipView(PageView.PersonNavView):
if handle: if handle:
box = self.write_person(_('Spouse'), handle) box = self.write_person(_('Spouse'), handle)
print family
if not self.write_marriage(box, family): if not self.write_marriage(box, family):
self.write_relationship(box, family) self.write_relationship(box, family)

View File

@ -431,13 +431,18 @@ class PeopleModel(gtk.GenericTreeModel):
return PeopleModel._GENDER[data[PeopleModel._GENDER_COL]] return PeopleModel._GENDER[data[PeopleModel._GENDER_COL]]
def column_birth_day(self, data, node): def column_birth_day(self, data, node):
if data[PeopleModel._BIRTH_COL]: index = data[PeopleModel._BIRTH_COL]
b = EventRef() if index != -1:
b.unserialize(data[PeopleModel._BIRTH_COL]) try:
birth = self.db.get_event_from_handle(b.ref) local = data[PeopleModel._EVENT_COL][index]
date_str = DateHandler.get_date(birth) b = EventRef()
if date_str != "": b.unserialize(local)
return cgi.escape(date_str) birth = self.db.get_event_from_handle(b.ref)
date_str = DateHandler.get_date(birth)
if date_str != "":
return cgi.escape(date_str)
except:
return u''
for event_ref in data[PeopleModel._EVENT_COL]: for event_ref in data[PeopleModel._EVENT_COL]:
er = EventRef() er = EventRef()
@ -452,13 +457,18 @@ class PeopleModel(gtk.GenericTreeModel):
return u"" return u""
def column_death_day(self, data, node): def column_death_day(self, data, node):
if data[PeopleModel._DEATH_COL]: index = data[PeopleModel._DEATH_COL]
dr = EventRef() if index != -1:
dr.unserialize(data[PeopleModel._DEATH_COL]) try:
death = self.db.get_event_from_handle(dr.ref) local = data[PeopleModel._EVENT_COL][index]
date_str = DateHandler.get_date(death) ref = EventRef()
if date_str != "": ref.unserialize(local)
return cgi.escape(date_str) event = self.db.get_event_from_handle(ref.ref)
date_str = DateHandler.get_date(event)
if date_str != "":
return cgi.escape(date_str)
except:
return u''
for event_ref in data[PeopleModel._EVENT_COL]: for event_ref in data[PeopleModel._EVENT_COL]:
er = EventRef() er = EventRef()
@ -473,25 +483,35 @@ class PeopleModel(gtk.GenericTreeModel):
return u"" return u""
def column_cause_of_death(self, data, node): def column_cause_of_death(self, data, node):
if data[PeopleModel._DEATH_COL]: index = data[PeopleModel._DEATH_COL]
dr = EventRef() if index != -1:
dr.unserialize(data[PeopleModel._DEATH_COL]) try:
return self.db.get_event_from_handle(dr.ref).get_cause() local = data[PeopleModel._EVENT_COL][index]
dr = EventRef()
dr.unserialize(local)
return self.db.get_event_from_handle(dr.ref).get_cause()
except:
return u''
else: else:
return u"" return u""
def column_birth_place(self, data, node): def column_birth_place(self, data, node):
if data[PeopleModel._BIRTH_COL]: index = data[PeopleModel._BIRTH_COL]
br = EventRef() if index != -1:
br.unserialize(data[PeopleModel._BIRTH_COL]) try:
event = self.db.get_event_from_handle(br.ref) local = data[PeopleModel._EVENT_COL][index]
if event: br = EventRef()
place_handle = event.get_place_handle() br.unserialize(local)
if place_handle: event = self.db.get_event_from_handle(br.ref)
place = self.db.get_place_from_handle(place_handle) if event:
place_title = place.get_title() place_handle = event.get_place_handle()
if place_title != "": if place_handle:
return cgi.escape(place_title) place = self.db.get_place_from_handle(place_handle)
place_title = place.get_title()
if place_title != "":
return cgi.escape(place_title)
except:
return u''
for event_ref in data[PeopleModel._EVENT_COL]: for event_ref in data[PeopleModel._EVENT_COL]:
er = EventRef() er = EventRef()
@ -509,17 +529,22 @@ class PeopleModel(gtk.GenericTreeModel):
return u"" return u""
def column_death_place(self, data, node): def column_death_place(self, data, node):
if data[PeopleModel._DEATH_COL]: index = data[PeopleModel._DEATH_COL]
dr = EventRef() if index != -1:
dr.unserialize(data[PeopleModel._DEATH_COL]) try:
event = self.db.get_event_from_handle(dr.ref) local = data[PeopleModel._EVENT_COL][index]
if event: dr = EventRef()
place_handle = event.get_place_handle() dr.unserialize(local)
if place_handle: event = self.db.get_event_from_handle(dr.ref)
place = self.db.get_place_from_handle(place_handle) if event:
place_title = place.get_title() place_handle = event.get_place_handle()
if place_title != "": if place_handle:
return cgi.escape(place_title) place = self.db.get_place_from_handle(place_handle)
place_title = place.get_title()
if place_title != "":
return cgi.escape(place_title)
except:
return u''
for event_ref in data[PeopleModel._EVENT_COL]: for event_ref in data[PeopleModel._EVENT_COL]:
er = EventRef() er = EventRef()

View File

@ -50,14 +50,10 @@ _std_types = [
class PersonEventEmbedList(EventEmbedList): class PersonEventEmbedList(EventEmbedList):
def __init__(self, dbstate, uistate, track, obj): def __init__(self, dbstate, uistate, track, obj):
self.orig_data = [ data for data in [ obj.get_birth_ref(), \
obj.get_death_ref()] + \
obj.get_event_ref_list() \
if data ]
EventEmbedList.__init__(self, dbstate, uistate, track, obj) EventEmbedList.__init__(self, dbstate, uistate, track, obj)
def get_data(self): def get_data(self):
return self.orig_data return self.obj.get_event_ref_list()
def default_role(self): def default_role(self):
return RelLib.EventRoleType(RelLib.EventRoleType.PRIMARY) return RelLib.EventRoleType(RelLib.EventRoleType.PRIMARY)
@ -66,12 +62,9 @@ class PersonEventEmbedList(EventEmbedList):
type_list = [] type_list = []
# combine return info into a single flat sequence # combine return info into a single flat sequence
ri = self.return_info()
ri = ri[0:2] + tuple(ri[2])
ref_list = [ ref for ref in ri if ref]
event = None event = None
for event_ref in ref_list: for event_ref in self.get_data():
event = self.dbstate.db.get_event_from_handle(event_ref.ref) event = self.dbstate.db.get_event_from_handle(event_ref.ref)
type_list.append(event.get_type()) type_list.append(event.get_type())
@ -84,17 +77,3 @@ class PersonEventEmbedList(EventEmbedList):
from Editors import EditEventRef from Editors import EditEventRef
return EditEventRef return EditEventRef
def return_info(self):
new_list = []
birth_ref = None
death_ref = None
for ref in self.orig_data:
event = self.dbstate.db.get_event_from_handle(ref.ref)
if birth_ref == None and event.get_type() == RelLib.EventType.BIRTH:
birth_ref = ref
elif death_ref == None and event.get_type() == RelLib.EventType.DEATH:
death_ref = ref
else:
new_list.append(ref)
return (birth_ref, death_ref, new_list)

View File

@ -62,6 +62,8 @@ import RelLib
import GrampsWidgets import GrampsWidgets
import Config import Config
from GrampsDb import set_birth_death_index
from _EditPrimary import EditPrimary from _EditPrimary import EditPrimary
from QuestionDialog import * from QuestionDialog import *
from DisplayTabs import \ from DisplayTabs import \
@ -537,11 +539,7 @@ class EditPerson(EditPrimary):
if self._check_for_unknown_gender(): if self._check_for_unknown_gender():
return return
(birth_ref, death_ref, event_list) = self.event_list.return_info() set_birth_death_index(self.db, self.obj)
self.obj.set_birth_ref(birth_ref)
self.obj.set_death_ref(death_ref)
self.obj.set_event_ref_list(event_list)
self.window.hide() self.window.hide()
trans = self.db.transaction_begin() trans = self.db.transaction_begin()

View File

@ -272,3 +272,17 @@ def update_secondary_empty(sec_table,handle,data):
def update_secondary_inmem(sec_table,handle,data): def update_secondary_inmem(sec_table,handle,data):
sec_table[str(data[1])] = str(handle) sec_table[str(data[1])] = str(handle)
def set_birth_death_index(db, person):
birth = -1
death = -1
index = 0
for ref in person.get_event_ref_list():
event = db.get_event_from_handle(ref.ref)
if int(event.get_type()) == RelLib.EventType.BIRTH and birth == -1:
birth = index
elif int(event.get_type()) == RelLib.EventType.DEATH and death == -1:
death = index
person.birth_ref_index = birth
person.death_ref_index = death

View File

@ -65,6 +65,9 @@ class LinkLabel(gtk.EventBox):
self.connect('enter-notify-event', self.enter_text, handle) self.connect('enter-notify-event', self.enter_text, handle)
self.connect('leave-notify-event', self.leave_text, handle) self.connect('leave-notify-event', self.leave_text, handle)
self.connect('realize', realize_cb) self.connect('realize', realize_cb)
def set_padding(self, x, y):
self.label.set_padding(x, y)
def enter_text(self, obj, event, handle): def enter_text(self, obj, event, handle):
text = '<span foreground="blue" underline="single">%s</span>' % self.orig_text text = '<span foreground="blue" underline="single">%s</span>' % self.orig_text