* src/FamilyView.py: new format
svn: r5658
This commit is contained in:
parent
e739d24062
commit
27d0144765
@ -1,3 +1,6 @@
|
|||||||
|
2006-01-03 Don Allingham <don@gramps-project.org>
|
||||||
|
* src/FamilyView.py: new format
|
||||||
|
|
||||||
2006-01-02 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
2006-01-02 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
||||||
* src/PedView.py: Show marriage data; Dont use a black border for
|
* src/PedView.py: Show marriage data; Dont use a black border for
|
||||||
living people
|
living people
|
||||||
|
@ -14,6 +14,7 @@ import re
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gobject
|
import gobject
|
||||||
import gtk
|
import gtk
|
||||||
|
import pango
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -23,37 +24,14 @@ import gtk
|
|||||||
import RelLib
|
import RelLib
|
||||||
import PageView
|
import PageView
|
||||||
import DisplayTrace
|
import DisplayTrace
|
||||||
import DisplayModels
|
import NameDisplay
|
||||||
|
|
||||||
class Gbutton(gtk.Button):
|
|
||||||
|
|
||||||
def __init__(self,stock_name,clicked=None):
|
|
||||||
gtk.Button.__init__(self)
|
|
||||||
image = gtk.Image()
|
|
||||||
image.set_from_stock(stock_name,gtk.ICON_SIZE_BUTTON)
|
|
||||||
self.add(image)
|
|
||||||
if clicked:
|
|
||||||
self.connect('clicked',clicked)
|
|
||||||
|
|
||||||
class Glabel(gtk.Label):
|
|
||||||
|
|
||||||
def __init__(self,val):
|
|
||||||
gtk.Label.__init__(self,'<b>%s</b>' % val)
|
|
||||||
self.set_use_markup(True)
|
|
||||||
self.set_use_underline(True)
|
|
||||||
self.set_alignment(0,0.5)
|
|
||||||
|
|
||||||
class Slabel(gtk.Label):
|
|
||||||
|
|
||||||
def __init__(self,val):
|
|
||||||
gtk.Label.__init__(self, val)
|
|
||||||
self.set_alignment(1.0,0.5)
|
|
||||||
|
|
||||||
class FamilyView(PageView.PageView):
|
class FamilyView(PageView.PageView):
|
||||||
|
|
||||||
def __init__(self,dbstate,uistate):
|
def __init__(self,dbstate,uistate):
|
||||||
PageView.PageView.__init__(self,'Pedigree View',dbstate,uistate)
|
PageView.PageView.__init__(self,'Pedigree View',dbstate,uistate)
|
||||||
dbstate.connect('database-changed',self.change_db)
|
dbstate.connect('database-changed',self.change_db)
|
||||||
|
dbstate.connect('active-changed',self.change_person)
|
||||||
|
|
||||||
def get_stock(self):
|
def get_stock(self):
|
||||||
"""
|
"""
|
||||||
@ -64,79 +42,10 @@ class FamilyView(PageView.PageView):
|
|||||||
return 'gramps-family'
|
return 'gramps-family'
|
||||||
|
|
||||||
def build_widget(self):
|
def build_widget(self):
|
||||||
fill = gtk.EXPAND|gtk.FILL
|
self.vbox = gtk.VBox()
|
||||||
|
self.vbox.show()
|
||||||
self.parents_box = gtk.ComboBox()
|
self.child = None
|
||||||
self.spouse_box = gtk.ComboBox()
|
return self.vbox
|
||||||
self.person_name = gtk.Entry()
|
|
||||||
self.person_birth = gtk.Entry()
|
|
||||||
self.person_death = gtk.Entry()
|
|
||||||
self.marriage_type = gtk.Entry()
|
|
||||||
self.marriage_info = gtk.Entry()
|
|
||||||
self.family_id = gtk.Entry()
|
|
||||||
self.child_list = gtk.TreeView()
|
|
||||||
self.child_model = DisplayModels.ChildModel([],self.dbstate.db)
|
|
||||||
|
|
||||||
switch = Gbutton(gtk.STOCK_GO_BACK, self.switch_spouse)
|
|
||||||
edit_active = Gbutton(gtk.STOCK_EDIT, self.edit_person)
|
|
||||||
new_spouse = Gbutton(gtk.STOCK_NEW)
|
|
||||||
spouse_select = Gbutton(gtk.STOCK_INDEX)
|
|
||||||
rel_edit = Gbutton(gtk.STOCK_EDIT)
|
|
||||||
parents_down = Gbutton(gtk.STOCK_GO_DOWN)
|
|
||||||
child_up = Gbutton(gtk.STOCK_GO_UP)
|
|
||||||
child_new = Gbutton(gtk.STOCK_NEW)
|
|
||||||
child_sel = Gbutton(gtk.STOCK_INDEX)
|
|
||||||
child_del = Gbutton(gtk.STOCK_REMOVE)
|
|
||||||
|
|
||||||
table = gtk.Table(10,8)
|
|
||||||
table.set_col_spacings(12)
|
|
||||||
table.set_row_spacings(6)
|
|
||||||
table.set_border_width(6)
|
|
||||||
|
|
||||||
# Parents
|
|
||||||
table.attach(Glabel(_("_Parents")), 0, 7, 0, 1, gtk.FILL,0,0,0)
|
|
||||||
table.attach(self.parents_box, 1, 7, 1, 2, gtk.FILL, gtk.FILL, 0, 0)
|
|
||||||
table.attach(parents_down, 7, 8, 1, 2, 0, 0, 0, 0)
|
|
||||||
|
|
||||||
# Active Person
|
|
||||||
table.attach(Glabel('_Active person'), 0, 3, 3, 4, gtk.FILL, 0, 0, 0)
|
|
||||||
table.attach(self.person_name, 1, 3, 4, 5, gtk.EXPAND | gtk.FILL, 0, 0, 0)
|
|
||||||
table.attach(Slabel(_("b.")), 1, 2, 5, 6, gtk.FILL, 0,0,0)
|
|
||||||
table.attach(self.person_birth, 2, 3, 5, 6, gtk.EXPAND|gtk.FILL, 0, 0, 0)
|
|
||||||
table.attach(Slabel(_("d.")), 1, 2, 6, 7, gtk.FILL, 0, 0, 0)
|
|
||||||
table.attach(self.person_death, 2, 3, 6, 7, gtk.EXPAND | gtk.FILL, 0,0,0)
|
|
||||||
table.attach(switch, 3, 4, 4, 5, gtk.FILL, 0,0,0)
|
|
||||||
table.attach(edit_active, 3, 4, 5, 6, gtk.FILL, 0, 0, 0)
|
|
||||||
|
|
||||||
# Spouse
|
|
||||||
table.attach(Glabel(_("_Spouse/Partner")), 4, 7, 3, 4, gtk.FILL, 0,0,0)
|
|
||||||
table.attach(self.spouse_box, 5, 7, 4, 5, gtk.FILL, gtk.FILL, 0, 0)
|
|
||||||
vbox90 = gtk.VBox(True, 6)
|
|
||||||
vbox90.pack_start(new_spouse, False, False, 0)
|
|
||||||
vbox90.pack_start(spouse_select, False, False, 0)
|
|
||||||
vbox90.pack_start(rel_edit, False, False, 0)
|
|
||||||
table.attach(vbox90, 7, 8, 4, 7, gtk.FILL, gtk.FILL, 0, 0)
|
|
||||||
table.attach(Slabel('Type:'), 5,6,5,6,gtk.FILL, 0,0,0)
|
|
||||||
table.attach(self.marriage_type, 6, 7, 5, 6, gtk.EXPAND|gtk.FILL, 0, 0, 0)
|
|
||||||
table.attach(self.marriage_info, 6, 7, 6, 7, gtk.EXPAND|gtk.FILL, 0, 0, 0)
|
|
||||||
|
|
||||||
# Children
|
|
||||||
|
|
||||||
table.attach(Glabel('_Children'), 0, 7, 8, 9, gtk.FILL, 0, 0, 0)
|
|
||||||
vbox89 = gtk.VBox(False, 6)
|
|
||||||
vbox89.pack_start(child_up, False, False, 0)
|
|
||||||
vbox89.pack_start(child_new, False, False, 0)
|
|
||||||
vbox89.pack_start(child_sel, False, False, 0)
|
|
||||||
vbox89.pack_start(child_del, False, False, 0)
|
|
||||||
table.attach (vbox89, 7, 8, 9, 10, gtk.FILL, gtk.FILL, 0, 0);
|
|
||||||
|
|
||||||
scrolledwindow83 = gtk.ScrolledWindow()
|
|
||||||
scrolledwindow83.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
|
||||||
scrolledwindow83.set_shadow_type(gtk.SHADOW_IN)
|
|
||||||
scrolledwindow83.add(self.child_list)
|
|
||||||
table.attach(scrolledwindow83, 1, 7, 9, 10, gtk.FILL, gtk.EXPAND|gtk.FILL, 0, 0)
|
|
||||||
|
|
||||||
return table
|
|
||||||
|
|
||||||
def navigation_type(self):
|
def navigation_type(self):
|
||||||
return PageView.NAVIGATION_PERSON
|
return PageView.NAVIGATION_PERSON
|
||||||
@ -155,8 +64,121 @@ class FamilyView(PageView.PageView):
|
|||||||
def change_db(self,db):
|
def change_db(self,db):
|
||||||
return
|
return
|
||||||
|
|
||||||
def switch_spouse(self,obj):
|
def get_name(self,handle):
|
||||||
print "switch spouse"
|
if handle:
|
||||||
|
p = self.dbstate.db.get_person_from_handle(handle)
|
||||||
|
return NameDisplay.displayer.display(p)
|
||||||
|
else:
|
||||||
|
return _(u"Unknown")
|
||||||
|
|
||||||
|
def change_person(self,obj):
|
||||||
|
if self.child:
|
||||||
|
self.vbox.remove(self.child)
|
||||||
|
self.child = gtk.Table(10,8)
|
||||||
|
self.child.set_border_width(12)
|
||||||
|
self.child.set_col_spacings(12)
|
||||||
|
self.child.set_row_spacings(6)
|
||||||
|
|
||||||
|
person = self.dbstate.db.get_person_from_handle(obj)
|
||||||
|
self.write_title(person)
|
||||||
|
|
||||||
|
family_handle_list = person.get_parent_family_handle_list()
|
||||||
|
for (family_handle,mrel,frel) in family_handle_list:
|
||||||
|
if family_handle:
|
||||||
|
self.write_label(_('Parents'))
|
||||||
|
self.write_parents(family_handle)
|
||||||
|
|
||||||
|
family_handle_list = person.get_family_handle_list()
|
||||||
|
for family_handle in family_handle_list:
|
||||||
|
if family_handle:
|
||||||
|
self.write_label(_('Family'))
|
||||||
|
self.write_family(family_handle)
|
||||||
|
|
||||||
|
self.child.show()
|
||||||
|
self.vbox.pack_start(self.child,expand=False,fill=False)
|
||||||
|
|
||||||
|
def make_button(self,handle,icon,func):
|
||||||
|
image = gtk.Image()
|
||||||
|
image.set_from_stock(icon,gtk.ICON_SIZE_MENU)
|
||||||
|
image.show()
|
||||||
|
button = gtk.Button()
|
||||||
|
button.add(image)
|
||||||
|
button.connect('clicked',func,handle)
|
||||||
|
button.show()
|
||||||
|
return button
|
||||||
|
|
||||||
|
def make_edit_button(self,handle):
|
||||||
|
return self.make_button(handle,gtk.STOCK_EDIT,self.edit_person)
|
||||||
|
|
||||||
|
def make_goto_button(self,handle):
|
||||||
|
return self.make_button(handle,gtk.STOCK_JUMP_TO,self.change_to)
|
||||||
|
|
||||||
|
def write_title(self,person):
|
||||||
|
label = gtk.Label('<span size="larger" weight="bold">%s</span>'
|
||||||
|
% NameDisplay.displayer.display(person))
|
||||||
|
label.set_use_markup(True)
|
||||||
|
label.set_alignment(0,0.5)
|
||||||
|
label.show()
|
||||||
|
self.child.attach(label,0,6,0,1)
|
||||||
|
button = self.make_edit_button(person.handle)
|
||||||
|
self.child.attach(button,7,8,0,1,xoptions=0)
|
||||||
|
self.row = 1
|
||||||
|
|
||||||
|
def write_label(self,title):
|
||||||
|
label = gtk.Label('<span weight="bold">%s</span>' % title)
|
||||||
|
label.set_use_markup(True)
|
||||||
|
label.set_alignment(0,0.5)
|
||||||
|
label.show()
|
||||||
|
self.child.attach(label,1,6,self.row,self.row+1)
|
||||||
|
self.row += 1
|
||||||
|
|
||||||
|
def write_person(self,title,handle):
|
||||||
|
if title:
|
||||||
|
format = '<span weight="bold">%s: </span>'
|
||||||
|
else:
|
||||||
|
format = "%s"
|
||||||
|
label = gtk.Label(format % title)
|
||||||
|
label.set_use_markup(True)
|
||||||
|
label.set_alignment(1.0,0.5)
|
||||||
|
label.show()
|
||||||
|
self.child.attach(label,2,3,self.row,self.row+1,xoptions=0)
|
||||||
|
|
||||||
|
label = gtk.Label(self.get_name(handle))
|
||||||
|
label.set_alignment(0,0.5)
|
||||||
|
label.show()
|
||||||
|
self.child.attach(label,3,4,self.row,self.row+1,
|
||||||
|
xoptions=gtk.EXPAND|gtk.FILL)
|
||||||
|
button = self.make_edit_button(handle)
|
||||||
|
self.child.attach(button,7,8,self.row,self.row+1,xoptions=0)
|
||||||
|
button = self.make_goto_button(handle)
|
||||||
|
self.child.attach(button,6,7,self.row,self.row+1,xoptions=0)
|
||||||
|
self.row += 1
|
||||||
|
|
||||||
|
def write_parents(self,family_handle):
|
||||||
|
family = self.dbstate.db.get_family_from_handle(family_handle)
|
||||||
|
self.write_person(_('Father'),family.get_father_handle())
|
||||||
|
self.write_person(_('Mother'),family.get_mother_handle())
|
||||||
|
|
||||||
|
def write_family(self,family_handle):
|
||||||
|
family = self.dbstate.db.get_family_from_handle(family_handle)
|
||||||
|
father_handle = family.get_father_handle()
|
||||||
|
mother_handle = family.get_mother_handle()
|
||||||
|
if self.dbstate.active.handle == father_handle:
|
||||||
|
self.write_person(_('Spouse'),mother_handle)
|
||||||
|
else:
|
||||||
|
self.write_person(_('Spouse'),father_handle)
|
||||||
|
child_list = family.get_child_handle_list()
|
||||||
|
label = _("Children")
|
||||||
|
if child_list:
|
||||||
|
for child in child_list:
|
||||||
|
self.write_person(label,child)
|
||||||
|
label = u""
|
||||||
|
|
||||||
|
def edit_person(self,obj,handle):
|
||||||
|
import EditPerson
|
||||||
|
person = self.dbstate.db.get_person_from_handle(handle)
|
||||||
|
EditPerson.EditPerson(self.dbstate, self.uistate, [], person)
|
||||||
|
|
||||||
|
def change_to(self,obj,handle):
|
||||||
|
self.dbstate.change_active_handle(handle)
|
||||||
|
|
||||||
def edit_person(self,obj):
|
|
||||||
print "edit person"
|
|
||||||
|
Loading…
Reference in New Issue
Block a user