Better column alignment and handling of attributes
svn: r17329
This commit is contained in:
parent
e1e8fa21d9
commit
0c5851b913
@ -43,8 +43,6 @@ class PersonDetails(Gramplet):
|
|||||||
"""
|
"""
|
||||||
Build the GUI interface.
|
Build the GUI interface.
|
||||||
"""
|
"""
|
||||||
self.load_obj = None
|
|
||||||
self.load_rect = None
|
|
||||||
self.top = gtk.HBox()
|
self.top = gtk.HBox()
|
||||||
vbox = gtk.VBox()
|
vbox = gtk.VBox()
|
||||||
self.photo = Photo(190.0)
|
self.photo = Photo(190.0)
|
||||||
@ -53,35 +51,29 @@ class PersonDetails(Gramplet):
|
|||||||
self.name.set_alignment(0, 0)
|
self.name.set_alignment(0, 0)
|
||||||
self.name.modify_font(pango.FontDescription('sans bold 12'))
|
self.name.modify_font(pango.FontDescription('sans bold 12'))
|
||||||
vbox.pack_start(self.name, fill=True, expand=False, padding=7)
|
vbox.pack_start(self.name, fill=True, expand=False, padding=7)
|
||||||
table = gtk.Table(2, 2)
|
self.table = gtk.Table(1, 2)
|
||||||
self.father = self.make_row(table, 0, _('Father'))
|
vbox.pack_start(self.table, fill=True, expand=False, padding=5)
|
||||||
self.mother = self.make_row(table, 1, _('Mother'))
|
|
||||||
vbox.pack_start(table, fill=True, expand=False, padding=5)
|
|
||||||
table = gtk.Table(4, 2)
|
|
||||||
self.birth = self.make_row(table, 0, _('Birth'))
|
|
||||||
self.baptism = self.make_row(table, 1, _('Baptism'))
|
|
||||||
self.death = self.make_row(table, 2, _('Death'))
|
|
||||||
self.burial = self.make_row(table, 3, _('Burial'))
|
|
||||||
vbox.pack_start(table, fill=True, expand=False, padding=5)
|
|
||||||
table = gtk.Table(1, 2)
|
|
||||||
self.occupation = self.make_row(table, 0, _('Occupation'))
|
|
||||||
vbox.pack_start(table, fill=True, expand=False, padding=5)
|
|
||||||
vbox.show_all()
|
vbox.show_all()
|
||||||
self.top.pack_start(self.photo, fill=True, expand=False, padding=5)
|
self.top.pack_start(self.photo, fill=True, expand=False, padding=5)
|
||||||
self.top.pack_start(vbox, fill=True, expand=True, padding=10)
|
self.top.pack_start(vbox, fill=True, expand=True, padding=10)
|
||||||
return self.top
|
return self.top
|
||||||
|
|
||||||
def make_row(self, table, row, title):
|
def add_row(self, title, value):
|
||||||
"""
|
"""
|
||||||
Make a row in a table.
|
Add a row to the table.
|
||||||
"""
|
"""
|
||||||
label = gtk.Label(title + ':')
|
label = gtk.Label(title + ':')
|
||||||
label.set_alignment(1, 0)
|
label.set_alignment(1, 0)
|
||||||
widget = gtk.Label()
|
label.show()
|
||||||
widget.set_alignment(0, 0)
|
value = gtk.Label(value)
|
||||||
table.attach(label, 0, 1, row, row + 1, xoptions=gtk.FILL, xpadding=10)
|
value.set_alignment(0, 0)
|
||||||
table.attach(widget, 1, 2, row, row + 1)
|
value.show()
|
||||||
return (label, widget)
|
rows = self.table.get_property('n-rows')
|
||||||
|
rows += 1
|
||||||
|
self.table.resize(rows, 2)
|
||||||
|
self.table.attach(label, 0, 1, rows, rows + 1, xoptions=gtk.FILL,
|
||||||
|
xpadding=10)
|
||||||
|
self.table.attach(value, 1, 2, rows, rows + 1)
|
||||||
|
|
||||||
def db_changed(self):
|
def db_changed(self):
|
||||||
self.dbstate.db.connect('person-update', self.update)
|
self.dbstate.db.connect('person-update', self.update)
|
||||||
@ -113,13 +105,17 @@ class PersonDetails(Gramplet):
|
|||||||
"""
|
"""
|
||||||
self.load_person_image(active_person)
|
self.load_person_image(active_person)
|
||||||
self.name.set_text(name_displayer.display(active_person))
|
self.name.set_text(name_displayer.display(active_person))
|
||||||
|
|
||||||
|
map(self.table.remove, self.table.get_children())
|
||||||
self.display_parents(active_person)
|
self.display_parents(active_person)
|
||||||
self.display_type(active_person, self.birth, EventType.BIRTH)
|
self.display_separator()
|
||||||
self.display_type(active_person, self.baptism, EventType.BAPTISM)
|
self.display_type(active_person, EventType(EventType.BIRTH))
|
||||||
self.display_type(active_person, self.death, EventType.DEATH)
|
self.display_type(active_person, EventType(EventType.BAPTISM))
|
||||||
self.display_type(active_person, self.burial, EventType.BURIAL)
|
self.display_type(active_person, EventType(EventType.DEATH))
|
||||||
occupation_text = self.get_attribute(active_person, 'Occupation')
|
self.display_type(active_person, EventType(EventType.BURIAL))
|
||||||
self.occupation[1].set_text(occupation_text)
|
self.display_separator()
|
||||||
|
self.display_attribute(active_person, _('Occupation'))
|
||||||
|
self.display_attribute(active_person, _('Religion'))
|
||||||
|
|
||||||
def display_empty(self):
|
def display_empty(self):
|
||||||
"""
|
"""
|
||||||
@ -127,17 +123,19 @@ class PersonDetails(Gramplet):
|
|||||||
"""
|
"""
|
||||||
self.photo.set_image(None)
|
self.photo.set_image(None)
|
||||||
self.name.set_text(_('No active person'))
|
self.name.set_text(_('No active person'))
|
||||||
self.father[1].set_text(_('Unknown'))
|
map(self.table.remove, self.table.get_children())
|
||||||
self.mother[1].set_text(_('Unknown'))
|
|
||||||
self.birth[0].hide()
|
def display_separator(self):
|
||||||
self.birth[1].hide()
|
"""
|
||||||
self.baptism[0].hide()
|
Display an empty row to separate groupd of entries.
|
||||||
self.baptism[1].hide()
|
"""
|
||||||
self.death[0].hide()
|
label = gtk.Label('')
|
||||||
self.death[1].hide()
|
label.modify_font(pango.FontDescription('sans 4'))
|
||||||
self.burial[0].hide()
|
label.show()
|
||||||
self.burial[1].hide()
|
rows = self.table.get_property('n-rows')
|
||||||
self.occupation[1].set_text(_('Unknown'))
|
rows += 1
|
||||||
|
self.table.resize(rows, 2)
|
||||||
|
self.table.attach(label, 0, 1, rows, rows + 1, xoptions=gtk.FILL)
|
||||||
|
|
||||||
def display_parents(self, active_person):
|
def display_parents(self, active_person):
|
||||||
"""
|
"""
|
||||||
@ -149,41 +147,40 @@ class PersonDetails(Gramplet):
|
|||||||
handle = family.get_father_handle()
|
handle = family.get_father_handle()
|
||||||
if handle:
|
if handle:
|
||||||
father = self.dbstate.db.get_person_from_handle(handle)
|
father = self.dbstate.db.get_person_from_handle(handle)
|
||||||
self.father[1].set_text(name_displayer.display(father))
|
father_name = name_displayer.display(father)
|
||||||
else:
|
else:
|
||||||
self.father[1].set_text(_('Unknown'))
|
father_name = _('Unknown')
|
||||||
handle = family.get_mother_handle()
|
handle = family.get_mother_handle()
|
||||||
if handle:
|
if handle:
|
||||||
mother = self.dbstate.db.get_person_from_handle(handle)
|
mother = self.dbstate.db.get_person_from_handle(handle)
|
||||||
self.mother[1].set_text(name_displayer.display(mother))
|
mother_name = name_displayer.display(mother)
|
||||||
else:
|
else:
|
||||||
self.mother[1].set_text(_('Unknown'))
|
mother_name = _('Unknown')
|
||||||
else:
|
else:
|
||||||
self.father[1].set_text(_('Unknown'))
|
father_name = _('Unknown')
|
||||||
self.mother[1].set_text(_('Unknown'))
|
mother_name = _('Unknown')
|
||||||
|
|
||||||
def get_attribute(self, person, attr_key):
|
self.add_row(_('Father'), father_name)
|
||||||
|
self.add_row(_('Mother'), mother_name)
|
||||||
|
|
||||||
|
def display_attribute(self, active_person, attr_key):
|
||||||
"""
|
"""
|
||||||
Return an attribute with the given key.
|
Display an attribute row.
|
||||||
"""
|
"""
|
||||||
for attr in person.get_attribute_list():
|
values = []
|
||||||
|
for attr in active_person.get_attribute_list():
|
||||||
if attr.get_type() == attr_key:
|
if attr.get_type() == attr_key:
|
||||||
return attr.get_value()
|
values.append(attr.get_value())
|
||||||
return _('Unknown')
|
if values:
|
||||||
|
self.add_row(attr_key, _(', ').join(values))
|
||||||
|
|
||||||
def display_type(self, active_person, widget, event_type):
|
def display_type(self, active_person, event_type):
|
||||||
"""
|
"""
|
||||||
Display an event type row.
|
Display an event type row.
|
||||||
"""
|
"""
|
||||||
event = self.get_event(active_person, event_type)
|
event = self.get_event(active_person, event_type)
|
||||||
if event:
|
if event:
|
||||||
widget[1].set_text(self.format_event(event))
|
self.add_row(str(event_type), self.format_event(event))
|
||||||
widget[0].show()
|
|
||||||
widget[1].show()
|
|
||||||
else:
|
|
||||||
widget[1].set_text('')
|
|
||||||
widget[0].hide()
|
|
||||||
widget[1].hide()
|
|
||||||
|
|
||||||
def get_event(self, person, event_type):
|
def get_event(self, person, event_type):
|
||||||
"""
|
"""
|
||||||
@ -192,7 +189,7 @@ class PersonDetails(Gramplet):
|
|||||||
for event_ref in person.get_event_ref_list():
|
for event_ref in person.get_event_ref_list():
|
||||||
if int(event_ref.get_role()) == EventRoleType.PRIMARY:
|
if int(event_ref.get_role()) == EventRoleType.PRIMARY:
|
||||||
event = self.dbstate.db.get_event_from_handle(event_ref.ref)
|
event = self.dbstate.db.get_event_from_handle(event_ref.ref)
|
||||||
if int(event.get_type()) == event_type:
|
if event.get_type() == event_type:
|
||||||
return event
|
return event
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -204,7 +201,8 @@ class PersonDetails(Gramplet):
|
|||||||
handle = event.get_place_handle()
|
handle = event.get_place_handle()
|
||||||
if handle:
|
if handle:
|
||||||
place = self.dbstate.db.get_place_from_handle(handle).get_title()
|
place = self.dbstate.db.get_place_from_handle(handle).get_title()
|
||||||
retval = _('%(date)s - %(place)s.') % {'date' : date, 'place' : place}
|
retval = _('%(date)s - %(place)s.') % {'date' : date,
|
||||||
|
'place' : place}
|
||||||
else:
|
else:
|
||||||
retval = _('%(date)s.') % dict(date = date)
|
retval = _('%(date)s.') % dict(date = date)
|
||||||
return retval
|
return retval
|
||||||
|
Loading…
Reference in New Issue
Block a user