Better handling of perferred spouse, and rework of parents

svn: r854
This commit is contained in:
Don Allingham 2002-03-24 03:15:54 +00:00
parent c63c61be7e
commit 26cc165273
7 changed files with 537 additions and 253 deletions

View File

@ -259,47 +259,18 @@ class ChooseParents:
Changes the family type of the specified family. If the family Changes the family type of the specified family. If the family
is None, the the relationship type shoud be deleted. is None, the the relationship type shoud be deleted.
""" """
is_main = mother_rel == "Birth" and father_rel == "Birth" if self.person not in family.getChildList():
family.addChild(self.person)
if family == self.person.getMainFamily(): for fam in self.person.getAltFamilyList():
# make sure that the person is listed as a child if family == fam[0]:
if self.person not in family.getChildList(): if mother_rel == fam[1] and father_rel == fam[2]:
family.addChild(self.person) return
# if the relationships indicate that this is no longer if mother_rel != fam[1] or father_rel != fam[2]:
# the main family, we need to delete the main family, self.person.removeAltFamily(family)
# and add it as an alternate family (assuming that it
# does not already in the list)
if not is_main:
self.person.setMainFamily(None)
for fam in self.person.getAltFamilyList():
if fam[0] == family:
if fam[1] == mother_rel and fam[2] == father_rel:
return
else:
self.person.removeFamily(fam[0])
else:
self.person.addAltFamily(family,mother_rel,father_rel) self.person.addAltFamily(family,mother_rel,father_rel)
# The family is not already the main family break
else: else:
if self.person not in family.getChildList(): self.person.addAltFamily(family,mother_rel,father_rel)
family.addChild(self.person)
for fam in self.person.getAltFamilyList():
if family == fam[0]:
if is_main:
self.person.setMainFamily(family)
self.person.removeAltFamily(family)
break
if mother_rel == fam[1] and father_rel == fam[2]:
return
if mother_rel != fam[1] or father_rel != fam[2]:
self.person.removeAltFamily(family)
self.person.addAltFamily(family,mother_rel,father_rel)
break
else:
if is_main:
self.person.setMainFamily(family)
else:
self.person.addAltFamily(family,mother_rel,father_rel)
Utils.modified() Utils.modified()
def add_parent_close(self,obj): def add_parent_close(self,obj):

View File

@ -288,23 +288,17 @@ class GrampsParser:
def start_childof(self,attrs): def start_childof(self,attrs):
family = self.db.findFamilyNoMap(u2l(attrs["ref"])) family = self.db.findFamilyNoMap(u2l(attrs["ref"]))
if len(attrs) == 1: if attrs.has_key("mrel"):
self.person.MainFamily = family mrel = u2l(attrs["mrel"])
else: else:
mrel = "" mrel = "Birth"
frel = "" if attrs.has_key("frel"):
if attrs.has_key("mrel"): frel = u2l(attrs["frel"])
mrel = u2l(attrs["mrel"]) else:
if attrs.has_key("frel"): frel = "Birth"
frel = u2l(attrs["frel"]) self.person.AltFamilyList.append((family,mrel,frel))
if mrel=="Birth" and frel=="Birth": if attrs.has_key('pref'):
self.person.MainFamily = family self.person.setMainFamily(family)
else:
if mrel or frel:
self.person.AltFamilyList.append((family,mrel,frel))
else:
type = u2l(attrs["type"])
self.person.AltFamilyList.append((family,type,type))
def start_parentin(self,attrs): def start_parentin(self,attrs):
self.person.FamilyList.append(self.db.findFamilyNoMap(u2l(attrs["ref"]))) self.person.FamilyList.append(self.db.findFamilyNoMap(u2l(attrs["ref"])))
@ -872,14 +866,6 @@ class GrampsImportParser(GrampsParser):
if attrs.has_key("type"): if attrs.has_key("type"):
self.family.setRelationship(u2l(attrs["type"])) self.family.setRelationship(u2l(attrs["type"]))
def start_childof(self,attrs):
family = self.db.findFamily(u2l(attrs["ref"]),self.fmap)
if attrs.has_key("type"):
type = u2l(attrs["type"])
self.person.addAltFamily(family,type)
else:
self.person.setMainFamily(family)
def start_sourceref(self,attrs): def start_sourceref(self,attrs):
self.source_ref = SourceRef() self.source_ref = SourceRef()
self.source = self.db.findSource(u2l(attrs["ref"]),self.smap) self.source = self.db.findSource(u2l(attrs["ref"]),self.smap)

