diff --git a/gramps/src/ChooseParents.py b/gramps/src/ChooseParents.py index b06de3b8f..c40e1ffa7 100644 --- a/gramps/src/ChooseParents.py +++ b/gramps/src/ChooseParents.py @@ -259,47 +259,18 @@ class ChooseParents: Changes the family type of the specified family. If the family is None, the the relationship type shoud be deleted. """ - is_main = mother_rel == "Birth" and father_rel == "Birth" - - if family == self.person.getMainFamily(): - # make sure that the person is listed as a child - if self.person not in family.getChildList(): - family.addChild(self.person) - # if the relationships indicate that this is no longer - # the main family, we need to delete the main 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: + if self.person not in family.getChildList(): + family.addChild(self.person) + for fam in self.person.getAltFamilyList(): + if family == fam[0]: + 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) - # The family is not already the main family + break else: - if self.person not in family.getChildList(): - 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) + self.person.addAltFamily(family,mother_rel,father_rel) Utils.modified() def add_parent_close(self,obj): diff --git a/gramps/src/GrampsParser.py b/gramps/src/GrampsParser.py index 4923e29f5..27f026c15 100644 --- a/gramps/src/GrampsParser.py +++ b/gramps/src/GrampsParser.py @@ -288,23 +288,17 @@ class GrampsParser: def start_childof(self,attrs): family = self.db.findFamilyNoMap(u2l(attrs["ref"])) - if len(attrs) == 1: - self.person.MainFamily = family + if attrs.has_key("mrel"): + mrel = u2l(attrs["mrel"]) else: - mrel = "" - frel = "" - if attrs.has_key("mrel"): - mrel = u2l(attrs["mrel"]) - if attrs.has_key("frel"): - frel = u2l(attrs["frel"]) - if mrel=="Birth" and frel=="Birth": - self.person.MainFamily = 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)) + mrel = "Birth" + if attrs.has_key("frel"): + frel = u2l(attrs["frel"]) + 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"]))) @@ -872,14 +866,6 @@ class GrampsImportParser(GrampsParser): if attrs.has_key("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): self.source_ref = SourceRef() self.source = self.db.findSource(u2l(attrs["ref"]),self.smap) diff --git a/gramps/src/RelLib.py b/gramps/src/RelLib.py index a2cc2cceb..89dccc862 100644 --- a/gramps/src/RelLib.py +++ b/gramps/src/RelLib.py @@ -886,7 +886,6 @@ class Person: self.EventList = [] self.FamilyList = [] self.AltFamilyList = [] - self.MainFamily = None self.photoList = [] self.nickname = "" self.alternateNames = [] @@ -1022,6 +1021,11 @@ class Person: parent or spouse""" 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) : """returns the list of Family instances in which the person is a parent or spouse""" @@ -1082,16 +1086,40 @@ class Person: for f in self.AltFamilyList[:]: if f[0] == family: 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): """sets the main Family of the Person, the Family in which the 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): """returns the main Family of the Person, the Family in which the 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): """sets the note attached to the Person to the passed text""" @@ -1127,8 +1155,7 @@ class Person: def setAncestor(self, value): """set ancestor flag and recurse""" self.ancestor = value - family = self.MainFamily - if family: + for (family,m,f) in self.AltFamilyList: if family.Father: # Don't waste time if the ancestor is already flagged. # This will happen when cousins marry. @@ -1712,7 +1739,6 @@ class GrampsDB: self.familyMap = {} for p in self.personMap.values(): - p.MainFamily = None p.AltFamilyList = [] p.FamilyList = [] self.personMap = {} diff --git a/gramps/src/SelectChild.py b/gramps/src/SelectChild.py index 144bcca51..38e7418dd 100644 --- a/gramps/src/SelectChild.py +++ b/gramps/src/SelectChild.py @@ -193,14 +193,14 @@ class SelectChild: if frel == "Birth": frel = "Unknown" - if mrel == "Birth" and frel == "Birth": - family = select_child.getMainFamily() - if family != None and family != self.family: - family.removeChild(select_child) - - select_child.setMainFamily(self.family) - else: - select_child.addAltFamily(self.family,mrel,frel) +# if mrel == "Birth" and frel == "Birth": +# family = select_child.getMainFamily() +# if family != None and family != self.family: +# family.removeChild(select_child) +# +# select_child.setMainFamily(self.family) +# else: + select_child.addAltFamily(self.family,mrel,frel) Utils.modified() @@ -373,11 +373,11 @@ class NewChild: mrel = const.childRelations[self.mrel.get_text()] frel = const.childRelations[self.frel.get_text()] - if mrel == "Birth" and frel == "Birth": - person.setMainFamily(self.family) - else: - person.addAltFamily(self.family,mrel,frel) - +# if mrel == "Birth" and frel == "Birth": +# person.setMainFamily(self.family) +# else: + person.addAltFamily(self.family,mrel,frel) + self.family.addChild(person) # must do an apply filter here to make sure the main window gets updated diff --git a/gramps/src/filters/AltFam.py b/gramps/src/filters/AltFam.py index 3ac1cb5c8..42ecebfcc 100644 --- a/gramps/src/filters/AltFam.py +++ b/gramps/src/filters/AltFam.py @@ -29,7 +29,7 @@ class HaveAltFamilies(Filter.Filter): "People who were adopted" def match(self,person): - return len(person.getAltFamilyList()) > 0 + return len(person.getAltFamilyList()) > 1 Filter.register_filter(HaveAltFamilies, diff --git a/gramps/src/gramps.glade b/gramps/src/gramps.glade index 341ed6f79..6ee3fd3f5 100644 --- a/gramps/src/gramps.glade +++ b/gramps/src/gramps.glade @@ -1443,116 +1443,70 @@ True - - - - - GtkHBox - hbox28 - False - 0 - - 0 - False - True - - - - GtkLabel - label226 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - True - False - - - - - GtkButton - button22 - 3 - Exchange active person and displayed spouse - True - - clicked - on_swap_clicked - spousename - Tue, 07 Nov 2000 02:58:26 GMT - - GTK_RELIEF_NORMAL - - 0 - False - False - - GtkVBox - vbox14 - False - 0 + GtkButton + button22 + 3 + Exchange active person and displayed spouse + True + + clicked + on_swap_clicked + spousename + Tue, 07 Nov 2000 02:58:26 GMT + + GTK_RELIEF_NORMAL + + 0 + False + False + - GtkArrow - arrow9 - 11 - 11 - GTK_ARROW_UP - GTK_SHADOW_OUT - 0.5 - 0.5 - 0 - 0 - - 0 - True - True - - + GtkVBox + vbox14 + False + 0 - - GtkArrow - arrow10 - 11 - 11 - GTK_ARROW_DOWN - GTK_SHADOW_OUT - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - + + GtkArrow + arrow9 + 11 + 11 + GTK_ARROW_UP + GTK_SHADOW_OUT + 0.5 + 0.5 + 0 + 0 + + 0 + True + True + + + + + GtkArrow + arrow10 + 11 + 11 + GTK_ARROW_DOWN + GTK_SHADOW_OUT + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + + - - - GtkLabel - label227 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - True - False - - @@ -1564,7 +1518,7 @@ GTK_SHADOW_ETCHED_IN 0 - False + True True @@ -1575,11 +1529,13 @@ 0 - GtkHBox - hbox25 - 5 + GtkTable + table28 + 2 + 2 False - 0 + 0 + 0 0 False @@ -1598,12 +1554,100 @@ GTK_RELIEF_NORMAL - 5 - False - False + 0 + 1 + 0 + 1 + 5 + 0 + False + False + False + False + True + False + + GtkNotebook + rel_notebook + False + False + False + GTK_POS_TOP + False + 2 + 2 + False + + 1 + 2 + 1 + 2 + 5 + 0 + False + True + False + False + True + True + + + + GtkCheckButton + prefrel + True + + toggled + on_prefrel_toggled + Sat, 23 Mar 2002 15:15:51 GMT + + + False + True + + + + GtkLabel + Notebook:tab + label296 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 5 + 0 + + + + GtkLabel + label298 + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 + + + + GtkLabel + Notebook:tab + label297 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + GtkNotebook lab_or_list @@ -1615,9 +1659,18 @@ 2 False - 5 - True - True + 1 + 2 + 0 + 1 + 5 + 0 + True + True + False + False + True + False @@ -1679,8 +1732,8 @@ 0 0 - False - False + True + True @@ -1751,7 +1804,7 @@ GtkTable table24 - 3 + 5 3 False 0 @@ -1868,8 +1921,8 @@ 0 1 - 1 - 2 + 2 + 3 5 5 False @@ -1892,8 +1945,8 @@ 1 2 - 1 - 2 + 2 + 3 5 5 True @@ -1919,8 +1972,8 @@ 2 3 - 1 - 2 + 2 + 3 5 5 False @@ -1946,17 +1999,211 @@ - GtkOptionMenu - childtype - True - - - 0 + GtkVBox + vbox50 + False + 0 + + 2 + 3 + 4 + 5 + 0 + 0 + False + False + False + False + True + True + + + + GtkButton + family_up + Make the current father the active person + True + + clicked + on_family_up_clicked + Sun, 24 Mar 2002 02:58:49 GMT + + GTK_RELIEF_NORMAL + + 0 + False + False + + + + GtkArrow + arrow11 + 10 + 10 + GTK_ARROW_UP + GTK_SHADOW_OUT + 0.5 + 0.5 + 0 + 0 + + + + + GtkButton + family_down + Make the current mother the active person + True + + clicked + on_family_down_clicked + Sun, 24 Mar 2002 02:58:37 GMT + + GTK_RELIEF_NORMAL + + 0 + False + False + + + + GtkArrow + arrow12 + 10 + 10 + GTK_ARROW_DOWN + GTK_SHADOW_OUT + 0.5 + 0.5 + 0 + 0 + + + + + + GtkHBox + hbox75 + False + 0 1 2 - 2 - 3 + 1 + 2 + 0 + 0 + False + False + False + False + True + True + + + + GtkLabel + label301 + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 5 + 0 + + 0 + False + False + + + + + GtkLabel + frel + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 + + 0 + True + True + + + + + + GtkHBox + hbox76 + False + 0 + + 1 + 2 + 3 + 4 + 0 + 0 + False + False + False + False + True + True + + + + GtkLabel + label302 + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 5 + 0 + + 0 + False + False + + + + + GtkLabel + mrel + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 + + 0 + True + True + + + + + + GtkCheckButton + preffam + False + True + + False + True + + 1 + 2 + 4 + 5 5 5 False @@ -1980,7 +2227,7 @@ 0 5 - False + True True diff --git a/gramps/src/gramps_main.py b/gramps/src/gramps_main.py index 4519760a9..fbbe4b5cb 100755 --- a/gramps/src/gramps_main.py +++ b/gramps/src/gramps_main.py @@ -88,6 +88,7 @@ class Gramps: self.active_father = None self.active_mother = None self.active_parents = None + self.parents_index = 0 self.active_person = None self.active_spouse = None self.bookmarks = None @@ -175,6 +176,8 @@ class Gramps: self.qual_label = self.gtop.get_widget("qual") self.child_type = self.gtop.get_widget("childtype") 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_del = self.gtop.get_widget("delete_sp") @@ -208,6 +211,9 @@ class Gramps: self.gtop.signal_autoconnect({ "delete_event" : self.delete_event, "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_add_bookmark_activate" : self.on_add_bookmark_activate, "on_add_child_clicked" : self.on_add_child_clicked, @@ -422,7 +428,8 @@ class Gramps: return 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 self.active_family.getFather() == None: self.delete_family_from(self.active_family.getMother()) @@ -437,7 +444,7 @@ class Gramps: self.database.deleteFamily(self.active_family) flist = self.active_person.getFamilyList() if len(flist) > 0: - self.active_family = flist[0] + self.active_family = flist[0][0] else: self.active_family = None @@ -822,14 +829,14 @@ class Gramps: if self.active_person.getGender == Person.male: if family.getMother() == None: for child in family.getChildList(): - child.setMainFamily(None) + child.removeAltFamily(family) del familymap[family] else: family.setFather(None) else: if family.getFather() == None: for child in family.getChildList(): - child.setMainFamily(None) + child.removeAltFamily(family) del familymap[family] else: family.setMother(None) @@ -869,10 +876,7 @@ class Gramps: return self.active_parents.removeChild(self.active_person) - if self.active_parents == self.active_person.getMainFamily(): - self.active_person.setMainFamily(None) - else: - self.active_person.removeAltFamily(self.active_parents) + self.active_person.removeAltFamily(self.active_parents) self.load_family() def on_person_list_select_row(self,obj,row,b,c): @@ -1299,6 +1303,11 @@ class Gramps: if self.active_person: 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): if epo: if epo.person.getId() == "": @@ -1370,54 +1379,64 @@ class Gramps: def load_family(self,family=None): if family != None: 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 = [] - main_family = None + main_family = None self.person_text.set_text(GrampsCfg.nameof(self.active_person)) if self.active_person: main_family = self.active_person.getMainFamily() self.active_parents = main_family + self.parents_index = 0 family_types = self.active_person.getAltFamilyList() if self.active_parents == None and len(family_types) > 0: - fam = family_types[0] - self.active_parents = fam[0] + self.active_parents = family_types[0][0] else: self.active_parents = None - if len(family_types) > 0: - typeMenu = gtk.GtkMenu() - if main_family: - menuitem = gtk.GtkMenuItem(_("Birth")) - menuitem.set_data("parents",main_family) - menuitem.connect("activate",self.on_current_type_changed) - menuitem.show() - typeMenu.append(menuitem) - for fam in family_types: - 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) - self.child_type.set_menu(typeMenu) - self.child_type.show() - else: - self.child_type.hide() +# 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: - number_of_families = len(self.active_person.getFamilyList()) + flist = self.active_person.getFamilyList() + number_of_families = len(flist) if number_of_families > 1: myMenu = gtk.GtkMenu() index = 0 opt_index = 0 - for f in self.active_person.getFamilyList(): + for f in flist: person = None if f.getMother() == self.active_person: if f.getFather() != None: @@ -1438,6 +1457,7 @@ class Gramps: self.spouse_menu.set_menu(myMenu) self.spouse_menu.set_history(opt_index) self.spouse_tab.set_page(1) + self.spouse_pref.set_active(0) self.spouse_edit.set_sensitive(1) self.spouse_del.set_sensitive(1) elif number_of_families == 1: @@ -1505,6 +1525,10 @@ class Gramps: else : fv_mother.set_text("") 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: fv_father.set_text("") fv_mother.set_text("") @@ -1522,9 +1546,11 @@ class Gramps: def display_marriage(self,family): + if self.active_person == None: + return self.active_family = family fv_prev = self.gtop.get_widget("fv_prev") - + self.child_list.clear() self.active_child = None @@ -1533,7 +1559,17 @@ class Gramps: self.child_list.set_sort_column(self.c_sort_col) 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: self.active_spouse = family.getMother() else: @@ -1784,8 +1820,26 @@ class Gramps: self.database.setDefaultPerson(self.active_person) Utils.modified() - def on_current_type_changed(self,obj): - self.active_parents = obj.get_data("parents") + def family_up_clicked(self,obj): + 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) def export_callback(self,obj,plugin_function):