Better handing of parents/spouses in family view.
svn: r858
This commit is contained in:
parent
507cde7298
commit
54da58996a
@ -82,16 +82,6 @@ class AddSpouse:
|
||||
self.spouse_list = self.glade.get_widget("spouseList")
|
||||
self.relation_def = self.glade.get_widget("reldef")
|
||||
self.top = self.glade.get_widget("spouseDialog")
|
||||
self.given = self.glade.get_widget("given")
|
||||
self.surname = self.glade.get_widget("surname")
|
||||
self.surname_combo = self.glade.get_widget("surname_combo")
|
||||
|
||||
self.rel_combo.set_popdown_strings(const.familyRelations)
|
||||
Utils.attach_surnames(self.surname_combo)
|
||||
|
||||
# Typing CR selects 'Add Existing' button
|
||||
self.top.editable_enters(self.given)
|
||||
self.top.editable_enters(self.surname)
|
||||
|
||||
self.name_list = self.db.getPersonMap().values()
|
||||
self.name_list.sort(sort.by_last_name)
|
||||
@ -114,38 +104,26 @@ class AddSpouse:
|
||||
Called when the spouse to be added does not exist, and needs
|
||||
to be created and added to the database
|
||||
"""
|
||||
spouse = RelLib.Person()
|
||||
self.db.addPerson(spouse)
|
||||
|
||||
name = spouse.getPrimaryName()
|
||||
name.setSurname(string.strip(self.surname.get_text()))
|
||||
name.setFirstName(string.strip(self.given.get_text()))
|
||||
import QuickAdd
|
||||
|
||||
relation = const.save_frel(self.relation_type.get_text())
|
||||
if relation == "Partners":
|
||||
spouse.setGender(self.person.getGender())
|
||||
if self.person.getGender() == RelLib.Person.male:
|
||||
gen = "male"
|
||||
else:
|
||||
gen = "female"
|
||||
elif self.person.getGender() == RelLib.Person.male:
|
||||
spouse.setGender(RelLib.Person.female)
|
||||
gen = "female"
|
||||
else:
|
||||
spouse.setGender(RelLib.Person.male)
|
||||
gen = "male"
|
||||
|
||||
family = self.db.newFamily()
|
||||
family.setRelationship(relation)
|
||||
QuickAdd.QuickAdd(self.db,gen,self.update_list)
|
||||
|
||||
self.person.addFamily(family)
|
||||
spouse.addFamily(family)
|
||||
|
||||
if self.person.getGender() == RelLib.Person.male:
|
||||
family.setMother(spouse)
|
||||
family.setFather(self.person)
|
||||
else:
|
||||
family.setFather(spouse)
|
||||
family.setMother(self.person)
|
||||
|
||||
Utils.destroy_passed_object(obj)
|
||||
Utils.modified()
|
||||
self.addperson(spouse)
|
||||
self.update(family)
|
||||
def update_list(self,person):
|
||||
self.name_list.append(person)
|
||||
self.name_list.sort(sort.by_last_name)
|
||||
self.addperson(person)
|
||||
self.relation_type_changed(self.relation_type)
|
||||
|
||||
def select_spouse_clicked(self,obj):
|
||||
"""
|
||||
|
@ -70,8 +70,6 @@ class ChooseParents:
|
||||
self.fcombo = self.glade.get_widget("prel_combo")
|
||||
self.prel = self.glade.get_widget("prel")
|
||||
self.title = self.glade.get_widget("chooseTitle")
|
||||
self.father_name = self.glade.get_widget("fatherName")
|
||||
self.mother_name = self.glade.get_widget("motherName")
|
||||
self.father_list = self.glade.get_widget("fatherList")
|
||||
self.mother_list = self.glade.get_widget("motherList")
|
||||
self.flabel = self.glade.get_widget("flabel")
|
||||
@ -91,8 +89,7 @@ class ChooseParents:
|
||||
"on_motherList_select_row" : self.mother_list_select_row,
|
||||
"on_fatherList_select_row" : self.father_list_select_row,
|
||||
"on_save_parents_clicked" : self.save_parents_clicked,
|
||||
"on_addmother_clicked" : self.add_mother_clicked,
|
||||
"on_addfather_clicked" : self.add_father_clicked,
|
||||
"on_add_parent_clicked" : self.add_parent_clicked,
|
||||
"on_prel_changed" : self.parent_relation_changed,
|
||||
"on_combo_insert_text" : Utils.combo_insert_text,
|
||||
"destroy_passed_object" : Utils.destroy_passed_object
|
||||
@ -110,9 +107,6 @@ class ChooseParents:
|
||||
|
||||
type = obj.get_text()
|
||||
|
||||
self.father_name.set_text(GrampsCfg.nameof(self.father))
|
||||
self.mother_name.set_text(GrampsCfg.nameof(self.mother))
|
||||
|
||||
self.father_list.freeze()
|
||||
self.mother_list.freeze()
|
||||
self.father_list.clear()
|
||||
@ -128,11 +122,17 @@ class ChooseParents:
|
||||
people.sort(sort.by_last_name)
|
||||
father_index = 1
|
||||
mother_index = 1
|
||||
fsel = 0
|
||||
msel = 0
|
||||
for person in people:
|
||||
if person == self.person:
|
||||
continue
|
||||
if person.getGender() == RelLib.Person.unknown:
|
||||
continue
|
||||
if self.father == person:
|
||||
fsel = father_index
|
||||
if self.mother == person:
|
||||
msel = mother_index
|
||||
rdata = [Utils.phonebook_name(person),Utils.birthday(person)]
|
||||
if type == "Partners":
|
||||
self.father_list.append(rdata)
|
||||
@ -150,12 +150,17 @@ class ChooseParents:
|
||||
self.mother_list.set_row_data(mother_index,person)
|
||||
mother_index = mother_index + 1
|
||||
|
||||
self.mother_list.select_row(msel,0)
|
||||
self.mother_list.moveto(msel,0)
|
||||
self.father_list.select_row(fsel,0)
|
||||
self.father_list.moveto(fsel,0)
|
||||
|
||||
if type == "Partners":
|
||||
self.mlabel.set_text(_("Parent"))
|
||||
self.flabel.set_text(_("Parent"))
|
||||
self.mlabel.set_label(_("Parent"))
|
||||
self.flabel.set_label(_("Parent"))
|
||||
else:
|
||||
self.mlabel.set_text(_("Mother"))
|
||||
self.flabel.set_text(_("Father"))
|
||||
self.mlabel.set_label(_("Mother"))
|
||||
self.flabel.set_label(_("Father"))
|
||||
|
||||
self.mother_list.thaw()
|
||||
self.father_list.thaw()
|
||||
@ -188,17 +193,18 @@ class ChooseParents:
|
||||
|
||||
def mother_list_select_row(self,obj,a,b,c):
|
||||
self.mother = obj.get_row_data(a)
|
||||
self.mother_name.set_text(GrampsCfg.nameof(self.mother))
|
||||
|
||||
def father_list_select_row(self,obj,a,b,c):
|
||||
self.father = obj.get_row_data(a)
|
||||
self.father_name.set_text(GrampsCfg.nameof(self.father))
|
||||
|
||||
def save_parents_clicked(self,obj):
|
||||
mother_rel = const.childRelations[self.mother_rel.get_text()]
|
||||
father_rel = const.childRelations[self.father_rel.get_text()]
|
||||
type = const.save_frel(self.prel.get_text())
|
||||
|
||||
msel = self.mother_list.selection
|
||||
fsel = self.father_list.selection
|
||||
|
||||
if self.father or self.mother:
|
||||
if self.mother and not self.father:
|
||||
if self.mother.getGender() == RelLib.Person.male:
|
||||
@ -230,25 +236,13 @@ class ChooseParents:
|
||||
self.change_family_type(self.family,mother_rel,father_rel)
|
||||
self.family_update(None)
|
||||
|
||||
def add_parent_clicked(self,obj,sex):
|
||||
self.xml = libglade.GladeXML(const.gladeFile,"addperson")
|
||||
self.xml.get_widget(sex).set_active(1)
|
||||
self.xml.signal_autoconnect({
|
||||
"on_addfather_close": self.add_parent_close,
|
||||
"on_combo_insert_text" : Utils.combo_insert_text,
|
||||
"destroy_passed_object" : Utils.destroy_passed_object
|
||||
})
|
||||
|
||||
window = self.xml.get_widget("addperson")
|
||||
window.editable_enters(self.xml.get_widget("given"))
|
||||
window.editable_enters(self.xml.get_widget("surname"))
|
||||
Utils.attach_surnames(self.xml.get_widget("surnameCombo"))
|
||||
|
||||
def add_father_clicked(self,obj):
|
||||
self.add_parent_clicked(obj,"male")
|
||||
|
||||
def add_mother_clicked(self,obj):
|
||||
self.add_parent_clicked(obj,"female")
|
||||
def add_new_parent(self,person):
|
||||
self.parent_relation_changed(self.prel)
|
||||
self.full_update()
|
||||
|
||||
def add_parent_clicked(self,obj):
|
||||
import QuickAdd
|
||||
QuickAdd.QuickAdd(self.db,"male",self.add_new_parent)
|
||||
|
||||
def change_family_type(self,family,mother_rel,father_rel):
|
||||
"""
|
||||
|
62
gramps/src/QuickAdd.py
Normal file
62
gramps/src/QuickAdd.py
Normal file
@ -0,0 +1,62 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
import libglade
|
||||
|
||||
import Utils
|
||||
import AutoComp
|
||||
import const
|
||||
import RelLib
|
||||
|
||||
class QuickAdd:
|
||||
def __init__(self,db,sex,callback):
|
||||
self.db = db
|
||||
self.callback = callback
|
||||
|
||||
self.xml = libglade.GladeXML(const.gladeFile,"addperson")
|
||||
self.xml.get_widget(sex).set_active(1)
|
||||
self.xml.signal_autoconnect({
|
||||
"on_addfather_close": self.close,
|
||||
"destroy_passed_object" : Utils.destroy_passed_object
|
||||
})
|
||||
|
||||
self.window = self.xml.get_widget("addperson")
|
||||
self.window.editable_enters(self.xml.get_widget("given"))
|
||||
self.window.editable_enters(self.xml.get_widget("surname"))
|
||||
self.c = AutoComp.AutoCombo(self.xml.get_widget("surnameCombo"),
|
||||
const.surnames)
|
||||
|
||||
def close(self,obj):
|
||||
surname = self.xml.get_widget("surname").get_text()
|
||||
given = self.xml.get_widget("given").get_text()
|
||||
person = RelLib.Person()
|
||||
self.db.addPerson(person)
|
||||
name = person.getPrimaryName()
|
||||
name.setSurname(surname)
|
||||
name.setFirstName(given)
|
||||
if self.xml.get_widget("male").get_active():
|
||||
person.setGender(RelLib.Person.male)
|
||||
self.father = person
|
||||
else:
|
||||
person.setGender(RelLib.Person.female)
|
||||
self.mother = person
|
||||
Utils.modified()
|
||||
Utils.destroy_passed_object(self.window)
|
||||
self.callback(person)
|
File diff suppressed because it is too large
Load Diff
@ -89,6 +89,7 @@ class Gramps:
|
||||
self.active_mother = None
|
||||
self.active_parents = None
|
||||
self.parents_index = 0
|
||||
self.spouse_index = 0
|
||||
self.active_person = None
|
||||
self.active_spouse = None
|
||||
self.bookmarks = None
|
||||
@ -176,7 +177,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.pref_spouse = self.gtop.get_widget("pref_spouse")
|
||||
self.multi_spouse= self.gtop.get_widget("multi_spouse")
|
||||
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")
|
||||
@ -211,9 +213,11 @@ 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_preffam_clicked" : self.on_preferred_fam_toggled,
|
||||
"on_family_up_clicked" : self.family_up_clicked,
|
||||
"on_family_down_clicked" : self.family_down_clicked,
|
||||
"on_spouse_up_clicked" : self.spouse_up_clicked,
|
||||
"on_spouse_down_clicked" : self.spouse_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,
|
||||
@ -285,7 +289,6 @@ class Gramps:
|
||||
"on_show_plugin_status" : self.on_show_plugin_status,
|
||||
"on_source_list_button_press_event" : self.source_view.on_button_press_event,
|
||||
"on_sources_activate" : self.on_sources_activate,
|
||||
"on_spouselist_changed" : self.on_spouselist_changed,
|
||||
"on_swap_clicked" : self.on_swap_clicked,
|
||||
"on_tools_clicked" : self.on_tools_clicked,
|
||||
"on_gramps_home_page_activate" : self.on_gramps_home_page_activate,
|
||||
@ -1300,18 +1303,12 @@ class Gramps:
|
||||
filter.hide()
|
||||
filter.set_sensitive(obj.get_data("qual"))
|
||||
|
||||
def on_spouselist_changed(self,obj):
|
||||
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)
|
||||
self.load_family(self.active_family)
|
||||
Utils.modified()
|
||||
|
||||
def on_preferred_fam_toggled(self,obj):
|
||||
obj.set_active(0)
|
||||
self.active_person.setMainParents(self.active_parents)
|
||||
self.change_parents(self.active_parents)
|
||||
Utils.modified()
|
||||
@ -1389,7 +1386,6 @@ class Gramps:
|
||||
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:
|
||||
@ -1397,6 +1393,8 @@ class Gramps:
|
||||
else:
|
||||
self.active_family = None
|
||||
|
||||
self.spouse_index = 0
|
||||
|
||||
family_types = []
|
||||
|
||||
main_family = None
|
||||
@ -1425,35 +1423,37 @@ class Gramps:
|
||||
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 flist:
|
||||
person = None
|
||||
if f.getMother() == self.active_person:
|
||||
if f.getFather() != None:
|
||||
person = f.getFather()
|
||||
else:
|
||||
if f.getMother() != None:
|
||||
person = f.getMother()
|
||||
if self.active_family == None:
|
||||
self.active_family = flist[0]
|
||||
else:
|
||||
for f in flist:
|
||||
if f == self.active_family:
|
||||
break
|
||||
self.spouse_index = self.spouse_index + 1
|
||||
|
||||
menuitem = gtk.GtkMenuItem(GrampsCfg.nameof(person))
|
||||
myMenu.append(menuitem)
|
||||
menuitem.set_data("person",person)
|
||||
menuitem.set_data("family",f)
|
||||
menuitem.connect("activate",self.on_spouselist_changed)
|
||||
menuitem.show()
|
||||
if family and f == family:
|
||||
opt_index = index
|
||||
index = index + 1
|
||||
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.pref_spouse.show()
|
||||
self.multi_spouse.show()
|
||||
if self.active_family == flist[0]:
|
||||
self.pref_spouse.set_sensitive(0)
|
||||
msg = _("Preferred Relationship (%d of %d)") % (self.spouse_index+1,
|
||||
len(flist))
|
||||
else:
|
||||
msg = _("Relationship (%d of %d)") % (self.spouse_index+1,
|
||||
len(flist))
|
||||
self.pref_spouse.set_sensitive(1)
|
||||
|
||||
self.gtop.get_widget('rel_frame').set_label(msg)
|
||||
if self.active_person != self.active_family.getFather():
|
||||
spouse = self.active_family.getFather()
|
||||
else:
|
||||
spouse = self.active_family.getMother()
|
||||
|
||||
self.spouse_text.set_text(GrampsCfg.nameof(spouse))
|
||||
self.spouse_edit.set_sensitive(1)
|
||||
self.spouse_del.set_sensitive(1)
|
||||
elif number_of_families == 1:
|
||||
self.spouse_tab.set_page(0)
|
||||
self.pref_spouse.hide()
|
||||
self.multi_spouse.hide()
|
||||
f = self.active_person.getFamilyList()[0]
|
||||
if self.active_person != f.getFather():
|
||||
spouse = f.getFather()
|
||||
@ -1461,18 +1461,17 @@ class Gramps:
|
||||
spouse = f.getMother()
|
||||
self.active_spouse = spouse
|
||||
self.spouse_text.set_text(GrampsCfg.nameof(spouse))
|
||||
self.spouse_text.set_data("person",spouse)
|
||||
self.spouse_text.set_data("family",self.active_person.getFamilyList()[0])
|
||||
self.spouse_edit.set_sensitive(1)
|
||||
self.spouse_del.set_sensitive(1)
|
||||
self.gtop.get_widget('rel_frame').set_label(_("Relationship"))
|
||||
else:
|
||||
self.spouse_tab.set_page(0)
|
||||
self.pref_spouse.hide()
|
||||
self.multi_spouse.hide()
|
||||
self.spouse_text.set_text("")
|
||||
self.spouse_text.set_data("person",None)
|
||||
self.spouse_text.set_data("family",None)
|
||||
self.active_spouse = None
|
||||
self.spouse_edit.set_sensitive(0)
|
||||
self.spouse_del.set_sensitive(0)
|
||||
self.gtop.get_widget('rel_frame').set_label(_("No Relationship"))
|
||||
|
||||
if number_of_families > 0:
|
||||
if family:
|
||||
@ -1577,15 +1576,6 @@ class Gramps:
|
||||
|
||||
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:
|
||||
@ -1855,6 +1845,28 @@ class Gramps:
|
||||
self.active_parents = flist[self.parents_index][0]
|
||||
self.change_parents(self.active_parents)
|
||||
|
||||
def spouse_up_clicked(self,obj):
|
||||
if self.active_family == None:
|
||||
return
|
||||
flist = self.active_person.getFamilyList()
|
||||
if self.spouse_index == 0:
|
||||
self.spouse_index = len(flist)-1
|
||||
else:
|
||||
self.spouse_index = self.spouse_index - 1
|
||||
self.active_family = flist[self.spouse_index]
|
||||
self.load_family()
|
||||
|
||||
def spouse_down_clicked(self,obj):
|
||||
if self.active_family == None:
|
||||
return
|
||||
flist = self.active_person.getFamilyList()
|
||||
if self.spouse_index == len(flist)-1:
|
||||
self.spouse_index = 0
|
||||
else:
|
||||
self.spouse_index = self.spouse_index + 1
|
||||
self.active_family = flist[self.spouse_index]
|
||||
self.load_family()
|
||||
|
||||
def export_callback(self,obj,plugin_function):
|
||||
"""Call the export plugin, with the active person and database"""
|
||||
if self.active_person:
|
||||
|
Loading…
Reference in New Issue
Block a user