View File

@ -886,7 +886,6 @@ class Person:
self.EventList = [] self.EventList = []
self.FamilyList = [] self.FamilyList = []
self.AltFamilyList = [] self.AltFamilyList = []
self.MainFamily = None
self.photoList = [] self.photoList = []
self.nickname = "" self.nickname = ""
self.alternateNames = [] self.alternateNames = []
@ -1022,6 +1021,11 @@ class Person:
parent or spouse""" parent or spouse"""
self.FamilyList.append(family) self.FamilyList.append(family)
def setPreferred(self,family):
if family in self.FamilyList:
self.FamilyList.remove(family)
self.FamilyList = [family] + self.FamilyList
def getFamilyList(self) : def getFamilyList(self) :
"""returns the list of Family instances in which the """returns the list of Family instances in which the
person is a parent or spouse""" person is a parent or spouse"""
@ -1082,16 +1086,40 @@ class Person:
for f in self.AltFamilyList[:]: for f in self.AltFamilyList[:]:
if f[0] == family: if f[0] == family:
self.AltFamilyList.remove(f) self.AltFamilyList.remove(f)
return f
else:
return None
def has_family(self,family):
for f in self.AltFamilyList:
if f[0] == family:
return f
else:
return None
def setMainFamily(self,family): def setMainFamily(self,family):
"""sets the main Family of the Person, the Family in which the """sets the main Family of the Person, the Family in which the
Person is a natural born child""" Person is a natural born child"""
self.MainFamily = family assert(family in self.AltFamilyList)
f = self.removeFamily(family)
self.AltFamilyList = [f] + self.AltFamilyList
def getMainFamily(self): def getMainFamily(self):
"""returns the main Family of the Person, the Family in which the """returns the main Family of the Person, the Family in which the
Person is a natural born child""" Person is a natural born child"""
return self.MainFamily if len(self.AltFamilyList) == 0:
return None
else:
return self.AltFamilyList[0][0]
def getMainFamilyRel(self):
"""returns the main Family of the Person, the Family in which the
Person is a natural born child"""
if len(self.AltFamilyList) == 0:
return None
else:
return self.AltFamilyList
def setNote(self,text): def setNote(self,text):
"""sets the note attached to the Person to the passed text""" """sets the note attached to the Person to the passed text"""
@ -1127,8 +1155,7 @@ class Person:
def setAncestor(self, value): def setAncestor(self, value):
"""set ancestor flag and recurse""" """set ancestor flag and recurse"""
self.ancestor = value self.ancestor = value
family = self.MainFamily for (family,m,f) in self.AltFamilyList:
if family:
if family.Father: if family.Father:
# Don't waste time if the ancestor is already flagged. # Don't waste time if the ancestor is already flagged.
# This will happen when cousins marry. # This will happen when cousins marry.
@ -1712,7 +1739,6 @@ class GrampsDB:
self.familyMap = {} self.familyMap = {}
for p in self.personMap.values(): for p in self.personMap.values():
p.MainFamily = None
p.AltFamilyList = [] p.AltFamilyList = []
p.FamilyList = [] p.FamilyList = []
self.personMap = {} self.personMap = {}

View File

