* src/gramps.glade: added select/edit buttions to family view

* src/SelectChild.py: change title from Add Children to Add Child
to Family
* src/FamilyView: add support for adding spouse/child with full
Edit Person window, along with old method of adding via selectors


svn: r1746
This commit is contained in:
Don Allingham 2003-06-15 04:13:16 +00:00
parent 67d9d84de5
commit 06e1a01c05
3 changed files with 192 additions and 17 deletions

View File

@ -42,6 +42,8 @@ import SelectChild
import DisplayTrace
import Marriage
import ChooseParents
import RelLib
import EditPerson
from intl import gettext as _
from QuestionDialog import QuestionDialog,WarningDialog
@ -70,6 +72,7 @@ class FamilyView:
self.swap_btn = self.top.get_widget('swap_spouse_btn')
self.add_spouse_btn = self.top.get_widget('add_spouse')
self.select_spouse_btn = self.top.get_widget('select_spouse')
self.remove_spouse_btn = self.top.get_widget('remove_spouse')
self.ap_parents = self.top.get_widget('ap_parents')
@ -102,6 +105,7 @@ class FamilyView:
self.top.get_widget('fam_back').connect('clicked',self.child_back)
self.top.get_widget('del_child_btn').connect('clicked',self.remove_child_clicked)
self.top.get_widget('add_child_btn').connect('clicked',self.add_child_clicked)
self.top.get_widget('select_child').connect('clicked',self.select_child_clicked)
column = gtk.TreeViewColumn('',gtk.CellRendererText(),text=0)
self.spouse_list.append_column(column)
@ -130,6 +134,7 @@ class FamilyView:
self.swap_btn.connect('clicked',self.spouse_swap)
self.remove_spouse_btn.connect('clicked',self.remove_spouse)
self.add_spouse_btn.connect('clicked',self.add_spouse)
self.select_spouse_btn.connect('clicked',self.select_spouse)
self.child_list.set_model(self.child_model)
self.child_list.set_search_column(0)
@ -181,7 +186,7 @@ class FamilyView:
except:
DisplayTrace.DisplayTrace()
def add_spouse(self,obj):
def select_spouse(self,obj):
if not self.person:
return
try:
@ -191,7 +196,79 @@ class FamilyView:
except:
DisplayTrace.DisplayTrace()
def add_spouse(self,obj):
person = RelLib.Person()
if self.person.getGender() == RelLib.Person.male:
person.setGender(RelLib.Person.female)
else:
person.setGender(RelLib.Person.male)
try:
EditPerson.EditPerson(person, self.parent.db, self.spouse_after_edit)
except:
DisplayTrace.DisplayTrace()
def spouse_after_edit(self,epo,plist):
if epo.person.getId() == "":
self.parent.db.addPerson(epo.person)
else:
self.parent.db.addPersonNoMap(epo.person,epo.person.getId())
self.parent.db.buildPersonDisplay(epo.person.getId())
self.parent.add_to_person_list(epo.person,0)
self.family = self.parent.db.newFamily()
self.person.addFamily(self.family)
epo.person.addFamily(self.family)
if self.person.getGender() == RelLib.Person.male:
self.family.setMother(epo.person)
self.family.setFather(self.person)
else:
self.family.setFather(epo.person)
self.family.setMother(self.person)
self.load_family(self.family)
Marriage.Marriage(self.family,self.parent.db,
self.parent.new_after_edit,
self.load_family)
def add_child_clicked(self,obj):
if not self.person:
return
person = RelLib.Person()
person.setGender(RelLib.Person.female)
autoname = GrampsCfg.lastnamegen
if autoname == 0:
name = self.north_american(0)
elif autoname == 2:
name = self.latin_american(0)
elif autoname == 3:
name = self.icelandic(0)
else:
name = ""
person.getPrimaryName().setSurname(name)
try:
EditPerson.EditPerson(person, self.parent.db, self.child_after_edit)
except:
DisplayTrace.DisplayTrace()
def child_after_edit(self,epo,plist):
if epo.person.getId() == "":
self.parent.db.addPerson(epo.person)
else:
self.parent.db.addPersonNoMap(epo.person,epo.person.getId())
self.parent.db.buildPersonDisplay(epo.person.getId())
self.parent.add_to_person_list(epo.person,0)
self.family.addChild(epo.person)
epo.person.addAltFamily(self.family,"Birth","Birth")
self.load_family()
def select_child_clicked(self,obj):
if not self.person:
return
try:
@ -611,6 +688,52 @@ class FamilyView:
data = str(('child',id));
sel_data.set(sel_data.target, bits_per, data)
def north_american(self,val):
if self.person.getGender() == Person.male:
return self.person.getPrimaryName().getSurname()
elif self.family:
f = self.family.getFather()
if f:
return f.getPrimaryName().getSurname()
return ""
def no_name(self,val):
return ""
def latin_american(self,val):
if self.family:
father = self.family.getFather()
mother = self.family.getMother()
if not father or not mother:
return ""
fsn = father.getPrimaryName().getSurname()
msn = mother.getPrimaryName().getSurname()
if not father or not mother:
return ""
try:
return "%s %s" % (fsn.split()[0],msn.split()[0])
except:
return ""
else:
return ""
def icelandic(self,val):
fname = ""
if self.person.getGender() == Person.male:
fname = self.person.getPrimaryName().getFirstName()
elif self.family:
f = self.family.getFather()
if f:
fname = f.getPrimaryName().getFirstName()
if fname:
fname = string.split(fname)[0]
if val == 0:
return "%ssson" % fname
elif val == 1:
return "%sdóttir" % fname
else:
return ""
def drag_begin(self, obj, context):
return
# model, iter = self.child_selection.get_selected()

