2006-04-13 21:50:57 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2007-06-28 11:11:40 +05:30
|
|
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
2009-02-08 04:24:16 +05:30
|
|
|
# 2009 Gary Burton
|
2006-04-13 21:50:57 +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
|
|
|
|
#
|
|
|
|
|
2008-01-22 14:47:46 +05:30
|
|
|
# $Id$
|
2006-04-13 21:50:57 +05:30
|
|
|
|
|
|
|
"""
|
|
|
|
The EditPersonRef module provides the EditPersonRef class. This provides a
|
|
|
|
mechanism for the user to edit address information.
|
|
|
|
"""
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
from gettext import gettext as _
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2008-02-19 05:18:35 +05:30
|
|
|
import gtk
|
2006-04-13 21:50:57 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
2009-10-08 06:42:51 +05:30
|
|
|
import config
|
2007-06-28 11:11:40 +05:30
|
|
|
from BasicUtils import name_displayer
|
2006-04-13 21:50:57 +05:30
|
|
|
from _EditSecondary import EditSecondary
|
2007-10-08 22:11:39 +05:30
|
|
|
from gen.lib import NoteType
|
2008-05-09 01:10:56 +05:30
|
|
|
from widgets import MonitoredEntry, PrivacyButton
|
2006-05-05 06:09:11 +05:30
|
|
|
from DisplayTabs import SourceEmbedList, NoteTab
|
2009-05-15 01:45:59 +05:30
|
|
|
from glade import Glade
|
2009-05-07 00:45:55 +05:30
|
|
|
|
2006-04-13 21:50:57 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# EditPersonRef class
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class EditPersonRef(EditSecondary):
|
|
|
|
"""
|
|
|
|
Displays a dialog that allows the user to edit an address.
|
|
|
|
"""
|
2006-11-26 10:09:34 +05:30
|
|
|
|
2006-04-13 21:50:57 +05:30
|
|
|
def __init__(self, dbstate, uistate, track, addr, callback):
|
|
|
|
"""
|
|
|
|
Displays the dialog box.
|
|
|
|
|
|
|
|
parent - The class that called the PersonRef editor.
|
|
|
|
addr - The address that is to be edited
|
|
|
|
"""
|
|
|
|
EditSecondary.__init__(self, dbstate, uistate, track, addr, callback)
|
|
|
|
|
|
|
|
def _local_init(self):
|
2009-10-08 06:42:51 +05:30
|
|
|
self.width_key = 'interface.person-ref-width'
|
|
|
|
self.height_key = 'interface.person-ref-height'
|
2009-05-07 00:45:55 +05:30
|
|
|
|
2009-05-15 01:45:59 +05:30
|
|
|
self.top = Glade()
|
2009-05-07 00:45:55 +05:30
|
|
|
|
2009-05-15 01:45:59 +05:30
|
|
|
self.set_window(self.top.toplevel,
|
2009-05-07 00:45:55 +05:30
|
|
|
self.top.get_object("title"),
|
2006-04-24 03:48:01 +05:30
|
|
|
_('Person Reference Editor'))
|
2009-05-07 00:45:55 +05:30
|
|
|
self.person_label = self.top.get_object('person')
|
2006-04-13 21:50:57 +05:30
|
|
|
|
|
|
|
def _setup_fields(self):
|
|
|
|
|
2006-04-14 01:04:07 +05:30
|
|
|
if self.obj.ref:
|
|
|
|
p = self.dbstate.db.get_person_from_handle(self.obj.ref)
|
2007-06-28 11:11:40 +05:30
|
|
|
self.person_label.set_text(name_displayer.display(p))
|
2006-04-14 01:04:07 +05:30
|
|
|
|
2006-04-13 21:50:57 +05:30
|
|
|
self.street = MonitoredEntry(
|
2009-05-07 00:45:55 +05:30
|
|
|
self.top.get_object("relationship"),
|
2006-04-13 21:50:57 +05:30
|
|
|
self.obj.set_relation,
|
|
|
|
self.obj.get_relation,
|
|
|
|
self.db.readonly)
|
|
|
|
|
|
|
|
self.priv = PrivacyButton(
|
2009-05-07 00:45:55 +05:30
|
|
|
self.top.get_object("private"),
|
2006-04-13 21:50:57 +05:30
|
|
|
self.obj,
|
|
|
|
self.db.readonly)
|
|
|
|
|
|
|
|
def _connect_signals(self):
|
2009-05-07 00:45:55 +05:30
|
|
|
#self.define_help_button(self.top.get_object('help'))
|
|
|
|
self.define_cancel_button(self.top.get_object('cancel'))
|
|
|
|
self.define_ok_button(self.top.get_object('ok'),self.save)
|
|
|
|
self.top.get_object('select').connect('clicked',self._select_person)
|
2006-04-13 21:50:57 +05:30
|
|
|
|
2009-08-05 16:02:05 +05:30
|
|
|
def _connect_db_signals(self):
|
|
|
|
"""
|
|
|
|
Connect any signals that need to be connected.
|
|
|
|
Called by the init routine of the base class (_EditPrimary).
|
|
|
|
"""
|
|
|
|
self._add_db_signal('person-rebuild', self.close)
|
|
|
|
self._add_db_signal('person-delete', self.check_for_close)
|
|
|
|
|
|
|
|
def check_for_close(self, handles):
|
|
|
|
"""
|
|
|
|
Callback method for delete signals.
|
|
|
|
If there is a delete signal of the primary object we are editing, the
|
|
|
|
editor (and all child windows spawned) should be closed
|
|
|
|
"""
|
|
|
|
if self.obj.ref in handles:
|
|
|
|
self.close()
|
|
|
|
|
2006-04-13 21:50:57 +05:30
|
|
|
def _select_person(self, obj):
|
2006-05-15 21:23:42 +05:30
|
|
|
from Selectors import selector_factory
|
|
|
|
SelectPerson = selector_factory('Person')
|
2006-04-13 21:50:57 +05:30
|
|
|
|
2006-05-31 23:56:50 +05:30
|
|
|
sel = SelectPerson(self.dbstate, self.uistate, self.track)
|
2006-04-13 21:50:57 +05:30
|
|
|
person = sel.run()
|
|
|
|
|
|
|
|
if person:
|
|
|
|
self.obj.ref = person.get_handle()
|
2007-06-28 11:11:40 +05:30
|
|
|
self.person_label.set_text(name_displayer.display(person))
|
2006-04-13 21:50:57 +05:30
|
|
|
|
|
|
|
def _create_tabbed_pages(self):
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Create the notebook tabs and inserts them into the main
|
2006-04-13 21:50:57 +05:30
|
|
|
window.
|
|
|
|
"""
|
|
|
|
|
|
|
|
notebook = gtk.Notebook()
|
|
|
|
|
|
|
|
self.srcref_list = self._add_tab(
|
|
|
|
notebook,
|
2006-10-09 08:15:26 +05:30
|
|
|
SourceEmbedList(self.dbstate,self.uistate,self.track,self.obj))
|
2006-04-13 21:50:57 +05:30
|
|
|
|
|
|
|
self.note_tab = self._add_tab(
|
|
|
|
notebook,
|
|
|
|
NoteTab(self.dbstate, self.uistate, self.track,
|
2007-05-08 02:11:16 +05:30
|
|
|
self.obj.get_note_list(),
|
|
|
|
notetype=NoteType.ASSOCIATION))
|
2006-04-13 21:50:57 +05:30
|
|
|
|
2007-01-16 12:42:10 +05:30
|
|
|
self._setup_notebook_tabs( notebook)
|
2006-04-13 21:50:57 +05:30
|
|
|
notebook.show_all()
|
2009-05-07 00:45:55 +05:30
|
|
|
self.top.get_object('vbox').pack_start(notebook,True)
|
2006-04-13 21:50:57 +05:30
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
def build_menu_names(self, obj):
|
2006-04-13 21:50:57 +05:30
|
|
|
return (_('Person Reference'),_('Person Reference Editor'))
|
|
|
|
|
|
|
|
def save(self,*obj):
|
|
|
|
"""
|
|
|
|
Called when the OK button is pressed. Gets data from the
|
|
|
|
form and updates the Address data structure.
|
|
|
|
"""
|
|
|
|
|
|
|
|
if self.obj.ref:
|
|
|
|
if self.callback:
|
|
|
|
self.callback(self.obj)
|
2006-04-24 04:13:36 +05:30
|
|
|
self.close()
|
2006-04-13 21:50:57 +05:30
|
|
|
else:
|
|
|
|
from QuestionDialog import ErrorDialog
|
|
|
|
|
|
|
|
ErrorDialog(
|
|
|
|
_('No person selected'),
|
|
|
|
_('You must either select a person or Cancel '
|
|
|
|
'the edit'))
|