@ -193,14 +193,14 @@ class SelectChild:
if frel == "Birth": if frel == "Birth":
frel = "Unknown" frel = "Unknown"
if mrel == "Birth" and frel == "Birth": # if mrel == "Birth" and frel == "Birth":
family = select_child.getMainFamily() # family = select_child.getMainFamily()
if family != None and family != self.family: # if family != None and family != self.family:
family.removeChild(select_child) # family.removeChild(select_child)
#
select_child.setMainFamily(self.family) # select_child.setMainFamily(self.family)
else: # else:
select_child.addAltFamily(self.family,mrel,frel) select_child.addAltFamily(self.family,mrel,frel)
Utils.modified() Utils.modified()
@ -373,11 +373,11 @@ class NewChild:
mrel = const.childRelations[self.mrel.get_text()] mrel = const.childRelations[self.mrel.get_text()]
frel = const.childRelations[self.frel.get_text()] frel = const.childRelations[self.frel.get_text()]
if mrel == "Birth" and frel == "Birth": # if mrel == "Birth" and frel == "Birth":
person.setMainFamily(self.family) # person.setMainFamily(self.family)
else: # else:
person.addAltFamily(self.family,mrel,frel) person.addAltFamily(self.family,mrel,frel)
self.family.addChild(person) self.family.addChild(person)
# must do an apply filter here to make sure the main window gets updated # must do an apply filter here to make sure the main window gets updated

View File

