* src/AddSpouse.py: use ComboBox instead of ComboBoxEntry for
handling child/parent relationships * src/ChooseParents.py: use ComboBox instead of ComboBoxEntry for handling child/parent relationships * src/FamilyView.py: use ModifyParents instead of EditRel * src/SelectChild.py: use ComboBox instead of ComboBoxEntry for handling child/parent relationships. Remove EditRel class * src/gramps.glade: use ComboBox instead of ComboBoxEntry for handling child/parent relationships, delete editrel svn: r4109
This commit is contained in:
parent
028ed21efc
commit
3f12ec9563
@ -1,3 +1,14 @@
|
|||||||
|
2005-03-02 Don Allingham <dallingham@users.sourceforge.net>
|
||||||
|
* src/AddSpouse.py: use ComboBox instead of ComboBoxEntry for
|
||||||
|
handling child/parent relationships
|
||||||
|
* src/ChooseParents.py: use ComboBox instead of ComboBoxEntry for
|
||||||
|
handling child/parent relationships
|
||||||
|
* src/FamilyView.py: use ModifyParents instead of EditRel
|
||||||
|
* src/SelectChild.py: use ComboBox instead of ComboBoxEntry for
|
||||||
|
handling child/parent relationships. Remove EditRel class
|
||||||
|
* src/gramps.glade: use ComboBox instead of ComboBoxEntry for
|
||||||
|
handling child/parent relationships, delete editrel
|
||||||
|
|
||||||
2005-03-02 Alex Roitman <shura@alex.neuro.umn.edu>
|
2005-03-02 Alex Roitman <shura@alex.neuro.umn.edu>
|
||||||
* src/DbPrompter.py (ImportDbPrompter.chooser): Explicitly
|
* src/DbPrompter.py (ImportDbPrompter.chooser): Explicitly
|
||||||
import XML and GEDCOM.
|
import XML and GEDCOM.
|
||||||
|
@ -136,7 +136,6 @@ class AddSpouse:
|
|||||||
"on_spouse_help_clicked" : self.on_spouse_help_clicked,
|
"on_spouse_help_clicked" : self.on_spouse_help_clicked,
|
||||||
"on_show_toggled" : self.on_show_toggled,
|
"on_show_toggled" : self.on_show_toggled,
|
||||||
"on_new_spouse_clicked" : self.new_spouse_clicked,
|
"on_new_spouse_clicked" : self.new_spouse_clicked,
|
||||||
"on_rel_type_changed" : self.relation_type_changed,
|
|
||||||
"destroy_passed_object" : Utils.destroy_passed_object
|
"destroy_passed_object" : Utils.destroy_passed_object
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ import const
|
|||||||
import Utils
|
import Utils
|
||||||
import PeopleModel
|
import PeopleModel
|
||||||
import NameDisplay
|
import NameDisplay
|
||||||
|
import GenericFilter
|
||||||
from QuestionDialog import ErrorDialog
|
from QuestionDialog import ErrorDialog
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -92,8 +93,11 @@ class ChooseParents:
|
|||||||
self.renderer = gtk.CellRendererText()
|
self.renderer = gtk.CellRendererText()
|
||||||
|
|
||||||
# set default filters
|
# set default filters
|
||||||
self.father_filter = self.likely_father_filter
|
self.father_filter = GenericFilter.GenericFilter()
|
||||||
self.mother_filter = self.likely_mother_filter
|
self.father_filter.add_rule(GenericFilter.IsMale([]))
|
||||||
|
|
||||||
|
self.mother_filter = GenericFilter.GenericFilter()
|
||||||
|
self.mother_filter.add_rule(GenericFilter.IsFemale([]))
|
||||||
|
|
||||||
birth_event = self.db.get_event_from_handle(self.person.get_birth_handle())
|
birth_event = self.db.get_event_from_handle(self.person.get_birth_handle())
|
||||||
if birth_event:
|
if birth_event:
|
||||||
@ -122,8 +126,8 @@ class ChooseParents:
|
|||||||
Utils.set_titles(self.top,self.glade.get_widget('title'),
|
Utils.set_titles(self.top,self.glade.get_widget('title'),
|
||||||
self.title_text,_('Choose Parents'))
|
self.title_text,_('Choose Parents'))
|
||||||
|
|
||||||
self.mother_rel = self.glade.get_widget("mrel")
|
self.mcombo = self.glade.get_widget("mcombo")
|
||||||
self.father_rel = self.glade.get_widget("frel")
|
self.fcombo = self.glade.get_widget("fcombo")
|
||||||
self.prel = self.glade.get_widget("prel_combo")
|
self.prel = self.glade.get_widget("prel_combo")
|
||||||
self.title = self.glade.get_widget("chooseTitle")
|
self.title = self.glade.get_widget("chooseTitle")
|
||||||
self.father_list = self.glade.get_widget("father_list")
|
self.father_list = self.glade.get_widget("father_list")
|
||||||
@ -132,6 +136,7 @@ class ChooseParents:
|
|||||||
self.mlabel = self.glade.get_widget("mlabel")
|
self.mlabel = self.glade.get_widget("mlabel")
|
||||||
self.showallf = self.glade.get_widget('showallf')
|
self.showallf = self.glade.get_widget('showallf')
|
||||||
self.showallm = self.glade.get_widget('showallm')
|
self.showallm = self.glade.get_widget('showallm')
|
||||||
|
self.add_itself_to_menu()
|
||||||
|
|
||||||
self.build_father_list()
|
self.build_father_list()
|
||||||
self.build_mother_list()
|
self.build_mother_list()
|
||||||
@ -142,12 +147,12 @@ class ChooseParents:
|
|||||||
|
|
||||||
for (f,mr,fr) in self.person.get_parent_family_handle_list():
|
for (f,mr,fr) in self.person.get_parent_family_handle_list():
|
||||||
if f == self.family:
|
if f == self.family:
|
||||||
self.mother_rel.set_text(_(mr))
|
mrel = mr
|
||||||
self.father_rel.set_text(_(fr))
|
frel = fr
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
self.mother_rel.set_text(_("Birth"))
|
mrel = "Birth"
|
||||||
self.father_rel.set_text(_("Birth"))
|
frel = "Birth"
|
||||||
|
|
||||||
if self.family:
|
if self.family:
|
||||||
self.type = self.family.get_relationship()
|
self.type = self.family.get_relationship()
|
||||||
@ -158,18 +163,44 @@ class ChooseParents:
|
|||||||
self.redrawm()
|
self.redrawm()
|
||||||
|
|
||||||
self.glade.signal_autoconnect({
|
self.glade.signal_autoconnect({
|
||||||
"on_save_parents_clicked" : self.save_parents_clicked,
|
|
||||||
"on_add_parent_clicked" : self.add_parent_clicked,
|
"on_add_parent_clicked" : self.add_parent_clicked,
|
||||||
"on_prel_changed" : self.parent_relation_changed,
|
"on_prel_changed" : self.parent_relation_changed,
|
||||||
"on_showallf_toggled" : self.showallf_toggled,
|
#"on_showallf_toggled" : self.showallf_toggled,
|
||||||
"on_showallm_toggled" : self.showallm_toggled,
|
#"on_showallm_toggled" : self.showallm_toggled,
|
||||||
"destroy_passed_object" : self.close,
|
#"destroy_passed_object" : self.close,
|
||||||
"on_help_familyDialog_clicked" : self.on_help_clicked,
|
"on_help_familyDialog_clicked" : self.on_help_clicked,
|
||||||
"on_familyDialog_delete_event" : self.on_delete_event,
|
"on_familyDialog_delete_event" : self.on_delete_event,
|
||||||
})
|
})
|
||||||
|
|
||||||
self.add_itself_to_menu()
|
values = const.child_relations.get_values()
|
||||||
self.top.show()
|
self.keys = []
|
||||||
|
for value in values:
|
||||||
|
self.keys.append(const.child_relations.find_key(value))
|
||||||
|
self.keys.sort()
|
||||||
|
|
||||||
|
self.build_list(self.mcombo,mr)
|
||||||
|
self.build_list(self.fcombo,fr)
|
||||||
|
|
||||||
|
self.val = self.top.run()
|
||||||
|
if self.val == gtk.RESPONSE_OK:
|
||||||
|
self.save_parents_clicked(None)
|
||||||
|
self.close(None)
|
||||||
|
|
||||||
|
def build_list(self,opt_menu,sel):
|
||||||
|
cell = gtk.CellRendererText()
|
||||||
|
opt_menu.pack_start(cell,True)
|
||||||
|
opt_menu.add_attribute(cell,'text',0)
|
||||||
|
|
||||||
|
store = gtk.ListStore(str)
|
||||||
|
sel_index = 0
|
||||||
|
index = 0
|
||||||
|
for val in self.keys:
|
||||||
|
if _(sel) == val:
|
||||||
|
sel_index = index
|
||||||
|
index += 1
|
||||||
|
store.append(row=[val])
|
||||||
|
opt_menu.set_model(store)
|
||||||
|
opt_menu.set_active(sel_index)
|
||||||
|
|
||||||
def build_father_list(self):
|
def build_father_list(self):
|
||||||
self.father_selection = self.father_list.get_selection()
|
self.father_selection = self.father_list.get_selection()
|
||||||
@ -202,12 +233,12 @@ class ChooseParents:
|
|||||||
tree.append_column(column)
|
tree.append_column(column)
|
||||||
|
|
||||||
def on_delete_event(self,obj,b):
|
def on_delete_event(self,obj,b):
|
||||||
self.close_child_windows()
|
|
||||||
self.remove_itself_from_menu()
|
self.remove_itself_from_menu()
|
||||||
|
self.close_child_windows()
|
||||||
|
|
||||||
def close(self,obj):
|
def close(self,obj):
|
||||||
self.close_child_windows()
|
|
||||||
self.remove_itself_from_menu()
|
self.remove_itself_from_menu()
|
||||||
|
self.close_child_windows()
|
||||||
self.top.destroy()
|
self.top.destroy()
|
||||||
|
|
||||||
def close_child_windows(self):
|
def close_child_windows(self):
|
||||||
@ -246,88 +277,9 @@ class ChooseParents:
|
|||||||
def all_females_filter(self,person):
|
def all_females_filter(self,person):
|
||||||
return (person.get_gender() == RelLib.Person.FEMALE)
|
return (person.get_gender() == RelLib.Person.FEMALE)
|
||||||
|
|
||||||
def likely_father_filter(self,person):
|
|
||||||
if person.get_gender() != RelLib.Person.MALE:
|
|
||||||
return 0
|
|
||||||
if self.exclude.has_key(person.get_handle()):
|
|
||||||
return 0
|
|
||||||
return self.likely_filter(person)
|
|
||||||
|
|
||||||
def likely_mother_filter(self,person):
|
|
||||||
if person.get_gender() != RelLib.Person.FEMALE:
|
|
||||||
return 0
|
|
||||||
if self.exclude.has_key(person.get_handle()):
|
|
||||||
return 0
|
|
||||||
return self.likely_filter(person)
|
|
||||||
|
|
||||||
def likely_filter(self,person):
|
|
||||||
if person.get_handle() == self.person.get_handle():
|
|
||||||
return 0
|
|
||||||
birth_event = self.db.get_event_from_handle(person.get_birth_handle())
|
|
||||||
if birth_event:
|
|
||||||
pbday = birth_event.get_date_object()
|
|
||||||
else:
|
|
||||||
pbday = None
|
|
||||||
|
|
||||||
death_event = self.db.get_event_from_handle(person.get_death_handle())
|
|
||||||
if death_event:
|
|
||||||
pdday = death_event.get_date_object()
|
|
||||||
else:
|
|
||||||
pdday = None
|
|
||||||
|
|
||||||
if self.bday and self.bday.get_year_valid():
|
|
||||||
if pbday and pbday.get_year_valid():
|
|
||||||
# reject if parents birthdate + 10 > child birthdate
|
|
||||||
if pbday.get_year()+10 > self.bday.get_high_year():
|
|
||||||
return 0
|
|
||||||
|
|
||||||
# reject if parents birthdate + 90 < child birthdate
|
|
||||||
if pbday.get_high_year()+90 < self.bday.get_year():
|
|
||||||
return 0
|
|
||||||
|
|
||||||
if pdday and pdday.get_year_valid():
|
|
||||||
# reject if parents birthdate + 10 > child deathdate
|
|
||||||
if self.dday and pbday.get_year()+10 > self.dday.get_high_year():
|
|
||||||
return 0
|
|
||||||
|
|
||||||
if self.dday and self.dday.get_year_valid():
|
|
||||||
if pbday and pbday.get_year_valid():
|
|
||||||
# reject if parents deathday + 3 < childs birth date
|
|
||||||
if pdday and self.bday and pdday.get_high_year()+3 < self.bday.get_year():
|
|
||||||
return 0
|
|
||||||
|
|
||||||
if pdday and pdday.get_year_valid():
|
|
||||||
# reject if parents deathday + 150 < childs death date
|
|
||||||
if pdday.get_high_year() + 150 < self.dday.get_year():
|
|
||||||
return 0
|
|
||||||
return 1
|
|
||||||
|
|
||||||
def build_exclude_list(self):
|
|
||||||
self.exclude = { self.person.get_handle() : 1 }
|
|
||||||
for family_handle in self.person.get_family_handle_list():
|
|
||||||
fam = self.db.get_family_from_handle(family_handle)
|
|
||||||
for handle in [fam.get_father_handle(), fam.get_mother_handle()] + \
|
|
||||||
fam.get_child_handle_list():
|
|
||||||
if handle:
|
|
||||||
self.exclude[handle] = 1
|
|
||||||
|
|
||||||
def redrawf(self):
|
def redrawf(self):
|
||||||
"""Redraws the potential father list"""
|
"""Redraws the potential father list"""
|
||||||
self.build_exclude_list()
|
self.father_model = PeopleModel.PeopleModel(self.db,self.father_filter)
|
||||||
self.father_nsort = PeopleModel.PeopleModel(self.db)
|
|
||||||
|
|
||||||
cursor = self.db.get_person_cursor()
|
|
||||||
data = cursor.first()
|
|
||||||
while data:
|
|
||||||
person = RelLib.Person()
|
|
||||||
person.unserialize(data[1])
|
|
||||||
visible = self.father_filter(person)
|
|
||||||
if visible:
|
|
||||||
self.father_nsort.set_visible(data[0],visible)
|
|
||||||
data = cursor.next()
|
|
||||||
cursor.close()
|
|
||||||
|
|
||||||
self.father_model = gtk.TreeModelSort(self.father_nsort)
|
|
||||||
self.father_list.set_model(self.father_model)
|
self.father_list.set_model(self.father_model)
|
||||||
|
|
||||||
if self.type == RelLib.Family.CIVIL_UNION:
|
if self.type == RelLib.Family.CIVIL_UNION:
|
||||||
@ -337,21 +289,7 @@ class ChooseParents:
|
|||||||
|
|
||||||
def redrawm(self):
|
def redrawm(self):
|
||||||
"""Redraws the potential mother list"""
|
"""Redraws the potential mother list"""
|
||||||
self.mother_nsort = PeopleModel.PeopleModel(self.db)
|
self.mother_model = PeopleModel.PeopleModel(self.db,self.mother_filter)
|
||||||
self.build_exclude_list()
|
|
||||||
|
|
||||||
cursor = self.db.get_person_cursor()
|
|
||||||
data = cursor.first()
|
|
||||||
while data:
|
|
||||||
person = RelLib.Person()
|
|
||||||
person.unserialize(data[1])
|
|
||||||
visible = self.mother_filter(person)
|
|
||||||
if visible:
|
|
||||||
self.mother_nsort.set_visible(data[0],visible)
|
|
||||||
data = cursor.next()
|
|
||||||
cursor.close()
|
|
||||||
|
|
||||||
self.mother_model = gtk.TreeModelSort(self.mother_nsort)
|
|
||||||
self.mother_list.set_model(self.mother_model)
|
self.mother_list.set_model(self.mother_model)
|
||||||
|
|
||||||
if self.type == RelLib.Family.CIVIL_UNION:
|
if self.type == RelLib.Family.CIVIL_UNION:
|
||||||
@ -492,14 +430,14 @@ class ChooseParents:
|
|||||||
of the main perosn.
|
of the main perosn.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
mother_rel = const.child_relations.find_value(self.mother_rel.get_text())
|
mother_rel = self.keys[self.mcombo.get_active()]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
mother_rel = const.child_relations.find_value("Birth")
|
mother_rel = "Birth"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
father_rel = const.child_relations.find_value(self.father_rel.get_text())
|
father_rel = self.keys[self.fcombo.get_active()]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
father_rel = const.child_relations.find_value("Birth")
|
father_rel = "Birth"
|
||||||
|
|
||||||
trans = self.db.transaction_begin()
|
trans = self.db.transaction_begin()
|
||||||
if self.father or self.mother:
|
if self.father or self.mother:
|
||||||
@ -548,7 +486,6 @@ class ChooseParents:
|
|||||||
self.db.commit_family(self.family,trans)
|
self.db.commit_family(self.family,trans)
|
||||||
self.family_update(None)
|
self.family_update(None)
|
||||||
self.db.transaction_commit(trans,_("Choose Parents"))
|
self.db.transaction_commit(trans,_("Choose Parents"))
|
||||||
self.close(obj)
|
|
||||||
|
|
||||||
def add_new_parent(self,epo,val):
|
def add_new_parent(self,epo,val):
|
||||||
"""Adds a new person to either the father list or the mother list,
|
"""Adds a new person to either the father list or the mother list,
|
||||||
@ -604,11 +541,11 @@ class ChooseParents:
|
|||||||
if mother_rel == fam[1] and father_rel == fam[2]:
|
if mother_rel == fam[1] and father_rel == fam[2]:
|
||||||
return
|
return
|
||||||
if mother_rel != fam[1] or father_rel != fam[2]:
|
if mother_rel != fam[1] or father_rel != fam[2]:
|
||||||
self.person.remove_parent_family_handle(family.get_handle())
|
self.person.remove_parent_family_handle(family_handle)
|
||||||
self.person.add_parent_family_handle(family.get_handle(),mother_rel,father_rel)
|
self.person.add_parent_family_handle(family_handle,mother_rel,father_rel)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
self.person.add_parent_family_handle(family.get_handle(),mother_rel,father_rel)
|
self.person.add_parent_family_handle(family_handle,mother_rel,father_rel)
|
||||||
|
|
||||||
trans = self.db.transaction_begin()
|
trans = self.db.transaction_begin()
|
||||||
self.db.commit_person(self.person,trans)
|
self.db.commit_person(self.person,trans)
|
||||||
@ -620,7 +557,8 @@ class ChooseParents:
|
|||||||
self.db.transaction_commit(trans,_("Choose Parents"))
|
self.db.transaction_commit(trans,_("Choose Parents"))
|
||||||
|
|
||||||
class ModifyParents:
|
class ModifyParents:
|
||||||
def __init__(self,db,person,family_handle,family_update,full_update,parent_window=None):
|
def __init__(self, db, person, family_handle, family_update,
|
||||||
|
full_update, parent_window=None):
|
||||||
"""
|
"""
|
||||||
Creates a ChoosePerson dialog box.
|
Creates a ChoosePerson dialog box.
|
||||||
|
|
||||||
@ -661,9 +599,6 @@ class ModifyParents:
|
|||||||
self.orig_mrel = _(mr)
|
self.orig_mrel = _(mr)
|
||||||
self.orig_frel = _(fr)
|
self.orig_frel = _(fr)
|
||||||
|
|
||||||
self.mother_rel.set_text(self.orig_mrel)
|
|
||||||
self.father_rel.set_text(self.orig_frel)
|
|
||||||
|
|
||||||
self.glade.signal_autoconnect({
|
self.glade.signal_autoconnect({
|
||||||
"on_parents_help_clicked" : self.on_help_clicked,
|
"on_parents_help_clicked" : self.on_help_clicked,
|
||||||
})
|
})
|
||||||
@ -682,35 +617,61 @@ class ModifyParents:
|
|||||||
fname = NameDisplay.displayer.display(self.father)
|
fname = NameDisplay.displayer.display(self.father)
|
||||||
self.glade.get_widget("fname").set_text(fname)
|
self.glade.get_widget("fname").set_text(fname)
|
||||||
else:
|
else:
|
||||||
self.father_rel.set_sensitive(0)
|
self.father_rel.set_sensitive(False)
|
||||||
|
|
||||||
if self.mother:
|
if self.mother:
|
||||||
mname = NameDisplay.displayer.display(self.mother)
|
mname = NameDisplay.displayer.display(self.mother)
|
||||||
self.glade.get_widget("mname").set_text(mname)
|
self.glade.get_widget("mname").set_text(mname)
|
||||||
else:
|
else:
|
||||||
self.mother_rel.set_sensitive(0)
|
self.mother_rel.set_sensitive(False)
|
||||||
|
|
||||||
self.pref = self.glade.get_widget('preferred')
|
self.pref = self.glade.get_widget('preferred')
|
||||||
if len(self.person.get_parent_family_handle_list()) > 1:
|
if len(self.person.get_parent_family_handle_list()) > 1:
|
||||||
self.glade.get_widget('pref_label').show()
|
self.glade.get_widget('pref_label').show()
|
||||||
self.pref.show()
|
self.pref.show()
|
||||||
if self.family == self.person.get_parent_family_handle_list()[0]:
|
if self.family == self.person.get_parent_family_handle_list()[0]:
|
||||||
self.pref.set_active(1)
|
self.pref.set_active(True)
|
||||||
else:
|
else:
|
||||||
self.pref.set_active(0)
|
self.pref.set_active(False)
|
||||||
|
|
||||||
if parent_window:
|
if parent_window:
|
||||||
self.top.set_transient_for(parent_window)
|
self.top.set_transient_for(parent_window)
|
||||||
|
|
||||||
self.glade.get_widget('fcombo').set_sensitive(False)
|
self.fcombo = self.glade.get_widget('fcombo')
|
||||||
self.glade.get_widget('mcombo').set_sensitive(False)
|
self.mcombo = self.glade.get_widget('mcombo')
|
||||||
|
|
||||||
|
if self.db.readonly:
|
||||||
|
self.fcombo.set_sensitive(False)
|
||||||
|
self.mcombo.set_sensitive(False)
|
||||||
self.glade.get_widget('ok').set_sensitive(False)
|
self.glade.get_widget('ok').set_sensitive(False)
|
||||||
|
|
||||||
|
values = const.child_relations.get_values()
|
||||||
|
self.keys = []
|
||||||
|
for value in values:
|
||||||
|
self.keys.append(const.child_relations.find_key(value))
|
||||||
|
self.keys.sort()
|
||||||
|
|
||||||
|
self.build_list(self.mcombo,self.orig_mrel)
|
||||||
|
self.build_list(self.fcombo,self.orig_frel)
|
||||||
|
|
||||||
self.val = self.top.run()
|
self.val = self.top.run()
|
||||||
if self.val == gtk.RESPONSE_OK:
|
if self.val == gtk.RESPONSE_OK:
|
||||||
self.save_parents_clicked()
|
self.save_parents_clicked()
|
||||||
self.top.destroy()
|
self.top.destroy()
|
||||||
|
|
||||||
|
def build_list(self,opt_menu,sel):
|
||||||
|
cell = gtk.CellRendererText()
|
||||||
|
|
||||||
|
store = gtk.ListStore(str)
|
||||||
|
sel_index = 0
|
||||||
|
index = 0
|
||||||
|
for val in self.keys:
|
||||||
|
if _(sel) == val:
|
||||||
|
sel_index = index
|
||||||
|
index += 1
|
||||||
|
store.append(row=[val])
|
||||||
|
opt_menu.set_model(store)
|
||||||
|
opt_menu.set_active(sel_index)
|
||||||
|
|
||||||
def on_help_clicked(self,obj):
|
def on_help_clicked(self,obj):
|
||||||
"""Display the relevant portion of GRAMPS manual"""
|
"""Display the relevant portion of GRAMPS manual"""
|
||||||
@ -722,14 +683,16 @@ class ModifyParents:
|
|||||||
Called with the OK button nis pressed. Saves the selected people as parents
|
Called with the OK button nis pressed. Saves the selected people as parents
|
||||||
of the main perosn.
|
of the main perosn.
|
||||||
"""
|
"""
|
||||||
mother_rel = const.child_relations.find_value(self.mother_rel.get_text())
|
|
||||||
father_rel = const.child_relations.find_value(self.father_rel.get_text())
|
|
||||||
mod = 0
|
|
||||||
|
|
||||||
|
mother_rel = self.keys[self.mcombo.get_active()]
|
||||||
|
father_rel = self.keys[self.fcombo.get_active()]
|
||||||
|
mod = False
|
||||||
|
|
||||||
|
fhandle = self.family.get_handle()
|
||||||
if mother_rel != self.orig_mrel or father_rel != self.orig_frel:
|
if mother_rel != self.orig_mrel or father_rel != self.orig_frel:
|
||||||
self.person.remove_parent_family_handle(self.family.get_handle())
|
self.person.remove_parent_family_handle(fhandle)
|
||||||
self.person.add_parent_family_handle(self.family.get_handle(),mother_rel,father_rel)
|
self.person.add_parent_family_handle(fhandle,mother_rel,father_rel)
|
||||||
mod = 1
|
mod = True
|
||||||
|
|
||||||
if len(self.person.get_parent_family_handle_list()):
|
if len(self.person.get_parent_family_handle_list()):
|
||||||
make_pref = self.pref.get_active()
|
make_pref = self.pref.get_active()
|
||||||
@ -737,15 +700,16 @@ class ModifyParents:
|
|||||||
plist = self.person.get_parent_family_handle_list()
|
plist = self.person.get_parent_family_handle_list()
|
||||||
if make_pref:
|
if make_pref:
|
||||||
if self.family != plist[0]:
|
if self.family != plist[0]:
|
||||||
self.person.set_main_parent_family_handle(self.family.get_handle())
|
self.person.set_main_parent_family_handle(fhandle)
|
||||||
mod = 1
|
mod = True
|
||||||
else:
|
else:
|
||||||
if self.family == plist[0]:
|
if self.family == plist[0]:
|
||||||
self.person.set_main_parent_family_handle(plist[0])
|
self.person.set_main_parent_family_handle(plist[0])
|
||||||
mod = 1
|
mod = True
|
||||||
|
|
||||||
if mod:
|
if mod:
|
||||||
trans = self.db.transaction_begin()
|
trans = self.db.transaction_begin()
|
||||||
self.db.commit_person(self.person,trans)
|
self.db.commit_person(self.person,trans)
|
||||||
self.db.transaction_commit(trans,_("Modify Parents"))
|
self.db.transaction_commit(trans,_("Modify Parents"))
|
||||||
|
if self.family_update:
|
||||||
self.family_update(None)
|
self.family_update(None)
|
||||||
|
@ -546,11 +546,13 @@ class FamilyView:
|
|||||||
def child_rel(self,obj):
|
def child_rel(self,obj):
|
||||||
handle = obj.get_data('o')
|
handle = obj.get_data('o')
|
||||||
person = self.parent.db.get_person_from_handle(handle)
|
person = self.parent.db.get_person_from_handle(handle)
|
||||||
SelectChild.EditRel(self.parent.db,person,self.family,self.load_family)
|
ChooseParents.ModifyParents(self.parent.db, person, self.family.get_handle(),
|
||||||
|
None,self.load_family)
|
||||||
|
|
||||||
def child_rel_by_id(self,handle):
|
def child_rel_by_id(self,handle):
|
||||||
person = self.parent.db.get_person_from_handle(handle)
|
person = self.parent.db.get_person_from_handle(handle)
|
||||||
SelectChild.EditRel(self.parent.db,person,self.family,self.load_family)
|
ChooseParents.ModifyParents(self.parent.db, person, self.family.get_handle(),
|
||||||
|
None,self.load_family)
|
||||||
|
|
||||||
def spouse_changed(self,obj):
|
def spouse_changed(self,obj):
|
||||||
if self.in_drag:
|
if self.in_drag:
|
||||||
|
@ -87,39 +87,26 @@ class SelectChild:
|
|||||||
|
|
||||||
self.add_child = self.xml.get_widget("childlist")
|
self.add_child = self.xml.get_widget("childlist")
|
||||||
|
|
||||||
if (self.family):
|
self.mrel = self.xml.get_widget("mrel_combo")
|
||||||
|
self.frel = self.xml.get_widget("frel_combo")
|
||||||
|
|
||||||
|
values = const.child_relations.get_values()
|
||||||
|
self.keys = []
|
||||||
|
for value in values:
|
||||||
|
self.keys.append(const.child_relations.find_key(value))
|
||||||
|
self.keys.sort()
|
||||||
|
|
||||||
|
self.build_list(self.mrel,"Birth")
|
||||||
|
self.build_list(self.frel,"Birth")
|
||||||
|
|
||||||
|
if self.family:
|
||||||
father = self.db.get_person_from_handle(self.family.get_father_handle())
|
father = self.db.get_person_from_handle(self.family.get_father_handle())
|
||||||
mother = self.db.get_person_from_handle(self.family.get_mother_handle())
|
mother = self.db.get_person_from_handle(self.family.get_mother_handle())
|
||||||
|
|
||||||
if father != None:
|
|
||||||
fname = NameDisplay.displayer.display(father)
|
|
||||||
label = _("Relationship to %(father)s") % {
|
|
||||||
'father' : fname
|
|
||||||
}
|
|
||||||
self.xml.get_widget("flabel").set_text(label)
|
|
||||||
|
|
||||||
if mother != None:
|
|
||||||
mname = NameDisplay.displayer.display(mother)
|
|
||||||
label = _("Relationship to %(mother)s") % {
|
|
||||||
'mother' : mname
|
|
||||||
}
|
|
||||||
self.xml.get_widget("mlabel").set_text(label)
|
|
||||||
else:
|
else:
|
||||||
fname = NameDisplay.displayer.display(self.person)
|
|
||||||
label = _("Relationship to %s") % fname
|
|
||||||
|
|
||||||
if self.person.get_gender() == RelLib.Person.MALE:
|
if self.person.get_gender() == RelLib.Person.MALE:
|
||||||
self.xml.get_widget("flabel").set_text(label)
|
self.mrel.set_sensitive(False)
|
||||||
self.xml.get_widget("mrel_combo").set_sensitive(0)
|
|
||||||
else:
|
else:
|
||||||
self.xml.get_widget("mlabel").set_text(label)
|
self.frel.set_sensitive(False)
|
||||||
self.xml.get_widget("frel_combo").set_sensitive(0)
|
|
||||||
|
|
||||||
self.mrel = self.xml.get_widget("mrel")
|
|
||||||
self.frel = self.xml.get_widget("frel")
|
|
||||||
self.mrel.set_text(_("Birth"))
|
|
||||||
|
|
||||||
self.frel.set_text(_("Birth"))
|
|
||||||
|
|
||||||
self.refmodel = PeopleModel.PeopleModel(self.db)
|
self.refmodel = PeopleModel.PeopleModel(self.db)
|
||||||
|
|
||||||
@ -129,6 +116,22 @@ class SelectChild:
|
|||||||
self.add_columns(self.add_child)
|
self.add_columns(self.add_child)
|
||||||
self.top.show()
|
self.top.show()
|
||||||
|
|
||||||
|
def build_list(self,opt_menu,sel):
|
||||||
|
cell = gtk.CellRendererText()
|
||||||
|
opt_menu.pack_start(cell,True)
|
||||||
|
opt_menu.add_attribute(cell,'text',0)
|
||||||
|
|
||||||
|
store = gtk.ListStore(str)
|
||||||
|
sel_index = 0
|
||||||
|
index = 0
|
||||||
|
for val in self.keys:
|
||||||
|
if _(sel) == val:
|
||||||
|
sel_index = index
|
||||||
|
index += 1
|
||||||
|
store.append(row=[val])
|
||||||
|
opt_menu.set_model(store)
|
||||||
|
opt_menu.set_active(sel_index)
|
||||||
|
|
||||||
def add_columns(self,tree):
|
def add_columns(self,tree):
|
||||||
column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0)
|
column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0)
|
||||||
column.set_resizable(True)
|
column.set_resizable(True)
|
||||||
@ -317,13 +320,13 @@ class SelectChild:
|
|||||||
|
|
||||||
self.family.add_child_handle(select_child.get_handle())
|
self.family.add_child_handle(select_child.get_handle())
|
||||||
|
|
||||||
mrel = const.child_relations.find_value(self.mrel.get_text())
|
mrel = self.keys[self.mrel.get_active()]
|
||||||
mother = self.db.get_person_from_handle(self.family.get_mother_handle())
|
mother = self.db.get_person_from_handle(self.family.get_mother_handle())
|
||||||
if mother and mother.get_gender() != RelLib.Person.FEMALE:
|
if mother and mother.get_gender() != RelLib.Person.FEMALE:
|
||||||
if mrel == "Birth":
|
if mrel == "Birth":
|
||||||
mrel = "Unknown"
|
mrel = "Unknown"
|
||||||
|
|
||||||
frel = const.child_relations.find_value(self.frel.get_text())
|
frel = self.keys[self.frel.get_active()]
|
||||||
father = self.db.get_person_from_handle(self.family.get_father_handle())
|
father = self.db.get_person_from_handle(self.family.get_father_handle())
|
||||||
if father and father.get_gender() !=RelLib.Person.MALE:
|
if father and father.get_gender() !=RelLib.Person.MALE:
|
||||||
if frel == "Birth":
|
if frel == "Birth":
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user