2003-08-15 04:03:30 +05:30
|
|
|
|
# -*- coding: utf-8 -*-
|
2002-10-20 19:55:16 +05:30
|
|
|
|
#
|
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
|
#
|
2004-02-15 12:51:29 +05:30
|
|
|
|
# Copyright (C) 2000-2004 Donald N. Allingham
|
2002-10-20 19:55:16 +05:30
|
|
|
|
#
|
|
|
|
|
# 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
|
|
|
|
|
#
|
|
|
|
|
|
2003-11-18 09:56:06 +05:30
|
|
|
|
# $Id$
|
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# internationalization
|
|
|
|
|
#
|
|
|
|
|
#-------------------------------------------------------------------------
|
2003-08-17 07:44:33 +05:30
|
|
|
|
from gettext import gettext as _
|
2002-11-03 02:49:58 +05:30
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# GTK/Gnome modules
|
|
|
|
|
#
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
import gtk.glade
|
2003-11-18 09:56:06 +05:30
|
|
|
|
import gnome
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# gramps modules
|
|
|
|
|
#
|
|
|
|
|
#-------------------------------------------------------------------------
|
2003-01-10 10:51:32 +05:30
|
|
|
|
import RelLib
|
2002-10-20 19:55:16 +05:30
|
|
|
|
import const
|
|
|
|
|
import Utils
|
2004-03-23 10:31:19 +05:30
|
|
|
|
import PeopleModel
|
2005-01-01 09:57:15 +05:30
|
|
|
|
import NameDisplay
|
|
|
|
|
|
2004-04-21 09:52:37 +05:30
|
|
|
|
from QuestionDialog import ErrorDialog
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# SelectChild
|
|
|
|
|
#
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
class SelectChild:
|
|
|
|
|
|
2004-02-25 10:04:20 +05:30
|
|
|
|
def __init__(self,parent,db,family,person,redraw,add_person):
|
|
|
|
|
self.parent = parent
|
2002-10-20 19:55:16 +05:30
|
|
|
|
self.db = db
|
|
|
|
|
self.person = person
|
|
|
|
|
self.family = family
|
|
|
|
|
self.redraw = redraw
|
2002-11-15 09:19:39 +05:30
|
|
|
|
self.add_person = add_person
|
2004-03-23 10:31:19 +05:30
|
|
|
|
self.renderer = gtk.CellRendererText()
|
2003-08-17 07:44:33 +05:30
|
|
|
|
self.xml = gtk.glade.XML(const.gladeFile,"select_child","gramps")
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
2003-05-18 09:48:12 +05:30
|
|
|
|
if person:
|
2004-02-14 11:10:30 +05:30
|
|
|
|
self.default_name = person.get_primary_name().get_surname().upper()
|
2003-05-18 09:48:12 +05:30
|
|
|
|
else:
|
|
|
|
|
self.default_name = ""
|
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
|
self.xml.signal_autoconnect({
|
|
|
|
|
"on_save_child_clicked" : self.on_save_child_clicked,
|
2003-11-18 09:56:06 +05:30
|
|
|
|
"on_child_help_clicked" : self.on_child_help_clicked,
|
2002-10-20 19:55:16 +05:30
|
|
|
|
"on_show_toggled" : self.on_show_toggled,
|
2004-02-25 10:04:20 +05:30
|
|
|
|
"destroy_passed_object" : self.close,
|
|
|
|
|
"on_select_child_delete_event" : self.on_delete_event,
|
2002-10-20 19:55:16 +05:30
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
self.select_child_list = {}
|
2003-03-05 11:31:31 +05:30
|
|
|
|
self.top = self.xml.get_widget("select_child")
|
|
|
|
|
title_label = self.xml.get_widget('title')
|
2003-03-06 11:42:51 +05:30
|
|
|
|
|
2003-06-15 09:43:16 +05:30
|
|
|
|
Utils.set_titles(self.top,title_label,_('Add Child to Family'))
|
2003-03-05 11:31:31 +05:30
|
|
|
|
|
2002-11-03 02:49:58 +05:30
|
|
|
|
self.add_child = self.xml.get_widget("childlist")
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
2005-03-03 02:18:58 +05:30
|
|
|
|
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:
|
2004-08-07 10:46:57 +05:30
|
|
|
|
father = self.db.get_person_from_handle(self.family.get_father_handle())
|
|
|
|
|
mother = self.db.get_person_from_handle(self.family.get_mother_handle())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
else:
|
2005-02-01 09:16:29 +05:30
|
|
|
|
if self.person.get_gender() == RelLib.Person.MALE:
|
2005-03-03 02:18:58 +05:30
|
|
|
|
self.mrel.set_sensitive(False)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
else:
|
2005-03-03 02:18:58 +05:30
|
|
|
|
self.frel.set_sensitive(False)
|
2002-11-03 02:49:58 +05:30
|
|
|
|
|
2004-03-23 10:31:19 +05:30
|
|
|
|
self.refmodel = PeopleModel.PeopleModel(self.db)
|
2004-06-03 08:58:46 +05:30
|
|
|
|
|
|
|
|
|
self.add_child.set_model(self.refmodel)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
self.redraw_child_list(2)
|
2004-02-25 10:04:20 +05:30
|
|
|
|
self.add_itself_to_menu()
|
2004-03-23 10:31:19 +05:30
|
|
|
|
self.add_columns(self.add_child)
|
2004-02-25 10:04:20 +05:30
|
|
|
|
self.top.show()
|
|
|
|
|
|
2005-03-03 02:18:58 +05:30
|
|
|
|
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)
|
|
|
|
|
|
2004-03-23 10:31:19 +05:30
|
|
|
|
def add_columns(self,tree):
|
|
|
|
|
column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0)
|
2005-02-24 05:55:34 +05:30
|
|
|
|
column.set_resizable(True)
|
|
|
|
|
#column.set_clickable(True)
|
2004-03-23 10:31:19 +05:30
|
|
|
|
column.set_min_width(225)
|
|
|
|
|
tree.append_column(column)
|
|
|
|
|
column = gtk.TreeViewColumn(_('ID'), self.renderer,text=1)
|
2005-02-24 05:55:34 +05:30
|
|
|
|
column.set_resizable(True)
|
|
|
|
|
#column.set_clickable(True)
|
2004-03-23 10:31:19 +05:30
|
|
|
|
column.set_min_width(75)
|
|
|
|
|
tree.append_column(column)
|
|
|
|
|
column = gtk.TreeViewColumn(_('Birth date'), self.renderer,text=3)
|
2005-02-24 05:55:34 +05:30
|
|
|
|
#column.set_resizable(True)
|
|
|
|
|
column.set_clickable(True)
|
2004-03-23 10:31:19 +05:30
|
|
|
|
tree.append_column(column)
|
|
|
|
|
|
2004-02-25 10:04:20 +05:30
|
|
|
|
def on_delete_event(self,obj,b):
|
|
|
|
|
self.remove_itself_from_menu()
|
|
|
|
|
|
|
|
|
|
def close(self,obj):
|
|
|
|
|
self.remove_itself_from_menu()
|
|
|
|
|
self.top.destroy()
|
|
|
|
|
|
|
|
|
|
def add_itself_to_menu(self):
|
|
|
|
|
self.parent.child_windows[self] = self
|
|
|
|
|
self.parent_menu_item = gtk.MenuItem(_('Add Child to Family'))
|
|
|
|
|
self.parent_menu_item.connect("activate",self.present)
|
|
|
|
|
self.parent_menu_item.show()
|
|
|
|
|
self.parent.winsmenu.append(self.parent_menu_item)
|
|
|
|
|
|
|
|
|
|
def remove_itself_from_menu(self):
|
|
|
|
|
del self.parent.child_windows[self]
|
|
|
|
|
self.parent_menu_item.destroy()
|
|
|
|
|
|
|
|
|
|
def present(self,obj):
|
|
|
|
|
self.top.present()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
2003-11-18 09:56:06 +05:30
|
|
|
|
def on_child_help_clicked(self,obj):
|
|
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
2003-12-02 09:57:23 +05:30
|
|
|
|
gnome.help_display('gramps-manual','gramps-edit-quick')
|
2003-11-18 09:56:06 +05:30
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
|
def redraw_child_list(self,filter):
|
2004-03-23 10:31:19 +05:30
|
|
|
|
return
|
|
|
|
|
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
|
birth = self.db.get_event_from_handle(self.person.get_birth_handle())
|
|
|
|
|
death = self.db.get_event_from_handle(self.person.get_death_handle())
|
2004-02-25 10:04:20 +05:30
|
|
|
|
if birth:
|
|
|
|
|
bday = birth.get_date_object()
|
|
|
|
|
else:
|
|
|
|
|
bday = None
|
|
|
|
|
if death:
|
|
|
|
|
dday = death.get_date_object()
|
|
|
|
|
else:
|
|
|
|
|
dday = None
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
2002-11-08 09:12:25 +05:30
|
|
|
|
slist = {}
|
2004-07-28 07:59:07 +05:30
|
|
|
|
for f in self.person.get_parent_family_handle_list():
|
2002-10-20 19:55:16 +05:30
|
|
|
|
if f:
|
2004-08-20 03:05:16 +05:30
|
|
|
|
family = self.db.get_family_from_handle(f[0])
|
2004-07-28 07:59:07 +05:30
|
|
|
|
if family.get_father_handle():
|
|
|
|
|
slist[family.get_father_handle()] = 1
|
|
|
|
|
elif family.get_mother_handle():
|
|
|
|
|
slist[family.get_mother_handle()] = 1
|
|
|
|
|
for c in family.get_child_handle_list():
|
2004-02-16 04:40:12 +05:30
|
|
|
|
slist[c] = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
|
|
person_list = []
|
2004-08-13 10:04:07 +05:30
|
|
|
|
for key in self.db.get_person_handles(sort_handles=True):
|
2004-08-07 10:46:57 +05:30
|
|
|
|
person = self.db.get_person_from_handle(key)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
if filter:
|
2004-07-28 07:59:07 +05:30
|
|
|
|
if slist.has_key(key) or person.get_main_parents_family_handle():
|
2002-10-20 19:55:16 +05:30
|
|
|
|
continue
|
|
|
|
|
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
|
birth_event = self.db.get_event_from_handle(person.get_birth_handle())
|
2004-02-25 10:04:20 +05:30
|
|
|
|
if birth_event:
|
|
|
|
|
pbday = birth_event.get_date_object()
|
|
|
|
|
else:
|
|
|
|
|
pbday = None
|
|
|
|
|
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
|
death_event = self.db.get_event_from_handle(person.get_death_handle())
|
2004-02-25 10:04:20 +05:30
|
|
|
|
if death_event:
|
|
|
|
|
pdday = death_event.get_date_object()
|
|
|
|
|
else:
|
|
|
|
|
pdday = None
|
|
|
|
|
|
|
|
|
|
if bday and bday.getYearValid():
|
|
|
|
|
if pbday and pbday.getYearValid():
|
2002-10-20 19:55:16 +05:30
|
|
|
|
# reject if child birthdate < parents birthdate + 10
|
|
|
|
|
if pbday.getLowYear() < bday.getHighYear()+10:
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
# reject if child birthdate > parents birthdate + 90
|
|
|
|
|
if pbday.getLowYear() > bday.getHighYear()+90:
|
|
|
|
|
continue
|
|
|
|
|
|
2004-02-25 10:04:20 +05:30
|
|
|
|
if pdday and pdday.getYearValid():
|
2002-10-20 19:55:16 +05:30
|
|
|
|
# reject if child deathdate < parents birthdate+ 10
|
|
|
|
|
if pdday.getLowYear() < bday.getHighYear()+10:
|
|
|
|
|
continue
|
|
|
|
|
|
2004-02-25 10:04:20 +05:30
|
|
|
|
if dday and dday.getYearValid():
|
|
|
|
|
if pbday and pbday.getYearValid():
|
2002-10-20 19:55:16 +05:30
|
|
|
|
# reject if childs birth date > parents deathday + 3
|
|
|
|
|
if pbday.getLowYear() > dday.getHighYear()+3:
|
|
|
|
|
continue
|
|
|
|
|
|
2004-02-25 10:04:20 +05:30
|
|
|
|
if pdday and pdday.getYearValid():
|
2002-10-20 19:55:16 +05:30
|
|
|
|
# reject if childs death date > parents deathday + 150
|
|
|
|
|
if pdday.getLowYear() > dday.getHighYear() + 150:
|
|
|
|
|
continue
|
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
|
person_list.append(person.get_handle())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
2004-08-23 04:46:57 +05:30
|
|
|
|
node = None
|
2002-11-08 09:12:25 +05:30
|
|
|
|
for idval in person_list:
|
2004-12-29 10:36:10 +05:30
|
|
|
|
person = self.db.get_person_from_handle(idval)
|
2005-01-01 09:57:15 +05:30
|
|
|
|
name = NameDisplay.displayer.display(person)
|
2005-02-01 09:16:29 +05:30
|
|
|
|
if person.gender == RelLib.Person.MALE:
|
2004-12-29 10:36:10 +05:30
|
|
|
|
gender = _("male")
|
2005-02-01 09:16:29 +05:30
|
|
|
|
elif person.gender == RelLib.Person.FEMALE:
|
2004-12-29 10:36:10 +05:30
|
|
|
|
gender = _("female")
|
|
|
|
|
else:
|
|
|
|
|
gender = _("unknown")
|
|
|
|
|
|
|
|
|
|
bh = person.get_birth_handle()
|
|
|
|
|
dh = person.get_death_handle()
|
|
|
|
|
if bh:
|
|
|
|
|
bdate = self.db.get_event_from_handle(bh).get_date()
|
|
|
|
|
else:
|
|
|
|
|
bdate = ""
|
|
|
|
|
if dh:
|
|
|
|
|
ddate = self.db.get_event_from_handle(bh).get_date()
|
|
|
|
|
else:
|
|
|
|
|
ddate = ""
|
|
|
|
|
|
|
|
|
|
rdata = [name,person.get_gramps_id(),gender,bdate,ddate]
|
2005-01-09 07:48:49 +05:30
|
|
|
|
node = self.refmodel.add(rdata)
|
2003-05-18 09:48:12 +05:30
|
|
|
|
|
2003-05-22 02:38:20 +05:30
|
|
|
|
self.refmodel.connect_model()
|
|
|
|
|
|
2004-08-23 04:46:57 +05:30
|
|
|
|
if node:
|
|
|
|
|
self.refmodel.selection.select_iter(node)
|
|
|
|
|
path = self.refmodel.model.get_path(node)
|
2003-05-18 09:48:12 +05:30
|
|
|
|
col = self.add_child.get_column(0)
|
|
|
|
|
self.add_child.scroll_to_cell(path,col,1,0.5,0.0)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
2004-08-23 04:46:57 +05:30
|
|
|
|
def select_function(self,store,path,node,id_list):
|
|
|
|
|
id_list.append(self.refmodel.get_value(node,PeopleModel.COLUMN_INT_ID))
|
2004-03-23 10:31:19 +05:30
|
|
|
|
|
|
|
|
|
def get_selected_ids(self):
|
|
|
|
|
mlist = []
|
|
|
|
|
self.add_child.get_selection().selected_foreach(self.select_function,mlist)
|
|
|
|
|
return mlist
|
2003-05-22 02:38:20 +05:30
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
|
def on_save_child_clicked(self,obj):
|
|
|
|
|
|
2004-03-23 10:31:19 +05:30
|
|
|
|
idlist = self.get_selected_ids()
|
|
|
|
|
|
|
|
|
|
if not idlist or not idlist[0]:
|
2002-11-03 02:49:58 +05:30
|
|
|
|
return
|
|
|
|
|
|
2004-10-06 09:12:54 +05:30
|
|
|
|
handle = idlist[0]
|
|
|
|
|
select_child = self.db.get_person_from_handle(handle)
|
|
|
|
|
if self.person.get_handle() == handle:
|
2004-04-22 07:18:47 +05:30
|
|
|
|
ErrorDialog(_("Error selecting a child"),
|
|
|
|
|
_("A person cannot be linked as his/her own child"),
|
|
|
|
|
self.top)
|
|
|
|
|
return
|
2004-08-13 10:04:07 +05:30
|
|
|
|
|
|
|
|
|
trans = self.db.transaction_begin()
|
2004-04-22 07:18:47 +05:30
|
|
|
|
|
2002-11-03 02:49:58 +05:30
|
|
|
|
if self.family == None:
|
2004-08-13 10:04:07 +05:30
|
|
|
|
self.family = RelLib.Family()
|
|
|
|
|
self.db.add_family(self.family,trans)
|
2004-07-28 07:59:07 +05:30
|
|
|
|
self.person.add_family_handle(self.family.get_handle())
|
2005-02-01 09:16:29 +05:30
|
|
|
|
if self.person.get_gender() == RelLib.Person.MALE:
|
2004-07-28 07:59:07 +05:30
|
|
|
|
self.family.set_father_handle(self.person)
|
2002-11-03 02:49:58 +05:30
|
|
|
|
else:
|
2004-07-28 07:59:07 +05:30
|
|
|
|
self.family.set_mother_handle(self.person)
|
2002-11-03 02:49:58 +05:30
|
|
|
|
|
2004-10-06 09:12:54 +05:30
|
|
|
|
if handle in (self.family.get_father_handle(),self.family.get_mother_handle()):
|
2004-04-22 07:18:47 +05:30
|
|
|
|
ErrorDialog(_("Error selecting a child"),
|
|
|
|
|
_("A person cannot be linked as his/her own child"),
|
|
|
|
|
self.top)
|
|
|
|
|
return
|
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
|
self.family.add_child_handle(select_child.get_handle())
|
2004-04-22 07:18:47 +05:30
|
|
|
|
|
2005-03-03 02:18:58 +05:30
|
|
|
|
mrel = self.keys[self.mrel.get_active()]
|
2004-08-07 10:46:57 +05:30
|
|
|
|
mother = self.db.get_person_from_handle(self.family.get_mother_handle())
|
2005-02-01 09:16:29 +05:30
|
|
|
|
if mother and mother.get_gender() != RelLib.Person.FEMALE:
|
2002-11-03 02:49:58 +05:30
|
|
|
|
if mrel == "Birth":
|
|
|
|
|
mrel = "Unknown"
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
2005-03-03 02:18:58 +05:30
|
|
|
|
frel = self.keys[self.frel.get_active()]
|
2004-08-07 10:46:57 +05:30
|
|
|
|
father = self.db.get_person_from_handle(self.family.get_father_handle())
|
2005-02-01 09:16:29 +05:30
|
|
|
|
if father and father.get_gender() !=RelLib.Person.MALE:
|
2002-11-03 02:49:58 +05:30
|
|
|
|
if frel == "Birth":
|
|
|
|
|
frel = "Unknown"
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
|
select_child.add_parent_family_handle(self.family.get_handle(),mrel,frel)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
2004-03-30 10:20:24 +05:30
|
|
|
|
self.db.commit_person(select_child,trans)
|
2004-05-19 11:43:36 +05:30
|
|
|
|
self.db.commit_family(self.family,trans)
|
|
|
|
|
n = select_child.get_primary_name().get_regular_name()
|
2004-08-13 10:04:07 +05:30
|
|
|
|
self.db.transaction_commit(trans,_("Add Child to Family (%s)") % n)
|
2004-05-19 11:43:36 +05:30
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
|
self.redraw(self.family)
|
2004-02-25 10:04:20 +05:30
|
|
|
|
self.close(obj)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
|
|
def on_show_toggled(self,obj):
|
2003-03-03 10:02:53 +05:30
|
|
|
|
self.redraw_child_list(not obj.get_active())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
2003-05-18 09:48:12 +05:30
|
|
|
|
def north_american(self,val):
|
2005-02-01 09:16:29 +05:30
|
|
|
|
if self.person.get_gender() == RelLib.Person.MALE:
|
2004-02-14 11:10:30 +05:30
|
|
|
|
return self.person.get_primary_name().get_surname()
|
2003-05-18 09:48:12 +05:30
|
|
|
|
elif self.family:
|
2004-07-28 07:59:07 +05:30
|
|
|
|
f = self.family.get_father_handle()
|
2003-05-18 09:48:12 +05:30
|
|
|
|
if f:
|
2004-02-14 11:10:30 +05:30
|
|
|
|
pname = f.get_primary_name()
|
|
|
|
|
return (pname.get_surname_prefix(),pname.get_surname())
|
2003-10-06 09:59:50 +05:30
|
|
|
|
return ("","")
|
2003-05-18 09:48:12 +05:30
|
|
|
|
|
|
|
|
|
def no_name(self,val):
|
2003-10-06 09:59:50 +05:30
|
|
|
|
return ("","")
|
2003-05-18 09:48:12 +05:30
|
|
|
|
|
|
|
|
|
def latin_american(self,val):
|
|
|
|
|
if self.family:
|
2004-07-28 07:59:07 +05:30
|
|
|
|
father = self.family.get_father_handle()
|
|
|
|
|
mother = self.family.get_mother_handle()
|
2003-05-18 09:48:12 +05:30
|
|
|
|
if not father or not mother:
|
2003-10-06 09:59:50 +05:30
|
|
|
|
return ("","")
|
2004-02-14 11:10:30 +05:30
|
|
|
|
fsn = father.get_primary_name().get_surname()
|
|
|
|
|
msn = mother.get_primary_name().get_surname()
|
2003-05-18 09:48:12 +05:30
|
|
|
|
if not father or not mother:
|
2003-10-06 09:59:50 +05:30
|
|
|
|
return ("","")
|
2003-05-18 09:48:12 +05:30
|
|
|
|
try:
|
2003-10-06 09:59:50 +05:30
|
|
|
|
return ("","%s %s" % (fsn.split()[0],msn.split()[0]))
|
2003-05-18 09:48:12 +05:30
|
|
|
|
except:
|
2003-10-06 09:59:50 +05:30
|
|
|
|
return ("","")
|
2003-05-18 09:48:12 +05:30
|
|
|
|
else:
|
2003-10-06 09:59:50 +05:30
|
|
|
|
return ("","")
|
2003-05-18 09:48:12 +05:30
|
|
|
|
|
|
|
|
|
def icelandic(self,val):
|
|
|
|
|
fname = ""
|
2005-02-01 09:16:29 +05:30
|
|
|
|
if self.person.get_gender() == RelLib.Person.MALE:
|
2004-02-14 11:10:30 +05:30
|
|
|
|
fname = self.person.get_primary_name().get_first_name()
|
2003-05-18 09:48:12 +05:30
|
|
|
|
elif self.family:
|
2004-07-28 07:59:07 +05:30
|
|
|
|
f = self.family.get_father_handle()
|
2003-05-18 09:48:12 +05:30
|
|
|
|
if f:
|
2004-02-14 11:10:30 +05:30
|
|
|
|
fname = f.get_primary_name().get_first_name()
|
2003-05-18 09:48:12 +05:30
|
|
|
|
if fname:
|
2003-10-30 09:47:05 +05:30
|
|
|
|
fname = fname.split()[0]
|
2003-05-18 09:48:12 +05:30
|
|
|
|
if val == 0:
|
2003-10-06 09:59:50 +05:30
|
|
|
|
return ("","%ssson" % fname)
|
2003-05-18 09:48:12 +05:30
|
|
|
|
elif val == 1:
|
2003-10-06 09:59:50 +05:30
|
|
|
|
return ("","%sd<EFBFBD>ttir" % fname)
|
2003-05-18 09:48:12 +05:30
|
|
|
|
else:
|
2003-10-06 09:59:50 +05:30
|
|
|
|
return ("","")
|
2003-06-17 09:45:58 +05:30
|
|
|
|
|
|
|
|
|
class EditRel:
|
|
|
|
|
|
2004-02-16 04:40:12 +05:30
|
|
|
|
def __init__(self,db,child,family,update):
|
|
|
|
|
self.db = db
|
2003-06-17 09:45:58 +05:30
|
|
|
|
self.update = update
|
|
|
|
|
self.child = child
|
|
|
|
|
self.family = family
|
|
|
|
|
|
2003-08-17 07:44:33 +05:30
|
|
|
|
self.xml = gtk.glade.XML(const.gladeFile,"editrel","gramps")
|
2003-06-17 09:45:58 +05:30
|
|
|
|
self.top = self.xml.get_widget('editrel')
|
|
|
|
|
self.mdesc = self.xml.get_widget('mrel_desc')
|
|
|
|
|
self.fdesc = self.xml.get_widget('frel_desc')
|
|
|
|
|
self.mentry = self.xml.get_widget('mrel')
|
|
|
|
|
self.fentry = self.xml.get_widget('frel')
|
|
|
|
|
self.mcombo = self.xml.get_widget('mrel_combo')
|
|
|
|
|
self.fcombo = self.xml.get_widget('frel_combo')
|
|
|
|
|
|
2005-01-01 09:57:15 +05:30
|
|
|
|
name = NameDisplay.displayer.display(child)
|
2003-06-17 09:45:58 +05:30
|
|
|
|
Utils.set_titles(self.top,self.xml.get_widget('title'),
|
|
|
|
|
_('Relationships of %s') % name)
|
|
|
|
|
|
2004-08-07 10:46:57 +05:30
|
|
|
|
father = self.db.get_person_from_handle(self.family.get_father_handle())
|
|
|
|
|
mother = self.db.get_person_from_handle(self.family.get_mother_handle())
|
2003-06-17 09:45:58 +05:30
|
|
|
|
|
|
|
|
|
if father:
|
2005-01-01 09:57:15 +05:30
|
|
|
|
fname = NameDisplay.displayer.display(father)
|
2003-07-23 11:19:02 +05:30
|
|
|
|
val = _("Relationship to %(father)s") % {
|
2003-07-09 10:37:26 +05:30
|
|
|
|
'father' : fname }
|
2003-06-17 09:45:58 +05:30
|
|
|
|
self.fdesc.set_text('<b>%s</b>' % val)
|
|
|
|
|
self.fcombo.set_sensitive(1)
|
|
|
|
|
else:
|
|
|
|
|
val = _("Relationship to father")
|
|
|
|
|
self.fdesc.set_text('<b>%s</b>' % val)
|
|
|
|
|
self.fcombo.set_sensitive(0)
|
|
|
|
|
|
|
|
|
|
if mother:
|
2005-01-01 09:57:15 +05:30
|
|
|
|
mname = NameDisplay.displayer.display(mother)
|
2003-07-23 11:19:02 +05:30
|
|
|
|
val = _("Relationship to %(mother)s") % {
|
2003-07-09 10:37:26 +05:30
|
|
|
|
'mother' : mname }
|
2003-06-17 09:45:58 +05:30
|
|
|
|
self.mdesc.set_text('<b>%s</b>' % val)
|
|
|
|
|
self.mcombo.set_sensitive(1)
|
|
|
|
|
else:
|
|
|
|
|
val = _("Relationship to mother")
|
|
|
|
|
self.mdesc.set_text('<b>%s</b>' % val)
|
|
|
|
|
self.mcombo.set_sensitive(0)
|
|
|
|
|
|
|
|
|
|
self.xml.signal_autoconnect({
|
|
|
|
|
"on_ok_clicked" : self.on_ok_clicked,
|
|
|
|
|
"destroy_passed_object" : self.close
|
|
|
|
|
})
|
|
|
|
|
|
2004-12-25 00:16:34 +05:30
|
|
|
|
f = self.child.get_parent_family(self.family.get_handle())
|
2004-06-27 08:40:06 +05:30
|
|
|
|
if f:
|
|
|
|
|
self.fentry.set_text(_(f[2]))
|
|
|
|
|
self.mentry.set_text(_(f[1]))
|
2003-06-17 09:45:58 +05:30
|
|
|
|
|
2005-02-24 05:55:34 +05:30
|
|
|
|
self.fdesc.set_use_markup(True)
|
|
|
|
|
self.mdesc.set_use_markup(True)
|
2003-06-17 09:45:58 +05:30
|
|
|
|
self.top.show()
|
|
|
|
|
|
|
|
|
|
def close(self,obj):
|
|
|
|
|
self.top.destroy()
|
|
|
|
|
|
|
|
|
|
def on_ok_clicked(self,obj):
|
2004-02-15 12:51:29 +05:30
|
|
|
|
mrel = const.child_relations.find_value(self.mentry.get_text())
|
2004-08-07 10:46:57 +05:30
|
|
|
|
mother = self.db.get_person_from_handle(self.family.get_mother_handle())
|
2005-02-01 09:16:29 +05:30
|
|
|
|
if mother and mother.get_gender() != RelLib.Person.FEMALE:
|
2003-06-17 09:45:58 +05:30
|
|
|
|
if mrel == "Birth":
|
|
|
|
|
mrel = "Unknown"
|
|
|
|
|
|
2004-02-15 12:51:29 +05:30
|
|
|
|
frel = const.child_relations.find_value(self.fentry.get_text())
|
2004-08-07 10:46:57 +05:30
|
|
|
|
father = self.db.get_person_from_handle(self.family.get_father_handle())
|
2005-02-01 09:16:29 +05:30
|
|
|
|
if father and father.get_gender() !=RelLib.Person.MALE:
|
2003-06-17 09:45:58 +05:30
|
|
|
|
if frel == "Birth":
|
|
|
|
|
frel = "Unknown"
|
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
|
self.child.change_parent_family_handle(self.family.get_handle(),mrel,frel)
|
2004-08-13 10:04:07 +05:30
|
|
|
|
trans = self.db.transaction_begin()
|
2004-03-30 10:20:24 +05:30
|
|
|
|
self.db.commit_person(self.child,trans)
|
2004-05-19 11:43:36 +05:30
|
|
|
|
n = self.child.get_primary_name().get_regular_name()
|
2004-08-13 10:04:07 +05:30
|
|
|
|
self.db.transaction_commit(trans,_("Parent Relationships (%s)") % n)
|
2004-03-30 10:20:24 +05:30
|
|
|
|
|
2003-06-17 09:45:58 +05:30
|
|
|
|
self.update()
|
|
|
|
|
self.top.destroy()
|