2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2005-03-09 10:20:10 +05:30
|
|
|
# Copyright (C) 2000-2005 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-19 08:44:14 +05:30
|
|
|
# $Id$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
|
|
|
ChooseParents interface allows users to select the paretns of an
|
|
|
|
individual.
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = "Donald N. Allingham"
|
|
|
|
__version__ = "$Revision$"
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# internationalization
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2003-08-17 07:44:33 +05:30
|
|
|
from gettext import gettext as _
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk.glade
|
2004-08-21 10:03:55 +05:30
|
|
|
import gtk.gdk
|
2003-11-19 08:44:14 +05:30
|
|
|
import gnome
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import RelLib
|
|
|
|
import const
|
|
|
|
import Utils
|
2004-03-22 10:11:35 +05:30
|
|
|
import PeopleModel
|
2005-05-11 19:34:47 +05:30
|
|
|
import Date
|
2005-01-01 09:57:15 +05:30
|
|
|
import NameDisplay
|
2005-05-11 19:34:47 +05:30
|
|
|
import DateHandler
|
2005-03-03 02:18:58 +05:30
|
|
|
import GenericFilter
|
2005-05-24 18:38:06 +05:30
|
|
|
from QuestionDialog import ErrorDialog, WarningDialog
|
2003-01-20 04:29:38 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# ChooseParents
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class ChooseParents:
|
|
|
|
"""
|
|
|
|
Displays the Choose Parents dialog box, allowing the parents
|
|
|
|
to be edited.
|
|
|
|
"""
|
2005-04-01 11:03:22 +05:30
|
|
|
def __init__(self,parent,db,person,family):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
|
|
|
Creates a ChoosePerson dialog box.
|
|
|
|
|
|
|
|
db - database associated the person
|
|
|
|
person - person whose parents we are selecting
|
|
|
|
family - current family
|
|
|
|
"""
|
2004-02-21 12:10:44 +05:30
|
|
|
self.parent = parent
|
2002-10-20 19:55:16 +05:30
|
|
|
self.db = db
|
2004-02-25 08:50:53 +05:30
|
|
|
self.child_windows = {}
|
2004-08-07 10:46:57 +05:30
|
|
|
self.person = self.db.get_person_from_handle(person.get_handle())
|
2004-04-17 00:45:02 +05:30
|
|
|
if family:
|
2004-08-19 21:30:40 +05:30
|
|
|
self.family = self.db.get_family_from_handle(family.get_handle())
|
2004-04-17 00:45:02 +05:30
|
|
|
else:
|
|
|
|
self.family = None
|
2002-10-20 19:55:16 +05:30
|
|
|
self.old_type = ""
|
|
|
|
self.type = ""
|
2003-10-14 09:52:24 +05:30
|
|
|
self.parent_selected = 0
|
2004-03-22 10:11:35 +05:30
|
|
|
self.renderer = gtk.CellRendererText()
|
2003-01-20 09:04:42 +05:30
|
|
|
|
2005-05-24 18:38:06 +05:30
|
|
|
db.connect('person-add', self.redraw)
|
|
|
|
db.connect('person-update', self.redraw)
|
|
|
|
db.connect('person-delete', self.redraw)
|
2005-06-05 09:31:56 +05:30
|
|
|
db.connect('person-rebuild', self.redraw)
|
2005-05-24 18:38:06 +05:30
|
|
|
|
2004-03-22 10:11:35 +05:30
|
|
|
# set default filters
|
2005-05-11 19:34:47 +05:30
|
|
|
self.all_males_filter = GenericFilter.GenericFilter()
|
|
|
|
self.all_males_filter.add_rule(GenericFilter.IsMale([]))
|
|
|
|
self.likely_males_filter = self.build_likely(True)
|
2005-03-03 02:18:58 +05:30
|
|
|
|
2005-05-11 19:34:47 +05:30
|
|
|
self.all_females_filter = GenericFilter.GenericFilter()
|
|
|
|
self.all_females_filter.add_rule(GenericFilter.IsFemale([]))
|
|
|
|
self.likely_females_filter = self.build_likely(False)
|
2004-03-22 10:11:35 +05:30
|
|
|
|
2005-05-11 19:34:47 +05:30
|
|
|
self.father_filter = self.likely_males_filter
|
|
|
|
self.mother_filter = self.likely_females_filter
|
2003-01-20 09:04:42 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.family:
|
2004-07-28 07:59:07 +05:30
|
|
|
self.father = self.family.get_father_handle()
|
|
|
|
self.mother = self.family.get_mother_handle()
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
self.mother = None
|
|
|
|
self.father = None
|
|
|
|
|
2003-08-17 07:44:33 +05:30
|
|
|
self.glade = gtk.glade.XML(const.gladeFile,"familyDialog","gramps")
|
2005-03-09 10:20:10 +05:30
|
|
|
self.window = self.glade.get_widget("familyDialog")
|
2003-03-05 11:31:31 +05:30
|
|
|
|
2005-01-01 09:57:15 +05:30
|
|
|
name = NameDisplay.displayer.display(self.person)
|
|
|
|
self.title_text = _("Choose the Parents of %s") % name
|
2005-03-09 10:20:10 +05:30
|
|
|
Utils.set_titles(self.window,self.glade.get_widget('title'),
|
2004-02-25 08:50:53 +05:30
|
|
|
self.title_text,_('Choose Parents'))
|
2003-03-06 11:42:51 +05:30
|
|
|
|
2005-03-03 02:18:58 +05:30
|
|
|
self.mcombo = self.glade.get_widget("mcombo")
|
|
|
|
self.fcombo = self.glade.get_widget("fcombo")
|
2004-07-31 00:26:49 +05:30
|
|
|
self.prel = self.glade.get_widget("prel_combo")
|
2002-10-20 19:55:16 +05:30
|
|
|
self.title = self.glade.get_widget("chooseTitle")
|
2004-08-21 10:03:55 +05:30
|
|
|
self.father_list = self.glade.get_widget("father_list")
|
2002-10-20 19:55:16 +05:30
|
|
|
self.mother_list = self.glade.get_widget("mother_list")
|
|
|
|
self.flabel = self.glade.get_widget("flabel")
|
|
|
|
self.mlabel = self.glade.get_widget("mlabel")
|
2003-05-22 02:22:53 +05:30
|
|
|
self.showallf = self.glade.get_widget('showallf')
|
2003-03-03 10:02:53 +05:30
|
|
|
self.showallm = self.glade.get_widget('showallm')
|
2005-03-03 02:18:58 +05:30
|
|
|
self.add_itself_to_menu()
|
2003-01-20 09:04:42 +05:30
|
|
|
|
2004-03-22 10:11:35 +05:30
|
|
|
self.build_father_list()
|
|
|
|
self.build_mother_list()
|
2003-01-20 04:29:38 +05:30
|
|
|
|
2004-08-21 10:03:55 +05:30
|
|
|
if gtk.gdk.screen_height() > 700:
|
|
|
|
self.father_list.set_size_request(-1,150)
|
|
|
|
self.mother_list.set_size_request(-1,150)
|
2005-03-03 02:18:58 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
for (f,mr,fr) in self.person.get_parent_family_handle_list():
|
2002-10-20 19:55:16 +05:30
|
|
|
if f == self.family:
|
2005-03-03 02:18:58 +05:30
|
|
|
mrel = mr
|
|
|
|
frel = fr
|
2002-10-20 19:55:16 +05:30
|
|
|
break
|
|
|
|
else:
|
2005-06-08 00:52:10 +05:30
|
|
|
mrel = RelLib.Person.CHILD_BIRTH
|
|
|
|
frel = RelLib.Person.CHILD_BIRTH
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if self.family:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.type = self.family.get_relationship()
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2005-05-31 02:11:43 +05:30
|
|
|
self.type = RelLib.Family.MARRIED
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-31 00:26:49 +05:30
|
|
|
self.prel.set_active(self.type)
|
2003-05-22 02:22:53 +05:30
|
|
|
self.redrawm()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.glade.signal_autoconnect({
|
2005-05-11 19:34:47 +05:30
|
|
|
"on_add_parent_clicked" : self.add_parent_clicked,
|
|
|
|
"on_prel_changed" : self.parent_relation_changed,
|
|
|
|
"destroy_passed_object" : self.close,
|
|
|
|
"on_showallf_toggled" : self.showallf_toggled,
|
|
|
|
"on_showallm_toggled" : self.showallm_toggled,
|
|
|
|
"on_save_parents_clicked" : self.save_parents_clicked,
|
|
|
|
"on_help_familyDialog_clicked" : self.on_help_clicked,
|
2004-02-25 08:50:53 +05:30
|
|
|
"on_familyDialog_delete_event" : self.on_delete_event,
|
2002-10-20 19:55:16 +05:30
|
|
|
})
|
|
|
|
|
2005-03-03 11:03:22 +05:30
|
|
|
self.keys = const.child_rel_list
|
|
|
|
self.build_list(self.mcombo,mrel)
|
|
|
|
self.build_list(self.fcombo,frel)
|
2005-03-03 02:18:58 +05:30
|
|
|
|
2005-03-09 10:20:10 +05:30
|
|
|
self.window.show()
|
2005-03-03 02:18:58 +05:30
|
|
|
|
2005-05-11 19:34:47 +05:30
|
|
|
def build_likely(self,is_male):
|
|
|
|
birth_handle = self.person.get_birth_handle()
|
|
|
|
|
|
|
|
filt = GenericFilter.GenericFilter()
|
|
|
|
if is_male:
|
|
|
|
filt.add_rule(GenericFilter.IsMale([]))
|
|
|
|
else:
|
|
|
|
filt.add_rule(GenericFilter.IsFemale([]))
|
|
|
|
|
|
|
|
if birth_handle:
|
|
|
|
birth = self.db.get_event_from_handle(birth_handle)
|
|
|
|
date_obj = Date.Date(birth.get_date_object())
|
|
|
|
year = date_obj.get_year()
|
|
|
|
if year:
|
|
|
|
date_obj.set_year(year-10)
|
|
|
|
date_obj.set_modifier(Date.MOD_BEFORE)
|
|
|
|
rule = GenericFilter.HasBirth(
|
|
|
|
[DateHandler.displayer.display(date_obj),"",""])
|
|
|
|
filt.add_rule(rule)
|
|
|
|
|
|
|
|
date_obj = Date.Date(birth.get_date_object())
|
|
|
|
date_obj.set_year(year-60)
|
|
|
|
date_obj.set_modifier(Date.MOD_AFTER)
|
|
|
|
rule = GenericFilter.HasBirth(
|
|
|
|
[DateHandler.displayer.display(date_obj),"",""])
|
|
|
|
filt.add_rule(rule)
|
|
|
|
return filt
|
|
|
|
|
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)
|
|
|
|
for val in self.keys:
|
|
|
|
store.append(row=[val])
|
|
|
|
opt_menu.set_model(store)
|
2005-03-03 11:03:22 +05:30
|
|
|
opt_menu.set_active(sel)
|
2004-02-25 08:50:53 +05:30
|
|
|
|
2004-03-22 10:11:35 +05:30
|
|
|
def build_father_list(self):
|
|
|
|
self.father_selection = self.father_list.get_selection()
|
|
|
|
self.father_selection.connect('changed',self.father_list_select_row)
|
|
|
|
self.add_columns(self.father_list)
|
|
|
|
self.redrawf()
|
|
|
|
|
|
|
|
def build_mother_list(self):
|
|
|
|
self.mother_selection = self.mother_list.get_selection()
|
|
|
|
self.mother_selection.connect('changed',self.mother_list_select_row)
|
|
|
|
self.add_columns(self.mother_list)
|
|
|
|
self.redrawm()
|
|
|
|
|
|
|
|
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_sort_column_id(0)
|
2004-03-22 10:11:35 +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_sort_column_id(1)
|
2004-03-22 10:11:35 +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-22 10:11:35 +05:30
|
|
|
tree.append_column(column)
|
|
|
|
|
2004-02-25 08:50:53 +05:30
|
|
|
def on_delete_event(self,obj,b):
|
|
|
|
self.remove_itself_from_menu()
|
2005-03-03 02:18:58 +05:30
|
|
|
self.close_child_windows()
|
2004-02-25 08:50:53 +05:30
|
|
|
|
|
|
|
def close(self,obj):
|
|
|
|
self.remove_itself_from_menu()
|
2005-03-03 02:18:58 +05:30
|
|
|
self.close_child_windows()
|
2005-03-09 10:20:10 +05:30
|
|
|
self.window.destroy()
|
2005-03-03 02:18:58 +05:30
|
|
|
|
2004-02-25 08:50:53 +05:30
|
|
|
def close_child_windows(self):
|
|
|
|
for child_window in self.child_windows.values():
|
2005-05-24 18:38:06 +05:30
|
|
|
child_window.close()
|
2004-02-25 08:50:53 +05:30
|
|
|
self.child_windows = {}
|
|
|
|
|
|
|
|
def add_itself_to_menu(self):
|
|
|
|
self.parent.child_windows[self] = self
|
|
|
|
self.win_menu_item = gtk.MenuItem(self.title_text)
|
|
|
|
self.win_menu_item.set_submenu(gtk.Menu())
|
|
|
|
self.win_menu_item.show()
|
|
|
|
self.parent.winsmenu.append(self.win_menu_item)
|
|
|
|
self.winsmenu = self.win_menu_item.get_submenu()
|
|
|
|
self.menu_item = gtk.MenuItem(_('Choose Parents'))
|
|
|
|
self.menu_item.connect("activate",self.present)
|
|
|
|
self.menu_item.show()
|
|
|
|
self.winsmenu.append(self.menu_item)
|
|
|
|
|
|
|
|
def remove_itself_from_menu(self):
|
|
|
|
del self.parent.child_windows[self]
|
|
|
|
self.menu_item.destroy()
|
|
|
|
self.winsmenu.destroy()
|
|
|
|
self.win_menu_item.destroy()
|
|
|
|
|
|
|
|
def present(self,obj):
|
2005-03-09 10:20:10 +05:30
|
|
|
self.window.present()
|
2004-02-25 08:50:53 +05:30
|
|
|
|
2003-11-19 08:44:14 +05:30
|
|
|
def on_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-19 08:44:14 +05:30
|
|
|
|
2005-05-24 18:38:06 +05:30
|
|
|
def redraw(self,handle_list):
|
|
|
|
self.redrawf()
|
|
|
|
self.redrawm()
|
|
|
|
|
2004-03-22 10:11:35 +05:30
|
|
|
def redrawf(self):
|
|
|
|
"""Redraws the potential father list"""
|
2005-03-03 02:18:58 +05:30
|
|
|
self.father_model = PeopleModel.PeopleModel(self.db,self.father_filter)
|
2004-03-22 10:11:35 +05:30
|
|
|
self.father_list.set_model(self.father_model)
|
2004-06-27 23:38:19 +05:30
|
|
|
|
2005-05-31 02:11:43 +05:30
|
|
|
if self.type == RelLib.Family.CIVIL_UNION:
|
2003-12-14 10:19:43 +05:30
|
|
|
self.flabel.set_label("<b>%s</b>" % _("Par_ent"))
|
2003-05-22 02:22:53 +05:30
|
|
|
else:
|
2003-12-14 10:19:43 +05:30
|
|
|
self.flabel.set_label("<b>%s</b>" % _("Fath_er"))
|
2003-05-22 02:22:53 +05:30
|
|
|
|
|
|
|
def redrawm(self):
|
|
|
|
"""Redraws the potential mother list"""
|
2005-03-03 02:18:58 +05:30
|
|
|
self.mother_model = PeopleModel.PeopleModel(self.db,self.mother_filter)
|
2004-03-22 10:11:35 +05:30
|
|
|
self.mother_list.set_model(self.mother_model)
|
2004-06-27 23:38:19 +05:30
|
|
|
|
2005-05-31 02:11:43 +05:30
|
|
|
if self.type == RelLib.Family.CIVIL_UNION:
|
2003-12-14 10:19:43 +05:30
|
|
|
self.mlabel.set_label("<b>%s</b>" % _("Pa_rent"))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2003-12-14 10:19:43 +05:30
|
|
|
self.mlabel.set_label("<b>%s</b>" % _("Mothe_r"))
|
2003-05-22 01:45:50 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def parent_relation_changed(self,obj):
|
2004-07-31 00:26:49 +05:30
|
|
|
"""Called everytime the parent relationship information is changed"""
|
2002-10-20 19:55:16 +05:30
|
|
|
self.old_type = self.type
|
2004-07-31 00:26:49 +05:30
|
|
|
self.type = self.prel.get_active()
|
2005-05-31 02:11:43 +05:30
|
|
|
if (self.old_type == RelLib.Family.CIVIL_UNION or
|
|
|
|
self.type == RelLib.Family.CIVIL_UNION):
|
2003-05-22 02:22:53 +05:30
|
|
|
self.redrawf()
|
|
|
|
self.redrawm()
|
|
|
|
|
|
|
|
def showallf_toggled(self,obj):
|
2005-05-11 19:34:47 +05:30
|
|
|
if self.father_filter == self.likely_males_filter:
|
2005-06-05 09:31:56 +05:30
|
|
|
self.father_filter = self.all_males_filter
|
2004-03-22 10:11:35 +05:30
|
|
|
else:
|
2005-05-11 19:34:47 +05:30
|
|
|
self.father_filter = self.likely_males_filter
|
2003-05-22 02:22:53 +05:30
|
|
|
self.redrawf()
|
2003-01-20 09:04:42 +05:30
|
|
|
|
2003-05-22 02:22:53 +05:30
|
|
|
def showallm_toggled(self,obj):
|
2005-05-11 19:34:47 +05:30
|
|
|
if self.mother_filter == self.likely_females_filter:
|
2004-03-22 10:11:35 +05:30
|
|
|
self.mother_filter = self.all_females_filter
|
|
|
|
else:
|
2005-05-11 19:34:47 +05:30
|
|
|
self.mother_filter = self.likely_females_filter
|
2003-05-22 02:22:53 +05:30
|
|
|
self.redrawm()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
def find_family(self,father_handle,mother_handle,trans):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
|
|
|
Finds the family associated with the father and mother.
|
|
|
|
If one does not exist, it is created.
|
|
|
|
"""
|
2004-07-28 07:59:07 +05:30
|
|
|
if not father_handle and not mother_handle:
|
2002-10-20 19:55:16 +05:30
|
|
|
return None
|
2005-03-09 03:54:41 +05:30
|
|
|
|
2004-08-13 10:04:07 +05:30
|
|
|
for family_handle in self.db.get_family_handles():
|
2004-08-19 21:30:40 +05:30
|
|
|
family = self.db.get_family_from_handle(family_handle)
|
2005-04-05 06:28:37 +05:30
|
|
|
if (family.get_father_handle() == father_handle and
|
|
|
|
family.get_mother_handle() == mother_handle):
|
2004-07-28 07:59:07 +05:30
|
|
|
family.add_child_handle(self.person.get_handle())
|
2004-04-17 00:45:02 +05:30
|
|
|
self.db.commit_family(family,trans)
|
2002-10-20 19:55:16 +05:30
|
|
|
return family
|
2005-04-05 06:28:37 +05:30
|
|
|
elif (family.get_father_handle() == mother_handle and
|
|
|
|
family.get_mother_handle() == father_handle):
|
2004-07-28 07:59:07 +05:30
|
|
|
family.add_child_handle(self.person.get_handle())
|
2004-04-17 00:45:02 +05:30
|
|
|
self.db.commit_family(family,trans)
|
2002-10-20 19:55:16 +05:30
|
|
|
return family
|
|
|
|
|
2004-08-13 10:04:07 +05:30
|
|
|
family = RelLib.Family()
|
2004-07-28 07:59:07 +05:30
|
|
|
family.set_father_handle(father_handle)
|
|
|
|
family.set_mother_handle(mother_handle)
|
|
|
|
family.add_child_handle(self.person.get_handle())
|
2004-08-13 10:04:07 +05:30
|
|
|
self.db.add_family(family,trans)
|
2004-02-16 02:19:34 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
if father_handle:
|
2004-08-07 10:46:57 +05:30
|
|
|
self.father = self.db.get_person_from_handle(father_handle)
|
2004-07-28 07:59:07 +05:30
|
|
|
self.father.add_family_handle(family.get_handle())
|
2004-04-17 00:45:02 +05:30
|
|
|
self.db.commit_person(self.father,trans)
|
2004-07-28 07:59:07 +05:30
|
|
|
if mother_handle:
|
2004-08-07 10:46:57 +05:30
|
|
|
self.mother = self.db.get_person_from_handle(mother_handle)
|
2004-07-28 07:59:07 +05:30
|
|
|
self.mother.add_family_handle(family.get_handle())
|
2004-04-17 00:45:02 +05:30
|
|
|
self.db.commit_person(self.mother,trans)
|
2004-02-16 02:19:34 +05:30
|
|
|
|
2004-03-30 10:20:24 +05:30
|
|
|
self.db.commit_family(family,trans)
|
2002-10-20 19:55:16 +05:30
|
|
|
return family
|
|
|
|
|
2004-03-22 10:11:35 +05:30
|
|
|
def father_select_function(self,store,path,iter,id_list):
|
2004-06-27 23:38:19 +05:30
|
|
|
if len(path) != 1:
|
|
|
|
val = self.father_model.get_value(iter,PeopleModel.COLUMN_INT_ID)
|
|
|
|
id_list.append(val)
|
2004-03-22 10:11:35 +05:30
|
|
|
|
|
|
|
def mother_select_function(self,store,path,iter,id_list):
|
2004-06-27 23:38:19 +05:30
|
|
|
if len(path) != 1:
|
|
|
|
val = self.mother_model.get_value(iter,PeopleModel.COLUMN_INT_ID)
|
|
|
|
id_list.append(val)
|
2004-03-22 10:11:35 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
def get_selected_father_handles(self):
|
2004-03-22 10:11:35 +05:30
|
|
|
mlist = []
|
2005-03-09 09:28:44 +05:30
|
|
|
self.father_selection.selected_foreach(self.father_select_function,
|
|
|
|
mlist)
|
2004-03-22 10:11:35 +05:30
|
|
|
return mlist
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
def get_selected_mother_handles(self):
|
2004-03-22 10:11:35 +05:30
|
|
|
mlist = []
|
2005-03-09 09:28:44 +05:30
|
|
|
self.mother_selection.selected_foreach(self.mother_select_function,
|
|
|
|
mlist)
|
2004-03-22 10:11:35 +05:30
|
|
|
return mlist
|
2003-10-14 09:52:24 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def father_list_select_row(self,obj):
|
|
|
|
"""Called when a row is selected in the father list. Sets the
|
|
|
|
active father based off the id associated with the row."""
|
2004-03-22 10:11:35 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
idlist = self.get_selected_father_handles()
|
2004-03-22 10:11:35 +05:30
|
|
|
if idlist and idlist[0]:
|
2004-08-07 10:46:57 +05:30
|
|
|
self.father = self.db.get_person_from_handle(idlist[0])
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
self.father = None
|
|
|
|
|
2003-10-14 09:52:24 +05:30
|
|
|
if not self.parent_selected and self.father:
|
|
|
|
self.parent_selected = 1
|
2004-07-28 07:59:07 +05:30
|
|
|
family_handle_list = self.father.get_family_handle_list()
|
|
|
|
if len(family_handle_list) >= 1:
|
2004-08-19 21:30:40 +05:30
|
|
|
family = self.db.get_family_from_handle(family_handle_list[0])
|
2005-04-05 06:28:37 +05:30
|
|
|
handle = family.get_mother_handle()
|
|
|
|
mother = self.db.get_person_from_handle(handle)
|
2004-03-30 10:20:24 +05:30
|
|
|
sname = mother.get_primary_name().get_surname()
|
2005-03-09 09:28:44 +05:30
|
|
|
tpath = self.mother_model.on_get_path(sname)
|
2004-03-30 10:20:24 +05:30
|
|
|
self.mother_list.expand_row(tpath,0)
|
2005-04-05 06:28:37 +05:30
|
|
|
path = self.mother_model.on_get_path(handle)
|
2004-03-30 10:20:24 +05:30
|
|
|
self.mother_selection.select_path(path)
|
|
|
|
self.mother_list.scroll_to_cell(path,None,1,0.5,0)
|
2004-03-22 10:11:35 +05:30
|
|
|
|
|
|
|
def mother_list_select_row(self,obj):
|
|
|
|
"""Called when a row is selected in the father list. Sets the
|
|
|
|
active father based off the id associated with the row."""
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
idlist = self.get_selected_mother_handles()
|
2004-03-22 10:11:35 +05:30
|
|
|
if idlist and idlist[0]:
|
2004-08-07 10:46:57 +05:30
|
|
|
self.mother = self.db.get_person_from_handle(idlist[0])
|
2004-03-22 10:11:35 +05:30
|
|
|
else:
|
|
|
|
self.mother = None
|
|
|
|
|
|
|
|
if not self.parent_selected and self.mother:
|
|
|
|
self.parent_selected = 1
|
2004-07-28 07:59:07 +05:30
|
|
|
family_handle_list = self.mother.get_family_handle_list()
|
|
|
|
if len(family_handle_list) >= 1:
|
2004-08-19 21:30:40 +05:30
|
|
|
family = self.db.get_family_from_handle(family_handle_list[0])
|
2005-04-05 06:28:37 +05:30
|
|
|
handle = family.get_father_handle()
|
|
|
|
father = self.db.get_person_from_handle(handle)
|
2004-03-30 10:20:24 +05:30
|
|
|
sname = father.get_primary_name().get_surname()
|
2005-03-09 09:28:44 +05:30
|
|
|
tpath = self.father_model.on_get_path(sname)
|
2004-03-30 10:20:24 +05:30
|
|
|
self.father_list.expand_row(tpath,0)
|
2005-04-05 06:28:37 +05:30
|
|
|
path = self.father_model.on_get_path(handle)
|
2004-03-30 10:20:24 +05:30
|
|
|
self.father_selection.select_path(path)
|
|
|
|
self.father_list.scroll_to_cell(path,None,1,0.5,0)
|
2003-10-14 09:52:24 +05:30
|
|
|
|
2003-11-24 02:02:40 +05:30
|
|
|
def save_parents_clicked(self,obj):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
2005-03-10 07:08:08 +05:30
|
|
|
Called with the OK button is pressed. Saves the selected people
|
|
|
|
as parents of the main person.
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
2003-04-20 09:22:54 +05:30
|
|
|
try:
|
2005-03-10 07:08:08 +05:30
|
|
|
mother_rel = self.mcombo.get_active()
|
2003-04-20 09:22:54 +05:30
|
|
|
except KeyError:
|
2005-06-08 00:52:10 +05:30
|
|
|
mother_rel = RelLib.Person.CHILD_BIRTH
|
2003-04-20 09:22:54 +05:30
|
|
|
|
|
|
|
try:
|
2005-03-10 07:08:08 +05:30
|
|
|
father_rel = self.fcombo.get_active()
|
2003-04-20 09:22:54 +05:30
|
|
|
except KeyError:
|
2005-06-08 00:52:10 +05:30
|
|
|
father_rel = RelLib.Person.CHILD_BIRTH
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-08-13 10:04:07 +05:30
|
|
|
trans = self.db.transaction_begin()
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.father or self.mother:
|
|
|
|
if self.mother and not self.father:
|
2005-05-31 02:11:43 +05:30
|
|
|
if self.mother.get_gender() == RelLib.Person.MALE:
|
2002-10-20 19:55:16 +05:30
|
|
|
self.father = self.mother
|
2004-07-28 07:59:07 +05:30
|
|
|
father_handle = self.father.get_handle()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.mother = None
|
2004-07-28 07:59:07 +05:30
|
|
|
mother_handle = None
|
2004-04-21 09:52:37 +05:30
|
|
|
else:
|
2004-07-28 07:59:07 +05:30
|
|
|
mother_handle = self.mother.get_handle()
|
|
|
|
father_handle = None
|
2002-10-20 19:55:16 +05:30
|
|
|
elif self.father and not self.mother:
|
2005-05-31 02:11:43 +05:30
|
|
|
if self.father.get_gender() == RelLib.Person.FEMALE:
|
2002-10-20 19:55:16 +05:30
|
|
|
self.mother = self.father
|
|
|
|
self.father = None
|
2004-07-28 07:59:07 +05:30
|
|
|
mother_handle = self.mother.get_handle()
|
|
|
|
father_handle = None
|
2004-04-21 09:52:37 +05:30
|
|
|
else:
|
2004-07-28 07:59:07 +05:30
|
|
|
father_handle = self.father.get_handle()
|
|
|
|
mother_handle = None
|
2004-02-14 11:10:30 +05:30
|
|
|
elif self.mother.get_gender() != self.father.get_gender():
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.type == "Partners":
|
|
|
|
self.type = "Unknown"
|
2005-05-31 02:11:43 +05:30
|
|
|
if self.father.get_gender() == RelLib.Person.FEMALE:
|
2004-02-16 02:19:34 +05:30
|
|
|
self.father, self.mother = self.mother, self.father
|
2004-07-28 07:59:07 +05:30
|
|
|
father_handle = self.father.get_handle()
|
|
|
|
mother_handle = self.mother.get_handle()
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
self.type = "Partners"
|
2004-07-28 07:59:07 +05:30
|
|
|
father_handle = self.father.get_handle()
|
|
|
|
mother_handle = self.mother.get_handle()
|
|
|
|
self.family = self.find_family(father_handle,mother_handle,trans)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
self.family = None
|
|
|
|
|
|
|
|
if self.family:
|
2004-07-28 07:59:07 +05:30
|
|
|
if self.person.get_handle() in (father_handle,mother_handle):
|
2004-04-21 09:52:37 +05:30
|
|
|
ErrorDialog(_("Error selecting a child"),
|
|
|
|
_("A person cannot be linked as his/her own parent"),
|
2005-03-09 10:20:10 +05:30
|
|
|
self.window)
|
2004-04-21 09:52:37 +05:30
|
|
|
return
|
2004-07-28 07:59:07 +05:30
|
|
|
self.family.add_child_handle(self.person.get_handle())
|
2004-02-14 11:10:30 +05:30
|
|
|
self.family.set_relationship(self.type)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.change_family_type(self.family,mother_rel,father_rel)
|
2004-05-19 11:43:36 +05:30
|
|
|
self.db.commit_family(self.family,trans)
|
2004-08-13 10:04:07 +05:30
|
|
|
self.db.transaction_commit(trans,_("Choose Parents"))
|
2005-03-09 10:20:10 +05:30
|
|
|
self.close(None)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-10-08 09:29:55 +05:30
|
|
|
def add_new_parent(self,epo,val):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""Adds a new person to either the father list or the mother list,
|
|
|
|
depending on the gender of the person."""
|
2003-07-31 17:28:08 +05:30
|
|
|
|
|
|
|
person = epo.person
|
2004-08-11 09:12:38 +05:30
|
|
|
handle = person.get_handle()
|
2004-07-28 07:59:07 +05:30
|
|
|
name = person.get_primary_name().get_surname()
|
2004-07-31 00:26:49 +05:30
|
|
|
self.type = self.prel.get_active()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-05-31 02:11:43 +05:30
|
|
|
if self.type == RelLib.Family.CIVIL_UNION:
|
2002-10-20 19:55:16 +05:30
|
|
|
self.parent_relation_changed(self.prel)
|
2005-05-31 02:11:43 +05:30
|
|
|
elif person.get_gender() == RelLib.Person.MALE:
|
2005-05-24 18:38:06 +05:30
|
|
|
try:
|
|
|
|
path = self.father_model.on_get_path(handle)
|
|
|
|
top_path = self.father_model.on_get_path(name)
|
|
|
|
self.father_list.expand_row(top_path,0)
|
|
|
|
self.father_selection.select_path(path)
|
|
|
|
self.father_list.scroll_to_cell(path,None,1,0.5,0)
|
|
|
|
except KeyError:
|
2005-06-05 09:31:56 +05:30
|
|
|
self.father_filter = self.all_males_filter
|
|
|
|
self.showallf_toggled(None)
|
|
|
|
path = self.father_model.on_get_path(handle)
|
|
|
|
top_path = self.father_model.on_get_path(name)
|
|
|
|
self.father_list.expand_row(top_path,0)
|
|
|
|
self.father_selection.select_path(path)
|
|
|
|
self.father_list.scroll_to_cell(path,None,1,0.5,0)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2005-05-24 18:38:06 +05:30
|
|
|
try:
|
|
|
|
path = self.mother_model.on_get_path(handle)
|
|
|
|
top_path = self.mother_model.on_get_path(name)
|
|
|
|
self.mother_list.expand_row(top_path,0)
|
|
|
|
self.mother_selection.select_path(path)
|
|
|
|
self.mother_list.scroll_to_cell(path,None,1,0.5,0)
|
|
|
|
except:
|
2005-06-05 09:31:56 +05:30
|
|
|
self.mother_filter = self.all_females_filter
|
|
|
|
self.showallm_toggled(None)
|
|
|
|
path = self.mother_model.on_get_path(handle)
|
|
|
|
top_path = self.mother_model.on_get_path(name)
|
|
|
|
self.mother_list.expand_row(top_path,0)
|
|
|
|
self.mother_selection.select_path(path)
|
|
|
|
self.mother_list.scroll_to_cell(path,None,1,0.5,0)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def add_parent_clicked(self,obj):
|
|
|
|
"""Called with the Add New Person button is pressed. Calls the QuickAdd
|
|
|
|
class to create a new person."""
|
|
|
|
|
2003-07-31 17:28:08 +05:30
|
|
|
person = RelLib.Person()
|
2005-05-31 02:11:43 +05:30
|
|
|
person.set_gender(RelLib.Person.MALE)
|
2003-07-31 17:28:08 +05:30
|
|
|
|
|
|
|
try:
|
|
|
|
import EditPerson
|
2004-02-25 08:50:53 +05:30
|
|
|
EditPerson.EditPerson(self, person,self.db,self.add_new_parent)
|
2003-07-31 17:28:08 +05:30
|
|
|
except:
|
|
|
|
import DisplayTrace
|
|
|
|
DisplayTrace.DisplayTrace()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def change_family_type(self,family,mother_rel,father_rel):
|
|
|
|
"""
|
|
|
|
Changes the family type of the specified family. If the family
|
|
|
|
is None, the the relationship type shoud be deleted.
|
|
|
|
"""
|
2004-07-28 07:59:07 +05:30
|
|
|
family_handle = family.get_handle()
|
|
|
|
if self.person.get_handle() not in family.get_child_handle_list():
|
|
|
|
family.add_child_handle(self.person.get_handle())
|
|
|
|
for fam in self.person.get_parent_family_handle_list():
|
|
|
|
if family_handle == fam[0]:
|
2002-10-20 19:55:16 +05:30
|
|
|
if mother_rel == fam[1] and father_rel == fam[2]:
|
|
|
|
return
|
|
|
|
if mother_rel != fam[1] or father_rel != fam[2]:
|
2005-03-03 02:18:58 +05:30
|
|
|
self.person.remove_parent_family_handle(family_handle)
|
2005-04-05 06:28:37 +05:30
|
|
|
self.person.add_parent_family_handle(family_handle,
|
|
|
|
mother_rel,father_rel)
|
2002-10-20 19:55:16 +05:30
|
|
|
break
|
|
|
|
else:
|
2005-04-05 06:28:37 +05:30
|
|
|
self.person.add_parent_family_handle(family_handle,
|
|
|
|
mother_rel,father_rel)
|
2004-03-30 10:20:24 +05:30
|
|
|
|
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.person,trans)
|
|
|
|
self.db.commit_family(family,trans)
|
2004-02-21 11:41:59 +05:30
|
|
|
if self.father:
|
2004-03-30 10:20:24 +05:30
|
|
|
self.db.commit_person(self.father,trans)
|
2004-02-21 11:41:59 +05:30
|
|
|
if self.mother:
|
2004-03-30 10:20:24 +05:30
|
|
|
self.db.commit_person(self.mother,trans)
|
2004-08-13 10:04:07 +05:30
|
|
|
self.db.transaction_commit(trans,_("Choose Parents"))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-03-09 10:20:10 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# ModifyParents
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2002-10-20 19:55:16 +05:30
|
|
|
class ModifyParents:
|
2005-04-01 11:03:22 +05:30
|
|
|
def __init__(self, db, person, family_handle, parent_window=None):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
|
|
|
Creates a ChoosePerson dialog box.
|
|
|
|
|
|
|
|
db - database associated the person
|
|
|
|
person - person whose parents we are selecting
|
|
|
|
family - current family
|
|
|
|
"""
|
|
|
|
self.db = db
|
|
|
|
self.person = person
|
2004-08-19 21:30:40 +05:30
|
|
|
self.family = self.db.get_family_from_handle(family_handle)
|
2005-02-20 06:32:15 +05:30
|
|
|
|
|
|
|
fid = self.family.get_father_handle()
|
|
|
|
mid = self.family.get_mother_handle()
|
|
|
|
self.father = self.db.get_person_from_handle(fid)
|
|
|
|
self.mother = self.db.get_person_from_handle(mid)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-08-17 07:44:33 +05:30
|
|
|
self.glade = gtk.glade.XML(const.gladeFile,"modparents","gramps")
|
2005-03-09 10:20:10 +05:30
|
|
|
self.window = self.glade.get_widget("modparents")
|
2003-03-06 11:42:51 +05:30
|
|
|
self.title = self.glade.get_widget("title")
|
2003-03-05 11:31:31 +05:30
|
|
|
|
2005-01-01 09:57:15 +05:30
|
|
|
name = NameDisplay.displayer.display(self.person)
|
|
|
|
title = _("Modify the Parents of %s") % name
|
2005-03-09 10:20:10 +05:30
|
|
|
Utils.set_titles(self.window, self.title, title, _("Modify Parents"))
|
2003-03-05 11:31:31 +05:30
|
|
|
|
2004-02-15 12:51:29 +05:30
|
|
|
self.mother_rel = self.glade.get_widget("mrel")
|
|
|
|
self.father_rel = self.glade.get_widget("frel")
|
2002-10-20 19:55:16 +05:30
|
|
|
self.flabel = self.glade.get_widget("flabel")
|
|
|
|
self.mlabel = self.glade.get_widget("mlabel")
|
2005-03-10 07:08:08 +05:30
|
|
|
self.fcombo = self.glade.get_widget('fcombo')
|
|
|
|
self.mcombo = self.glade.get_widget('mcombo')
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-06-08 00:52:10 +05:30
|
|
|
self.orig_mrel = RelLib.Person.CHILD_BIRTH
|
|
|
|
self.orig_frel = RelLib.Person.CHILD_BIRTH
|
2004-07-28 07:59:07 +05:30
|
|
|
for (f,mr,fr) in self.person.get_parent_family_handle_list():
|
|
|
|
if f == self.family.get_handle():
|
2005-03-03 11:03:22 +05:30
|
|
|
self.orig_mrel = mr
|
|
|
|
self.orig_frel = fr
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.glade.signal_autoconnect({
|
2003-11-19 08:44:14 +05:30
|
|
|
"on_parents_help_clicked" : self.on_help_clicked,
|
2002-10-20 19:55:16 +05:30
|
|
|
})
|
|
|
|
|
2005-02-24 05:55:34 +05:30
|
|
|
self.title.set_use_markup(True)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-05-31 02:11:43 +05:30
|
|
|
if self.family.get_relationship() == RelLib.Family.CIVIL_UNION:
|
2004-07-31 00:26:49 +05:30
|
|
|
self.mlabel.set_label("<b>%s</b>" % _("Pa_rent"))
|
|
|
|
self.flabel.set_label("<b>%s</b>" % _("Par_ent"))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2003-03-05 11:31:31 +05:30
|
|
|
self.mlabel.set_label('<b>%s</b>' % _("Mother"))
|
|
|
|
self.flabel.set_label('<b>%s</b>' % _("Father"))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if self.father:
|
2005-01-01 09:57:15 +05:30
|
|
|
fname = NameDisplay.displayer.display(self.father)
|
2002-10-27 09:13:12 +05:30
|
|
|
self.glade.get_widget("fname").set_text(fname)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2005-03-10 07:08:08 +05:30
|
|
|
self.fcombo.set_sensitive(False)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2002-10-27 09:13:12 +05:30
|
|
|
if self.mother:
|
2005-01-01 09:57:15 +05:30
|
|
|
mname = NameDisplay.displayer.display(self.mother)
|
2002-10-27 09:13:12 +05:30
|
|
|
self.glade.get_widget("mname").set_text(mname)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2005-03-10 07:08:08 +05:30
|
|
|
self.mcombo.set_sensitive(False)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-07-21 05:39:12 +05:30
|
|
|
self.pref = self.glade.get_widget('preferred')
|
2004-07-28 07:59:07 +05:30
|
|
|
if len(self.person.get_parent_family_handle_list()) > 1:
|
2003-07-21 05:39:12 +05:30
|
|
|
self.glade.get_widget('pref_label').show()
|
|
|
|
self.pref.show()
|
2004-07-28 07:59:07 +05:30
|
|
|
if self.family == self.person.get_parent_family_handle_list()[0]:
|
2005-03-03 02:18:58 +05:30
|
|
|
self.pref.set_active(True)
|
2003-07-21 05:39:12 +05:30
|
|
|
else:
|
2005-03-03 02:18:58 +05:30
|
|
|
self.pref.set_active(False)
|
2003-07-21 05:39:12 +05:30
|
|
|
|
2003-11-19 08:44:14 +05:30
|
|
|
if parent_window:
|
2005-03-09 10:20:10 +05:30
|
|
|
self.window.set_transient_for(parent_window)
|
2005-02-20 06:32:15 +05:30
|
|
|
|
2005-03-03 02:18:58 +05:30
|
|
|
if self.db.readonly:
|
|
|
|
self.fcombo.set_sensitive(False)
|
|
|
|
self.mcombo.set_sensitive(False)
|
|
|
|
self.glade.get_widget('ok').set_sensitive(False)
|
|
|
|
|
2005-03-03 11:03:22 +05:30
|
|
|
self.keys = const.child_rel_list
|
2005-03-03 02:18:58 +05:30
|
|
|
|
|
|
|
self.build_list(self.mcombo,self.orig_mrel)
|
|
|
|
self.build_list(self.fcombo,self.orig_frel)
|
|
|
|
|
2005-03-09 10:20:10 +05:30
|
|
|
self.val = self.window.run()
|
2003-11-19 08:44:14 +05:30
|
|
|
if self.val == gtk.RESPONSE_OK:
|
|
|
|
self.save_parents_clicked()
|
2005-03-09 10:20:10 +05:30
|
|
|
self.window.destroy()
|
2003-07-21 05:39:12 +05:30
|
|
|
|
2005-03-03 02:18:58 +05:30
|
|
|
def build_list(self,opt_menu,sel):
|
|
|
|
store = gtk.ListStore(str)
|
|
|
|
for val in self.keys:
|
|
|
|
store.append(row=[val])
|
|
|
|
opt_menu.set_model(store)
|
2005-03-03 11:03:22 +05:30
|
|
|
opt_menu.set_active(sel)
|
2003-07-21 05:39:12 +05:30
|
|
|
|
2003-11-19 08:44:14 +05:30
|
|
|
def on_help_clicked(self,obj):
|
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
|
|
|
gnome.help_display('gramps-manual','gramps-spec-par')
|
2005-03-09 10:20:10 +05:30
|
|
|
self.val = self.window.run()
|
2003-11-19 08:44:14 +05:30
|
|
|
|
|
|
|
def save_parents_clicked(self):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
2005-03-10 07:08:08 +05:30
|
|
|
Called with the OK button nis pressed. Saves the selected people
|
|
|
|
as parents of the main person.
|
2002-10-20 19:55:16 +05:30
|
|
|
"""
|
|
|
|
|
2005-03-09 10:20:10 +05:30
|
|
|
mother_rel = self.mcombo.get_active()
|
|
|
|
father_rel = self.fcombo.get_active()
|
2005-03-03 02:18:58 +05:30
|
|
|
mod = False
|
|
|
|
|
|
|
|
fhandle = self.family.get_handle()
|
2002-10-20 19:55:16 +05:30
|
|
|
if mother_rel != self.orig_mrel or father_rel != self.orig_frel:
|
2005-03-03 02:18:58 +05:30
|
|
|
self.person.remove_parent_family_handle(fhandle)
|
|
|
|
self.person.add_parent_family_handle(fhandle,mother_rel,father_rel)
|
|
|
|
mod = True
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
if len(self.person.get_parent_family_handle_list()):
|
2003-07-21 05:39:12 +05:30
|
|
|
make_pref = self.pref.get_active()
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
plist = self.person.get_parent_family_handle_list()
|
2003-07-21 05:39:12 +05:30
|
|
|
if make_pref:
|
|
|
|
if self.family != plist[0]:
|
2005-03-03 02:18:58 +05:30
|
|
|
self.person.set_main_parent_family_handle(fhandle)
|
|
|
|
mod = True
|
2003-07-21 05:39:12 +05:30
|
|
|
else:
|
|
|
|
if self.family == plist[0]:
|
2004-07-28 07:59:07 +05:30
|
|
|
self.person.set_main_parent_family_handle(plist[0])
|
2005-03-03 02:18:58 +05:30
|
|
|
mod = True
|
2003-07-21 05:39:12 +05:30
|
|
|
|
|
|
|
if mod:
|
2004-08-13 10:04:07 +05:30
|
|
|
trans = self.db.transaction_begin()
|
2004-05-19 11:43:36 +05:30
|
|
|
self.db.commit_person(self.person,trans)
|
2004-08-13 10:04:07 +05:30
|
|
|
self.db.transaction_commit(trans,_("Modify Parents"))
|