Concept of a preferred set of parents

svn: r855
This commit is contained in:
Don Allingham 2002-03-24 16:44:31 +00:00
parent 26cc165273
commit a96442f263
5 changed files with 168 additions and 147 deletions

View File

@ -297,8 +297,6 @@ class GrampsParser:
else:
frel = "Birth"
self.person.AltFamilyList.append((family,mrel,frel))
if attrs.has_key('pref'):
self.person.setMainFamily(family)
def start_parentin(self,attrs):
self.person.FamilyList.append(self.db.findFamilyNoMap(u2l(attrs["ref"])))

View File

@ -1079,12 +1079,15 @@ class Person:
def addAltFamily(self,family,mrel,frel):
"""adds a Family to the alternate family list, indicating the relationship
to the mother (mrel) and the father (frel)"""
assert(family==None)
self.AltFamilyList.append((family,mrel,frel))
def removeAltFamily(self,family):
"""removes a Family instance from the alternate family list"""
for f in self.AltFamilyList[:]:
print "+",f[0],family
if f[0] == family:
print f, family
self.AltFamilyList.remove(f)
return f
else:
@ -1101,9 +1104,9 @@ class Person:
"""sets the main Family of the Person, the Family in which the
Person is a natural born child"""
assert(family in self.AltFamilyList)
f = self.removeFamily(family)
self.AltFamilyList = [f] + self.AltFamilyList
f = self.removeAltFamily(family)
if f:
self.AltFamilyList = [f] + self.AltFamilyList
def getMainFamily(self):
"""returns the main Family of the Person, the Family in which the

View File

@ -250,13 +250,12 @@ class XmlWriter:
self.write_attribute_list(person.getAttributeList())
self.write_url_list(person.getUrlList())
self.write_ref("childof",person.getMainFamily(),3)
for alt in person.getAltFamilyList():
if alt[1] != "":
if alt[1] != "Birth":
mrel=' mrel="%s"' % alt[1]
else:
mrel=''
if alt[2] != "":
if alt[2] != "Birth":
frel=' frel="%s"' % alt[2]
else:
frel=''

View File

@ -1511,7 +1511,7 @@
<widget>
<class>GtkFrame</class>
<name>frame1</name>
<name>rel_frame</name>
<border_width>5</border_width>
<label>Relationship</label>
<label_xalign>0</label_xalign>
@ -1784,7 +1784,7 @@
<widget>
<class>GtkFrame</class>
<name>frame2</name>
<name>parent_frame</name>
<border_width>5</border_width>
<label>Parents</label>
<label_xalign>0</label_xalign>
@ -1998,9 +1998,119 @@
</widget>
</widget>
<widget>
<class>GtkHBox</class>
<name>hbox75</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<left_attach>1</left_attach>
<right_attach>3</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
<widget>
<class>GtkLabel</class>
<name>label301</name>
<label>Related by:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>5</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>frel</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
</widget>
<widget>
<class>GtkHBox</class>
<name>hbox76</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<left_attach>1</left_attach>
<right_attach>3</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
<widget>
<class>GtkLabel</class>
<name>label302</name>
<label>Related by:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>5</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>mrel</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox50</name>
<name>multi_parents</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
@ -2011,7 +2121,7 @@
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
@ -2081,122 +2191,17 @@
</widget>
</widget>
<widget>
<class>GtkHBox</class>
<name>hbox75</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
<widget>
<class>GtkLabel</class>
<name>label301</name>
<label>Related by:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>5</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>frel</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
</widget>
<widget>
<class>GtkHBox</class>
<name>hbox76</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
<widget>
<class>GtkLabel</class>
<name>label302</name>
<label>Related by:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>5</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>mrel</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
</widget>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>preffam</name>
<visible>False</visible>
<can_focus>True</can_focus>
<label>Preferred Family</label>
<signal>
<name>toggled</name>
<handler>on_preffam_toggled</handler>
<last_modification_time>Sun, 24 Mar 2002 16:20:15 GMT</last_modification_time>
</signal>
<label>Make this the preferred family</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
@ -2204,8 +2209,8 @@
<right_attach>2</right_attach>
<top_attach>4</top_attach>
<bottom_attach>5</bottom_attach>
<xpad>5</xpad>
<ypad>5</ypad>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>

View File

@ -211,6 +211,7 @@ class Gramps:
self.gtop.signal_autoconnect({
"delete_event" : self.delete_event,
"destroy_passed_object" : Utils.destroy_passed_object,
"on_preffam_toggled" : self.on_preferred_fam_toggled,
"on_family_up_clicked" : self.family_up_clicked,
"on_family_down_clicked" : self.family_down_clicked,
"on_prefrel_toggled" : self.on_preferred_rel_toggled,
@ -1307,6 +1308,13 @@ class Gramps:
self.spouse_ptab.set_page(1)
self.spouse_pref.set_active(0)
self.active_person.setPreferred(self.active_family)
Utils.modified()
def on_preferred_fam_toggled(self,obj):
obj.set_active(0)
self.active_person.setMainFamily(self.active_parents)
self.change_parents(self.active_parents)
Utils.modified()
def new_after_edit(self,epo,plist):
if epo:
@ -1402,31 +1410,15 @@ class Gramps:
if self.active_parents == None and len(family_types) > 0:
self.active_parents = family_types[0][0]
if len(family_types) > 1:
self.gtop.get_widget('multi_parents').show()
self.gtop.get_widget('preffam').show()
else:
self.gtop.get_widget('multi_parents').hide()
self.gtop.get_widget('preffam').hide()
else:
self.active_parents = None
# if len(family_types) > 0:
# typeMenu = gtk.GtkMenu()
# index = 0
# pref = 0
# for fam in family_types:
# if fam[0] == main_family:
# pref = index
# if self.active_person == fam[0].getFather():
# menuitem = gtk.GtkMenuItem("%s/%s" % (fam[1],fam[2]))
# else:
# menuitem = gtk.GtkMenuItem("%s/%s" % (fam[2],fam[1]))
# menuitem.set_data("parents",fam[0])
# menuitem.connect("activate",self.on_current_type_changed)
# menuitem.show()
# typeMenu.append(menuitem)
# index = index + 1
# self.child_type.set_menu(typeMenu)
# self.child_type.set_history(pref)
# self.child_type.show()
# else:
# self.child_type.hide()
self.change_parents(self.active_parents)
if self.active_person:
@ -1494,6 +1486,8 @@ class Gramps:
self.display_marriage(None)
def change_parents(self,family):
"""Switches to a different set of parents on the Family View"""
if self.active_parents and self.active_parents.getRelationship() == "Partners":
fn = _("Parent")
mn = _("Parent")
@ -1501,6 +1495,24 @@ class Gramps:
fn = _("Father")
mn = _("Mother")
pframe = self.gtop.get_widget('parent_frame')
if self.active_parents:
val = len(self.active_person.getAltFamilyList())
if self.active_parents == self.active_person.getMainFamily():
self.gtop.get_widget('preffam').set_sensitive(0)
if val > 1:
pframe.set_label(_("Preferred Parents (%d of %d)") % \
(self.parents_index+1,val))
else:
pframe.set_label(_("Preferred Parents"))
else:
self.gtop.get_widget('preffam').set_sensitive(1)
pframe.set_label(_("Alternate Parents (%d of %d)") % \
(self.parents_index+1,val))
else:
self.gtop.get_widget('parent_frame').set_label(_("No Parents"))
self.gtop.get_widget("editFather").children()[0].set_text(fn)
self.gtop.get_widget("editMother").children()[0].set_text(mn)
@ -1508,6 +1520,9 @@ class Gramps:
fv_mother = self.gtop.get_widget("fv_mother")
father_next = self.gtop.get_widget("father_next")
mother_next = self.gtop.get_widget("mother_next")
self.gtop.get_widget("mrel").set_text('')
self.gtop.get_widget("frel").set_text('')
if family != None :
self.active_father = family.getFather()
@ -1529,6 +1544,7 @@ class Gramps:
if f[0] == family:
self.gtop.get_widget("mrel").set_text(_(f[1]))
self.gtop.get_widget("frel").set_text(_(f[2]))
break
elif self.active_person == None:
fv_father.set_text("")
fv_mother.set_text("")