2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2005-01-19 08:54:33 +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-10-20 08:17:03 +05:30
|
|
|
# $Id$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Standard python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-10-09 07:05:58 +05:30
|
|
|
import os
|
2005-03-14 03:40:40 +05:30
|
|
|
import locale
|
2005-03-08 22:48:33 +05:30
|
|
|
from gettext import gettext as _
|
2005-12-07 01:24:16 +05:30
|
|
|
from cgi import escape
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
2004-05-02 09:40:33 +05:30
|
|
|
import gobject
|
2005-04-28 10:18:30 +05:30
|
|
|
import gtk.gdk
|
2002-11-15 09:19:39 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
|
|
|
import Utils
|
2005-01-06 22:58:31 +05:30
|
|
|
import GrampsKeys
|
2004-11-29 08:54:02 +05:30
|
|
|
import GrampsMime
|
2002-10-20 19:55:16 +05:30
|
|
|
import ImageSelect
|
|
|
|
import AutoComp
|
2003-01-10 10:51:32 +05:30
|
|
|
import RelLib
|
2004-09-17 09:00:04 +05:30
|
|
|
import DateHandler
|
2005-01-01 09:57:15 +05:30
|
|
|
import NameDisplay
|
2005-04-28 10:18:30 +05:30
|
|
|
import NameEdit
|
2005-08-20 03:40:35 +05:30
|
|
|
import DisplayState
|
2005-12-07 01:24:16 +05:30
|
|
|
import GrampsDisplay
|
2006-02-08 10:38:28 +05:30
|
|
|
import GrampsWidgets
|
2006-01-29 10:00:16 +05:30
|
|
|
from DisplayTabs import *
|
2003-10-30 09:47:05 +05:30
|
|
|
|
2005-12-07 01:24:16 +05:30
|
|
|
from WindowUtils import GladeIf
|
2005-04-04 06:41:50 +05:30
|
|
|
from QuestionDialog import WarningDialog, ErrorDialog, SaveDialog, QuestionDialog2
|
2005-12-07 01:24:16 +05:30
|
|
|
from DdTargets import DdTargets
|
2005-03-26 02:35:09 +05:30
|
|
|
|
2004-08-13 10:04:07 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
_temple_names = const.lds_temple_codes.keys()
|
|
|
|
_temple_names.sort()
|
|
|
|
_temple_names = [""] + _temple_names
|
2005-04-19 09:50:17 +05:30
|
|
|
_select_gender = ((True,False,False),(False,True,False),(False,False,True))
|
2004-10-09 07:05:58 +05:30
|
|
|
_use_patronymic = [
|
|
|
|
"ru","RU","ru_RU","koi8r","ru_koi8r","russian","Russian",
|
|
|
|
]
|
2005-12-07 01:24:16 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# EditPerson class
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-08-20 03:40:35 +05:30
|
|
|
class EditPerson(DisplayState.ManagedWindow):
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-12-01 09:45:08 +05:30
|
|
|
use_patronymic = locale.getlocale(locale.LC_TIME)[0] in _use_patronymic
|
2005-12-23 05:13:32 +05:30
|
|
|
|
2005-12-14 12:24:02 +05:30
|
|
|
def __init__(self,state,uistate,track,person,callback=None):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""Creates an edit window. Associates a person with the window."""
|
2004-02-14 11:10:30 +05:30
|
|
|
|
2005-08-20 03:40:35 +05:30
|
|
|
self.dp = DateHandler.parser
|
|
|
|
self.dd = DateHandler.displayer
|
|
|
|
self.nd = NameDisplay.displayer
|
|
|
|
|
2006-02-03 11:01:42 +05:30
|
|
|
self.person = person
|
|
|
|
self.orig_handle = self.person.get_handle()
|
2006-02-03 09:32:12 +05:30
|
|
|
if self.orig_handle:
|
|
|
|
self.person = state.db.get_person_from_handle(self.orig_handle)
|
2005-12-22 01:18:18 +05:30
|
|
|
|
2006-02-03 09:32:12 +05:30
|
|
|
DisplayState.ManagedWindow.__init__(self, uistate, track, self.person)
|
2005-08-20 03:40:35 +05:30
|
|
|
|
|
|
|
if self.already_exist:
|
|
|
|
return
|
|
|
|
|
2006-01-29 10:00:16 +05:30
|
|
|
self.dbstate = state
|
2005-08-11 05:23:24 +05:30
|
|
|
self.uistate = uistate
|
2005-02-27 11:21:59 +05:30
|
|
|
self.retval = const.UPDATE_PERSON
|
|
|
|
|
2005-07-09 01:54:54 +05:30
|
|
|
self.orig_surname = self.person.get_primary_name().get_group_name()
|
2006-01-29 10:00:16 +05:30
|
|
|
self.db = self.dbstate.db
|
2002-10-20 19:55:16 +05:30
|
|
|
self.callback = callback
|
2003-06-13 20:38:07 +05:30
|
|
|
self.pdmap = {}
|
2002-10-20 19:55:16 +05:30
|
|
|
self.add_places = []
|
2005-06-09 02:42:32 +05:30
|
|
|
self.should_guess_gender = (not person.get_gramps_id() and
|
2004-02-14 11:10:30 +05:30
|
|
|
person.get_gender () ==
|
2005-05-31 02:11:43 +05:30
|
|
|
RelLib.Person.UNKNOWN)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-08-10 19:58:16 +05:30
|
|
|
for key in self.db.get_place_handles():
|
|
|
|
p = self.db.get_place_from_handle(key).get_display_info()
|
2003-06-13 20:38:07 +05:30
|
|
|
self.pdmap[p[0]] = key
|
2005-02-18 10:19:59 +05:30
|
|
|
|
|
|
|
mod = not self.db.readonly
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.load_obj = None
|
2005-04-23 21:23:30 +05:30
|
|
|
self.top = gtk.glade.XML(const.editPersonFile, "edit_person","gramps")
|
2005-12-07 01:24:16 +05:30
|
|
|
self.window = self.top.get_widget("edit_person")
|
|
|
|
self.gladeif = GladeIf(self.top)
|
* src/SourceView.py (button_press,on_add_clicked,on_delete_clicked,
on_edit_clicked): Pass parent window to the child dialog.
* src/Sources.py (add_src_clicked): Likewise.
* src/EditSource.py (__init__): Add optional parent_window argument.
Make dialog modal and transient for its parent.
* src/gramps.glade (sourceEditor dialog): Delete unneeded handlers
for buttons.
* src/QuestionDialog.py (SaveDialog,QuestionDialog,OptionDialog,
ErrorDialog,WarningDialog,MissingMediaDialog): Set transient status
if parent is given.
* src/EventEdit.py (__init__): Make dialog modal and transient for
its parent.
* src/Witness.py: Make WittnessEditor dialog modal and transient for
its parent. Call SelectPerson with itself as a parent.
* src/SelectPerson.py (__init__): Make dialog transient for its parent.
* src/imagesel.glade: Define proper responses and delete unneeded handlers
for buttons. Make gtkFileEntry modal.
* src/dialog.glade (all dialogs): Define proper responses for buttons.
* src/EditPerson.py (on_add_aka_clicked, on_aka_update_clicked):
Call NameEdit with itself as a parent; (on_add_attr_clicked,
on_update_attr_clicked): Call AttributeEditor with itself as a parent;
(on_add_addr_clicked,on_update_addr_clicked): Call AddressEditor with
itself as a parent; (on_add_url_clicked,on_update_url_clicked): Call
UrlEditor with itself as a parent; (on_name_note_clicked,
on_ldsbap_note_clicked,on_ldsendow_note_clicked,
on_ldsseal_note_clicked): Call NoteEditor with itself as a parent.
* src/NameEdit.py (__init__): Make dialog modal and transient for
its parent.
* src/AttrEdit.py (__init__): Likewise.
* src/AddrEdit.py (__init__): Likewise.
* src/UrlEdit.py (__init__): Likewise.
* src/NoteEdit.py (__init__): Likewise.
svn: r2131
2003-09-15 09:41:30 +05:30
|
|
|
self.window.set_title("%s - GRAMPS" % _('Edit Person'))
|
|
|
|
|
2005-12-07 01:24:16 +05:30
|
|
|
self.marker = self.top.get_widget('marker')
|
2005-09-16 20:55:27 +05:30
|
|
|
self.marker.set_sensitive(mod)
|
|
|
|
if person:
|
|
|
|
try:
|
|
|
|
defval = person.get_marker()[0]
|
|
|
|
except:
|
|
|
|
defval = (RelLib.PrimaryObject.MARKER_NONE,"")
|
|
|
|
else:
|
|
|
|
defval = None
|
|
|
|
self.marker_type_selector = AutoComp.StandardCustomSelector(
|
|
|
|
Utils.marker_types, self.marker,
|
|
|
|
RelLib.PrimaryObject.MARKER_CUSTOM, defval)
|
|
|
|
|
2005-12-07 01:24:16 +05:30
|
|
|
self.gender = self.top.get_widget('gender')
|
2005-04-19 09:50:17 +05:30
|
|
|
self.gender.set_sensitive(mod)
|
2006-02-08 10:38:28 +05:30
|
|
|
self.private = GrampsWidgets.PrivacyButton(self.top.get_widget('private'),
|
|
|
|
self.person)
|
|
|
|
|
2005-12-07 01:24:16 +05:30
|
|
|
self.ntype_field = self.top.get_widget("ntype")
|
|
|
|
self.ntype_field.set_sensitive(mod)
|
2006-01-29 10:00:16 +05:30
|
|
|
|
|
|
|
self.vbox = self.top.get_widget('vbox')
|
2005-12-07 01:24:16 +05:30
|
|
|
self.suffix = self.top.get_widget("suffix")
|
2005-02-18 10:19:59 +05:30
|
|
|
self.suffix.set_editable(mod)
|
2005-12-07 01:24:16 +05:30
|
|
|
self.prefix = self.top.get_widget("prefix")
|
2005-02-18 10:19:59 +05:30
|
|
|
self.prefix.set_editable(mod)
|
2005-12-14 06:53:23 +05:30
|
|
|
self.given = self.top.get_widget("given_name")
|
2005-02-18 10:19:59 +05:30
|
|
|
self.given.set_editable(mod)
|
2005-12-07 01:24:16 +05:30
|
|
|
self.title = self.top.get_widget("title")
|
2005-02-18 10:19:59 +05:30
|
|
|
self.title.set_editable(mod)
|
2005-12-07 01:24:16 +05:30
|
|
|
self.surname = self.top.get_widget("surname")
|
2005-02-18 10:19:59 +05:30
|
|
|
self.surname.set_editable(mod)
|
2005-12-07 01:24:16 +05:30
|
|
|
self.gid = self.top.get_widget("gid")
|
2005-02-18 10:19:59 +05:30
|
|
|
self.gid.set_editable(mod)
|
2005-12-07 01:24:16 +05:30
|
|
|
|
|
|
|
self.person_photo = self.top.get_widget("personPix")
|
|
|
|
self.eventbox = self.top.get_widget("eventbox1")
|
|
|
|
self.prefix_label = self.top.get_widget('prefix_label')
|
2004-10-09 07:05:58 +05:30
|
|
|
|
|
|
|
if self.use_patronymic:
|
|
|
|
self.prefix_label.set_text(_('Patronymic:'))
|
|
|
|
self.prefix_label.set_use_underline(True)
|
|
|
|
|
2005-05-27 10:37:26 +05:30
|
|
|
self.birth_ref = person.get_birth_ref()
|
|
|
|
self.death_ref = person.get_death_ref()
|
2005-03-14 03:40:40 +05:30
|
|
|
|
2006-02-03 11:01:42 +05:30
|
|
|
self.pname = RelLib.Name(self.person.get_primary_name())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-02-03 11:01:42 +05:30
|
|
|
self.gender.set_active(self.person.get_gender())
|
2005-04-19 09:50:17 +05:30
|
|
|
|
2004-05-02 09:40:33 +05:30
|
|
|
self.place_list = self.pdmap.keys()
|
|
|
|
self.place_list.sort()
|
|
|
|
|
2004-08-13 10:04:07 +05:30
|
|
|
build_dropdown(self.surname,self.db.get_surname_list())
|
2004-08-19 09:14:10 +05:30
|
|
|
|
2006-02-03 11:01:42 +05:30
|
|
|
gid = self.person.get_gramps_id()
|
2004-08-19 09:14:10 +05:30
|
|
|
if gid:
|
|
|
|
self.gid.set_text(gid)
|
2005-04-28 10:18:30 +05:30
|
|
|
self.gid.set_editable(True)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-01-29 10:00:16 +05:30
|
|
|
# self.lds_baptism = RelLib.LdsOrd(self.person.get_lds_baptism())
|
|
|
|
# self.lds_endowment = RelLib.LdsOrd(self.person.get_lds_endowment())
|
|
|
|
# self.lds_sealing = RelLib.LdsOrd(self.person.get_lds_sealing())
|
|
|
|
|
|
|
|
# if GrampsKeys.get_uselds() \
|
|
|
|
# or (not self.lds_baptism.is_empty()) \
|
|
|
|
# or (not self.lds_endowment.is_empty()) \
|
|
|
|
# or (not self.lds_sealing.is_empty()):
|
|
|
|
# self.top.get_widget("lds_tab").show()
|
|
|
|
# self.top.get_widget("lds_page").show()
|
|
|
|
# if (not self.lds_baptism.is_empty()) \
|
|
|
|
# or (not self.lds_endowment.is_empty()) \
|
|
|
|
# or (not self.lds_sealing.is_empty()):
|
|
|
|
# Utils.bold_label(self.lds_tab)
|
|
|
|
# else:
|
|
|
|
# self.top.get_widget("lds_tab").hide()
|
|
|
|
# self.top.get_widget("lds_page").hide()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-06-01 18:44:29 +05:30
|
|
|
self.ntype_selector = \
|
|
|
|
AutoComp.StandardCustomSelector(Utils.name_types,
|
|
|
|
self.ntype_field,
|
|
|
|
RelLib.Name.CUSTOM,
|
|
|
|
RelLib.Name.BIRTH)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.write_primary_name()
|
|
|
|
self.load_person_image()
|
|
|
|
|
2005-12-14 06:53:23 +05:30
|
|
|
self.gladeif.connect("edit_person", "delete_event", self.on_delete_event)
|
2005-12-07 01:24:16 +05:30
|
|
|
self.gladeif.connect("button15", "clicked", self.on_cancel_edit)
|
|
|
|
self.gladeif.connect("ok", "clicked", self.on_apply_person_clicked)
|
|
|
|
self.gladeif.connect("button134", "clicked", self.on_help_clicked)
|
2006-01-30 10:31:21 +05:30
|
|
|
self.gladeif.connect("given_name", "focus_out_event",
|
|
|
|
self.on_given_focus_out_event)
|
2005-12-07 01:24:16 +05:30
|
|
|
self.gladeif.connect("button177", "clicked", self.on_edit_name_clicked)
|
2003-10-29 10:34:43 +05:30
|
|
|
|
2004-11-29 08:54:02 +05:30
|
|
|
self.eventbox.connect('button-press-event',self.image_button_press)
|
|
|
|
|
2006-01-31 20:43:54 +05:30
|
|
|
self._create_tabbed_pages()
|
|
|
|
|
2006-02-09 06:05:46 +05:30
|
|
|
self.surname.grab_focus()
|
2006-01-31 20:43:54 +05:30
|
|
|
self.show()
|
|
|
|
|
|
|
|
def _add_page(self,page):
|
|
|
|
self.notebook.insert_page(page)
|
|
|
|
self.notebook.set_tab_label(page,page.get_tab_widget())
|
|
|
|
return page
|
|
|
|
|
|
|
|
def _create_tabbed_pages(self):
|
|
|
|
"""
|
|
|
|
Creates the notebook tabs and inserts them into the main
|
|
|
|
window.
|
|
|
|
|
|
|
|
"""
|
2006-01-29 10:00:16 +05:30
|
|
|
self.notebook = gtk.Notebook()
|
|
|
|
|
2006-01-31 20:43:54 +05:30
|
|
|
self.event_list = self._add_page(PersonEventEmbedList(
|
|
|
|
self.dbstate,self.uistate, self.track,self.person))
|
|
|
|
|
|
|
|
self.name_list = self._add_page(NameEmbedList(
|
|
|
|
self.dbstate, self.uistate, self.track,
|
|
|
|
self.person.get_alternate_names()))
|
|
|
|
self.srcref_list = self._add_page(SourceEmbedList(
|
|
|
|
self.dbstate,self.uistate, self.track,
|
|
|
|
self.person.source_list))
|
|
|
|
self.attr_list = self._add_page(AttrEmbedList(
|
|
|
|
self.dbstate,self.uistate,self.track,
|
|
|
|
self.person.get_attribute_list()))
|
|
|
|
self.addr_list = self._add_page(AddrEmbedList(
|
|
|
|
self.dbstate,self.uistate,self.track,
|
|
|
|
self.person.get_address_list()))
|
|
|
|
self.note_tab = self._add_page(NoteTab(
|
|
|
|
self.dbstate, self.uistate, self.track,
|
|
|
|
self.person.get_note_object()))
|
|
|
|
self.gallery_tab = self._add_page(GalleryTab(
|
|
|
|
self.dbstate, self.uistate, self.track,
|
|
|
|
self.person.get_media_list()))
|
|
|
|
self.web_list = self._add_page(WebEmbedList(
|
|
|
|
self.dbstate,self.uistate,self.track,
|
|
|
|
self.person.get_url_list()))
|
2005-02-17 04:19:54 +05:30
|
|
|
|
2006-01-31 20:43:54 +05:30
|
|
|
self.notebook.show_all()
|
|
|
|
self.vbox.pack_start(self.notebook,True)
|
2003-03-14 11:16:02 +05:30
|
|
|
|
2005-12-23 05:13:32 +05:30
|
|
|
def build_menu_names(self,person):
|
|
|
|
win_menu_label = self.nd.display(person)
|
|
|
|
if not win_menu_label.strip():
|
|
|
|
win_menu_label = _("New Person")
|
2005-12-24 01:06:53 +05:30
|
|
|
return (_('Edit Person'),win_menu_label)
|
2005-12-23 05:13:32 +05:30
|
|
|
|
2005-12-24 01:39:02 +05:30
|
|
|
def build_window_key(self,person):
|
|
|
|
if person:
|
|
|
|
return person.get_handle()
|
2005-12-23 05:13:32 +05:30
|
|
|
else:
|
2005-12-24 01:39:02 +05:30
|
|
|
return id(self)
|
2005-12-23 05:13:32 +05:30
|
|
|
|
2005-12-07 01:24:16 +05:30
|
|
|
def set_list_dnd(self,obj, get, begin, receive):
|
|
|
|
obj.drag_dest_set(gtk.DEST_DEFAULT_ALL, [DdTargets.NAME.target()],
|
|
|
|
gtk.gdk.ACTION_COPY)
|
|
|
|
obj.drag_source_set(gtk.gdk.BUTTON1_MASK,[DdTargets.NAME.target()],
|
|
|
|
gtk.gdk.ACTION_COPY)
|
|
|
|
obj.connect('drag_data_get', get)
|
|
|
|
obj.connect('drag_begin', begin)
|
|
|
|
if not self.db.readonly:
|
|
|
|
obj.connect('drag_data_received', receive)
|
|
|
|
|
2005-05-11 22:55:14 +05:30
|
|
|
def build_pdmap(self):
|
|
|
|
self.pdmap.clear()
|
|
|
|
cursor = self.db.get_place_cursor()
|
|
|
|
data = cursor.next()
|
|
|
|
while data:
|
2005-06-05 09:31:56 +05:30
|
|
|
if data[1][2]:
|
|
|
|
self.pdmap[data[1][2]] = data[0]
|
2005-05-11 22:55:14 +05:30
|
|
|
data = cursor.next()
|
|
|
|
cursor.close()
|
|
|
|
|
2004-11-29 08:54:02 +05:30
|
|
|
def image_button_press(self,obj,event):
|
|
|
|
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
|
|
|
|
|
|
|
media_list = self.person.get_media_list()
|
|
|
|
if media_list:
|
|
|
|
ph = media_list[0]
|
|
|
|
object_handle = ph.get_reference_handle()
|
|
|
|
obj = self.db.get_object_from_handle(object_handle)
|
2005-02-16 11:11:33 +05:30
|
|
|
ImageSelect.LocalMediaProperties(ph,obj.get_path(),
|
|
|
|
self,self.window)
|
|
|
|
|
2004-11-29 08:54:02 +05:30
|
|
|
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
|
|
|
media_list = self.person.get_media_list()
|
|
|
|
if media_list:
|
|
|
|
ph = media_list[0]
|
|
|
|
self.show_popup(ph,event)
|
|
|
|
|
|
|
|
def show_popup(self, photo, event):
|
|
|
|
"""Look for right-clicks on a picture and create a popup
|
|
|
|
menu of the available actions."""
|
|
|
|
|
|
|
|
menu = gtk.Menu()
|
|
|
|
menu.set_title(_("Media Object"))
|
|
|
|
obj = self.db.get_object_from_handle(photo.get_reference_handle())
|
|
|
|
mtype = obj.get_mime_type()
|
|
|
|
progname = GrampsMime.get_application(mtype)
|
|
|
|
|
|
|
|
if progname and len(progname) > 1:
|
|
|
|
Utils.add_menuitem(menu,_("Open in %s") % progname[1],
|
|
|
|
photo,self.popup_view_photo)
|
2005-05-24 18:38:06 +05:30
|
|
|
if mtype and mtype.startswith("image"):
|
2004-11-29 08:54:02 +05:30
|
|
|
Utils.add_menuitem(menu,_("Edit with the GIMP"),
|
|
|
|
photo,self.popup_edit_photo)
|
|
|
|
Utils.add_menuitem(menu,_("Edit Object Properties"),photo,
|
|
|
|
self.popup_change_description)
|
|
|
|
menu.popup(None,None,None,event.button,event.time)
|
|
|
|
|
|
|
|
def popup_view_photo(self, obj):
|
|
|
|
"""Open this picture in a picture viewer"""
|
|
|
|
media_list = self.person.get_media_list()
|
|
|
|
if media_list:
|
|
|
|
ph = media_list[0]
|
|
|
|
object_handle = ph.get_reference_handle()
|
|
|
|
Utils.view_photo(self.db.get_object_from_handle(object_handle))
|
|
|
|
|
|
|
|
def popup_edit_photo(self, obj):
|
|
|
|
"""Open this picture in a picture editor"""
|
|
|
|
media_list = self.person.get_media_list()
|
|
|
|
if media_list:
|
|
|
|
ph = media_list[0]
|
|
|
|
object_handle = ph.get_reference_handle()
|
|
|
|
if os.fork() == 0:
|
|
|
|
obj = self.db.get_object_from_handle(object_handle)
|
|
|
|
os.execvp(const.editor,[const.editor, obj.get_path()])
|
|
|
|
|
|
|
|
def popup_change_description(self,obj):
|
|
|
|
media_list = self.person.get_media_list()
|
|
|
|
if media_list:
|
|
|
|
ph = media_list[0]
|
|
|
|
object_handle = ph.get_reference_handle()
|
|
|
|
obj = self.db.get_object_from_handle(object_handle)
|
2005-04-28 10:18:30 +05:30
|
|
|
ImageSelect.LocalMediaProperties(ph,obj.get_path(),self,
|
|
|
|
self.window)
|
2004-11-29 08:54:02 +05:30
|
|
|
|
2003-11-18 09:56:06 +05:30
|
|
|
def on_help_clicked(self,obj):
|
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
2005-12-07 01:24:16 +05:30
|
|
|
GrampsDisplay.help('adv-pers')
|
2003-11-18 09:56:06 +05:30
|
|
|
|
2003-06-24 19:46:47 +05:30
|
|
|
def on_gender_activate (self, button):
|
2004-09-20 08:42:51 +05:30
|
|
|
self.should_guess_gender = False
|
2003-06-24 19:46:47 +05:30
|
|
|
|
2004-10-01 00:02:56 +05:30
|
|
|
def on_given_focus_out_event (self, entry, event):
|
2003-06-24 19:46:47 +05:30
|
|
|
if not self.should_guess_gender:
|
|
|
|
return
|
|
|
|
|
2005-06-09 02:42:32 +05:30
|
|
|
gender = self.db.genderStats.guess_gender(unicode(entry.get_text ()))
|
|
|
|
self.gender.set_active( gender)
|
|
|
|
|
2003-11-17 06:11:32 +05:30
|
|
|
def build_menu(self,list,task,opt_menu,type):
|
2005-01-07 10:04:02 +05:30
|
|
|
cell = gtk.CellRendererText()
|
|
|
|
opt_menu.pack_start(cell,True)
|
|
|
|
opt_menu.add_attribute(cell,'text',0)
|
|
|
|
|
|
|
|
store = gtk.ListStore(str)
|
2002-10-20 19:55:16 +05:30
|
|
|
for val in list:
|
2005-01-07 10:04:02 +05:30
|
|
|
store.append(row=[val])
|
|
|
|
opt_menu.set_model(store)
|
|
|
|
opt_menu.connect('changed',task)
|
|
|
|
opt_menu.set_active(type)
|
2005-02-23 10:00:08 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def on_cancel_edit(self,obj):
|
|
|
|
"""If the data has changed, give the user a chance to cancel
|
|
|
|
the close window"""
|
2004-11-11 09:58:40 +05:30
|
|
|
|
2005-12-07 01:24:16 +05:30
|
|
|
if not self.db.readonly and self.did_data_change() and not GrampsKeys.get_dont_ask():
|
|
|
|
n = "<i>%s</i>" % escape(self.nd.display(self.person))
|
2003-05-24 09:10:58 +05:30
|
|
|
SaveDialog(_('Save changes to %s?') % n,
|
2003-02-24 10:21:57 +05:30
|
|
|
_('If you close without saving, the changes you '
|
|
|
|
'have made will be lost'),
|
|
|
|
self.cancel_callback,
|
|
|
|
self.save)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-08-04 10:23:29 +05:30
|
|
|
self.close()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-02-24 10:21:57 +05:30
|
|
|
def save(self):
|
|
|
|
self.on_apply_person_clicked(None)
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def on_delete_event(self,obj,b):
|
|
|
|
"""If the data has changed, give the user a chance to cancel
|
|
|
|
the close window"""
|
2005-12-07 01:24:16 +05:30
|
|
|
if not self.db.readonly and self.did_data_change() and not GrampsKeys.get_dont_ask():
|
|
|
|
n = "<i>%s</i>" % escape(self.nd.display(self.person))
|
2003-05-24 09:10:58 +05:30
|
|
|
SaveDialog(_('Save Changes to %s?') % n,
|
2003-02-24 10:21:57 +05:30
|
|
|
_('If you close without saving, the changes you '
|
|
|
|
'have made will be lost'),
|
|
|
|
self.cancel_callback,
|
|
|
|
self.save)
|
2004-09-20 08:42:51 +05:30
|
|
|
return True
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-08-04 10:23:29 +05:30
|
|
|
self.close()
|
2004-09-20 08:42:51 +05:30
|
|
|
return False
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def cancel_callback(self):
|
|
|
|
"""If the user answered yes to abandoning changes, close the window"""
|
2004-08-04 10:23:29 +05:30
|
|
|
self.close()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def did_data_change(self):
|
|
|
|
"""Check to see if any of the data has changed from the
|
2004-03-09 10:42:14 +05:30
|
|
|
orig record"""
|
2003-09-21 01:26:27 +05:30
|
|
|
|
2006-01-29 10:00:16 +05:30
|
|
|
return False
|
2004-05-02 09:40:33 +05:30
|
|
|
surname = unicode(self.surname.get_text())
|
2003-12-17 10:53:16 +05:30
|
|
|
|
2005-06-01 18:44:29 +05:30
|
|
|
ntype = self.ntype_selector.get_values()
|
2003-12-17 10:53:16 +05:30
|
|
|
suffix = unicode(self.suffix.get_text())
|
|
|
|
prefix = unicode(self.prefix.get_text())
|
|
|
|
given = unicode(self.given.get_text())
|
|
|
|
title = unicode(self.title.get_text())
|
2005-02-27 11:21:59 +05:30
|
|
|
|
2003-12-17 10:53:16 +05:30
|
|
|
idval = unicode(self.gid.get_text())
|
2004-08-27 03:24:14 +05:30
|
|
|
if idval == "":
|
|
|
|
idval = None
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-09-20 08:42:51 +05:30
|
|
|
changed = False
|
2004-02-14 11:10:30 +05:30
|
|
|
name = self.person.get_primary_name()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-02-20 03:41:51 +05:30
|
|
|
if self.private.get_active() != self.person.get_privacy():
|
|
|
|
changed = True
|
2005-02-19 10:11:59 +05:30
|
|
|
|
|
|
|
if self.person.get_gramps_id() != idval:
|
|
|
|
changed = True
|
|
|
|
if suffix != name.get_suffix():
|
|
|
|
changed = True
|
|
|
|
if self.use_patronymic:
|
|
|
|
if prefix != name.get_patronymic():
|
|
|
|
changed = True
|
|
|
|
elif prefix != name.get_surname_prefix():
|
|
|
|
changed = True
|
|
|
|
if surname.upper() != name.get_surname().upper():
|
|
|
|
changed = True
|
2005-06-01 18:44:29 +05:30
|
|
|
if ntype != name.get_type():
|
2005-02-19 10:11:59 +05:30
|
|
|
changed = True
|
|
|
|
if given != name.get_first_name():
|
|
|
|
changed = True
|
|
|
|
if title != name.get_title():
|
|
|
|
changed = True
|
|
|
|
if self.pname.get_note() != name.get_note():
|
|
|
|
changed = True
|
2006-02-09 02:43:05 +05:30
|
|
|
# if self.check_lds():
|
2006-02-02 10:50:42 +05:30
|
|
|
# changed = True
|
2005-02-19 10:11:59 +05:30
|
|
|
|
2005-04-19 09:50:17 +05:30
|
|
|
(female,male,unknown) = _select_gender[self.gender.get_active()]
|
|
|
|
|
2005-05-31 02:11:43 +05:30
|
|
|
if male and self.person.get_gender() != RelLib.Person.MALE:
|
2005-02-19 10:11:59 +05:30
|
|
|
changed = True
|
2005-05-31 02:11:43 +05:30
|
|
|
elif female and self.person.get_gender() != RelLib.Person.FEMALE:
|
2005-02-19 10:11:59 +05:30
|
|
|
changed = True
|
2005-05-31 02:11:43 +05:30
|
|
|
elif unknown and self.person.get_gender() != RelLib.Person.UNKNOWN:
|
2005-02-19 10:11:59 +05:30
|
|
|
changed = True
|
|
|
|
|
2006-02-09 02:43:05 +05:30
|
|
|
# if not self.lds_baptism.are_equal(self.person.get_lds_baptism()):
|
|
|
|
# changed= True
|
2005-02-19 10:11:59 +05:30
|
|
|
|
2006-02-09 02:43:05 +05:30
|
|
|
# if not self.lds_endowment.are_equal(self.person.get_lds_endowment()):
|
|
|
|
# changed = True
|
2005-02-19 10:11:59 +05:30
|
|
|
|
2006-02-09 02:43:05 +05:30
|
|
|
# if not self.lds_sealing.are_equal(self.person.get_lds_sealing()):
|
|
|
|
# changed = True
|
2005-02-19 10:11:59 +05:30
|
|
|
|
|
|
|
return changed
|
|
|
|
|
2006-02-02 10:50:42 +05:30
|
|
|
# def check_lds(self):
|
|
|
|
# date_str = unicode(self.ldsbap_date.get_text())
|
|
|
|
# DateHandler.set_date(self.lds_baptism,date_str)
|
|
|
|
# temple = _temple_names[self.ldsbap_temple.get_active()]
|
|
|
|
# if const.lds_temple_codes.has_key(temple):
|
|
|
|
# self.lds_baptism.set_temple(const.lds_temple_codes[temple])
|
|
|
|
# else:
|
|
|
|
# self.lds_baptism.set_temple("")
|
|
|
|
# self.lds_baptism.set_place_handle(self.get_place(self.ldsbapplace,1))
|
|
|
|
|
|
|
|
# date_str = unicode(self.ldsend_date.get_text())
|
|
|
|
# DateHandler.set_date(self.lds_endowment,date_str)
|
|
|
|
# temple = _temple_names[self.ldsend_temple.get_active()]
|
|
|
|
# if const.lds_temple_codes.has_key(temple):
|
|
|
|
# self.lds_endowment.set_temple(const.lds_temple_codes[temple])
|
|
|
|
# else:
|
|
|
|
# self.lds_endowment.set_temple("")
|
|
|
|
# self.lds_endowment.set_place_handle(self.get_place(self.ldsendowplace,1))
|
|
|
|
|
|
|
|
# date_str = unicode(self.ldsseal_date.get_text())
|
|
|
|
# DateHandler.set_date(self.lds_sealing,date_str)
|
|
|
|
# temple = _temple_names[self.ldsseal_temple.get_active()]
|
|
|
|
# if const.lds_temple_codes.has_key(temple):
|
|
|
|
# self.lds_sealing.set_temple(const.lds_temple_codes[temple])
|
|
|
|
# else:
|
|
|
|
# self.lds_sealing.set_temple("")
|
|
|
|
# self.lds_sealing.set_family_handle(self.ldsfam)
|
|
|
|
# self.lds_sealing.set_place_handle(self.get_place(self.ldssealplace,1))
|
2005-02-19 10:11:59 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def load_photo(self,photo):
|
|
|
|
"""loads, scales, and displays the person's main photo"""
|
|
|
|
self.load_obj = photo
|
|
|
|
if photo == None:
|
2004-11-29 08:54:02 +05:30
|
|
|
self.person_photo.hide()
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
try:
|
2005-04-28 10:18:30 +05:30
|
|
|
i = gtk.gdk.pixbuf_new_from_file(photo)
|
2002-10-20 19:55:16 +05:30
|
|
|
ratio = float(max(i.get_height(),i.get_width()))
|
2005-04-19 09:50:17 +05:30
|
|
|
scale = float(100.0)/ratio
|
2002-10-20 19:55:16 +05:30
|
|
|
x = int(scale*(i.get_width()))
|
|
|
|
y = int(scale*(i.get_height()))
|
2005-04-28 10:18:30 +05:30
|
|
|
i = i.scale_simple(x,y,gtk.gdk.INTERP_BILINEAR)
|
2004-11-29 08:54:02 +05:30
|
|
|
self.person_photo.set_from_pixbuf(i)
|
|
|
|
self.person_photo.show()
|
2002-10-20 19:55:16 +05:30
|
|
|
except:
|
2004-11-29 08:54:02 +05:30
|
|
|
self.person_photo.hide()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-02-03 09:32:12 +05:30
|
|
|
def _check_for_unknown_gender(self):
|
2005-05-31 02:11:43 +05:30
|
|
|
if self.gender.get_active() == RelLib.Person.UNKNOWN:
|
2005-04-04 06:41:50 +05:30
|
|
|
dialog = QuestionDialog2(
|
|
|
|
_("Unknown gender specified"),
|
|
|
|
_("The gender of the person is currently unknown. "
|
|
|
|
"Usually, this is a mistake. You may choose to "
|
|
|
|
"either continue saving, or returning to the "
|
|
|
|
"Edit Person dialog to fix the problem."),
|
|
|
|
_("Continue saving"), _("Return to window"),
|
|
|
|
self.window)
|
|
|
|
if not dialog.run():
|
2006-02-03 09:32:12 +05:30
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
def _check_and_update_id(self):
|
2003-12-17 10:53:16 +05:30
|
|
|
idval = unicode(self.gid.get_text())
|
2004-06-27 08:40:06 +05:30
|
|
|
if idval != self.person.get_gramps_id():
|
2004-08-07 10:46:57 +05:30
|
|
|
person = self.db.get_person_from_gramps_id(idval)
|
2004-07-09 10:01:43 +05:30
|
|
|
if not person:
|
2004-06-27 08:40:06 +05:30
|
|
|
self.person.set_gramps_id(idval)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2005-08-18 11:28:28 +05:30
|
|
|
n = self.nd.display(person)
|
2002-10-20 19:55:16 +05:30
|
|
|
msg1 = _("GRAMPS ID value was not changed.")
|
2003-02-27 05:59:37 +05:30
|
|
|
msg2 = _("You have attempted to change the GRAMPS ID to a value "
|
|
|
|
"of %(grampsid)s. This value is already used by %(person)s.") % {
|
2002-10-20 19:55:16 +05:30
|
|
|
'grampsid' : idval,
|
|
|
|
'person' : n }
|
2003-02-27 05:59:37 +05:30
|
|
|
WarningDialog(msg1,msg2)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-02-03 09:32:12 +05:30
|
|
|
def _update_primary_name(self):
|
|
|
|
surname = unicode(self.surname.get_text())
|
|
|
|
suffix = unicode(self.suffix.get_text())
|
|
|
|
prefix = unicode(self.prefix.get_text())
|
|
|
|
ntype = self.ntype_selector.get_values()
|
|
|
|
given = unicode(self.given.get_text())
|
|
|
|
title = unicode(self.title.get_text())
|
|
|
|
|
|
|
|
name = self.pname
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if suffix != name.get_suffix():
|
|
|
|
name.set_suffix(suffix)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-10-09 07:05:58 +05:30
|
|
|
if self.use_patronymic:
|
|
|
|
if prefix != name.get_patronymic():
|
|
|
|
name.set_patronymic(prefix)
|
|
|
|
else:
|
|
|
|
if prefix != name.get_surname_prefix():
|
|
|
|
name.set_surname_prefix(prefix)
|
2005-12-07 01:24:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if surname != name.get_surname():
|
|
|
|
name.set_surname(surname)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if given != name.get_first_name():
|
|
|
|
name.set_first_name(given)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if title != name.get_title():
|
|
|
|
name.set_title(title)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
name.set_source_reference_list(self.pname.get_source_references())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-10-09 07:05:58 +05:30
|
|
|
if name != self.person.get_primary_name():
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person.set_primary_name(name)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
|
2006-02-03 09:32:12 +05:30
|
|
|
def _update_family_ids(self, trans):
|
2002-10-20 19:55:16 +05:30
|
|
|
# Update each of the families child lists to reflect any
|
|
|
|
# change in ordering due to the new birth date
|
2004-07-28 07:59:07 +05:30
|
|
|
family = self.person.get_main_parents_family_handle()
|
2002-10-20 19:55:16 +05:30
|
|
|
if (family):
|
2004-08-11 09:12:38 +05:30
|
|
|
f = self.db.find_family_from_handle(family,trans)
|
2004-07-28 07:59:07 +05:30
|
|
|
new_order = self.reorder_child_list(self.person,f.get_child_handle_list())
|
|
|
|
f.set_child_handle_list(new_order)
|
|
|
|
for (family, rel1, rel2) in self.person.get_parent_family_handle_list():
|
2004-08-11 09:12:38 +05:30
|
|
|
f = self.db.find_family_from_handle(family,trans)
|
2004-07-28 07:59:07 +05:30
|
|
|
new_order = self.reorder_child_list(self.person,f.get_child_handle_list())
|
|
|
|
f.set_child_handle_list(new_order)
|
2005-04-23 21:23:30 +05:30
|
|
|
|
2004-09-20 08:42:51 +05:30
|
|
|
error = False
|
2005-04-19 09:50:17 +05:30
|
|
|
(female,male,unknown) = _select_gender[self.gender.get_active()]
|
2005-05-31 02:11:43 +05:30
|
|
|
if male and self.person.get_gender() != RelLib.Person.MALE:
|
|
|
|
self.person.set_gender(RelLib.Person.MALE)
|
2005-04-26 21:34:21 +05:30
|
|
|
for temp_family_handle in self.person.get_family_handle_list():
|
|
|
|
temp_family = self.db.get_family_from_handle(temp_family_handle)
|
2004-07-28 07:59:07 +05:30
|
|
|
if self.person == temp_family.get_mother_handle():
|
|
|
|
if temp_family.get_father_handle() != None:
|
2004-09-20 08:42:51 +05:30
|
|
|
error = True
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-07-28 07:59:07 +05:30
|
|
|
temp_family.set_mother_handle(None)
|
|
|
|
temp_family.set_father_handle(self.person)
|
2005-05-31 02:11:43 +05:30
|
|
|
elif female and self.person.get_gender() != RelLib.Person.FEMALE:
|
|
|
|
self.person.set_gender(RelLib.Person.FEMALE)
|
2005-04-26 21:34:21 +05:30
|
|
|
for temp_family_handle in self.person.get_family_handle_list():
|
|
|
|
temp_family = self.db.get_family_from_handle(temp_family_handle)
|
2004-07-28 07:59:07 +05:30
|
|
|
if self.person == temp_family.get_father_handle():
|
|
|
|
if temp_family.get_mother_handle() != None:
|
2004-09-20 08:42:51 +05:30
|
|
|
error = True
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-07-28 07:59:07 +05:30
|
|
|
temp_family.set_father_handle(None)
|
|
|
|
temp_family.set_mother_handle(self.person)
|
2005-05-31 02:11:43 +05:30
|
|
|
elif unknown and self.person.get_gender() != RelLib.Person.UNKNOWN:
|
|
|
|
self.person.set_gender(RelLib.Person.UNKNOWN)
|
2005-04-26 21:34:21 +05:30
|
|
|
for temp_family_handle in self.person.get_family_handle_list():
|
|
|
|
temp_family = self.db.get_family_from_handle(temp_family_handle)
|
2004-07-28 07:59:07 +05:30
|
|
|
if self.person == temp_family.get_father_handle():
|
|
|
|
if temp_family.get_mother_handle() != None:
|
2004-09-20 08:42:51 +05:30
|
|
|
error = True
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-07-28 07:59:07 +05:30
|
|
|
temp_family.set_father_handle(None)
|
|
|
|
temp_family.set_mother_handle(self.person)
|
|
|
|
if self.person == temp_family.get_mother_handle():
|
|
|
|
if temp_family.get_father_handle() != None:
|
2004-09-20 08:42:51 +05:30
|
|
|
error = True
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-07-28 07:59:07 +05:30
|
|
|
temp_family.set_mother_handle(None)
|
|
|
|
temp_family.set_father_handle(self.person)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-10-04 02:34:54 +05:30
|
|
|
if error:
|
2003-02-24 10:21:57 +05:30
|
|
|
msg2 = _("Problem changing the gender")
|
2002-10-20 19:55:16 +05:30
|
|
|
msg = _("Changing the gender caused problems "
|
|
|
|
"with marriage information.\nPlease check "
|
|
|
|
"the person's marriages.")
|
2002-10-21 06:48:07 +05:30
|
|
|
ErrorDialog(msg)
|
2006-02-03 09:32:12 +05:30
|
|
|
|
|
|
|
|
|
|
|
def on_apply_person_clicked(self,obj):
|
|
|
|
"""
|
|
|
|
Save the data.
|
|
|
|
"""
|
|
|
|
|
|
|
|
if self._check_for_unknown_gender():
|
|
|
|
return
|
|
|
|
|
|
|
|
self.window.hide()
|
|
|
|
|
|
|
|
trans = self.db.transaction_begin()
|
|
|
|
|
|
|
|
self._check_and_update_id()
|
|
|
|
self._update_primary_name()
|
|
|
|
|
|
|
|
self.build_pdmap()
|
|
|
|
|
|
|
|
self._update_family_ids(trans)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-09-16 20:55:27 +05:30
|
|
|
self.person.set_marker(self.marker_type_selector.get_values())
|
2005-02-20 03:41:51 +05:30
|
|
|
self.person.set_privacy(self.private.get_active())
|
2003-12-03 09:19:39 +05:30
|
|
|
|
2006-02-02 10:50:42 +05:30
|
|
|
# if not self.lds_not_loaded:
|
|
|
|
# self.check_lds()
|
|
|
|
# lds_ord = RelLib.LdsOrd(self.person.get_lds_baptism())
|
|
|
|
# if not self.lds_baptism.are_equal(lds_ord):
|
|
|
|
# self.person.set_lds_baptism(self.lds_baptism)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-02-02 10:50:42 +05:30
|
|
|
# lds_ord = RelLib.LdsOrd(self.person.get_lds_endowment())
|
|
|
|
# if not self.lds_endowment.are_equal(lds_ord):
|
|
|
|
# self.person.set_lds_endowment(self.lds_endowment)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-02-02 10:50:42 +05:30
|
|
|
# lds_ord = RelLib.LdsOrd(self.person.get_lds_sealing())
|
|
|
|
# if not self.lds_sealing.are_equal(lds_ord):
|
|
|
|
# self.person.set_lds_sealing(self.lds_sealing)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-02-03 09:32:12 +05:30
|
|
|
# self.person.set_source_reference_list(self.srcreflist)
|
2003-10-29 10:34:43 +05:30
|
|
|
|
2004-09-29 08:49:01 +05:30
|
|
|
if not self.person.get_handle():
|
2004-08-29 01:19:34 +05:30
|
|
|
self.db.add_person(self.person, trans)
|
|
|
|
else:
|
2004-09-29 08:49:01 +05:30
|
|
|
if not self.person.get_gramps_id():
|
|
|
|
self.person.set_gramps_id(self.db.find_next_person_gramps_id())
|
2004-08-29 01:19:34 +05:30
|
|
|
self.db.commit_person(self.person, trans)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
n = self.nd.display(self.person)
|
2005-05-01 05:15:17 +05:30
|
|
|
|
2004-08-13 10:04:07 +05:30
|
|
|
self.db.transaction_commit(trans,_("Edit Person (%s)") % n)
|
2004-08-04 10:23:29 +05:30
|
|
|
self.close()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def get_place(self,field,makenew=0):
|
2004-08-24 09:18:15 +05:30
|
|
|
text = unicode(field.get_text().strip())
|
2002-10-20 19:55:16 +05:30
|
|
|
if text:
|
2003-06-13 20:38:07 +05:30
|
|
|
if self.pdmap.has_key(text):
|
2004-02-14 11:10:30 +05:30
|
|
|
return self.pdmap[text]
|
2002-10-20 19:55:16 +05:30
|
|
|
elif makenew:
|
2003-01-10 10:51:32 +05:30
|
|
|
place = RelLib.Place()
|
2002-10-20 19:55:16 +05:30
|
|
|
place.set_title(text)
|
2004-08-13 10:04:07 +05:30
|
|
|
trans = self.db.transaction_begin()
|
2004-06-27 23:38:19 +05:30
|
|
|
self.db.add_place(place,trans)
|
2005-02-27 11:21:59 +05:30
|
|
|
self.retval |= const.UPDATE_PLACE
|
2004-08-13 10:04:07 +05:30
|
|
|
self.db.transaction_commit(trans,_('Add Place (%s)' % text))
|
2004-07-28 07:59:07 +05:30
|
|
|
self.pdmap[text] = place.get_handle()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.add_places.append(place)
|
2004-07-28 07:59:07 +05:30
|
|
|
return place.get_handle()
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2005-01-19 08:54:33 +05:30
|
|
|
return u""
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2005-01-19 08:54:33 +05:30
|
|
|
return u""
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-09-29 07:36:46 +05:30
|
|
|
def on_edit_name_clicked(self,obj):
|
2005-06-01 18:44:29 +05:30
|
|
|
ntype = self.ntype_selector.get_values()
|
|
|
|
self.pname.set_type(ntype)
|
2004-10-01 00:02:56 +05:30
|
|
|
self.pname.set_suffix(unicode(self.suffix.get_text()))
|
2004-10-04 09:58:58 +05:30
|
|
|
self.pname.set_surname(unicode(self.surname.get_text()))
|
2004-10-09 07:05:58 +05:30
|
|
|
if self.use_patronymic:
|
|
|
|
self.pname.set_patronymic(unicode(self.prefix.get_text()))
|
|
|
|
else:
|
|
|
|
self.pname.set_surname_prefix(unicode(self.prefix.get_text()))
|
2004-10-01 00:02:56 +05:30
|
|
|
self.pname.set_first_name(unicode(self.given.get_text()))
|
|
|
|
self.pname.set_title(unicode(self.title.get_text()))
|
|
|
|
|
2006-02-05 10:49:51 +05:30
|
|
|
NameEdit.NameEditor(self.dbstate, self.uistate, self.track,
|
|
|
|
self.pname, self)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-09-29 07:36:46 +05:30
|
|
|
def update_name(self,name):
|
|
|
|
self.write_primary_name()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def load_person_image(self):
|
2004-02-21 11:41:59 +05:30
|
|
|
media_list = self.person.get_media_list()
|
|
|
|
if media_list:
|
|
|
|
ph = media_list[0]
|
2004-07-28 07:59:07 +05:30
|
|
|
object_handle = ph.get_reference_handle()
|
2004-08-11 09:12:38 +05:30
|
|
|
obj = self.db.get_object_from_handle(object_handle)
|
|
|
|
if self.load_obj != obj.get_path():
|
2005-05-24 18:38:06 +05:30
|
|
|
mime_type = obj.get_mime_type()
|
|
|
|
if mime_type and mime_type.startswith("image"):
|
2004-08-11 09:12:38 +05:30
|
|
|
self.load_photo(obj.get_path())
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
self.load_photo(None)
|
|
|
|
else:
|
|
|
|
self.load_photo(None)
|
|
|
|
|
|
|
|
def write_primary_name(self):
|
2005-12-07 01:24:16 +05:30
|
|
|
# initial values
|
2004-02-14 11:10:30 +05:30
|
|
|
self.suffix.set_text(self.pname.get_suffix())
|
2004-10-09 07:05:58 +05:30
|
|
|
if self.use_patronymic:
|
|
|
|
self.prefix.set_text(self.pname.get_patronymic())
|
|
|
|
else:
|
|
|
|
self.prefix.set_text(self.pname.get_surname_prefix())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-05-02 09:40:33 +05:30
|
|
|
self.surname.set_text(self.pname.get_surname())
|
2004-02-14 11:10:30 +05:30
|
|
|
self.given.set_text(self.pname.get_first_name())
|
|
|
|
self.title.set_text(self.pname.get_title())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-15 07:27:07 +05:30
|
|
|
def birth_dates_in_order(self,list):
|
|
|
|
"""Check any *valid* birthdates in the list to insure that they are in
|
|
|
|
numerically increasing order."""
|
2004-09-20 08:42:51 +05:30
|
|
|
inorder = True
|
2004-09-23 07:55:07 +05:30
|
|
|
prev_date = 0
|
2004-02-15 07:27:07 +05:30
|
|
|
for i in range(len(list)):
|
2004-07-28 07:59:07 +05:30
|
|
|
child_handle = list[i]
|
2004-08-07 10:46:57 +05:30
|
|
|
child = self.db.get_person_from_handle(child_handle)
|
2005-05-27 10:37:26 +05:30
|
|
|
if child.get_birth_ref():
|
|
|
|
event = self.db.get_event_from_handle(child.get_birth_ref().ref)
|
2004-09-23 07:55:07 +05:30
|
|
|
child_date = event.get_date_object().get_sort_value()
|
2004-02-19 10:37:46 +05:30
|
|
|
else:
|
2004-02-15 07:27:07 +05:30
|
|
|
continue
|
2004-02-20 06:22:24 +05:30
|
|
|
if (prev_date <= child_date): # <= allows for twins
|
2004-02-15 07:27:07 +05:30
|
|
|
prev_date = child_date
|
|
|
|
else:
|
2004-09-20 08:42:51 +05:30
|
|
|
inorder = False
|
2004-02-15 07:27:07 +05:30
|
|
|
return inorder
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-15 07:27:07 +05:30
|
|
|
def reorder_child_list(self, person, list):
|
|
|
|
"""Reorder the child list to put the specified person in his/her
|
|
|
|
correct birth order. Only check *valid* birthdates. Move the person
|
|
|
|
as short a distance as possible."""
|
2004-06-29 09:21:49 +05:30
|
|
|
|
2004-02-15 07:27:07 +05:30
|
|
|
if (self.birth_dates_in_order(list)):
|
|
|
|
return(list)
|
|
|
|
|
|
|
|
# Build the person's date string once
|
2005-05-27 10:37:26 +05:30
|
|
|
event_ref = person.get_birth_ref()
|
|
|
|
if event_ref:
|
|
|
|
event = self.db.get_event_from_handle(event_ref.ref)
|
2004-09-23 07:55:07 +05:30
|
|
|
person_bday = event.get_date_object().get_sort_value()
|
2004-02-19 10:37:46 +05:30
|
|
|
else:
|
2004-09-23 07:55:07 +05:30
|
|
|
person_bday = 0
|
2004-02-15 07:27:07 +05:30
|
|
|
|
|
|
|
# First, see if the person needs to be moved forward in the list
|
2004-06-29 09:21:49 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
index = list.index(person.get_handle())
|
2004-02-15 07:27:07 +05:30
|
|
|
target = index
|
|
|
|
for i in range(index-1, -1, -1):
|
2004-08-07 10:46:57 +05:30
|
|
|
other = self.db.get_person_from_handle(list[i])
|
2005-05-27 10:37:26 +05:30
|
|
|
event_ref = other.get_birth_ref()
|
|
|
|
if event_ref:
|
|
|
|
event = self.db.get_event_from_handle(event_ref.ref)
|
2004-09-23 07:55:07 +05:30
|
|
|
other_bday = event.get_date_object().get_sort_value()
|
|
|
|
if other_bday == 0:
|
2004-02-19 10:37:46 +05:30
|
|
|
continue;
|
2004-09-23 07:55:07 +05:30
|
|
|
if person_bday < other_bday:
|
2004-02-19 10:37:46 +05:30
|
|
|
target = i
|
|
|
|
else:
|
|
|
|
continue
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-15 07:27:07 +05:30
|
|
|
# Now try moving to a later position in the list
|
|
|
|
if (target == index):
|
|
|
|
for i in range(index, len(list)):
|
2004-08-07 10:46:57 +05:30
|
|
|
other = self.db.get_person_from_handle(list[i])
|
2005-05-27 10:37:26 +05:30
|
|
|
event_ref = other.get_birth_ref()
|
|
|
|
if event_ref:
|
|
|
|
event = self.db.get_event_from_handle(event_ref.ref)
|
2004-09-23 07:55:07 +05:30
|
|
|
other_bday = event.get_date_object().get_sort_value()
|
|
|
|
if other_bday == "99999999":
|
2004-02-19 10:37:46 +05:30
|
|
|
continue;
|
2004-09-23 07:55:07 +05:30
|
|
|
if person_bday > other_bday:
|
2004-02-19 10:37:46 +05:30
|
|
|
target = i
|
|
|
|
else:
|
|
|
|
continue
|
2004-02-15 07:27:07 +05:30
|
|
|
|
|
|
|
# Actually need to move? Do it now.
|
|
|
|
if (target != index):
|
2004-07-28 07:59:07 +05:30
|
|
|
list.remove(person.get_handle())
|
|
|
|
list.insert(target,person.get_handle())
|
2004-02-15 07:27:07 +05:30
|
|
|
return list
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-05-02 09:40:33 +05:30
|
|
|
def build_dropdown(entry,strings):
|
2005-02-23 10:00:08 +05:30
|
|
|
store = gtk.ListStore(str)
|
2004-05-02 09:40:33 +05:30
|
|
|
for value in strings:
|
2004-08-11 09:12:38 +05:30
|
|
|
node = store.append()
|
2005-02-23 10:00:08 +05:30
|
|
|
store.set(node,0,unicode(value))
|
2004-05-02 09:40:33 +05:30
|
|
|
completion = gtk.EntryCompletion()
|
|
|
|
completion.set_text_column(0)
|
|
|
|
completion.set_model(store)
|
|
|
|
entry.set_completion(completion)
|
2005-02-23 10:00:08 +05:30
|
|
|
|
|
|
|
def build_combo(entry,strings):
|
|
|
|
cell = gtk.CellRendererText()
|
|
|
|
entry.pack_start(cell,True)
|
|
|
|
entry.add_attribute(cell,'text',0)
|
|
|
|
store = gtk.ListStore(str)
|
|
|
|
for value in strings:
|
|
|
|
node = store.append()
|
|
|
|
store.set(node,0,unicode(value))
|
|
|
|
entry.set_model(store)
|