2006-04-19 01:57:53 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
|
|
|
#
|
|
|
|
# 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: _EditChildRef.py 6282 2006-04-06 22:02:46Z rshura $
|
|
|
|
|
|
|
|
"""
|
|
|
|
The EditChildRef module provides the EditChildRef class. This provides a
|
|
|
|
mechanism for the user to edit address information.
|
|
|
|
"""
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
from gettext import gettext as _
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2008-01-18 04:45:08 +05:30
|
|
|
import gtk
|
2006-04-19 01:57:53 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
|
|
|
from _EditSecondary import EditSecondary
|
2007-10-08 22:11:39 +05:30
|
|
|
from gen.lib import NoteType
|
2008-01-18 04:45:08 +05:30
|
|
|
import Errors
|
2006-04-19 01:57:53 +05:30
|
|
|
|
2006-05-05 06:09:11 +05:30
|
|
|
from DisplayTabs import SourceEmbedList, NoteTab
|
2008-01-18 04:45:08 +05:30
|
|
|
from GrampsWidgets import MonitoredDataType, PrivacyButton
|
|
|
|
from BasicUtils import name_displayer
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
_RETURN = gtk.gdk.keyval_from_name("Return")
|
|
|
|
_KP_ENTER = gtk.gdk.keyval_from_name("KP_Enter")
|
2006-04-19 01:57:53 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# EditChildRef class
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class EditChildRef(EditSecondary):
|
|
|
|
"""
|
|
|
|
Displays a dialog that allows the user to edit an address.
|
|
|
|
"""
|
2006-07-06 00:30:32 +05:30
|
|
|
def __init__(self, name, dbstate, uistate, track, childref, callback):
|
2006-04-19 01:57:53 +05:30
|
|
|
"""
|
|
|
|
Displays the dialog box.
|
|
|
|
|
|
|
|
parent - The class that called the ChildRef editor.
|
|
|
|
addr - The address that is to be edited
|
|
|
|
"""
|
2006-07-06 00:30:32 +05:30
|
|
|
self.name = name
|
2006-04-19 01:57:53 +05:30
|
|
|
EditSecondary.__init__(self, dbstate, uistate, track,
|
|
|
|
childref, callback)
|
|
|
|
|
|
|
|
def _local_init(self):
|
2007-09-08 11:24:02 +05:30
|
|
|
self.top = gtk.glade.XML(const.GLADE_FILE, "cref_edit","gramps")
|
2006-04-24 03:48:01 +05:30
|
|
|
self.set_window(self.top.get_widget("cref_edit"),
|
|
|
|
self.top.get_widget("title"),
|
2006-07-06 00:30:32 +05:30
|
|
|
self.name,
|
2006-04-24 03:48:01 +05:30
|
|
|
_('Child Reference Editor'))
|
2008-01-18 03:22:13 +05:30
|
|
|
self.ok_button = self.top.get_widget('ok')
|
2008-01-18 04:45:08 +05:30
|
|
|
self.edit_button = self.top.get_widget('edit')
|
|
|
|
self.name_label = self.top.get_widget('name')
|
|
|
|
self.name_label.set_text(self.name)
|
2006-04-19 01:57:53 +05:30
|
|
|
|
|
|
|
def _setup_fields(self):
|
|
|
|
self.frel = MonitoredDataType(
|
|
|
|
self.top.get_widget('frel'),
|
|
|
|
self.obj.set_father_relation,
|
|
|
|
self.obj.get_father_relation,
|
2006-05-21 09:54:56 +05:30
|
|
|
self.db.readonly,
|
|
|
|
self.db.get_child_reference_types()
|
2006-04-19 01:57:53 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
self.mrel = MonitoredDataType(
|
|
|
|
self.top.get_widget('mrel'),
|
|
|
|
self.obj.set_mother_relation,
|
|
|
|
self.obj.get_mother_relation,
|
2006-05-21 09:54:56 +05:30
|
|
|
self.db.readonly,
|
|
|
|
self.db.get_child_reference_types()
|
2006-04-19 01:57:53 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
self.priv = PrivacyButton(
|
|
|
|
self.top.get_widget("private"),
|
|
|
|
self.obj,
|
|
|
|
self.db.readonly)
|
|
|
|
|
|
|
|
def _connect_signals(self):
|
2008-01-18 03:22:13 +05:30
|
|
|
self.define_help_button(self.top.get_widget('help'), 'adv-ad')
|
2006-04-19 01:57:53 +05:30
|
|
|
self.define_cancel_button(self.top.get_widget('cancel'))
|
2008-01-18 03:22:13 +05:30
|
|
|
self.define_ok_button(self.ok_button, self.save)
|
2008-01-18 04:45:08 +05:30
|
|
|
self.edit_button.connect('button-press-event', self.edit_child)
|
|
|
|
self.edit_button.connect('key-press-event', self.edit_child)
|
|
|
|
self._add_db_signal('person-update', self.person_change)
|
2006-04-19 01:57:53 +05:30
|
|
|
|
|
|
|
def _create_tabbed_pages(self):
|
|
|
|
"""
|
|
|
|
Creates the notebook tabs and inserts them into the main
|
|
|
|
window.
|
|
|
|
"""
|
|
|
|
notebook = gtk.Notebook()
|
2008-01-18 13:56:48 +05:30
|
|
|
|
2006-04-19 01:57:53 +05:30
|
|
|
self.srcref_list = self._add_tab(
|
|
|
|
notebook,
|
2006-10-09 08:15:26 +05:30
|
|
|
SourceEmbedList(self.dbstate,self.uistate,self.track,self.obj))
|
2008-01-18 13:56:48 +05:30
|
|
|
|
2006-04-19 01:57:53 +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.CHILDREF))
|
2006-04-19 01:57:53 +05:30
|
|
|
|
2007-01-16 12:42:10 +05:30
|
|
|
self._setup_notebook_tabs( notebook)
|
2006-04-19 01:57:53 +05:30
|
|
|
notebook.show_all()
|
|
|
|
self.top.get_widget('vbox').pack_start(notebook,True)
|
|
|
|
|
2008-01-18 03:22:13 +05:30
|
|
|
def _post_init(self):
|
|
|
|
self.ok_button.grab_focus()
|
|
|
|
|
2006-04-19 01:57:53 +05:30
|
|
|
def build_menu_names(self,obj):
|
2006-10-28 09:23:46 +05:30
|
|
|
return (_('Child Reference'),_('Child Reference Editor'))
|
2006-04-19 01:57:53 +05:30
|
|
|
|
2008-01-18 04:45:08 +05:30
|
|
|
def edit_child(self,obj,event):
|
|
|
|
if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1 \
|
|
|
|
or event.keyval in (_RETURN, _KP_ENTER):
|
|
|
|
from _EditPerson import EditPerson
|
|
|
|
handle = self.obj.ref
|
|
|
|
try:
|
|
|
|
person = self.db.get_person_from_handle(handle)
|
|
|
|
EditPerson(self.dbstate, self.uistate,
|
|
|
|
self.track, person)
|
|
|
|
except Errors.WindowActiveError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def person_change(self, handles):
|
|
|
|
# check to see if the handle matches the current object
|
|
|
|
if self.obj.ref in handles:
|
|
|
|
p = self.dbstate.db.get_person_from_handle(self.obj.ref)
|
|
|
|
self.name = name_displayer.display(p)
|
|
|
|
self.name_label.set_text(self.name)
|
|
|
|
|
2006-04-19 01:57:53 +05:30
|
|
|
def save(self,*obj):
|
|
|
|
"""
|
|
|
|
Called when the OK button is pressed. Gets data from the
|
|
|
|
form and updates the ChildRef data structure.
|
|
|
|
"""
|
|
|
|
if self.callback:
|
|
|
|
self.callback(self.obj)
|
2006-04-24 04:13:36 +05:30
|
|
|
self.close()
|