2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-04-13 22:45:21 +05:30
|
|
|
# Copyright (C) 2000-2006 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.
|
|
|
|
#
|
2006-04-08 01:58:41 +05:30
|
|
|
# This program is distributed in the hope that it will be useful,
|
2002-10-20 19:55:16 +05:30
|
|
|
# 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$
|
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
"""
|
|
|
|
EditPerson Dialog. Provides the interface to allow the GRAMPS program
|
|
|
|
to edit information about a particular Person.
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = "Don Allingham"
|
|
|
|
__revision__ = "$Revision$"
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Standard python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-03-14 03:40:40 +05:30
|
|
|
import locale
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
2005-04-28 10:18:30 +05:30
|
|
|
import gtk.gdk
|
2002-11-15 09:19:39 +05:30
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
try:
|
|
|
|
set()
|
|
|
|
except NameError:
|
|
|
|
from sets import Set as set
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
|
|
|
import Utils
|
2006-03-03 05:53:04 +05:30
|
|
|
import Mime
|
2003-01-10 10:51:32 +05:30
|
|
|
import RelLib
|
2006-02-08 10:38:28 +05:30
|
|
|
import GrampsWidgets
|
2006-05-08 06:45:19 +05:30
|
|
|
import Config
|
2003-10-30 09:47:05 +05:30
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
from _EditPrimary import EditPrimary
|
2006-05-08 06:45:19 +05:30
|
|
|
from QuestionDialog import *
|
2006-05-05 06:09:11 +05:30
|
|
|
from DisplayTabs import \
|
|
|
|
PersonEventEmbedList,NameEmbedList,SourceEmbedList,AttrEmbedList,\
|
|
|
|
AddrEmbedList,NoteTab,GalleryTab,WebEmbedList,PersonRefEmbedList, \
|
|
|
|
LdsEmbedList
|
2006-03-01 10:38:11 +05:30
|
|
|
|
2004-08-13 10:04:07 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
_select_gender = ((True, False, False),
|
|
|
|
(False, True, False),
|
|
|
|
(False, False, True))
|
|
|
|
|
|
|
|
_use_patronymic = set(
|
|
|
|
["ru", "RU", "ru_RU", "koi8r", "ru_koi8r", "russian", "Russian"]
|
|
|
|
)
|
2005-12-07 01:24:16 +05:30
|
|
|
|
2006-03-04 12:04:48 +05:30
|
|
|
class EditPerson(EditPrimary):
|
2006-04-08 01:58:41 +05:30
|
|
|
"""
|
|
|
|
The EditPerson dialog is derived from the EditPrimary class. It
|
|
|
|
allos for the editing of the primary object type of Person.
|
|
|
|
"""
|
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
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
def __init__(self, state, uistate, track, person, callback=None):
|
|
|
|
"""
|
|
|
|
Creates an EditPerson window. Associates a person with the window.
|
|
|
|
"""
|
2004-02-14 11:10:30 +05:30
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
EditPrimary.__init__(self, state, uistate, track, person,
|
2006-03-04 12:04:48 +05:30
|
|
|
state.db.get_person_from_handle, callback)
|
2005-08-20 03:40:35 +05:30
|
|
|
|
2006-04-01 01:16:41 +05:30
|
|
|
def empty_object(self):
|
2006-04-08 01:58:41 +05:30
|
|
|
"""
|
|
|
|
Returns an empty Person object for comparison for changes. This
|
|
|
|
is used by the base class (EditPrimary)
|
|
|
|
"""
|
2006-04-01 01:16:41 +05:30
|
|
|
return RelLib.Person()
|
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def _local_init(self):
|
2006-04-08 01:58:41 +05:30
|
|
|
"""
|
|
|
|
Local initialization function. Performs basic initialization,
|
|
|
|
including setting up widgets and the glade interface. This is called
|
|
|
|
by the base class of EditPrimary, and overridden here.
|
|
|
|
"""
|
2006-03-01 10:38:11 +05:30
|
|
|
self.pname = self.obj.get_primary_name()
|
|
|
|
self.should_guess_gender = (not self.obj.get_gramps_id() and
|
|
|
|
self.obj.get_gender () ==
|
2005-05-31 02:11:43 +05:30
|
|
|
RelLib.Person.UNKNOWN)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.load_obj = None
|
2006-04-08 01:58:41 +05:30
|
|
|
self.top = gtk.glade.XML(const.person_glade, "edit_person", "gramps")
|
2006-04-24 03:48:01 +05:30
|
|
|
self.set_window(self.top.get_widget("edit_person"), None,
|
|
|
|
_('Edit Person'))
|
2005-09-16 20:55:27 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj_photo = self.top.get_widget("personPix")
|
2005-12-07 01:24:16 +05:30
|
|
|
self.eventbox = self.top.get_widget("eventbox1")
|
2004-10-09 07:05:58 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def _post_init(self):
|
2006-04-08 01:58:41 +05:30
|
|
|
"""
|
|
|
|
Post initalization function. Handles any initialization that
|
|
|
|
needs to be done after the interface is brought up. This called
|
|
|
|
by _EditPrimary's init routine, and overridden in the derived
|
|
|
|
class (this class)
|
|
|
|
"""
|
2006-03-01 10:38:11 +05:30
|
|
|
self.load_person_image()
|
|
|
|
self.surname_field.grab_focus()
|
2005-03-14 03:40:40 +05:30
|
|
|
|
2006-05-08 06:45:19 +05:30
|
|
|
# if not Config.get(Config.HIDE_EP_MSG):
|
|
|
|
# MessageHideDialog(
|
|
|
|
# _('Editing a person'),
|
|
|
|
# _('This window allows you to enter information about '
|
|
|
|
# 'a person. You can add events, including birth and '
|
|
|
|
# 'death information under the Events tab. Similarly, '
|
|
|
|
# 'you can add additional information, such as sources, '
|
|
|
|
# 'names, and images on other tabs.'),
|
|
|
|
# Config.HIDE_EP_MSG)
|
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def _connect_signals(self):
|
2006-04-08 01:58:41 +05:30
|
|
|
"""
|
|
|
|
Connects any signals that need to be connected. Called by the
|
|
|
|
init routine of the base class (_EditPrimary).
|
|
|
|
"""
|
2006-03-01 10:38:11 +05:30
|
|
|
self.define_cancel_button(self.top.get_widget("button15"))
|
|
|
|
self.define_ok_button(self.top.get_widget("ok"), self.save)
|
2006-04-08 01:58:41 +05:30
|
|
|
self.define_help_button(self.top.get_widget("button134"), 'adv-pers')
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
self.given.connect("focus_out_event", self._given_focus_out_event)
|
|
|
|
self.top.get_widget("button177").connect("clicked",
|
|
|
|
self._edit_name_clicked)
|
2003-10-29 10:34:43 +05:30
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
self.eventbox.connect('button-press-event',
|
|
|
|
self._image_button_press)
|
2004-11-29 08:54:02 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def _setup_fields(self):
|
2006-04-08 01:58:41 +05:30
|
|
|
"""
|
|
|
|
Connects the GrampsWidget objects to field in the interface. This
|
|
|
|
allows the widgets to keep the data in the attached Person object
|
|
|
|
up to date at all times, eliminating a lot of need in 'save' routine.
|
|
|
|
"""
|
2006-03-01 10:38:11 +05:30
|
|
|
|
|
|
|
self.private = GrampsWidgets.PrivacyButton(
|
2006-04-08 01:58:41 +05:30
|
|
|
self.top.get_widget('private'),
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj)
|
|
|
|
|
|
|
|
self.gender = GrampsWidgets.MonitoredMenu(
|
2006-04-08 01:58:41 +05:30
|
|
|
self.top.get_widget('gender'),
|
|
|
|
self.obj.set_gender,
|
|
|
|
self.obj.get_gender,
|
2006-03-01 10:38:11 +05:30
|
|
|
(
|
2006-04-08 01:58:41 +05:30
|
|
|
(_('female'), RelLib.Person.FEMALE),
|
|
|
|
(_('male'), RelLib.Person.MALE),
|
|
|
|
(_('unknown'), RelLib.Person.UNKNOWN)
|
|
|
|
),
|
2006-03-01 10:38:11 +05:30
|
|
|
self.db.readonly)
|
|
|
|
|
2006-04-14 10:06:25 +05:30
|
|
|
self.ntype_field = GrampsWidgets.MonitoredDataType(
|
2006-04-08 01:58:41 +05:30
|
|
|
self.top.get_widget("ntype"),
|
|
|
|
self.pname.set_type,
|
2006-04-19 09:27:10 +05:30
|
|
|
self.pname.get_type,
|
2006-05-21 09:54:56 +05:30
|
|
|
self.db.readonly,
|
|
|
|
self.db.get_name_types())
|
2006-03-01 10:38:11 +05:30
|
|
|
|
2006-04-20 08:40:23 +05:30
|
|
|
self.marker = GrampsWidgets.MonitoredDataType(
|
2006-04-08 01:58:41 +05:30
|
|
|
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-01-31 20:43:54 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
if self.use_patronymic:
|
|
|
|
self.prefix = GrampsWidgets.MonitoredEntry(
|
2006-04-08 01:58:41 +05:30
|
|
|
self.top.get_widget("prefix"),
|
|
|
|
self.pname.set_patronymic,
|
|
|
|
self.pname.get_patronymic,
|
2006-03-01 10:38:11 +05:30
|
|
|
self.db.readonly)
|
|
|
|
|
|
|
|
prefix_label = self.top.get_widget('prefix_label')
|
|
|
|
prefix_label.set_text(_('Patronymic:'))
|
|
|
|
prefix_label.set_use_underline(True)
|
|
|
|
else:
|
|
|
|
self.prefix = GrampsWidgets.MonitoredEntry(
|
2006-04-08 01:58:41 +05:30
|
|
|
self.top.get_widget("prefix"),
|
|
|
|
self.pname.set_surname_prefix,
|
|
|
|
self.pname.get_surname_prefix,
|
2006-03-01 10:38:11 +05:30
|
|
|
self.db.readonly)
|
|
|
|
|
|
|
|
self.suffix = GrampsWidgets.MonitoredEntry(
|
2006-04-08 01:58:41 +05:30
|
|
|
self.top.get_widget("suffix"),
|
|
|
|
self.pname.set_suffix,
|
|
|
|
self.pname.get_suffix,
|
2006-03-01 10:38:11 +05:30
|
|
|
self.db.readonly)
|
|
|
|
|
2006-05-06 02:46:24 +05:30
|
|
|
self.call = GrampsWidgets.MonitoredEntry(
|
|
|
|
self.top.get_widget("call"),
|
|
|
|
self.pname.set_call_name,
|
|
|
|
self.pname.get_call_name,
|
|
|
|
self.db.readonly)
|
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
self.given = GrampsWidgets.MonitoredEntry(
|
2006-04-08 01:58:41 +05:30
|
|
|
self.top.get_widget("given_name"),
|
|
|
|
self.pname.set_first_name,
|
|
|
|
self.pname.get_first_name,
|
2006-03-01 10:38:11 +05:30
|
|
|
self.db.readonly)
|
|
|
|
|
|
|
|
self.title = GrampsWidgets.MonitoredEntry(
|
2006-04-08 01:58:41 +05:30
|
|
|
self.top.get_widget("title"),
|
|
|
|
self.pname.set_title,
|
|
|
|
self.pname.get_title,
|
2006-03-01 10:38:11 +05:30
|
|
|
self.db.readonly)
|
2006-01-31 20:43:54 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
self.surname_field = GrampsWidgets.MonitoredEntry(
|
2006-04-08 01:58:41 +05:30
|
|
|
self.top.get_widget("surname"),
|
|
|
|
self.pname.set_surname,
|
|
|
|
self.pname.get_surname,
|
|
|
|
self.db.readonly,
|
2006-03-30 21:59:59 +05:30
|
|
|
autolist=self.db.get_surname_list())
|
2006-03-01 10:38:11 +05:30
|
|
|
|
|
|
|
self.gid = GrampsWidgets.MonitoredEntry(
|
2006-04-08 01:58:41 +05:30
|
|
|
self.top.get_widget("gid"),
|
|
|
|
self.obj.set_gramps_id,
|
|
|
|
self.obj.get_gramps_id,
|
2006-03-01 10:38:11 +05:30
|
|
|
self.db.readonly)
|
|
|
|
|
2006-01-31 20:43:54 +05:30
|
|
|
def _create_tabbed_pages(self):
|
|
|
|
"""
|
|
|
|
Creates the notebook tabs and inserts them into the main
|
|
|
|
window.
|
|
|
|
|
|
|
|
"""
|
2006-03-01 10:38:11 +05:30
|
|
|
notebook = gtk.Notebook()
|
2006-01-29 10:00:16 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
self.event_list = self._add_tab(
|
2006-04-08 01:58:41 +05:30
|
|
|
notebook,
|
|
|
|
PersonEventEmbedList(self.dbstate, self.uistate,
|
|
|
|
self.track, self.obj))
|
2006-01-31 20:43:54 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
self.name_list = self._add_tab(
|
2006-04-08 01:58:41 +05:30
|
|
|
notebook,
|
|
|
|
NameEmbedList(self.dbstate, self.uistate, self.track,
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj.get_alternate_names()))
|
|
|
|
|
|
|
|
self.srcref_list = self._add_tab(
|
2006-04-08 01:58:41 +05:30
|
|
|
notebook,
|
|
|
|
SourceEmbedList(self.dbstate, self.uistate,
|
2006-03-01 10:38:11 +05:30
|
|
|
self.track, self.obj.source_list))
|
|
|
|
|
|
|
|
self.attr_list = self._add_tab(
|
2006-04-08 01:58:41 +05:30
|
|
|
notebook,
|
|
|
|
AttrEmbedList(self.dbstate, self.uistate, self.track,
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj.get_attribute_list()))
|
|
|
|
|
|
|
|
self.addr_list = self._add_tab(
|
2006-04-08 01:58:41 +05:30
|
|
|
notebook,
|
|
|
|
AddrEmbedList(self.dbstate, self.uistate, self.track,
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj.get_address_list()))
|
|
|
|
|
|
|
|
self.note_tab = self._add_tab(
|
2006-04-08 01:58:41 +05:30
|
|
|
notebook,
|
|
|
|
NoteTab(self.dbstate, self.uistate, self.track,
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj.get_note_object()))
|
|
|
|
|
|
|
|
self.gallery_tab = self._add_tab(
|
2006-04-08 01:58:41 +05:30
|
|
|
notebook,
|
|
|
|
GalleryTab(self.dbstate, self.uistate, self.track,
|
2006-04-28 02:48:59 +05:30
|
|
|
self.obj.get_media_list(),
|
|
|
|
self.load_person_image))
|
2006-03-01 10:38:11 +05:30
|
|
|
|
|
|
|
self.web_list = self._add_tab(
|
2006-04-08 01:58:41 +05:30
|
|
|
notebook,
|
|
|
|
WebEmbedList(self.dbstate, self.uistate, self.track,
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj.get_url_list()))
|
|
|
|
|
2006-04-13 21:46:00 +05:30
|
|
|
self.pref_list = self._add_tab(
|
|
|
|
notebook,
|
|
|
|
PersonRefEmbedList(self.dbstate, self.uistate, self.track,
|
|
|
|
self.obj.get_person_ref_list()))
|
|
|
|
|
2006-04-04 23:37:23 +05:30
|
|
|
self.lds_list = self._add_tab(
|
2006-04-08 01:58:41 +05:30
|
|
|
notebook,
|
|
|
|
LdsEmbedList(self.dbstate, self.uistate, self.track,
|
2006-04-04 23:37:23 +05:30
|
|
|
self.obj.get_lds_ord_list()))
|
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
notebook.show_all()
|
2006-04-08 01:58:41 +05:30
|
|
|
self.top.get_widget('vbox').pack_start(notebook, True)
|
2003-03-14 11:16:02 +05:30
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
def build_menu_names(self, person):
|
|
|
|
"""
|
|
|
|
Provides the information need by the base class to define the
|
|
|
|
window management menu entries.
|
|
|
|
"""
|
2005-12-23 05:13:32 +05:30
|
|
|
win_menu_label = self.nd.display(person)
|
|
|
|
if not win_menu_label.strip():
|
|
|
|
win_menu_label = _("New Person")
|
2006-04-08 01:58:41 +05:30
|
|
|
return (_('Edit Person'), win_menu_label)
|
|
|
|
|
|
|
|
def _image_callback(self, ref):
|
|
|
|
"""
|
|
|
|
Called when a media reference had been edited. This allows fot
|
|
|
|
the updating image on the main form which has just been modified.
|
|
|
|
"""
|
2006-02-22 10:03:34 +05:30
|
|
|
obj = self.db.get_object_from_handle(ref.get_reference_handle())
|
|
|
|
self.load_photo(obj)
|
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
def _image_button_press(self, obj, event):
|
|
|
|
"""
|
|
|
|
Button press event that is caught when a button has been
|
|
|
|
pressed while on the image on the main form. This does not apply
|
|
|
|
to the images in galleries, just the image on the main form.
|
|
|
|
"""
|
2004-11-29 08:54:02 +05:30
|
|
|
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
|
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
media_list = self.obj.get_media_list()
|
2004-11-29 08:54:02 +05:30
|
|
|
if media_list:
|
2006-03-30 04:21:27 +05:30
|
|
|
from Editors import EditMediaRef
|
2006-02-22 10:03:34 +05:30
|
|
|
|
|
|
|
media_ref = media_list[0]
|
|
|
|
object_handle = media_ref.get_reference_handle()
|
|
|
|
media_obj = self.db.get_object_from_handle(object_handle)
|
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
EditMediaRef(self.dbstate, self.uistate, self.track,
|
|
|
|
media_obj, media_ref, self._image_callback)
|
2004-11-29 08:54:02 +05:30
|
|
|
elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
|
2006-03-01 10:38:11 +05:30
|
|
|
media_list = self.obj.get_media_list()
|
2004-11-29 08:54:02 +05:30
|
|
|
if media_list:
|
2006-04-08 01:58:41 +05:30
|
|
|
photo = media_list[0]
|
|
|
|
self._show_popup(photo, event)
|
2004-11-29 08:54:02 +05:30
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
def _show_popup(self, photo, event):
|
|
|
|
"""
|
|
|
|
Look for right-clicks on a picture and create a popup
|
|
|
|
menu of the available actions.
|
|
|
|
"""
|
2004-11-29 08:54:02 +05:30
|
|
|
|
|
|
|
menu = gtk.Menu()
|
|
|
|
menu.set_title(_("Media Object"))
|
|
|
|
obj = self.db.get_object_from_handle(photo.get_reference_handle())
|
|
|
|
mtype = obj.get_mime_type()
|
2006-03-03 05:53:04 +05:30
|
|
|
progname = Mime.get_application(mtype)
|
2004-11-29 08:54:02 +05:30
|
|
|
|
|
|
|
if progname and len(progname) > 1:
|
2006-04-08 01:58:41 +05:30
|
|
|
Utils.add_menuitem(menu, _("Open in %s") % progname[1],
|
|
|
|
photo, self._popup_view_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 the default picture viewer
|
|
|
|
"""
|
2006-03-01 10:38:11 +05:30
|
|
|
media_list = self.obj.get_media_list()
|
2004-11-29 08:54:02 +05:30
|
|
|
if media_list:
|
2006-04-08 01:58:41 +05:30
|
|
|
photo = media_list[0]
|
|
|
|
object_handle = photo.get_reference_handle()
|
2004-11-29 08:54:02 +05:30
|
|
|
Utils.view_photo(self.db.get_object_from_handle(object_handle))
|
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
def _popup_change_description(self, obj):
|
|
|
|
"""
|
|
|
|
Brings up the EditMediaRef dialog for the image on the main form.
|
|
|
|
"""
|
2006-03-01 10:38:11 +05:30
|
|
|
media_list = self.obj.get_media_list()
|
2004-11-29 08:54:02 +05:30
|
|
|
if media_list:
|
2006-03-30 04:21:27 +05:30
|
|
|
from Editors import EditMediaRef
|
2006-02-22 10:03:34 +05:30
|
|
|
|
|
|
|
media_ref = media_list[0]
|
|
|
|
object_handle = media_ref.get_reference_handle()
|
|
|
|
media_obj = self.db.get_object_from_handle(object_handle)
|
2006-04-08 01:58:41 +05:30
|
|
|
EditMediaRef(self.dbstate, self.uistate, self.track,
|
|
|
|
media_obj, media_ref, self._image_callback)
|
2006-02-22 10:03:34 +05:30
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
def _given_focus_out_event (self, entry, event):
|
|
|
|
"""
|
|
|
|
Callback that occurs when the user leaves the given name field,
|
|
|
|
allowing us to attempt to guess the gender of the person if
|
|
|
|
so requested.
|
|
|
|
"""
|
2003-06-24 19:46:47 +05:30
|
|
|
if not self.should_guess_gender:
|
2006-03-02 04:57:45 +05:30
|
|
|
return False
|
2006-03-06 10:52:45 +05:30
|
|
|
try:
|
2006-04-08 01:58:41 +05:30
|
|
|
gender_type = self.db.genderStats.guess_gender(entry.get_text())
|
|
|
|
self.gender.force(gender_type)
|
2006-03-06 10:52:45 +05:30
|
|
|
except:
|
|
|
|
return False
|
2006-03-02 04:57:45 +05:30
|
|
|
return False
|
2005-02-19 10:11:59 +05:30
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
def load_photo(self, photo):
|
2002-10-20 19:55:16 +05:30
|
|
|
"""loads, scales, and displays the person's main photo"""
|
|
|
|
self.load_obj = photo
|
|
|
|
if photo == None:
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj_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)
|
2006-04-08 01:58:41 +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()))
|
2006-04-08 01:58:41 +05:30
|
|
|
i = i.scale_simple(x, y, gtk.gdk.INTERP_BILINEAR)
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj_photo.set_from_pixbuf(i)
|
|
|
|
self.obj_photo.show()
|
2002-10-20 19:55:16 +05:30
|
|
|
except:
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj_photo.hide()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-02-03 09:32:12 +05:30
|
|
|
def _check_for_unknown_gender(self):
|
2006-03-01 10:38:11 +05:30
|
|
|
if self.obj.get_gender() == RelLib.Person.UNKNOWN:
|
2005-04-04 06:41:50 +05:30
|
|
|
dialog = QuestionDialog2(
|
2006-04-08 01:58:41 +05:30
|
|
|
_("Unknown gender specified"),
|
2005-04-04 06:41:50 +05:30
|
|
|
_("The gender of the person is currently unknown. "
|
|
|
|
"Usually, this is a mistake. You may choose to "
|
|
|
|
"either continue saving, or returning to the "
|
2006-04-08 01:58:41 +05:30
|
|
|
"Edit Person dialog to fix the problem."),
|
|
|
|
_("Continue saving"), _("Return to window"),
|
2005-04-04 06:41:50 +05:30
|
|
|
self.window)
|
|
|
|
if not dialog.run():
|
2006-02-03 09:32:12 +05:30
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
def _check_and_update_id(self):
|
2006-03-01 10:38:11 +05:30
|
|
|
original = self.db.get_person_from_handle(self.obj.get_handle())
|
|
|
|
|
2006-03-06 10:59:24 +05:30
|
|
|
if original and original.get_gramps_id() != self.obj.get_gramps_id():
|
2006-03-01 10:38:11 +05:30
|
|
|
idval = self.obj.get_gramps_id()
|
2004-08-07 10:46:57 +05:30
|
|
|
person = self.db.get_person_from_gramps_id(idval)
|
2006-03-01 10:38:11 +05:30
|
|
|
if person:
|
2006-04-08 01:58:41 +05:30
|
|
|
name = self.nd.display(person)
|
2002-10-20 19:55:16 +05:30
|
|
|
msg1 = _("GRAMPS ID value was not changed.")
|
2006-04-08 01:58:41 +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.") % {
|
|
|
|
'grampsid' : idval,
|
|
|
|
'person' : name }
|
|
|
|
WarningDialog(msg1, msg2)
|
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
|
2006-03-01 10:38:11 +05:30
|
|
|
family = self.obj.get_main_parents_family_handle()
|
2002-10-20 19:55:16 +05:30
|
|
|
if (family):
|
2006-04-08 01:58:41 +05:30
|
|
|
f = self.db.find_family_from_handle(family, trans)
|
2006-04-13 22:19:52 +05:30
|
|
|
new_order = self.reorder_child_ref_list(self.obj,
|
|
|
|
f.get_child_ref_list())
|
2006-04-13 22:40:29 +05:30
|
|
|
f.set_child_ref_list(new_order)
|
|
|
|
for family in self.obj.get_parent_family_handle_list():
|
2006-04-08 01:58:41 +05:30
|
|
|
f = self.db.find_family_from_handle(family, trans)
|
2006-04-13 22:19:52 +05:30
|
|
|
new_order = self.reorder_child_ref_list(self.obj,
|
|
|
|
f.get_child_ref_list())
|
2006-04-13 22:40:29 +05:30
|
|
|
f.set_child_ref_list(new_order)
|
2005-04-23 21:23:30 +05:30
|
|
|
|
2004-09-20 08:42:51 +05:30
|
|
|
error = False
|
2006-03-01 10:38:11 +05:30
|
|
|
original = self.db.get_person_from_handle(self.obj.handle)
|
2006-03-06 11:02:36 +05:30
|
|
|
|
|
|
|
if original:
|
2006-04-08 01:58:41 +05:30
|
|
|
(female, male, unknown) = _select_gender[self.obj.get_gender()]
|
2006-03-06 11:02:36 +05:30
|
|
|
if male and original.get_gender() != RelLib.Person.MALE:
|
2006-04-08 01:58:41 +05:30
|
|
|
for tmp_handle in self.obj.get_family_handle_list():
|
|
|
|
temp_family = self.db.get_family_from_handle(tmp_handle)
|
2006-03-06 11:02:36 +05:30
|
|
|
if self.obj == temp_family.get_mother_handle():
|
|
|
|
if temp_family.get_father_handle() != None:
|
|
|
|
error = True
|
|
|
|
else:
|
|
|
|
temp_family.set_mother_handle(None)
|
|
|
|
temp_family.set_father_handle(self.obj)
|
|
|
|
elif female and original != RelLib.Person.FEMALE:
|
2006-04-08 01:58:41 +05:30
|
|
|
for tmp_handle in self.obj.get_family_handle_list():
|
|
|
|
temp_family = self.db.get_family_from_handle(tmp_handle)
|
2006-03-06 11:02:36 +05:30
|
|
|
if self.obj == temp_family.get_father_handle():
|
|
|
|
if temp_family.get_mother_handle() != None:
|
|
|
|
error = True
|
|
|
|
else:
|
|
|
|
temp_family.set_father_handle(None)
|
|
|
|
temp_family.set_mother_handle(self.obj)
|
|
|
|
elif unknown and original.get_gender() != RelLib.Person.UNKNOWN:
|
2006-04-08 01:58:41 +05:30
|
|
|
for tmp_handle in self.obj.get_family_handle_list():
|
|
|
|
temp_family = self.db.get_family_from_handle(tmp_handle)
|
2006-03-06 11:02:36 +05:30
|
|
|
if self.obj == temp_family.get_father_handle():
|
|
|
|
if temp_family.get_mother_handle() != None:
|
|
|
|
error = True
|
|
|
|
else:
|
|
|
|
temp_family.set_father_handle(None)
|
|
|
|
temp_family.set_mother_handle(self.obj)
|
|
|
|
if self.obj == temp_family.get_mother_handle():
|
|
|
|
if temp_family.get_father_handle() != None:
|
|
|
|
error = True
|
|
|
|
else:
|
|
|
|
temp_family.set_mother_handle(None)
|
|
|
|
temp_family.set_father_handle(self.obj)
|
|
|
|
|
|
|
|
if error:
|
|
|
|
msg2 = _("Problem changing the gender")
|
|
|
|
msg = _("Changing the gender caused problems "
|
|
|
|
"with marriage information.\nPlease check "
|
|
|
|
"the person's marriages.")
|
2006-04-08 01:58:41 +05:30
|
|
|
ErrorDialog(msg2, msg)
|
2006-02-03 09:32:12 +05:30
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
def save(self, *obj):
|
2006-02-03 09:32:12 +05:30
|
|
|
"""
|
|
|
|
Save the data.
|
|
|
|
"""
|
2006-04-01 01:16:41 +05:30
|
|
|
|
|
|
|
if self.object_is_empty():
|
2006-04-08 01:58:41 +05:30
|
|
|
ErrorDialog(_("Cannot save person"),
|
2006-04-01 01:16:41 +05:30
|
|
|
_("No data exists for this person. Please "
|
|
|
|
"enter data or cancel the edit."))
|
|
|
|
return
|
|
|
|
|
2006-02-03 09:32:12 +05:30
|
|
|
if self._check_for_unknown_gender():
|
|
|
|
return
|
2006-02-10 06:40:52 +05:30
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
(birth_ref, death_ref, event_list) = self.event_list.return_info()
|
|
|
|
self.obj.set_birth_ref(birth_ref)
|
|
|
|
self.obj.set_death_ref(death_ref)
|
|
|
|
self.obj.set_event_ref_list(event_list)
|
2006-02-03 09:32:12 +05:30
|
|
|
|
|
|
|
self.window.hide()
|
|
|
|
|
|
|
|
trans = self.db.transaction_begin()
|
|
|
|
|
|
|
|
self._check_and_update_id()
|
|
|
|
self._update_family_ids(trans)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
if not self.obj.get_handle():
|
|
|
|
self.db.add_person(self.obj, trans)
|
2004-08-29 01:19:34 +05:30
|
|
|
else:
|
2006-03-01 10:38:11 +05:30
|
|
|
if not self.obj.get_gramps_id():
|
|
|
|
self.obj.set_gramps_id(self.db.find_next_person_gramps_id())
|
|
|
|
self.db.commit_person(self.obj, trans)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
msg = _("Edit Person (%s)") % self.nd.display(self.obj)
|
|
|
|
self.db.transaction_commit(trans, msg)
|
2004-08-04 10:23:29 +05:30
|
|
|
self.close()
|
2006-03-21 08:09:01 +05:30
|
|
|
if self.callback:
|
|
|
|
self.callback(self.obj)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
def _edit_name_clicked(self, obj):
|
|
|
|
"""
|
|
|
|
Called when the edit name button is clicked for the primary name
|
|
|
|
on the main form (not in the names tab). Brings up the EditName
|
|
|
|
dialog for this name.
|
|
|
|
"""
|
|
|
|
from Editors import EditName
|
|
|
|
EditName(self.dbstate, self.uistate, self.track,
|
|
|
|
self.pname, self._update_name)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-04-08 01:58:41 +05:30
|
|
|
def _update_name(self, name):
|
|
|
|
"""
|
|
|
|
Called when the primary name has been changed by the EditName
|
|
|
|
dialog. This allows us to update the main form in response to
|
|
|
|
any changes.
|
|
|
|
"""
|
|
|
|
for obj in (self.suffix, self.prefix, self.given, self.title,
|
2006-05-06 02:46:24 +05:30
|
|
|
self.ntype_field, self.surname_field, self.call):
|
2006-03-01 10:38:11 +05:30
|
|
|
obj.update()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def load_person_image(self):
|
2006-04-08 01:58:41 +05:30
|
|
|
"""
|
|
|
|
Loads the primary image into the main form if it exists.
|
|
|
|
"""
|
2006-03-01 10:38:11 +05:30
|
|
|
media_list = self.obj.get_media_list()
|
2004-02-21 11:41:59 +05:30
|
|
|
if media_list:
|
2006-04-08 01:58:41 +05:30
|
|
|
photo = media_list[0]
|
|
|
|
object_handle = photo.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)
|
|
|
|
|
2006-04-13 22:19:52 +05:30
|
|
|
def birth_dates_in_order(self, child_ref_list):
|
2004-02-15 07:27:07 +05:30
|
|
|
"""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
|
2006-04-13 22:19:52 +05:30
|
|
|
handle_list = [ref.ref for ref in child_ref_list]
|
|
|
|
for i in range(len(handle_list)):
|
|
|
|
child_handle = 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():
|
2006-04-08 01:58:41 +05:30
|
|
|
event_handle = child.get_birth_ref().ref
|
|
|
|
event = self.db.get_event_from_handle(event_handle)
|
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
|
|
|
|
2006-04-13 22:19:52 +05:30
|
|
|
def reorder_child_ref_list(self, person, child_ref_list):
|
2004-02-15 07:27:07 +05:30
|
|
|
"""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
|
|
|
|
2006-04-13 22:19:52 +05:30
|
|
|
if self.birth_dates_in_order(child_ref_list):
|
|
|
|
return(child_ref_list)
|
2004-02-15 07:27:07 +05:30
|
|
|
|
|
|
|
# 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
|
2006-04-13 22:19:52 +05:30
|
|
|
handle_list = [ref.ref for ref in child_ref_list]
|
2004-06-29 09:21:49 +05:30
|
|
|
|
2006-04-13 22:19:52 +05:30
|
|
|
index = handle_list.index(person.get_handle())
|
2004-02-15 07:27:07 +05:30
|
|
|
target = index
|
|
|
|
for i in range(index-1, -1, -1):
|
2006-04-13 22:19:52 +05:30
|
|
|
other = self.db.get_person_from_handle(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):
|
2006-04-13 22:19:52 +05:30
|
|
|
for i in range(index, len(handle_list)):
|
|
|
|
other = self.db.get_person_from_handle(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):
|
2006-04-13 22:19:52 +05:30
|
|
|
ref = child_ref_list.pop(index)
|
|
|
|
child_ref_list.insert(target, ref)
|
|
|
|
return child_ref_list
|
2002-10-20 19:55:16 +05:30
|
|
|
|