View File

@ -75,7 +75,7 @@ class SelectChild:
self.top = self.xml.get_widget("select_child")
title_label = self.xml.get_widget('title')
Utils.set_titles(self.top,title_label,_('Add Children'))
Utils.set_titles(self.top,title_label,_('Add Child to Family'))
self.add_child = self.xml.get_widget("childlist")

View File

@ -1446,20 +1446,20 @@
<widget class="GtkVBox" id="vbox55">
<property name="visible">True</property>
<property name="homogeneous">True</property>
<property name="spacing">0</property>
<property name="spacing">6</property>
<child>
<widget class="GtkButton" id="add_spouse">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Adds a spouse</property>
<property name="tooltip" translatable="yes">Adds a new person to the database and to a new relationship</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<child>
<widget class="GtkImage" id="image84">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
<property name="stock">gtk-new</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
@ -1468,7 +1468,33 @@
</child>
</widget>
<packing>
<property name="padding">5</property>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="select_spouse">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Selects an existing person from the database and adds to a new relationship</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<child>
<widget class="GtkImage" id="image475">
<property name="visible">True</property>
<property name="stock">gtk-index</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
@ -1494,7 +1520,7 @@
</child>
</widget>
<packing>
<property name="padding">5</property>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
@ -1514,7 +1540,7 @@
<widget class="GtkVBox" id="vbox57">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<property name="spacing">6</property>
<child>
<widget class="GtkButton" id="ap_parents_btn">
@ -1536,7 +1562,7 @@
</child>
</widget>
<packing>
<property name="padding">6</property>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
@ -1638,7 +1664,7 @@
<widget class="GtkVBox" id="vbox56">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<property name="spacing">6</property>
<child>
<widget class="GtkButton" id="sp_parents_btn">
@ -1660,7 +1686,7 @@
</child>
</widget>
<packing>
<property name="padding">6</property>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
@ -1972,7 +1998,7 @@
<widget class="GtkVBox" id="vbox65">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<property name="spacing">6</property>
<child>
<widget class="GtkButton" id="fam_back">
@ -1994,7 +2020,7 @@
</child>
</widget>
<packing>
<property name="padding">10</property>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
@ -2003,15 +2029,41 @@
<child>
<widget class="GtkButton" id="add_child_btn">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Adds a new child to the selected family</property>
<property name="tooltip" translatable="yes">Adds a new child to the database and to the current family</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<child>
<widget class="GtkImage" id="image94">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
<property name="stock">gtk-new</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="select_child">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Selects an existing person from the database and adds as a child to the current family</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<child>
<widget class="GtkImage" id="image474">
<property name="visible">True</property>
<property name="stock">gtk-index</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>