@ -29,7 +29,7 @@ class HaveAltFamilies(Filter.Filter):
"People who were adopted" "People who were adopted"
def match(self,person): def match(self,person):
return len(person.getAltFamilyList()) > 0 return len(person.getAltFamilyList()) > 1
Filter.register_filter(HaveAltFamilies, Filter.register_filter(HaveAltFamilies,

View File

@ -1443,116 +1443,70 @@
<fill>True</fill> <fill>True</fill>
</child> </child>
</widget> </widget>
</widget>
</widget>
<widget>
<class>GtkHBox</class>
<name>hbox28</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>label226</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkButton</class>
<name>button22</name>
<border_width>3</border_width>
<tooltip>Exchange active person and displayed spouse</tooltip>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_swap_clicked</handler>
<object>spousename</object>
<last_modification_time>Tue, 07 Nov 2000 02:58:26 GMT</last_modification_time>
</signal>
<relief>GTK_RELIEF_NORMAL</relief>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget> <widget>
<class>GtkVBox</class> <class>GtkButton</class>
<name>vbox14</name> <name>button22</name>
<homogeneous>False</homogeneous> <border_width>3</border_width>
<spacing>0</spacing> <tooltip>Exchange active person and displayed spouse</tooltip>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_swap_clicked</handler>
<object>spousename</object>
<last_modification_time>Tue, 07 Nov 2000 02:58:26 GMT</last_modification_time>
</signal>
<relief>GTK_RELIEF_NORMAL</relief>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget> <widget>
<class>GtkArrow</class> <class>GtkVBox</class>
<name>arrow9</name> <name>vbox14</name>
<width>11</width> <homogeneous>False</homogeneous>
<height>11</height> <spacing>0</spacing>
<arrow_type>GTK_ARROW_UP</arrow_type>
<shadow_type>GTK_SHADOW_OUT</shadow_type>
<xalign>0.5</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>GtkArrow</class> <class>GtkArrow</class>
<name>arrow10</name> <name>arrow9</name>
<width>11</width> <width>11</width>
<height>11</height> <height>11</height>
<arrow_type>GTK_ARROW_DOWN</arrow_type> <arrow_type>GTK_ARROW_UP</arrow_type>
<shadow_type>GTK_SHADOW_OUT</shadow_type> <shadow_type>GTK_SHADOW_OUT</shadow_type>
<xalign>0.5</xalign> <xalign>0.5</xalign>
<yalign>0.5</yalign> <yalign>0.5</yalign>
<xpad>0</xpad> <xpad>0</xpad>
<ypad>0</ypad> <ypad>0</ypad>
<child> <child>
<padding>0</padding> <padding>0</padding>
<expand>False</expand> <expand>True</expand>
<fill>False</fill> <fill>True</fill>
</child> </child>
</widget>
<widget>
<class>GtkArrow</class>
<name>arrow10</name>
<width>11</width>
<height>11</height>
<arrow_type>GTK_ARROW_DOWN</arrow_type>
<shadow_type>GTK_SHADOW_OUT</shadow_type>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget> </widget>
</widget> </widget>
</widget> </widget>
<widget>
<class>GtkLabel</class>
<name>label227</name>
<label></label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>False</fill>
</child>
</widget>
</widget> </widget>
<widget> <widget>
@ -1564,7 +1518,7 @@
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child> <child>
<padding>0</padding> <padding>0</padding>
<expand>False</expand> <expand>True</expand>
<fill>True</fill> <fill>True</fill>
</child> </child>
@ -1575,11 +1529,13 @@
<spacing>0</spacing> <spacing>0</spacing>
<widget> <widget>
<class>GtkHBox</class> <class>GtkTable</class>
<name>hbox25</name> <name>table28</name>
<border_width>5</border_width> <rows>2</rows>
<columns>2</columns>
<homogeneous>False</homogeneous> <homogeneous>False</homogeneous>
<spacing>0</spacing> <row_spacing>0</row_spacing>
<column_spacing>0</column_spacing>
<child> <child>
<padding>0</padding> <padding>0</padding>
<expand>False</expand> <expand>False</expand>
@ -1598,12 +1554,100 @@
<label>Spouse</label> <label>Spouse</label>
<relief>GTK_RELIEF_NORMAL</relief> <relief>GTK_RELIEF_NORMAL</relief>
<child> <child>
<padding>5</padding> <left_attach>0</left_attach>
<expand>False</expand> <right_attach>1</right_attach>
<fill>False</fill> <top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>5</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child> </child>
</widget> </widget>
<widget>
<class>GtkNotebook</class>
<name>rel_notebook</name>
<visible>False</visible>
<show_tabs>False</show_tabs>
<show_border>False</show_border>
<tab_pos>GTK_POS_TOP</tab_pos>
<scrollable>False</scrollable>
<tab_hborder>2</tab_hborder>
<tab_vborder>2</tab_vborder>
<popup_enable>False</popup_enable>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>5</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
<widget>
<class>GtkCheckButton</class>
<name>prefrel</name>
<can_focus>True</can_focus>
<signal>
<name>toggled</name>
<handler>on_prefrel_toggled</handler>
<last_modification_time>Sat, 23 Mar 2002 15:15:51 GMT</last_modification_time>
</signal>
<label>Make this the preferred relationship</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>Notebook:tab</child_name>
<name>label296</name>
<label>label296</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>5</xpad>
<ypad>0</ypad>
</widget>
<widget>
<class>GtkLabel</class>
<name>label298</name>
<label>Preferred Relationship</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>Notebook:tab</child_name>
<name>label297</name>
<label>label297</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</widget>
<widget> <widget>
<class>GtkNotebook</class> <class>GtkNotebook</class>
<name>lab_or_list</name> <name>lab_or_list</name>
@ -1615,9 +1659,18 @@
<tab_vborder>2</tab_vborder> <tab_vborder>2</tab_vborder>
<popup_enable>False</popup_enable> <popup_enable>False</popup_enable>
<child> <child>
<padding>5</padding> <left_attach>1</left_attach>
<expand>True</expand> <right_attach>2</right_attach>
<fill>True</fill> <top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>5</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child> </child>
<widget> <widget>
@ -1679,8 +1732,8 @@
<child_ipad_y>0</child_ipad_y> <child_ipad_y>0</child_ipad_y>
<child> <child>
<padding>0</padding> <padding>0</padding>
<expand>False</expand> <expand>True</expand>
<fill>False</fill> <fill>True</fill>
</child> </child>
<widget> <widget>
@ -1751,7 +1804,7 @@
<widget> <widget>
<class>GtkTable</class> <class>GtkTable</class>
<name>table24</name> <name>table24</name>
<rows>3</rows> <rows>5</rows>
<columns>3</columns> <columns>3</columns>
<homogeneous>False</homogeneous> <homogeneous>False</homogeneous>
<row_spacing>0</row_spacing> <row_spacing>0</row_spacing>
@ -1868,8 +1921,8 @@
<child> <child>
<left_attach>0</left_attach> <left_attach>0</left_attach>
<right_attach>1</right_attach> <right_attach>1</right_attach>
<top_attach>1</top_attach> <top_attach>2</top_attach>
<bottom_attach>2</bottom_attach> <bottom_attach>3</bottom_attach>
<xpad>5</xpad> <xpad>5</xpad>
<ypad>5</ypad> <ypad>5</ypad>
<xexpand>False</xexpand> <xexpand>False</xexpand>
@ -1892,8 +1945,8 @@
<child> <child>
<left_attach>1</left_attach> <left_attach>1</left_attach>
<right_attach>2</right_attach> <right_attach>2</right_attach>
<top_attach>1</top_attach> <top_attach>2</top_attach>
<bottom_attach>2</bottom_attach> <bottom_attach>3</bottom_attach>
<xpad>5</xpad> <xpad>5</xpad>
<ypad>5</ypad> <ypad>5</ypad>
<xexpand>True</xexpand> <xexpand>True</xexpand>
@ -1919,8 +1972,8 @@
<child> <child>
<left_attach>2</left_attach> <left_attach>2</left_attach>
<right_attach>3</right_attach> <right_attach>3</right_attach>
<top_attach>1</top_attach> <top_attach>2</top_attach>
<bottom_attach>2</bottom_attach> <bottom_attach>3</bottom_attach>
<xpad>5</xpad> <xpad>5</xpad>
<ypad>5</ypad> <ypad>5</ypad>
<xexpand>False</xexpand> <xexpand>False</xexpand>
@ -1946,17 +1999,211 @@
</widget> </widget>
<widget> <widget>
<class>GtkOptionMenu</class> <class>GtkVBox</class>
<name>childtype</name> <name>vbox50</name>
<can_focus>True</can_focus> <homogeneous>False</homogeneous>
<items> <spacing>0</spacing>
</items> <child>
<initial_choice>0</initial_choice> <left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>4</top_attach>
<bottom_attach>5</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>GtkButton</class>
<name>family_up</name>
<tooltip>Make the current father the active person</tooltip>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_family_up_clicked</handler>
<last_modification_time>Sun, 24 Mar 2002 02:58:49 GMT</last_modification_time>
</signal>
<relief>GTK_RELIEF_NORMAL</relief>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkArrow</class>
<name>arrow11</name>
<width>10</width>
<height>10</height>
<arrow_type>GTK_ARROW_UP</arrow_type>
<shadow_type>GTK_SHADOW_OUT</shadow_type>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</widget>
<widget>
<class>GtkButton</class>
<name>family_down</name>
<tooltip>Make the current mother the active person</tooltip>
<can_focus>True</can_focus>
<signal>
<name>clicked</name>
<handler>on_family_down_clicked</handler>
<last_modification_time>Sun, 24 Mar 2002 02:58:37 GMT</last_modification_time>
</signal>
<relief>GTK_RELIEF_NORMAL</relief>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkArrow</class>
<name>arrow12</name>
<width>10</width>
<height>10</height>
<arrow_type>GTK_ARROW_DOWN</arrow_type>
<shadow_type>GTK_SHADOW_OUT</shadow_type>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</widget>
</widget>
<widget>
<class>GtkHBox</class>
<name>hbox75</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child> <child>
<left_attach>1</left_attach> <left_attach>1</left_attach>
<right_attach>2</right_attach> <right_attach>2</right_attach>
<top_attach>2</top_attach> <top_attach>1</top_attach>
<bottom_attach>3</bottom_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>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>4</top_attach>
<bottom_attach>5</bottom_attach>
<xpad>5</xpad> <xpad>5</xpad>
<ypad>5</ypad> <ypad>5</ypad>
<xexpand>False</xexpand> <xexpand>False</xexpand>
@ -1980,7 +2227,7 @@
<child_ipad_y>0</child_ipad_y> <child_ipad_y>0</child_ipad_y>
<child> <child>
<padding>5</padding> <padding>5</padding>
<expand>False</expand> <expand>True</expand>
<fill>True</fill> <fill>True</fill>
</child> </child>

View File

@ -88,6 +88,7 @@ class Gramps:
self.active_father = None self.active_father = None
self.active_mother = None self.active_mother = None
self.active_parents = None self.active_parents = None
self.parents_index = 0
self.active_person = None self.active_person = None
self.active_spouse = None self.active_spouse = None
self.bookmarks = None self.bookmarks = None
@ -175,6 +176,8 @@ class Gramps:
self.qual_label = self.gtop.get_widget("qual") self.qual_label = self.gtop.get_widget("qual")
self.child_type = self.gtop.get_widget("childtype") self.child_type = self.gtop.get_widget("childtype")
self.spouse_tab = self.gtop.get_widget("lab_or_list") self.spouse_tab = self.gtop.get_widget("lab_or_list")
self.spouse_ptab = self.gtop.get_widget("rel_notebook")
self.spouse_pref = self.gtop.get_widget("prefrel")
self.spouse_edit = self.gtop.get_widget("edit_sp") self.spouse_edit = self.gtop.get_widget("edit_sp")
self.spouse_del = self.gtop.get_widget("delete_sp") self.spouse_del = self.gtop.get_widget("delete_sp")
@ -208,6 +211,9 @@ class Gramps:
self.gtop.signal_autoconnect({ self.gtop.signal_autoconnect({
"delete_event" : self.delete_event, "delete_event" : self.delete_event,
"destroy_passed_object" : Utils.destroy_passed_object, "destroy_passed_object" : Utils.destroy_passed_object,
"on_family_up_clicked" : self.family_up_clicked,
"on_family_down_clicked" : self.family_down_clicked,
"on_prefrel_toggled" : self.on_preferred_rel_toggled,
"on_about_activate" : self.on_about_activate, "on_about_activate" : self.on_about_activate,
"on_add_bookmark_activate" : self.on_add_bookmark_activate, "on_add_bookmark_activate" : self.on_add_bookmark_activate,
"on_add_child_clicked" : self.on_add_child_clicked, "on_add_child_clicked" : self.on_add_child_clicked,
@ -422,7 +428,8 @@ class Gramps:
return return
self.active_family.removeChild(self.active_child) self.active_family.removeChild(self.active_child)
self.active_child.setMainFamily(None) self.active_child.removeAltFamily(self.active_child)
if len(self.active_family.getChildList()) == 0: if len(self.active_family.getChildList()) == 0:
if self.active_family.getFather() == None: if self.active_family.getFather() == None:
self.delete_family_from(self.active_family.getMother()) self.delete_family_from(self.active_family.getMother())
@ -437,7 +444,7 @@ class Gramps:
self.database.deleteFamily(self.active_family) self.database.deleteFamily(self.active_family)
flist = self.active_person.getFamilyList() flist = self.active_person.getFamilyList()
if len(flist) > 0: if len(flist) > 0:
self.active_family = flist[0] self.active_family = flist[0][0]
else: else:
self.active_family = None self.active_family = None
@ -822,14 +829,14 @@ class Gramps:
if self.active_person.getGender == Person.male: if self.active_person.getGender == Person.male:
if family.getMother() == None: if family.getMother() == None:
for child in family.getChildList(): for child in family.getChildList():
child.setMainFamily(None) child.removeAltFamily(family)
del familymap[family] del familymap[family]
else: else:
family.setFather(None) family.setFather(None)
else: else:
if family.getFather() == None: if family.getFather() == None:
for child in family.getChildList(): for child in family.getChildList():
child.setMainFamily(None) child.removeAltFamily(family)
del familymap[family] del familymap[family]
else: else:
family.setMother(None) family.setMother(None)
@ -869,10 +876,7 @@ class Gramps:
return return
self.active_parents.removeChild(self.active_person) self.active_parents.removeChild(self.active_person)
if self.active_parents == self.active_person.getMainFamily(): self.active_person.removeAltFamily(self.active_parents)
self.active_person.setMainFamily(None)
else:
self.active_person.removeAltFamily(self.active_parents)
self.load_family() self.load_family()
def on_person_list_select_row(self,obj,row,b,c): def on_person_list_select_row(self,obj,row,b,c):
@ -1299,6 +1303,11 @@ class Gramps:
if self.active_person: if self.active_person:
self.display_marriage(obj.get_data("family")) self.display_marriage(obj.get_data("family"))
def on_preferred_rel_toggled(self,obj):
self.spouse_ptab.set_page(1)
self.spouse_pref.set_active(0)
self.active_person.setPreferred(self.active_family)
def new_after_edit(self,epo,plist): def new_after_edit(self,epo,plist):
if epo: if epo:
if epo.person.getId() == "": if epo.person.getId() == "":
@ -1370,54 +1379,64 @@ class Gramps:
def load_family(self,family=None): def load_family(self,family=None):
if family != None: if family != None:
self.active_family = family self.active_family = family
if self.active_family:
flist = self.active_person.getFamilyList()
if self.active_family:
if self.active_person != self.active_family.getFather() and \
self.active_family != self.active_family.getMother():
if len(flist) > 0:
self.active_family = flist[0]
else:
self.active_family = None
family_types = [] family_types = []
main_family = None
main_family = None
self.person_text.set_text(GrampsCfg.nameof(self.active_person)) self.person_text.set_text(GrampsCfg.nameof(self.active_person))
if self.active_person: if self.active_person:
main_family = self.active_person.getMainFamily() main_family = self.active_person.getMainFamily()
self.active_parents = main_family self.active_parents = main_family
self.parents_index = 0
family_types = self.active_person.getAltFamilyList() family_types = self.active_person.getAltFamilyList()
if self.active_parents == None and len(family_types) > 0: if self.active_parents == None and len(family_types) > 0:
fam = family_types[0] self.active_parents = family_types[0][0]
self.active_parents = fam[0]
else: else:
self.active_parents = None self.active_parents = None
if len(family_types) > 0: # if len(family_types) > 0:
typeMenu = gtk.GtkMenu() # typeMenu = gtk.GtkMenu()
if main_family: # index = 0
menuitem = gtk.GtkMenuItem(_("Birth")) # pref = 0
menuitem.set_data("parents",main_family) # for fam in family_types:
menuitem.connect("activate",self.on_current_type_changed) # if fam[0] == main_family:
menuitem.show() # pref = index
typeMenu.append(menuitem) # if self.active_person == fam[0].getFather():
for fam in family_types: # menuitem = gtk.GtkMenuItem("%s/%s" % (fam[1],fam[2]))
if self.active_person == fam[0].getFather(): # else:
menuitem = gtk.GtkMenuItem("%s/%s" % (fam[1],fam[2])) # menuitem = gtk.GtkMenuItem("%s/%s" % (fam[2],fam[1]))
else: # menuitem.set_data("parents",fam[0])
menuitem = gtk.GtkMenuItem("%s/%s" % (fam[2],fam[1])) # menuitem.connect("activate",self.on_current_type_changed)
menuitem.set_data("parents",fam[0]) # menuitem.show()
menuitem.connect("activate",self.on_current_type_changed) # typeMenu.append(menuitem)
menuitem.show() # index = index + 1
typeMenu.append(menuitem) # self.child_type.set_menu(typeMenu)
self.child_type.set_menu(typeMenu) # self.child_type.set_history(pref)
self.child_type.show() # self.child_type.show()
else: # else:
self.child_type.hide() # self.child_type.hide()
self.change_parents(self.active_parents) self.change_parents(self.active_parents)
if self.active_person: if self.active_person:
number_of_families = len(self.active_person.getFamilyList()) flist = self.active_person.getFamilyList()
number_of_families = len(flist)
if number_of_families > 1: if number_of_families > 1:
myMenu = gtk.GtkMenu() myMenu = gtk.GtkMenu()
index = 0 index = 0
opt_index = 0 opt_index = 0
for f in self.active_person.getFamilyList(): for f in flist:
person = None person = None
if f.getMother() == self.active_person: if f.getMother() == self.active_person:
if f.getFather() != None: if f.getFather() != None:
@ -1438,6 +1457,7 @@ class Gramps:
self.spouse_menu.set_menu(myMenu) self.spouse_menu.set_menu(myMenu)
self.spouse_menu.set_history(opt_index) self.spouse_menu.set_history(opt_index)
self.spouse_tab.set_page(1) self.spouse_tab.set_page(1)
self.spouse_pref.set_active(0)
self.spouse_edit.set_sensitive(1) self.spouse_edit.set_sensitive(1)
self.spouse_del.set_sensitive(1) self.spouse_del.set_sensitive(1)
elif number_of_families == 1: elif number_of_families == 1:
@ -1505,6 +1525,10 @@ class Gramps:
else : else :
fv_mother.set_text("") fv_mother.set_text("")
mother_next.set_sensitive(0) mother_next.set_sensitive(0)
for f in self.active_person.getAltFamilyList():
if f[0] == family:
self.gtop.get_widget("mrel").set_text(_(f[1]))
self.gtop.get_widget("frel").set_text(_(f[2]))
elif self.active_person == None: elif self.active_person == None:
fv_father.set_text("") fv_father.set_text("")
fv_mother.set_text("") fv_mother.set_text("")
@ -1522,9 +1546,11 @@ class Gramps:
def display_marriage(self,family): def display_marriage(self,family):
if self.active_person == None:
return
self.active_family = family self.active_family = family
fv_prev = self.gtop.get_widget("fv_prev") fv_prev = self.gtop.get_widget("fv_prev")
self.child_list.clear() self.child_list.clear()
self.active_child = None self.active_child = None
@ -1533,7 +1559,17 @@ class Gramps:
self.child_list.set_sort_column(self.c_sort_col) self.child_list.set_sort_column(self.c_sort_col)
self.child_list.set_reorderable(self.c_sort_col == self.c_birth_order) self.child_list.set_reorderable(self.c_sort_col == self.c_birth_order)
if family != None: if family:
flist = self.active_person.getFamilyList()
if len(flist) <= 1:
self.spouse_ptab.hide()
else:
if family == flist[0]:
self.spouse_ptab.set_page(1)
else:
self.spouse_ptab.set_page(0)
self.spouse_ptab.show()
if self.active_person.getGender() == Person.male: if self.active_person.getGender() == Person.male:
self.active_spouse = family.getMother() self.active_spouse = family.getMother()
else: else:
@ -1784,8 +1820,26 @@ class Gramps:
self.database.setDefaultPerson(self.active_person) self.database.setDefaultPerson(self.active_person)
Utils.modified() Utils.modified()
def on_current_type_changed(self,obj): def family_up_clicked(self,obj):
self.active_parents = obj.get_data("parents") if self.active_parents == None:
return
flist = self.active_person.getAltFamilyList()
if self.parents_index == 0:
self.parents_index = len(flist)-1
else:
self.parents_index = self.parents_index - 1
self.active_parents = flist[self.parents_index][0]
self.change_parents(self.active_parents)
def family_down_clicked(self,obj):
if self.active_parents == None:
return
flist = self.active_person.getAltFamilyList()
if self.parents_index == len(flist)-1:
self.parents_index = 0
else:
self.parents_index = self.parents_index + 1
self.active_parents = flist[self.parents_index][0]
self.change_parents(self.active_parents) self.change_parents(self.active_parents)
def export_callback(self,obj,plugin_function): def export_callback(self,obj,plugin_function):