gramps/gramps2/src/Witness.py

264 lines
9.3 KiB
Python
Raw Normal View History

2003-03-08 05:49:32 +05:30
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2005 Donald N. Allingham
2003-03-08 05:49:32 +05:30
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
2003-03-08 05:49:32 +05:30
#-------------------------------------------------------------------------
#
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
import gtk
import gtk.glade
#-------------------------------------------------------------------------
#
# gramps modules
#
#-------------------------------------------------------------------------
import const
import Utils
import RelLib
import ListModel
2005-01-01 09:57:15 +05:30
import NameDisplay
import GrampsDisplay
2003-03-08 05:49:32 +05:30
#-------------------------------------------------------------------------
#
# WitnessTab
#
#-------------------------------------------------------------------------
class WitnessTab:
* 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
def __init__(self,srclist,parent,top,window,clist,add_btn,edit_btn,del_btn):
2003-03-08 05:49:32 +05:30
self.db = parent.db
self.parent = parent
self.list = srclist
self.top = 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 = window
2003-03-08 05:49:32 +05:30
self.slist = clist
self.selection = clist.get_selection()
titles = [ (_('Witness'),0,300),(_('ID'),1,100)]
self.model = ListModel.ListModel(clist,titles,event_func=self.edit_clicked);
add_btn.connect('clicked', self.add_clicked)
edit_btn.connect('clicked', self.edit_clicked)
del_btn.connect('clicked', self.del_clicked)
self.redraw()
def redraw(self):
self.model.clear()
for s in self.list:
if s.get_type() == RelLib.Event.ID:
handle = s.get_value()
if self.db.has_person_handle(handle):
person = self.db.get_person_from_handle(handle)
2005-01-01 09:57:15 +05:30
n = NameDisplay.displayer.sorted(person)
the_id = person.get_gramps_id()
2003-03-08 05:49:32 +05:30
else:
n = _('Unknown')
the_id = ''
self.model.add([n,the_id],s)
2003-03-08 05:49:32 +05:30
else:
self.model.add([s.get_value(),''],s)
if self.list:
Utils.bold_label(self.parent.witnesses_label)
else:
Utils.unbold_label(self.parent.witnesses_label)
2003-03-08 05:49:32 +05:30
def update_clist(self):
self.redraw()
self.parent.lists_changed = 1
def edit_clicked(self,obj):
store,node = self.selection.get_selected()
if node:
2003-03-08 05:49:32 +05:30
objs = self.model.get_selected_objects()
src = objs[0]
WitnessEditor(src,self.db,self,self.update_clist,self.window)
2003-03-08 05:49:32 +05:30
def add_clicked(self,obj):
WitnessEditor(None,self.db,self,self.update_clist,self.window)
2003-03-08 05:49:32 +05:30
def add_ref(self,inst,ref):
self.parent.lists_changed = 1
inst.list.append(ref)
inst.redraw()
def del_clicked(self,obj):
(store,node) = self.selection.get_selected()
if node:
path = store.get_path(node)
2003-03-08 05:49:32 +05:30
del self.list[path[0]]
self.redraw()
#-------------------------------------------------------------------------
#
# WitnessEditor
#
#-------------------------------------------------------------------------
class WitnessEditor:
def __init__(self,ref,database,parent,update=None,parent_window=None):
2003-03-08 05:49:32 +05:30
self.db = database
self.parent = parent
if ref:
if self.parent.parent.child_windows.has_key(ref):
self.parent.parent.child_windows[ref].present(None)
return
else:
self.win_key = ref
else:
self.win_key = self
2003-03-08 05:49:32 +05:30
self.update = update
self.ref = ref
2003-08-17 07:44:33 +05:30
self.show_witness = gtk.glade.XML(const.dialogFile, "witness_edit","gramps")
2003-03-08 05:49:32 +05:30
self.show_witness.signal_autoconnect({
"on_toggled" : self.on_toggled,
"on_witness_edit_delete_event" : self.on_delete_event,
"on_cancel_witness_clicked" : self.close,
"on_help_witness_clicked" : self.on_help_clicked,
"on_ok_witness_clicked" : self.ok_clicked,
2003-03-08 05:49:32 +05:30
})
* 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 = self.show_witness.get_widget('witness_edit')
2003-03-08 05:49:32 +05:30
self.name = self.show_witness.get_widget("name")
self.private = self.show_witness.get_widget("priv")
self.select = self.show_witness.get_widget("select")
self.select.connect('clicked',self.choose)
2003-03-08 05:49:32 +05:30
self.ok = self.show_witness.get_widget("ok")
self.in_db = self.show_witness.get_widget("in_db")
self.comment = self.show_witness.get_widget("comment")
2003-03-08 05:49:32 +05:30
if self.ref:
if self.ref.get_type():
self.idval = self.ref.get_value()
if self.db.has_person_handle(self.idval):
person = self.db.get_person_from_handle(self.idval)
2005-07-27 04:32:53 +05:30
name = NameDisplay.displayer.display(person)
self.name.set_text(name)
self.in_db.set_active(True)
else:
self.name.set_text(_("Unknown"))
2005-07-27 04:32:53 +05:30
self.in_db.set_active(False)
else:
self.name.set_text(self.ref.get_value())
2005-07-27 04:32:53 +05:30
self.in_db.set_active(False)
2003-03-08 05:49:32 +05:30
self.comment.get_buffer().set_text(self.ref.get_comment())
self.private.set_active(self.ref.get_privacy())
2003-03-08 05:49:32 +05:30
self.on_toggled(None)
2003-03-08 05:49:32 +05:30
Utils.set_titles(self.show_witness.get_widget('witness_edit'),
self.show_witness.get_widget('title'),
_('Witness Editor'))
* 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
if parent_window:
self.window.set_transient_for(parent_window)
self.add_itself_to_menu()
self.window.show()
def on_delete_event(self,obj,b):
self.remove_itself_from_menu()
def close(self,obj):
self.remove_itself_from_menu()
* 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.destroy()
def add_itself_to_menu(self):
self.parent.parent.child_windows[self.win_key] = self
self.parent_menu_item = gtk.MenuItem(_('Witness Editor'))
self.parent_menu_item.connect("activate",self.present)
self.parent_menu_item.show()
2004-02-25 08:50:53 +05:30
self.parent.parent.winsmenu.append(self.parent_menu_item)
def remove_itself_from_menu(self):
del self.parent.parent.child_windows[self.win_key]
self.parent_menu_item.destroy()
def present(self,obj):
self.window.present()
def on_help_clicked(self,obj):
"""Display the relevant portion of GRAMPS manual"""
GrampsDisplay.help('adv-wit')
def choose(self,obj):
import SelectPerson
2005-07-27 04:32:53 +05:30
sel_person = SelectPerson.SelectPerson(self.db,_('Select Person'),
parent_window=self.window)
new_person = sel_person.run()
if new_person:
self.new_person = new_person
self.idval = new_person.get_handle()
2005-07-27 04:32:53 +05:30
new_name = NameDisplay.displayer.display(new_person)
if new_name:
self.name.set_text(new_name)
2003-03-08 05:49:32 +05:30
def on_toggled(self,obj):
if self.in_db.get_active():
2005-07-27 04:32:53 +05:30
self.name.set_editable(False)
self.name.set_sensitive(False)
self.select.set_sensitive(True)
2003-03-08 05:49:32 +05:30
else:
2005-07-27 04:32:53 +05:30
self.name.set_editable(True)
self.name.set_sensitive(True)
self.select.set_sensitive(False)
2003-03-08 05:49:32 +05:30
def ok_clicked(self,obj):
2003-03-08 05:49:32 +05:30
if not self.ref:
if self.in_db.get_active():
self.ref = RelLib.Witness(RelLib.Event.ID)
else:
self.ref = RelLib.Witness(RelLib.Event.NAME)
self.parent.list.append(self.ref)
if self.in_db.get_active():
try:
self.ref.set_value(self.idval)
self.ref.set_type(RelLib.Event.ID)
except AttributeError:
import QuestionDialog
QuestionDialog.ErrorDialog(
_("Witness selection error"),
_("Since you have indicated that the person is "
"in the database, you need to actually select "
"the person by pressing the Select button.\n\n"
"Please try again. The witness has not been changed."),
self.window)
2003-03-08 05:49:32 +05:30
else:
* src/PlaceView.py: Make sure to add new place after edit * src/AddMedia.py: unicode conversion from gtk.Entry * src/AddSpouse.py: unicode conversion from gtk.Entry * src/AddrEdit.py: unicode conversion from gtk.Entry * src/AttrEdit.py: unicode conversion from gtk.Entry * src/AutoComp.py: unicode conversion from gtk.Entry * src/ChooseParents.py: unicode conversion from gtk.Entry * src/DateEdit.py: unicode conversion from gtk.Entry * src/EditPerson.py: unicode conversion from gtk.Entry * src/EditPlace.py: unicode conversion from gtk.Entry * src/EditSource.py: unicode conversion from gtk.Entry * src/EventEdit.py: unicode conversion from gtk.Entry * src/Find.py: unicode conversion from gtk.Entry * src/GrampsCfg.py: unicode conversion from gtk.Entry * src/ImageSelect.py: unicode conversion from gtk.Entry * src/LocEdit.py: unicode conversion from gtk.Entry * src/Marriage.py: unicode conversion from gtk.Entry * src/MergeData.py: unicode conversion from gtk.Entry * src/NameEdit.py: unicode conversion from gtk.Entry * src/PeopleView.py: unicode conversion from gtk.Entry * src/Report.py: unicode conversion from gtk.Entry * src/SelectChild.py: unicode conversion from gtk.Entry * src/Sources.py: unicode conversion from gtk.Entry * src/StartupDialog.py: unicode conversion from gtk.Entry * src/StyleEditor.py: unicode conversion from gtk.Entry * src/UrlEdit.py: unicode conversion from gtk.Entry * src/Utils.py: unicode conversion from gtk.Entry * src/VersionControl.py: unicode conversion from gtk.Entry * src/Witness.py: unicode conversion from gtk.Entry svn: r2534
2003-12-17 10:53:16 +05:30
self.ref.set_value(unicode(self.name.get_text()))
self.ref.set_type(RelLib.Event.NAME)
2003-03-08 05:49:32 +05:30
c = self.comment.get_buffer()
self.ref.set_comment(unicode(c.get_text(c.get_start_iter(),c.get_end_iter(),False)))
self.ref.set_privacy(self.private.get_active())
2003-03-08 05:49:32 +05:30
if self.update:
self.update()
self.close(obj)