2006-01-12 05:37:11 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2007-06-22 11:27:48 +05:30
|
|
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
2009-02-27 03:14:22 +05:30
|
|
|
# Copyright (C) 2009 Gary Burton
|
2006-01-12 05:37:11 +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
|
|
|
|
#
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2008-01-08 20:57:28 +05:30
|
|
|
from bsddb import db as bsddb_db
|
2008-02-08 20:59:28 +05:30
|
|
|
from gettext import gettext as _
|
|
|
|
from DdTargets import DdTargets
|
|
|
|
import pickle
|
2006-02-07 05:14:09 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# enable logging for error handling
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-01-12 05:37:11 +05:30
|
|
|
import logging
|
|
|
|
log = logging.getLogger(".")
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2008-02-08 20:59:28 +05:30
|
|
|
import gtk
|
2008-01-08 20:57:28 +05:30
|
|
|
from gtk import glade
|
2008-02-08 20:59:28 +05:30
|
|
|
from gtk import gdk
|
2009-02-06 02:55:05 +05:30
|
|
|
import pango
|
2006-01-12 05:37:11 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import Utils
|
2008-02-08 20:59:28 +05:30
|
|
|
import const
|
|
|
|
import Config
|
2007-06-28 11:11:40 +05:30
|
|
|
from BasicUtils import name_displayer
|
2007-10-08 22:11:39 +05:30
|
|
|
import gen.lib
|
2006-03-24 10:37:58 +05:30
|
|
|
import Errors
|
2008-02-23 05:23:24 +05:30
|
|
|
import DateHandler
|
2006-03-18 11:17:39 +05:30
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
from Editors import EditPrimary
|
2006-05-31 07:33:29 +05:30
|
|
|
from ReportBase import ReportUtils
|
2008-02-08 20:59:28 +05:30
|
|
|
from DisplayTabs import (EmbeddedList, EventEmbedList, SourceEmbedList,
|
|
|
|
FamilyAttrEmbedList, NoteTab, GalleryTab,
|
|
|
|
FamilyLdsEmbedList, ChildModel)
|
2008-05-09 01:10:56 +05:30
|
|
|
from widgets import (PrivacyButton, MonitoredEntry, MonitoredDataType,
|
|
|
|
IconButton, LinkBox, BasicLabel)
|
2007-08-31 01:19:04 +05:30
|
|
|
from ReportBase import CATEGORY_QR_FAMILY
|
2008-02-18 15:39:50 +05:30
|
|
|
from QuestionDialog import (ErrorDialog, RunDatabaseRepair, WarningDialog,
|
|
|
|
MessageHideDialog)
|
2006-03-18 11:17:39 +05:30
|
|
|
|
2006-05-15 21:23:42 +05:30
|
|
|
from Selectors import selector_factory
|
|
|
|
SelectPerson = selector_factory('Person')
|
2006-03-20 05:04:23 +05:30
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
_RETURN = gdk.keyval_from_name("Return")
|
|
|
|
_KP_ENTER = gdk.keyval_from_name("KP_Enter")
|
2008-02-23 03:39:39 +05:30
|
|
|
_LEFT_BUTTON = 1
|
|
|
|
_RIGHT_BUTTON = 3
|
2007-10-02 02:20:36 +05:30
|
|
|
|
2006-01-16 10:23:42 +05:30
|
|
|
class ChildEmbedList(EmbeddedList):
|
2006-02-07 05:14:09 +05:30
|
|
|
"""
|
|
|
|
The child embed list is specific to the Edit Family dialog, so it
|
|
|
|
is contained here instead of in DisplayTabs.
|
|
|
|
"""
|
2006-01-13 06:15:22 +05:30
|
|
|
|
2006-01-19 04:03:27 +05:30
|
|
|
_HANDLE_COL = 10
|
2006-02-02 03:27:11 +05:30
|
|
|
_DND_TYPE = DdTargets.PERSON_LINK
|
2006-01-14 10:57:48 +05:30
|
|
|
|
2006-04-19 04:52:21 +05:30
|
|
|
_MSG = {
|
|
|
|
'add' : _('Create a new person and add the child to the family'),
|
|
|
|
'del' : _('Remove the child from the family'),
|
2008-01-18 04:45:08 +05:30
|
|
|
'edit' : _('Edit the child reference'),
|
2006-04-19 04:52:21 +05:30
|
|
|
'share' : _('Add an existing person as a child of the family'),
|
2007-04-21 13:39:51 +05:30
|
|
|
'up' : _('Move the child up in the childrens list'),
|
|
|
|
'down' : _('Move the child down in the childrens list'),
|
2006-04-19 04:52:21 +05:30
|
|
|
}
|
|
|
|
|
2006-01-29 02:08:03 +05:30
|
|
|
_column_names = [
|
2006-01-13 06:15:22 +05:30
|
|
|
(_('#'),0) ,
|
|
|
|
(_('ID'),1) ,
|
2007-05-10 08:13:56 +05:30
|
|
|
(_('Name'),11),
|
2006-01-13 06:15:22 +05:30
|
|
|
(_('Gender'),3),
|
2007-05-10 08:13:56 +05:30
|
|
|
(_('Paternal'),4),
|
|
|
|
(_('Maternal'),5),
|
|
|
|
(_('Birth Date'),12),
|
|
|
|
(_('Death Date'),13),
|
|
|
|
(_('Birth Place'),8),
|
|
|
|
(_('Death Place'),9),
|
2006-01-13 06:15:22 +05:30
|
|
|
]
|
|
|
|
|
2006-04-22 09:30:58 +05:30
|
|
|
def __init__(self, dbstate, uistate, track, family):
|
2006-02-07 05:14:09 +05:30
|
|
|
"""
|
|
|
|
Create the object, storing the passed family value
|
|
|
|
"""
|
2006-01-13 06:15:22 +05:30
|
|
|
self.family = family
|
2008-12-01 01:03:54 +05:30
|
|
|
EmbeddedList.__init__(self, dbstate, uistate, track, _('Chil_dren'),
|
2008-02-25 00:28:45 +05:30
|
|
|
ChildModel, share_button=True, move_buttons=True)
|
2006-01-13 09:24:31 +05:30
|
|
|
|
2006-07-08 09:47:50 +05:30
|
|
|
def get_popup_menu_items(self):
|
|
|
|
return [
|
2008-02-12 17:47:58 +05:30
|
|
|
(False, True, (gtk.STOCK_EDIT, _('Edit child')),
|
|
|
|
self.edit_child_button_clicked),
|
2006-12-15 18:09:28 +05:30
|
|
|
(True, True, gtk.STOCK_ADD, self.add_button_clicked),
|
2008-02-12 17:47:58 +05:30
|
|
|
(True, False, _('Add an existing child'),
|
|
|
|
self.share_button_clicked),
|
|
|
|
(False, True, (gtk.STOCK_EDIT, _('Edit relationship')),
|
|
|
|
self.edit_button_clicked),
|
2006-12-15 18:09:28 +05:30
|
|
|
(True, True, gtk.STOCK_REMOVE, self.del_button_clicked),
|
2006-07-08 09:47:50 +05:30
|
|
|
]
|
|
|
|
|
2008-02-12 18:08:47 +05:30
|
|
|
def get_middle_click(self):
|
|
|
|
return self.edit_child_button_clicked
|
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
def find_index(self, obj):
|
2006-03-07 02:29:00 +05:30
|
|
|
"""
|
|
|
|
returns the index of the object within the associated data
|
|
|
|
"""
|
2007-04-21 13:39:51 +05:30
|
|
|
reflist = [ref.ref for ref in self.family.get_child_ref_list()]
|
2006-06-21 02:48:49 +05:30
|
|
|
return reflist.index(obj)
|
2006-03-07 02:29:00 +05:30
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
def _find_row(self, x, y):
|
|
|
|
row = self.tree.get_path_at_pos(x, y)
|
2008-06-16 20:31:46 +05:30
|
|
|
if row is None:
|
2006-04-13 21:46:00 +05:30
|
|
|
return len(self.family.get_child_ref_list())
|
2006-03-07 02:29:00 +05:30
|
|
|
else:
|
|
|
|
return row[0][0]
|
|
|
|
|
|
|
|
def _handle_drag(self, row, obj):
|
2008-02-08 20:59:28 +05:30
|
|
|
self.family.get_child_ref_list().insert(row, obj)
|
2006-03-07 02:29:00 +05:30
|
|
|
self.changed = True
|
|
|
|
self.rebuild()
|
|
|
|
|
|
|
|
def _move(self, row_from, row_to, obj):
|
2006-04-13 21:46:00 +05:30
|
|
|
dlist = self.family.get_child_ref_list()
|
2006-03-07 02:29:00 +05:30
|
|
|
if row_from < row_to:
|
2008-02-08 20:59:28 +05:30
|
|
|
dlist.insert(row_to, obj)
|
2006-03-07 02:29:00 +05:30
|
|
|
del dlist[row_from]
|
|
|
|
else:
|
|
|
|
del dlist[row_from]
|
2008-02-08 20:59:28 +05:30
|
|
|
dlist.insert(row_to-1, obj)
|
2006-03-07 02:29:00 +05:30
|
|
|
self.changed = True
|
|
|
|
self.rebuild()
|
|
|
|
|
2006-01-19 04:03:27 +05:30
|
|
|
def build_columns(self):
|
2006-02-07 05:14:09 +05:30
|
|
|
"""
|
|
|
|
We can't use the default build_columns in the base class, because
|
|
|
|
we are using the custom TypeCellRenderer to handle father parent
|
|
|
|
relationships. The Paternal and Maternal columns (columns 4 and 5)
|
|
|
|
use this.
|
|
|
|
"""
|
2006-01-19 04:03:27 +05:30
|
|
|
for column in self.columns:
|
|
|
|
self.tree.remove_column(column)
|
|
|
|
self.columns = []
|
|
|
|
|
|
|
|
for pair in self.column_order():
|
|
|
|
if not pair[0]:
|
|
|
|
continue
|
2006-01-29 02:08:03 +05:30
|
|
|
name = self._column_names[pair[1]][0]
|
2006-04-19 01:57:53 +05:30
|
|
|
render = gtk.CellRendererText()
|
2007-12-16 05:24:52 +05:30
|
|
|
column = gtk.TreeViewColumn(name, render, markup=pair[1])
|
2006-04-19 01:57:53 +05:30
|
|
|
column.set_min_width(50)
|
2006-01-19 04:03:27 +05:30
|
|
|
|
|
|
|
column.set_resizable(True)
|
2006-01-29 02:08:03 +05:30
|
|
|
column.set_sort_column_id(self._column_names[pair[1]][1])
|
2006-01-19 04:03:27 +05:30
|
|
|
self.columns.append(column)
|
|
|
|
self.tree.append_column(column)
|
|
|
|
|
2006-01-15 10:19:13 +05:30
|
|
|
def get_icon_name(self):
|
2006-02-07 05:14:09 +05:30
|
|
|
return 'gramps-family'
|
2006-01-15 10:19:13 +05:30
|
|
|
|
2006-01-29 02:08:03 +05:30
|
|
|
def is_empty(self):
|
2006-02-07 05:14:09 +05:30
|
|
|
"""
|
|
|
|
The list is considered empty if the child list is empty.
|
|
|
|
"""
|
2006-04-13 21:46:00 +05:30
|
|
|
return len(self.family.get_child_ref_list()) == 0
|
2006-01-29 02:08:03 +05:30
|
|
|
|
2006-01-13 06:15:22 +05:30
|
|
|
def get_data(self):
|
2006-02-07 05:14:09 +05:30
|
|
|
"""
|
|
|
|
Normally, get_data returns a list. However, we return family
|
|
|
|
object here instead.
|
|
|
|
"""
|
2006-01-19 04:03:27 +05:30
|
|
|
return self.family
|
2006-01-13 06:15:22 +05:30
|
|
|
|
|
|
|
def column_order(self):
|
2008-02-08 20:59:28 +05:30
|
|
|
return [(1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6),
|
|
|
|
(0, 8), (0, 9)]
|
2006-01-13 06:15:22 +05:30
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
def add_button_clicked(self, obj):
|
2006-03-19 12:19:03 +05:30
|
|
|
from Editors import EditPerson
|
2007-10-08 22:11:39 +05:30
|
|
|
person = gen.lib.Person()
|
2006-04-25 02:34:01 +05:30
|
|
|
autoname = Config.get(Config.SURNAME_GUESSING)
|
2007-12-01 21:02:05 +05:30
|
|
|
#_("Father's surname"),
|
|
|
|
#_("None"),
|
|
|
|
#_("Combination of mother's and father's surname"),
|
|
|
|
#_("Icelandic style"),
|
2006-03-31 03:45:03 +05:30
|
|
|
if autoname == 0:
|
|
|
|
name = self.north_american()
|
|
|
|
elif autoname == 2:
|
|
|
|
name = self.latin_american()
|
|
|
|
else:
|
|
|
|
name = self.no_name()
|
|
|
|
person.get_primary_name().set_surname(name[1])
|
|
|
|
person.get_primary_name().set_surname_prefix(name[0])
|
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
EditPerson(self.dbstate, self.uistate, self.track, person,
|
2006-06-16 23:12:36 +05:30
|
|
|
self.new_child_added)
|
2006-03-19 12:19:03 +05:30
|
|
|
|
|
|
|
def new_child_added(self, person):
|
2007-10-08 22:11:39 +05:30
|
|
|
ref = gen.lib.ChildRef()
|
2006-04-13 21:46:00 +05:30
|
|
|
ref.ref = person.get_handle()
|
|
|
|
self.family.add_child_ref(ref)
|
2006-03-19 12:19:03 +05:30
|
|
|
self.rebuild()
|
2008-01-18 03:22:13 +05:30
|
|
|
self.call_edit_childref(ref.ref)
|
2006-03-19 12:19:03 +05:30
|
|
|
|
2006-04-19 01:57:53 +05:30
|
|
|
def child_ref_edited(self, person):
|
|
|
|
self.rebuild()
|
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
def share_button_clicked(self, obj):
|
2006-03-19 12:19:03 +05:30
|
|
|
# it only makes sense to skip those who are already in the family
|
2006-04-28 01:51:32 +05:30
|
|
|
skip_list = [self.family.get_father_handle(), \
|
|
|
|
self.family.get_mother_handle()] + \
|
2006-04-22 09:30:58 +05:30
|
|
|
[x.ref for x in self.family.get_child_ref_list() ]
|
2006-02-09 06:05:46 +05:30
|
|
|
|
2006-05-31 23:56:50 +05:30
|
|
|
sel = SelectPerson(self.dbstate, self.uistate, self.track,
|
|
|
|
_("Select Child"), skip=skip_list)
|
2006-03-19 12:19:03 +05:30
|
|
|
person = sel.run()
|
2006-03-20 05:04:23 +05:30
|
|
|
|
2006-03-19 12:19:03 +05:30
|
|
|
if person:
|
2007-10-08 22:11:39 +05:30
|
|
|
ref = gen.lib.ChildRef()
|
2006-04-13 21:46:00 +05:30
|
|
|
ref.ref = person.get_handle()
|
|
|
|
self.family.add_child_ref(ref)
|
2006-03-19 12:19:03 +05:30
|
|
|
self.rebuild()
|
2008-01-18 03:22:13 +05:30
|
|
|
self.call_edit_childref(ref.ref)
|
2006-03-19 12:19:03 +05:30
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
def run(self, skip):
|
2006-04-22 09:30:58 +05:30
|
|
|
skip_list = [ x for x in skip if x]
|
2006-05-31 23:56:50 +05:30
|
|
|
SelectPerson(self.dbstate, self.uistate, self.track,
|
|
|
|
_("Select Child"), skip=skip_list)
|
2006-03-20 05:04:23 +05:30
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
def del_button_clicked(self, obj):
|
2006-04-20 09:14:11 +05:30
|
|
|
handle = self.get_selected()
|
|
|
|
if handle:
|
|
|
|
for ref in self.family.get_child_ref_list():
|
|
|
|
if ref.ref == handle:
|
|
|
|
self.family.remove_child_ref(ref)
|
2006-01-14 23:32:07 +05:30
|
|
|
self.rebuild()
|
2006-01-14 10:57:48 +05:30
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
def edit_button_clicked(self, obj):
|
2006-01-14 10:57:48 +05:30
|
|
|
handle = self.get_selected()
|
|
|
|
if handle:
|
2008-01-18 03:22:13 +05:30
|
|
|
self.call_edit_childref(handle)
|
|
|
|
|
|
|
|
def call_edit_childref(self, handle):
|
|
|
|
from Editors import EditChildRef
|
|
|
|
|
|
|
|
for ref in self.family.get_child_ref_list():
|
|
|
|
if ref.ref == handle:
|
|
|
|
p = self.dbstate.db.get_person_from_handle(handle)
|
|
|
|
n = name_displayer.display(p)
|
|
|
|
try:
|
|
|
|
EditChildRef(n, self.dbstate, self.uistate, self.track,
|
|
|
|
ref, self.child_ref_edited)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
|
|
|
break
|
|
|
|
|
|
|
|
def edit_child_button_clicked(self, obj):
|
2006-07-08 09:47:50 +05:30
|
|
|
handle = self.get_selected()
|
|
|
|
if handle:
|
|
|
|
from Editors import EditPerson
|
|
|
|
|
|
|
|
for ref in self.family.get_child_ref_list():
|
|
|
|
if ref.ref == handle:
|
|
|
|
p = self.dbstate.db.get_person_from_handle(handle)
|
2008-01-18 04:45:08 +05:30
|
|
|
try:
|
|
|
|
EditPerson(self.dbstate, self.uistate, self.track,
|
2006-07-08 09:47:50 +05:30
|
|
|
p, self.child_ref_edited)
|
2008-01-18 04:45:08 +05:30
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-07-08 09:47:50 +05:30
|
|
|
break
|
2007-04-21 13:39:51 +05:30
|
|
|
|
|
|
|
def up_button_clicked(self, obj):
|
|
|
|
handle = self.get_selected()
|
|
|
|
if handle:
|
|
|
|
pos = self.find_index(handle)
|
|
|
|
if pos > 0 :
|
2008-02-08 20:59:28 +05:30
|
|
|
self._move_up(pos,self.family.get_child_ref_list()[pos],
|
|
|
|
selmethod=self.family.get_child_ref_list)
|
2007-04-21 13:39:51 +05:30
|
|
|
|
|
|
|
def down_button_clicked(self, obj):
|
|
|
|
ref = self.get_selected()
|
|
|
|
if ref:
|
|
|
|
pos = self.find_index(ref)
|
|
|
|
if pos >=0 and pos < len(self.family.get_child_ref_list())-1:
|
2008-02-08 20:59:28 +05:30
|
|
|
self._move_down(pos,self.family.get_child_ref_list()[pos],
|
|
|
|
selmethod=self.family.get_child_ref_list)
|
2007-04-21 13:39:51 +05:30
|
|
|
|
2006-07-08 09:47:50 +05:30
|
|
|
|
2006-06-21 02:48:49 +05:30
|
|
|
def drag_data_received(self, widget, context, x, y, sel_data, info, time):
|
|
|
|
"""
|
|
|
|
Handle the standard gtk interface for drag_data_received.
|
|
|
|
|
|
|
|
If the selection data is define, extract the value from sel_data.data,
|
|
|
|
and decide if this is a move or a reorder.
|
|
|
|
"""
|
|
|
|
if sel_data and sel_data.data:
|
|
|
|
(mytype, selfid, obj, row_from) = pickle.loads(sel_data.data)
|
|
|
|
|
|
|
|
# make sure this is the correct DND type for this object
|
|
|
|
if mytype == self._DND_TYPE.drag_type:
|
|
|
|
|
|
|
|
# determine the destination row
|
|
|
|
row = self._find_row(x, y)
|
|
|
|
|
|
|
|
# if the is same object, we have a move, otherwise,
|
|
|
|
# it is a standard drag-n-drop
|
|
|
|
|
|
|
|
if id(self) == selfid:
|
2007-04-21 13:39:51 +05:30
|
|
|
obj = self.get_data().get_child_ref_list()[row_from]
|
2006-06-21 02:48:49 +05:30
|
|
|
self._move(row_from, row, obj)
|
|
|
|
else:
|
2007-04-21 13:39:51 +05:30
|
|
|
handle = obj
|
2007-10-08 22:11:39 +05:30
|
|
|
obj = gen.lib.ChildRef()
|
2007-04-21 13:39:51 +05:30
|
|
|
obj.ref = handle
|
2006-06-21 02:48:49 +05:30
|
|
|
self._handle_drag(row, obj)
|
|
|
|
self.rebuild()
|
|
|
|
elif self._DND_EXTRA and mytype == self._DND_EXTRA.drag_type:
|
|
|
|
self.handle_extra_type(mytype, obj)
|
|
|
|
|
2006-03-31 03:45:03 +05:30
|
|
|
def north_american(self):
|
|
|
|
father_handle = self.family.get_father_handle()
|
|
|
|
if father_handle:
|
|
|
|
father = self.dbstate.db.get_person_from_handle(father_handle)
|
|
|
|
pname = father.get_primary_name()
|
2008-02-08 20:59:28 +05:30
|
|
|
return (pname.get_surname_prefix(), pname.get_surname())
|
2006-03-31 03:45:03 +05:30
|
|
|
return ("","")
|
|
|
|
|
|
|
|
def no_name(self):
|
|
|
|
return ("","")
|
|
|
|
|
|
|
|
def latin_american(self):
|
|
|
|
if self.family:
|
|
|
|
father_handle = self.family.get_father_handle()
|
|
|
|
mother_handle = self.family.get_mother_handle()
|
|
|
|
if not father_handle or not mother_handle:
|
|
|
|
return ("","")
|
2006-04-22 09:30:58 +05:30
|
|
|
father = self.dbstate.db.get_person_from_handle(father_handle)
|
|
|
|
mother = self.dbstate.db.get_person_from_handle(mother_handle)
|
2006-03-31 03:45:03 +05:30
|
|
|
if not father or not mother:
|
|
|
|
return ("","")
|
2007-12-01 21:02:05 +05:30
|
|
|
fsn = father.get_primary_name().get_surname()
|
|
|
|
msn = mother.get_primary_name().get_surname()
|
2006-03-31 03:45:03 +05:30
|
|
|
try:
|
2008-02-08 20:59:28 +05:30
|
|
|
return ("", "%s %s" % (fsn.split()[0], msn.split()[0]))
|
2006-03-31 03:45:03 +05:30
|
|
|
except:
|
2008-02-08 20:59:28 +05:30
|
|
|
return ("", "")
|
2006-03-31 03:45:03 +05:30
|
|
|
else:
|
2008-02-08 20:59:28 +05:30
|
|
|
return ("", "")
|
2006-03-31 03:45:03 +05:30
|
|
|
|
2006-03-19 08:55:31 +05:30
|
|
|
class FastMaleFilter:
|
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
def __init__(self, db):
|
2006-03-19 08:55:31 +05:30
|
|
|
self.db = db
|
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
def match(self, handle, db):
|
2006-03-19 08:55:31 +05:30
|
|
|
value = self.db.get_raw_person_data(handle)
|
2007-10-08 22:11:39 +05:30
|
|
|
return value[2] == gen.lib.Person.MALE
|
2006-03-19 08:55:31 +05:30
|
|
|
|
|
|
|
class FastFemaleFilter:
|
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
def __init__(self, db):
|
2006-03-19 08:55:31 +05:30
|
|
|
self.db = db
|
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
def match(self, handle, db):
|
2006-03-19 08:55:31 +05:30
|
|
|
value = self.db.get_raw_person_data(handle)
|
2007-10-08 22:11:39 +05:30
|
|
|
return value[2] == gen.lib.Person.FEMALE
|
2006-03-19 08:55:31 +05:30
|
|
|
|
2006-01-12 05:37:11 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2006-01-13 06:15:22 +05:30
|
|
|
# EditFamily
|
2006-01-12 05:37:11 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-03-04 12:04:48 +05:30
|
|
|
class EditFamily(EditPrimary):
|
2006-01-12 05:37:11 +05:30
|
|
|
|
2007-08-31 01:19:04 +05:30
|
|
|
QR_CATEGORY = CATEGORY_QR_FAMILY
|
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
def __init__(self, dbstate, uistate, track, family):
|
2006-04-08 11:26:31 +05:30
|
|
|
|
2006-04-29 04:12:07 +05:30
|
|
|
self.tooltips = gtk.Tooltips()
|
2006-03-04 12:04:48 +05:30
|
|
|
EditPrimary.__init__(self, dbstate, uistate, track,
|
2008-02-11 14:31:57 +05:30
|
|
|
family, dbstate.db.get_family_from_handle,
|
|
|
|
dbstate.db.get_family_from_gramps_id)
|
2006-01-12 05:37:11 +05:30
|
|
|
|
2009-02-27 03:14:22 +05:30
|
|
|
self.track_ref_for_deletion("tooltips")
|
|
|
|
|
2006-03-22 09:27:51 +05:30
|
|
|
# look for the scenerio of a child and no parents on a new
|
|
|
|
# family
|
|
|
|
|
2008-06-16 20:31:46 +05:30
|
|
|
if self.added and self.obj.get_father_handle() is None and \
|
|
|
|
self.obj.get_mother_handle() is None and \
|
2006-04-20 10:29:04 +05:30
|
|
|
len(self.obj.get_child_ref_list()) == 1:
|
2006-03-24 09:34:24 +05:30
|
|
|
self.add_parent = True
|
2006-04-25 02:34:01 +05:30
|
|
|
if not Config.get(Config.FAMILY_WARN):
|
2006-03-22 09:27:51 +05:30
|
|
|
for i in self.hidden:
|
|
|
|
i.set_sensitive(False)
|
|
|
|
|
2008-02-18 15:39:50 +05:30
|
|
|
MessageHideDialog(
|
2006-09-24 10:07:59 +05:30
|
|
|
_("Adding parents to a person"),
|
|
|
|
_("It is possible to accidentally create multiple "
|
|
|
|
"families with the same parents. To help avoid "
|
|
|
|
"this problem, only the buttons to select parents "
|
|
|
|
"are available when you create a new family. The "
|
|
|
|
"remaining fields will become available after you "
|
|
|
|
"attempt to select a parent."),
|
|
|
|
Config.FAMILY_WARN)
|
2006-03-24 09:34:24 +05:30
|
|
|
else:
|
|
|
|
self.add_parent = False
|
2006-03-01 10:38:11 +05:30
|
|
|
|
2006-04-01 01:16:41 +05:30
|
|
|
def empty_object(self):
|
2007-10-08 22:11:39 +05:30
|
|
|
return gen.lib.Family()
|
2006-04-01 01:16:41 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def _local_init(self):
|
2006-01-12 05:37:11 +05:30
|
|
|
self.build_interface()
|
|
|
|
|
2007-02-03 23:38:43 +05:30
|
|
|
self._add_db_signal('family-update', self.check_for_family_change)
|
|
|
|
self._add_db_signal('family-delete', self.check_for_close)
|
2008-01-01 00:53:16 +05:30
|
|
|
|
|
|
|
# Add a signal pick up changes to events, bug #1329
|
|
|
|
self._add_db_signal('event-update', self.event_updated)
|
2006-01-14 03:58:54 +05:30
|
|
|
|
2008-06-16 20:31:46 +05:30
|
|
|
self.added = self.obj.handle is None
|
2006-03-08 05:19:26 +05:30
|
|
|
if self.added:
|
|
|
|
self.obj.handle = Utils.create_id()
|
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
self.load_data()
|
2006-01-12 05:37:11 +05:30
|
|
|
|
2007-02-03 23:38:43 +05:30
|
|
|
def check_for_close(self, handles):
|
|
|
|
if self.obj.get_handle() in handles:
|
|
|
|
self._do_close()
|
|
|
|
|
|
|
|
def check_for_family_change(self, handles):
|
|
|
|
|
|
|
|
# check to see if the handle matches the current object
|
2007-06-22 11:27:48 +05:30
|
|
|
if self.obj.get_handle() in handles:
|
2007-02-03 23:38:43 +05:30
|
|
|
|
|
|
|
self.obj = self.dbstate.db.get_family_from_handle(self.obj.get_handle())
|
|
|
|
self.reload_people()
|
2009-02-27 03:14:22 +05:30
|
|
|
self.event_list.rebuild()
|
|
|
|
self.source_list.rebuild()
|
|
|
|
self.attr_list.data = self.obj.get_attribute_list()
|
|
|
|
self.attr_list.rebuild()
|
2007-02-03 23:38:43 +05:30
|
|
|
self.lds_embed.data = self.obj.get_lds_ord_list()
|
|
|
|
self.lds_embed.rebuild()
|
|
|
|
|
2008-02-18 15:39:50 +05:30
|
|
|
WarningDialog(
|
2007-02-03 23:38:43 +05:30
|
|
|
_("Family has changed"),
|
2007-02-03 23:49:25 +05:30
|
|
|
_("The family you are editing has changed. To make sure that the "
|
|
|
|
"database is not corrupted, GRAMPS has updated the family to "
|
|
|
|
"reflect these changes. Any edits you have made may have been lost."))
|
2006-01-19 01:06:23 +05:30
|
|
|
|
2008-01-01 00:53:16 +05:30
|
|
|
def event_updated(self, obj):
|
|
|
|
self.load_data()
|
|
|
|
|
2009-02-06 19:12:12 +05:30
|
|
|
def show_buttons(self):
|
|
|
|
"""
|
|
|
|
Used to reshow hidden/showing buttons.
|
|
|
|
"""
|
|
|
|
fhandle = self.obj.get_father_handle()
|
|
|
|
self.update_father(fhandle)
|
|
|
|
mhandle = self.obj.get_mother_handle()
|
|
|
|
self.update_mother(mhandle)
|
|
|
|
|
2006-01-19 01:06:23 +05:30
|
|
|
def reload_people(self):
|
2006-03-01 10:38:11 +05:30
|
|
|
fhandle = self.obj.get_father_handle()
|
2006-01-19 01:06:23 +05:30
|
|
|
self.update_father(fhandle)
|
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
mhandle = self.obj.get_mother_handle()
|
2006-01-19 01:06:23 +05:30
|
|
|
self.update_mother(mhandle)
|
2009-02-27 03:14:22 +05:30
|
|
|
self.child_tab.rebuild()
|
2006-01-19 01:06:23 +05:30
|
|
|
|
2006-11-27 02:48:30 +05:30
|
|
|
def get_menu_title(self):
|
|
|
|
if self.obj.get_handle():
|
|
|
|
dialog_title = Utils.family_name(self.obj, self.db, _("New Family"))
|
|
|
|
dialog_title = _("Family") + ': ' + dialog_title
|
|
|
|
else:
|
|
|
|
dialog_title = _("New Family")
|
|
|
|
return dialog_title
|
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
def build_menu_names(self, family):
|
2006-11-27 02:48:30 +05:30
|
|
|
return (_('Edit Family'), self.get_menu_title())
|
2006-01-12 05:37:11 +05:30
|
|
|
|
|
|
|
def build_interface(self):
|
2009-02-08 04:24:16 +05:30
|
|
|
self.width_key = Config.FAMILY_WIDTH
|
|
|
|
self.height_key = Config.FAMILY_HEIGHT
|
2006-01-16 10:23:42 +05:30
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
self.top = glade.XML(const.GLADE_FILE, "family_editor", "gramps")
|
2006-03-01 10:38:11 +05:30
|
|
|
|
2006-11-27 02:48:30 +05:30
|
|
|
self.set_window(self.top.get_widget("family_editor"), None, self.get_menu_title())
|
2006-01-12 05:37:11 +05:30
|
|
|
|
2009-02-06 19:12:12 +05:30
|
|
|
# HACK: how to prevent hidden items from showing
|
|
|
|
# when you use show_all?
|
|
|
|
# Consider using show() rather than show_all()?
|
|
|
|
# FIXME: remove if we can use show()
|
|
|
|
self.window.show_all = self.window.show
|
|
|
|
|
2006-04-28 01:51:32 +05:30
|
|
|
self.fbirth = self.top.get_widget('fbirth')
|
|
|
|
self.fdeath = self.top.get_widget('fdeath')
|
2008-02-23 05:23:24 +05:30
|
|
|
self.fbirth_label = self.top.get_widget('label578')
|
|
|
|
self.fdeath_label = self.top.get_widget('label579')
|
2006-01-12 05:37:11 +05:30
|
|
|
|
2006-04-28 01:51:32 +05:30
|
|
|
self.mbirth = self.top.get_widget('mbirth')
|
|
|
|
self.mdeath = self.top.get_widget('mdeath')
|
2008-02-23 05:23:24 +05:30
|
|
|
self.mbirth_label = self.top.get_widget('label567')
|
|
|
|
self.mdeath_label = self.top.get_widget('label568')
|
2006-01-12 05:37:11 +05:30
|
|
|
|
2009-02-06 19:12:12 +05:30
|
|
|
self.mname = self.top.get_widget('mname')
|
|
|
|
self.fname = self.top.get_widget('fname')
|
|
|
|
|
|
|
|
self.mbutton_index = self.top.get_widget('mbutton_index')
|
|
|
|
self.mbutton_add = self.top.get_widget('mbutton_add')
|
|
|
|
self.mbutton_del = self.top.get_widget('mbutton_del')
|
|
|
|
self.mbutton_edit = self.top.get_widget('mbutton_edit')
|
|
|
|
|
|
|
|
self.tooltips.set_tip(self.mbutton_index,
|
|
|
|
_("Select a person as the mother"))
|
|
|
|
self.tooltips.set_tip(self.mbutton_add,
|
2006-04-29 04:12:07 +05:30
|
|
|
_("Add a new person as the mother"))
|
2009-02-06 19:12:12 +05:30
|
|
|
self.tooltips.set_tip(self.mbutton_del,
|
|
|
|
_("Remove the person as the mother"))
|
|
|
|
|
|
|
|
self.mbutton_edit.connect('button-press-event', self.edit_mother)
|
|
|
|
self.mbutton_edit.connect('key-press-event', self.edit_mother)
|
|
|
|
self.mbutton_index.connect('clicked', self.sel_mother_clicked)
|
|
|
|
self.mbutton_del.connect('clicked', self.del_mother_clicked)
|
|
|
|
self.mbutton_add.connect('clicked', self.add_mother_clicked)
|
|
|
|
|
|
|
|
self.fbutton_index = self.top.get_widget('fbutton_index')
|
|
|
|
self.fbutton_add = self.top.get_widget('fbutton_add')
|
|
|
|
self.fbutton_del = self.top.get_widget('fbutton_del')
|
|
|
|
self.fbutton_edit = self.top.get_widget('fbutton_edit')
|
|
|
|
|
|
|
|
self.tooltips.set_tip(self.fbutton_index,
|
|
|
|
_("Select a person as the father"))
|
|
|
|
self.tooltips.set_tip(self.fbutton_add,
|
2006-04-29 04:12:07 +05:30
|
|
|
_("Add a new person as the father"))
|
2009-02-06 19:12:12 +05:30
|
|
|
self.tooltips.set_tip(self.fbutton_del,
|
|
|
|
_("Remove the person as the father"))
|
|
|
|
|
|
|
|
self.fbutton_edit.connect('button-press-event', self.edit_father)
|
|
|
|
self.fbutton_edit.connect('key-press-event', self.edit_father)
|
|
|
|
self.fbutton_index.connect('clicked', self.sel_father_clicked)
|
|
|
|
self.fbutton_del.connect('clicked', self.del_father_clicked)
|
|
|
|
self.fbutton_add.connect('clicked', self.add_father_clicked)
|
2006-04-29 04:12:07 +05:30
|
|
|
|
2007-08-31 01:19:04 +05:30
|
|
|
#allow for a context menu
|
|
|
|
self.set_contexteventbox(self.top.get_widget("eventboxtop"))
|
2006-01-14 03:58:54 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def _connect_signals(self):
|
|
|
|
self.define_ok_button(self.top.get_widget('ok'), self.save)
|
|
|
|
self.define_cancel_button(self.top.get_widget('cancel'))
|
2006-02-10 09:07:20 +05:30
|
|
|
|
2006-03-22 09:27:51 +05:30
|
|
|
def _can_be_replaced(self):
|
|
|
|
pass
|
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def _setup_fields(self):
|
2006-02-06 10:33:44 +05:30
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
self.private = PrivacyButton(
|
2006-03-01 10:38:11 +05:30
|
|
|
self.top.get_widget('private'),
|
|
|
|
self.obj,
|
|
|
|
self.db.readonly)
|
|
|
|
|
|
|
|
self.gid = MonitoredEntry(
|
|
|
|
self.top.get_widget('gid'),
|
|
|
|
self.obj.set_gramps_id,
|
|
|
|
self.obj.get_gramps_id,
|
|
|
|
self.db.readonly)
|
|
|
|
|
2006-04-21 08:29:15 +05:30
|
|
|
self.marker = MonitoredDataType(
|
|
|
|
self.top.get_widget('marker'),
|
|
|
|
self.obj.set_marker,
|
|
|
|
self.obj.get_marker,
|
2006-05-21 09:54:56 +05:30
|
|
|
self.db.readonly,
|
|
|
|
self.db.get_marker_types(),
|
|
|
|
)
|
2006-04-21 08:29:15 +05:30
|
|
|
|
2006-04-20 04:29:33 +05:30
|
|
|
self.data_type = MonitoredDataType(
|
2006-03-01 10:38:11 +05:30
|
|
|
self.top.get_widget('marriage_type'),
|
|
|
|
self.obj.set_relationship,
|
|
|
|
self.obj.get_relationship,
|
2006-05-21 09:54:56 +05:30
|
|
|
self.db.readonly,
|
2009-02-15 20:26:13 +05:30
|
|
|
self.db.get_family_relation_types(),
|
2006-04-20 04:29:33 +05:30
|
|
|
)
|
2006-01-14 03:58:54 +05:30
|
|
|
|
2006-01-12 05:37:11 +05:30
|
|
|
def load_data(self):
|
2006-03-01 10:38:11 +05:30
|
|
|
fhandle = self.obj.get_father_handle()
|
2006-01-19 01:06:23 +05:30
|
|
|
self.update_father(fhandle)
|
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
mhandle = self.obj.get_mother_handle()
|
2006-01-19 01:06:23 +05:30
|
|
|
self.update_mother(mhandle)
|
|
|
|
|
2006-04-13 21:46:00 +05:30
|
|
|
self.phandles = [mhandle, fhandle] + \
|
|
|
|
[ x.ref for x in self.obj.get_child_ref_list()]
|
|
|
|
|
2006-01-19 01:06:23 +05:30
|
|
|
self.phandles = [handle for handle in self.phandles if handle]
|
2006-01-14 03:58:54 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def _create_tabbed_pages(self):
|
|
|
|
|
|
|
|
notebook = gtk.Notebook()
|
|
|
|
|
2009-02-27 03:14:22 +05:30
|
|
|
self.child_list = ChildEmbedList(self.dbstate,
|
|
|
|
self.uistate,
|
|
|
|
self.track,
|
|
|
|
self.obj)
|
|
|
|
self.child_tab = self._add_tab(notebook, self.child_list)
|
|
|
|
self.track_ref_for_deletion("child_list")
|
|
|
|
self.track_ref_for_deletion("child_tab")
|
2006-03-01 10:38:11 +05:30
|
|
|
|
2009-02-27 03:14:22 +05:30
|
|
|
self.event_list = EventEmbedList(self.dbstate,
|
|
|
|
self.uistate,
|
|
|
|
self.track,
|
|
|
|
self.obj)
|
|
|
|
self._add_tab(notebook, self.event_list)
|
|
|
|
self.track_ref_for_deletion("event_list")
|
2006-03-01 10:38:11 +05:30
|
|
|
|
2009-02-27 03:14:22 +05:30
|
|
|
self.source_list = SourceEmbedList(self.dbstate,
|
|
|
|
self.uistate,
|
|
|
|
self.track,
|
|
|
|
self.obj)
|
|
|
|
self._add_tab(notebook, self.source_list)
|
|
|
|
self.track_ref_for_deletion("source_list")
|
|
|
|
|
|
|
|
self.attr_list = FamilyAttrEmbedList(self.dbstate,
|
|
|
|
self.uistate,
|
2008-02-08 20:59:28 +05:30
|
|
|
self.track,
|
2007-02-03 23:38:43 +05:30
|
|
|
self.obj.get_attribute_list())
|
2009-02-27 03:14:22 +05:30
|
|
|
self._add_tab(notebook, self.attr_list)
|
|
|
|
self.track_ref_for_deletion("attr_list")
|
2006-03-01 10:38:11 +05:30
|
|
|
|
2009-02-27 03:14:22 +05:30
|
|
|
self.note_tab = NoteTab(self.dbstate,
|
|
|
|
self.uistate,
|
|
|
|
self.track,
|
|
|
|
self.obj.get_note_list(),
|
|
|
|
self.get_menu_title(),
|
|
|
|
notetype=gen.lib.NoteType.FAMILY)
|
|
|
|
self._add_tab(notebook, self.note_tab)
|
|
|
|
self.track_ref_for_deletion("note_tab")
|
2006-03-01 10:38:11 +05:30
|
|
|
|
2009-02-27 03:14:22 +05:30
|
|
|
self.gallery_tab = GalleryTab(self.dbstate,
|
|
|
|
self.uistate,
|
|
|
|
self.track,
|
|
|
|
self.obj.get_media_list())
|
|
|
|
self._add_tab(notebook, self.gallery_tab)
|
|
|
|
self.track_ref_for_deletion("gallery_tab")
|
|
|
|
|
|
|
|
self.lds_embed = FamilyLdsEmbedList(self.dbstate,
|
|
|
|
self.uistate,
|
2008-02-08 20:59:28 +05:30
|
|
|
self.track,
|
2007-02-03 23:38:43 +05:30
|
|
|
self.obj.get_lds_ord_list())
|
2009-02-27 03:14:22 +05:30
|
|
|
self._add_tab(notebook, self.lds_embed)
|
|
|
|
self.track_ref_for_deletion("lds_embed")
|
2006-04-06 04:06:48 +05:30
|
|
|
|
2007-01-16 12:42:10 +05:30
|
|
|
self._setup_notebook_tabs( notebook)
|
2006-03-01 10:38:11 +05:30
|
|
|
notebook.show_all()
|
2006-03-22 09:27:51 +05:30
|
|
|
|
|
|
|
self.hidden = (notebook, self.top.get_widget('info'))
|
2008-02-08 20:59:28 +05:30
|
|
|
self.top.get_widget('vbox').pack_start(notebook, True)
|
2006-01-13 09:24:31 +05:30
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
def update_father(self, handle):
|
2009-02-06 19:12:12 +05:30
|
|
|
self.load_parent(handle, self.fname, self.fbirth, self.fbirth_label,
|
|
|
|
self.fdeath, self.fdeath_label,
|
|
|
|
self.fbutton_index, self.fbutton_add,
|
|
|
|
self.fbutton_del, self.fbutton_edit)
|
2006-01-14 03:58:54 +05:30
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
def update_mother(self, handle):
|
2009-02-06 19:12:12 +05:30
|
|
|
self.load_parent(handle, self.mname, self.mbirth, self.mbirth_label,
|
|
|
|
self.mdeath, self.mdeath_label,
|
|
|
|
self.mbutton_index, self.mbutton_add,
|
|
|
|
self.mbutton_del, self.mbutton_edit)
|
2006-01-14 03:58:54 +05:30
|
|
|
|
2006-04-28 01:51:32 +05:30
|
|
|
def add_mother_clicked(self, obj):
|
|
|
|
from Editors import EditPerson
|
2007-10-08 22:11:39 +05:30
|
|
|
person = gen.lib.Person()
|
|
|
|
person.set_gender(gen.lib.Person.FEMALE)
|
2007-12-01 21:02:05 +05:30
|
|
|
autoname = Config.get(Config.SURNAME_GUESSING)
|
|
|
|
#_("Father's surname"),
|
|
|
|
#_("None"),
|
|
|
|
#_("Combination of mother's and father's surname"),
|
|
|
|
#_("Icelandic style"),
|
|
|
|
if autoname == 2:
|
|
|
|
name = self.latin_american_child("mother")
|
|
|
|
else:
|
|
|
|
name = self.no_name()
|
|
|
|
person.get_primary_name().set_surname(name[1])
|
|
|
|
person.get_primary_name().set_surname_prefix(name[0])
|
2006-06-16 23:12:36 +05:30
|
|
|
EditPerson(self.dbstate, self.uistate, self.track, person,
|
|
|
|
self.new_mother_added)
|
2006-04-28 01:51:32 +05:30
|
|
|
|
|
|
|
def add_father_clicked(self, obj):
|
|
|
|
from Editors import EditPerson
|
2007-10-08 22:11:39 +05:30
|
|
|
person = gen.lib.Person()
|
|
|
|
person.set_gender(gen.lib.Person.MALE)
|
2007-11-30 03:37:05 +05:30
|
|
|
autoname = Config.get(Config.SURNAME_GUESSING)
|
2007-12-01 21:02:05 +05:30
|
|
|
#_("Father's surname"),
|
|
|
|
#_("None"),
|
|
|
|
#_("Combination of mother's and father's surname"),
|
|
|
|
#_("Icelandic style"),
|
2007-11-30 03:37:05 +05:30
|
|
|
if autoname == 0:
|
|
|
|
name = self.north_american_child()
|
2007-12-01 21:02:05 +05:30
|
|
|
elif autoname == 2:
|
|
|
|
name = self.latin_american_child("father")
|
2007-11-30 03:37:05 +05:30
|
|
|
else:
|
|
|
|
name = self.no_name()
|
|
|
|
person.get_primary_name().set_surname(name[1])
|
|
|
|
person.get_primary_name().set_surname_prefix(name[0])
|
2006-06-16 23:12:36 +05:30
|
|
|
EditPerson(self.dbstate, self.uistate, self.track,
|
|
|
|
person, self.new_father_added)
|
2006-04-28 01:51:32 +05:30
|
|
|
|
|
|
|
def new_mother_added(self, person):
|
2006-06-22 01:02:50 +05:30
|
|
|
for i in self.hidden:
|
|
|
|
i.set_sensitive(True)
|
2006-04-28 01:51:32 +05:30
|
|
|
self.obj.set_mother_handle(person.handle)
|
|
|
|
self.update_mother(person.handle)
|
|
|
|
|
|
|
|
def new_father_added(self, person):
|
2006-06-22 01:02:50 +05:30
|
|
|
for i in self.hidden:
|
|
|
|
i.set_sensitive(True)
|
2006-04-28 01:51:32 +05:30
|
|
|
self.obj.set_father_handle(person.handle)
|
|
|
|
self.update_father(person.handle)
|
2006-02-09 06:05:46 +05:30
|
|
|
|
2009-02-06 19:12:12 +05:30
|
|
|
def del_mother_clicked(self, obj):
|
2006-03-22 09:27:51 +05:30
|
|
|
for i in self.hidden:
|
|
|
|
i.set_sensitive(True)
|
2006-03-21 11:53:45 +05:30
|
|
|
|
2009-02-06 19:12:12 +05:30
|
|
|
self.obj.set_mother_handle(None)
|
|
|
|
self.update_mother(None)
|
2006-03-22 09:27:51 +05:30
|
|
|
|
2009-02-06 19:12:12 +05:30
|
|
|
def sel_mother_clicked(self, obj):
|
|
|
|
for i in self.hidden:
|
|
|
|
i.set_sensitive(True)
|
2006-03-22 09:27:51 +05:30
|
|
|
|
2009-02-06 19:12:12 +05:30
|
|
|
data_filter = FastFemaleFilter(self.dbstate.db)
|
|
|
|
sel = SelectPerson(self.dbstate, self.uistate, self.track,
|
|
|
|
_("Select Mother"),
|
|
|
|
filter=data_filter,
|
|
|
|
skip=[x.ref for x in self.obj.get_child_ref_list()])
|
|
|
|
person = sel.run()
|
2006-03-24 09:34:24 +05:30
|
|
|
|
2009-02-06 19:12:12 +05:30
|
|
|
if person:
|
|
|
|
self.check_for_existing_family(self.obj.get_father_handle(),
|
|
|
|
person.handle,
|
|
|
|
self.obj.handle)
|
|
|
|
self.obj.set_mother_handle(person.handle)
|
|
|
|
self.update_mother(person.handle)
|
2006-03-22 09:27:51 +05:30
|
|
|
|
2006-02-08 20:33:06 +05:30
|
|
|
def on_change_father(self, selector_window, obj):
|
2007-10-08 22:11:39 +05:30
|
|
|
if obj.__class__ == gen.lib.Person:
|
2006-01-20 16:00:35 +05:30
|
|
|
try:
|
2006-02-08 20:33:06 +05:30
|
|
|
person = obj
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj.set_father_handle(person.get_handle())
|
2006-02-07 05:14:09 +05:30
|
|
|
self.update_father(person.get_handle())
|
2006-01-20 16:00:35 +05:30
|
|
|
except:
|
|
|
|
log.warn("Failed to update father: \n"
|
2006-02-08 20:33:06 +05:30
|
|
|
"obj returned from selector was: %s\n"
|
|
|
|
% (repr(obj),))
|
2006-01-20 16:00:35 +05:30
|
|
|
raise
|
2006-02-08 20:33:06 +05:30
|
|
|
|
2006-01-20 16:00:35 +05:30
|
|
|
else:
|
2006-02-08 20:33:06 +05:30
|
|
|
log.warn(
|
|
|
|
"Object selector returned obj.__class__ = %s, it should "
|
|
|
|
"have been of type %s." % (obj.__class__.__name__,
|
2007-10-08 22:11:39 +05:30
|
|
|
gen.lib.Person.__name__))
|
2006-01-20 16:00:35 +05:30
|
|
|
|
|
|
|
selector_window.close()
|
2006-01-14 03:58:54 +05:30
|
|
|
|
2009-02-06 19:12:12 +05:30
|
|
|
def del_father_clicked(self, obj):
|
2006-03-22 09:27:51 +05:30
|
|
|
for i in self.hidden:
|
|
|
|
i.set_sensitive(True)
|
2006-03-24 09:34:24 +05:30
|
|
|
|
2009-02-06 19:12:12 +05:30
|
|
|
self.obj.set_father_handle(None)
|
|
|
|
self.update_father(None)
|
|
|
|
|
|
|
|
def sel_father_clicked(self, obj):
|
|
|
|
for i in self.hidden:
|
|
|
|
i.set_sensitive(True)
|
|
|
|
|
|
|
|
data_filter = FastMaleFilter(self.dbstate.db)
|
|
|
|
sel = SelectPerson(self.dbstate, self.uistate, self.track,
|
|
|
|
_("Select Father"),
|
|
|
|
filter=data_filter,
|
|
|
|
skip=[x.ref for x in self.obj.get_child_ref_list()])
|
|
|
|
person = sel.run()
|
|
|
|
if person:
|
|
|
|
self.check_for_existing_family(person.handle,
|
|
|
|
self.obj.get_mother_handle(),
|
|
|
|
self.obj.handle)
|
|
|
|
self.obj.set_father_handle(person.handle)
|
|
|
|
self.update_father(person.handle)
|
2006-03-18 11:17:39 +05:30
|
|
|
|
2006-03-24 09:34:24 +05:30
|
|
|
def check_for_existing_family(self, father_handle, mother_handle,
|
|
|
|
family_handle):
|
2006-03-25 09:17:47 +05:30
|
|
|
|
2006-03-24 09:34:24 +05:30
|
|
|
if father_handle:
|
|
|
|
father = self.dbstate.db.get_person_from_handle(father_handle)
|
|
|
|
ffam = set(father.get_family_handle_list())
|
|
|
|
if mother_handle:
|
|
|
|
mother = self.dbstate.db.get_person_from_handle(mother_handle)
|
|
|
|
mfam = set(mother.get_family_handle_list())
|
|
|
|
common = list(mfam.intersection(ffam))
|
|
|
|
if len(common) > 0:
|
2006-06-22 01:43:40 +05:30
|
|
|
if self.add_parent or self.obj.handle not in common:
|
2008-02-18 15:39:50 +05:30
|
|
|
WarningDialog(
|
2006-03-24 09:34:24 +05:30
|
|
|
_('Duplicate Family'),
|
|
|
|
_('A family with these parents already exists '
|
|
|
|
'in the database. If you save, you will create '
|
2006-06-23 09:43:06 +05:30
|
|
|
'a duplicate family. It is recommended that '
|
|
|
|
'you cancel the editing of this window, and '
|
|
|
|
'select the existing family'))
|
2006-03-24 09:34:24 +05:30
|
|
|
|
2009-02-06 19:12:12 +05:30
|
|
|
def edit_father(self, obj, event):
|
|
|
|
handle = self.obj.get_father_handle()
|
|
|
|
return self.edit_person(obj, event, handle)
|
|
|
|
|
|
|
|
def edit_mother(self, obj, event):
|
|
|
|
handle = self.obj.get_mother_handle()
|
|
|
|
return self.edit_person(obj, event, handle)
|
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
def edit_person(self, obj, event, handle):
|
2008-02-23 03:39:39 +05:30
|
|
|
if button_activated(event, _LEFT_BUTTON):
|
2006-03-09 09:23:09 +05:30
|
|
|
from _EditPerson import EditPerson
|
2006-03-01 10:38:11 +05:30
|
|
|
try:
|
|
|
|
person = self.db.get_person_from_handle(handle)
|
2006-03-09 09:30:29 +05:30
|
|
|
EditPerson(self.dbstate, self.uistate,
|
2006-06-16 23:12:36 +05:30
|
|
|
self.track, person)
|
2006-03-01 10:38:11 +05:30
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
2006-01-13 06:15:22 +05:30
|
|
|
|
2009-02-06 19:12:12 +05:30
|
|
|
def load_parent(self, handle, name_obj, birth_obj, birth_label, death_obj,
|
|
|
|
death_label, btn_index, btn_add, btn_del, btn_edit):
|
|
|
|
# is a parent used here:
|
2008-06-16 20:31:46 +05:30
|
|
|
is_used = handle is not None
|
2006-01-14 03:58:54 +05:30
|
|
|
|
2009-02-06 19:12:12 +05:30
|
|
|
# now we display the area:
|
2006-01-13 06:15:22 +05:30
|
|
|
if is_used:
|
2006-03-01 10:38:11 +05:30
|
|
|
db = self.db
|
2006-01-12 05:37:11 +05:30
|
|
|
person = db.get_person_from_handle(handle)
|
2007-06-28 11:11:40 +05:30
|
|
|
name = "%s [%s]" % (name_displayer.display(person),
|
2006-01-12 05:37:11 +05:30
|
|
|
person.gramps_id)
|
2008-02-23 05:23:24 +05:30
|
|
|
birth = ReportUtils.get_birth_or_fallback(db, person)
|
|
|
|
if birth and birth.get_type() == gen.lib.EventType.BAPTISM:
|
|
|
|
birth_label.set_label(_("Baptism:"))
|
|
|
|
|
|
|
|
death = ReportUtils.get_death_or_fallback(db, person)
|
|
|
|
if death and death.get_type() == gen.lib.EventType.BURIAL:
|
|
|
|
death_label.set_label(_("Burial:"))
|
2006-01-13 06:15:22 +05:30
|
|
|
|
2009-02-06 19:12:12 +05:30
|
|
|
self.tooltips.set_tip(btn_edit, _('Edit %s') % name)
|
|
|
|
btn_index.hide()
|
|
|
|
btn_add.hide()
|
|
|
|
btn_del.show()
|
|
|
|
btn_edit.show()
|
2006-01-12 05:37:11 +05:30
|
|
|
else:
|
|
|
|
name = ""
|
2008-02-23 05:23:24 +05:30
|
|
|
birth = None
|
|
|
|
death = None
|
2006-01-12 05:37:11 +05:30
|
|
|
|
2009-02-06 19:12:12 +05:30
|
|
|
btn_index.show()
|
|
|
|
btn_add.show()
|
|
|
|
btn_del.hide()
|
|
|
|
btn_edit.hide()
|
2006-01-13 06:15:22 +05:30
|
|
|
|
2009-02-06 19:12:12 +05:30
|
|
|
if name_obj:
|
|
|
|
name_obj.set_text(name)
|
2008-02-23 05:23:24 +05:30
|
|
|
if birth:
|
|
|
|
birth_str = DateHandler.displayer.display(birth.get_date_object())
|
2009-02-06 19:12:12 +05:30
|
|
|
else:
|
|
|
|
birth_str = ""
|
|
|
|
birth_obj.set_text(birth_str)
|
2008-02-23 05:23:24 +05:30
|
|
|
if death:
|
|
|
|
death_str = DateHandler.displayer.display(death.get_date_object())
|
2009-02-06 19:12:12 +05:30
|
|
|
else:
|
|
|
|
death_str = ""
|
|
|
|
death_obj.set_text(death_str)
|
2006-01-12 05:37:11 +05:30
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
def fix_parent_handles(self, orig_handle, new_handle, trans):
|
2006-02-06 10:33:44 +05:30
|
|
|
if orig_handle != new_handle:
|
|
|
|
if orig_handle:
|
2006-03-01 10:38:11 +05:30
|
|
|
person = self.db.get_person_from_handle(orig_handle)
|
|
|
|
person.family_list.remove(self.obj.handle)
|
2008-02-08 20:59:28 +05:30
|
|
|
self.db.commit_person(person, trans)
|
2006-02-06 10:33:44 +05:30
|
|
|
if new_handle:
|
2006-04-10 21:41:03 +05:30
|
|
|
person = self.db.get_person_from_handle(new_handle)
|
2006-03-09 07:25:03 +05:30
|
|
|
if self.obj.handle not in person.family_list:
|
2006-03-01 10:38:11 +05:30
|
|
|
person.family_list.append(self.obj.handle)
|
2008-02-08 20:59:28 +05:30
|
|
|
self.db.commit_person(person, trans)
|
2006-03-01 10:38:11 +05:30
|
|
|
|
2006-04-08 11:26:31 +05:30
|
|
|
def object_is_empty(self):
|
2008-06-16 20:31:46 +05:30
|
|
|
return self.obj.get_father_handle() is None and \
|
|
|
|
self.obj.get_mother_handle() is None and \
|
2006-04-13 21:46:00 +05:30
|
|
|
len(self.obj.get_child_ref_list()) == 0
|
2007-08-31 01:19:04 +05:30
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
def save(self, *obj):
|
2007-05-15 09:47:12 +05:30
|
|
|
try:
|
|
|
|
self.__do_save()
|
2008-01-08 20:57:28 +05:30
|
|
|
except bsddb_db.DBRunRecoveryError, msg:
|
2008-02-18 15:39:50 +05:30
|
|
|
RunDatabaseRepair(msg[1])
|
2006-04-08 11:26:31 +05:30
|
|
|
|
2007-05-15 09:47:12 +05:30
|
|
|
def __do_save(self):
|
2007-04-08 09:54:38 +05:30
|
|
|
self.ok_button.set_sensitive(False)
|
2007-03-07 02:48:40 +05:30
|
|
|
|
2006-03-08 05:19:26 +05:30
|
|
|
if not self.added:
|
2006-03-01 10:38:11 +05:30
|
|
|
original = self.db.get_family_from_handle(self.obj.handle)
|
2006-02-07 05:14:09 +05:30
|
|
|
else:
|
|
|
|
original = None
|
2006-02-06 03:53:53 +05:30
|
|
|
|
2006-05-27 02:18:40 +05:30
|
|
|
# do some basic checks
|
|
|
|
|
|
|
|
child_list = [ ref.ref for ref in self.obj.get_child_ref_list() ]
|
|
|
|
|
|
|
|
if self.obj.get_father_handle() in child_list:
|
|
|
|
|
2006-11-27 03:20:21 +05:30
|
|
|
father = self.db.get_person_from_handle(self.obj.get_father_handle())
|
2007-06-28 11:11:40 +05:30
|
|
|
name = "%s [%s]" % (name_displayer.display(father),
|
2006-05-27 02:18:40 +05:30
|
|
|
father.gramps_id)
|
2008-02-18 15:39:50 +05:30
|
|
|
ErrorDialog(_("A father cannot be his own child"),
|
2007-02-03 23:38:43 +05:30
|
|
|
_("%s is listed as both the father and child "
|
|
|
|
"of the family.") % name)
|
2007-04-08 09:54:38 +05:30
|
|
|
self.ok_button.set_sensitive(True)
|
2006-05-27 02:18:40 +05:30
|
|
|
return
|
|
|
|
elif self.obj.get_mother_handle() in child_list:
|
|
|
|
|
2006-11-27 03:20:21 +05:30
|
|
|
mother = self.db.get_person_from_handle(self.obj.get_mother_handle())
|
2007-06-28 11:11:40 +05:30
|
|
|
name = "%s [%s]" % (name_displayer.display(mother),
|
2006-05-27 02:18:40 +05:30
|
|
|
mother.gramps_id)
|
2008-02-18 15:39:50 +05:30
|
|
|
ErrorDialog(_("A mother cannot be her own child"),
|
2007-02-03 23:38:43 +05:30
|
|
|
_("%s is listed as both the mother and child "
|
|
|
|
"of the family.") % name)
|
2007-04-08 09:54:38 +05:30
|
|
|
self.ok_button.set_sensitive(True)
|
2006-05-27 02:18:40 +05:30
|
|
|
return
|
|
|
|
|
2007-06-22 11:27:48 +05:30
|
|
|
if not original and self.object_is_empty():
|
2008-02-18 15:39:50 +05:30
|
|
|
ErrorDialog(
|
2007-06-22 11:27:48 +05:30
|
|
|
_("Cannot save family"),
|
|
|
|
_("No data exists for this family. "
|
|
|
|
"Please enter data or cancel the edit."))
|
|
|
|
self.ok_button.set_sensitive(True)
|
2008-02-18 15:39:50 +05:30
|
|
|
return
|
|
|
|
|
|
|
|
(uses_dupe_id, id) = self._uses_duplicate_id()
|
|
|
|
if uses_dupe_id:
|
|
|
|
msg1 = _("Cannot save family. ID already exists.")
|
|
|
|
msg2 = _("You have attempted to use the existing GRAMPS ID with "
|
|
|
|
"value %(id)s. This value is already used. Please "
|
|
|
|
"enter a different ID or leave "
|
|
|
|
"blank to get the next available ID value.") % {
|
|
|
|
'id' : id}
|
|
|
|
ErrorDialog(msg1, msg2)
|
|
|
|
self.ok_button.set_sensitive(True)
|
2007-06-22 11:27:48 +05:30
|
|
|
return
|
2006-05-27 02:18:40 +05:30
|
|
|
|
2007-06-22 11:27:48 +05:30
|
|
|
# We disconnect the callbacks to all signals we connected earlier.
|
|
|
|
# This prevents the signals originating in any of the following
|
|
|
|
# commits from being caught by us again.
|
|
|
|
for key in self.signal_keys:
|
|
|
|
self.db.disconnect(key)
|
|
|
|
self.signal_keys = []
|
|
|
|
|
2006-04-01 01:16:41 +05:30
|
|
|
if not original and not self.object_is_empty():
|
2006-03-01 10:38:11 +05:30
|
|
|
trans = self.db.transaction_begin()
|
2006-03-08 05:19:26 +05:30
|
|
|
|
|
|
|
# find the father, add the family handle to the father
|
2006-03-08 03:21:08 +05:30
|
|
|
handle = self.obj.get_father_handle()
|
|
|
|
if handle:
|
|
|
|
parent = self.db.get_person_from_handle(handle)
|
|
|
|
parent.add_family_handle(self.obj.handle)
|
2008-02-08 20:59:28 +05:30
|
|
|
self.db.commit_person(parent, trans)
|
2006-03-08 03:21:08 +05:30
|
|
|
|
2006-03-08 05:19:26 +05:30
|
|
|
# find the mother, add the family handle to the mother
|
2006-03-08 03:21:08 +05:30
|
|
|
handle = self.obj.get_mother_handle()
|
|
|
|
if handle:
|
|
|
|
parent = self.db.get_person_from_handle(handle)
|
|
|
|
parent.add_family_handle(self.obj.handle)
|
2008-02-08 20:59:28 +05:30
|
|
|
self.db.commit_person(parent, trans)
|
2006-03-08 03:21:08 +05:30
|
|
|
|
2006-03-08 05:19:26 +05:30
|
|
|
# for each child, add the family handle to the child
|
2006-04-13 21:46:00 +05:30
|
|
|
for ref in self.obj.get_child_ref_list():
|
2006-04-14 18:09:17 +05:30
|
|
|
child = self.db.get_person_from_handle(ref.ref)
|
2006-03-09 07:25:03 +05:30
|
|
|
# fix - relationships need to be extracted from the list
|
2006-04-14 18:09:17 +05:30
|
|
|
child.add_parent_family_handle(self.obj.handle)
|
2008-02-08 20:59:28 +05:30
|
|
|
self.db.commit_person(child, trans)
|
2006-03-08 03:21:08 +05:30
|
|
|
|
2008-02-08 20:59:28 +05:30
|
|
|
self.db.add_family(self.obj, trans)
|
|
|
|
self.db.transaction_commit(trans, _("Add Family"))
|
2006-03-01 10:38:11 +05:30
|
|
|
elif cmp(original.serialize(),self.obj.serialize()):
|
2006-02-06 10:33:44 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
trans = self.db.transaction_begin()
|
2006-02-06 10:33:44 +05:30
|
|
|
|
|
|
|
self.fix_parent_handles(original.get_father_handle(),
|
2008-02-08 20:59:28 +05:30
|
|
|
self.obj.get_father_handle(), trans)
|
2006-02-06 10:33:44 +05:30
|
|
|
self.fix_parent_handles(original.get_mother_handle(),
|
2008-02-08 20:59:28 +05:30
|
|
|
self.obj.get_mother_handle(), trans)
|
2006-02-06 10:33:44 +05:30
|
|
|
|
2006-04-13 21:46:00 +05:30
|
|
|
orig_set = set(original.get_child_ref_list())
|
|
|
|
new_set = set(self.obj.get_child_ref_list())
|
2006-02-06 10:33:44 +05:30
|
|
|
|
|
|
|
# remove the family from children which have been removed
|
2006-04-15 11:54:35 +05:30
|
|
|
for ref in orig_set.difference(new_set):
|
|
|
|
person = self.db.get_person_from_handle(ref.ref)
|
2006-03-01 10:38:11 +05:30
|
|
|
person.remove_parent_family_handle(self.obj.handle)
|
2008-02-08 20:59:28 +05:30
|
|
|
self.db.commit_person(person, trans)
|
2006-02-06 10:33:44 +05:30
|
|
|
|
2008-02-08 19:10:04 +05:30
|
|
|
# add the family to children which have been added
|
2006-04-15 11:54:35 +05:30
|
|
|
for ref in new_set.difference(orig_set):
|
|
|
|
person = self.db.get_person_from_handle(ref.ref)
|
|
|
|
person.add_parent_family_handle(self.obj.handle)
|
2008-02-08 20:59:28 +05:30
|
|
|
self.db.commit_person(person, trans)
|
2006-02-06 10:33:44 +05:30
|
|
|
|
2006-04-01 01:16:41 +05:30
|
|
|
if self.object_is_empty():
|
2008-02-08 20:59:28 +05:30
|
|
|
self.db.remove_family(self.obj.handle, trans)
|
2006-04-01 01:16:41 +05:30
|
|
|
else:
|
2008-02-08 19:10:04 +05:30
|
|
|
if not self.obj.get_gramps_id():
|
|
|
|
self.obj.set_gramps_id(self.db.find_next_family_gramps_id())
|
2008-02-08 20:59:28 +05:30
|
|
|
self.db.commit_family(self.obj, trans)
|
|
|
|
self.db.transaction_commit(trans, _("Edit Family"))
|
2006-04-08 11:26:31 +05:30
|
|
|
|
2008-08-05 03:59:44 +05:30
|
|
|
self._do_close()
|
2006-11-12 08:42:57 +05:30
|
|
|
|
2007-12-01 21:02:05 +05:30
|
|
|
def no_name(self):
|
|
|
|
"""
|
|
|
|
Default surname guess.
|
|
|
|
"""
|
|
|
|
return ("","")
|
|
|
|
|
2007-11-30 03:37:05 +05:30
|
|
|
def north_american_child(self):
|
|
|
|
"""
|
|
|
|
If SURNAME_GUESSING is north american, then find a child
|
|
|
|
and return their name for the father.
|
|
|
|
"""
|
|
|
|
# for each child, find one with a last name
|
|
|
|
for ref in self.obj.get_child_ref_list():
|
|
|
|
child = self.db.get_person_from_handle(ref.ref)
|
|
|
|
if child:
|
|
|
|
pname = child.get_primary_name()
|
2008-02-08 20:59:28 +05:30
|
|
|
return (pname.get_surname_prefix(), pname.get_surname())
|
|
|
|
return ("", "")
|
2007-11-30 03:37:05 +05:30
|
|
|
|
2007-12-01 21:02:05 +05:30
|
|
|
def latin_american_child(self, parent):
|
|
|
|
"""
|
|
|
|
If SURNAME_GUESSING is latin american, then find a child
|
|
|
|
and return their name for the father or mother.
|
|
|
|
|
|
|
|
parent = "mother" | "father"
|
|
|
|
"""
|
|
|
|
# for each child, find one with a last name
|
|
|
|
for ref in self.obj.get_child_ref_list():
|
|
|
|
child = self.db.get_person_from_handle(ref.ref)
|
|
|
|
if child:
|
|
|
|
pname = child.get_primary_name()
|
|
|
|
prefix, surname = (pname.get_surname_prefix(),
|
|
|
|
pname.get_surname())
|
|
|
|
if " " in surname:
|
|
|
|
fsn, msn = surname.split(" ", 1)
|
|
|
|
else:
|
|
|
|
fsn, msn = surname, surname
|
|
|
|
if parent == "father":
|
2008-02-08 20:59:28 +05:30
|
|
|
return prefix, fsn
|
2007-12-01 21:02:05 +05:30
|
|
|
elif parent == "mother":
|
2008-02-08 20:59:28 +05:30
|
|
|
return prefix, msn
|
2007-12-01 21:02:05 +05:30
|
|
|
else:
|
2008-02-08 20:59:28 +05:30
|
|
|
return ("", "")
|
|
|
|
return ("", "")
|
2008-02-23 03:39:39 +05:30
|
|
|
|
|
|
|
def button_activated(event, mouse_button):
|
|
|
|
if (event.type == gtk.gdk.BUTTON_PRESS and \
|
|
|
|
event.button == mouse_button) or \
|
|
|
|
(event.type == gtk.gdk.KEY_PRESS and \
|
|
|
|
event.keyval in (_RETURN, _KP_ENTER)):
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|