2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2005-02-25 22:59:39 +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-11-13 00:15:07 +05:30
|
|
|
# $Id$
|
|
|
|
|
2004-09-19 20:47:57 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
from gettext import gettext as _
|
2005-08-03 01:09:53 +05:30
|
|
|
import sets
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
2003-11-18 09:56:06 +05:30
|
|
|
import gnome
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import Sources
|
2003-02-24 10:21:57 +05:30
|
|
|
import Witness
|
2002-10-20 19:55:16 +05:30
|
|
|
import const
|
|
|
|
import Utils
|
|
|
|
import AutoComp
|
2003-01-10 10:51:32 +05:30
|
|
|
import RelLib
|
|
|
|
import Date
|
2004-09-17 09:00:04 +05:30
|
|
|
import DateHandler
|
2004-06-03 11:05:30 +05:30
|
|
|
import ImageSelect
|
2004-09-18 09:28:30 +05:30
|
|
|
import DateEdit
|
2005-08-05 09:11:23 +05:30
|
|
|
import Spell
|
|
|
|
|
2005-03-24 04:28:46 +05:30
|
|
|
from QuestionDialog import WarningDialog, ErrorDialog
|
2004-09-19 20:47:57 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# EventEditor class
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class EventEditor:
|
|
|
|
|
2005-02-19 10:11:59 +05:30
|
|
|
def __init__(self,parent,name,elist,trans,event,def_placename,
|
2005-04-01 11:03:22 +05:30
|
|
|
read_only, cb, def_event=None, noedit=False):
|
2002-10-20 19:55:16 +05:30
|
|
|
self.parent = parent
|
2003-11-13 00:15:07 +05:30
|
|
|
self.db = self.parent.db
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
if event:
|
2004-07-28 07:59:07 +05:30
|
|
|
if self.parent.child_windows.has_key(event.get_handle()):
|
|
|
|
self.parent.child_windows[event.get_handle()].present(None)
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
return
|
|
|
|
else:
|
2004-07-28 07:59:07 +05:30
|
|
|
self.win_key = event.get_handle()
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
else:
|
|
|
|
self.win_key = self
|
2002-10-20 19:55:16 +05:30
|
|
|
self.event = event
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
self.child_windows = {}
|
2002-10-20 19:55:16 +05:30
|
|
|
self.trans = trans
|
|
|
|
self.callback = cb
|
2004-06-03 11:05:30 +05:30
|
|
|
self.path = self.db.get_save_path()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.plist = []
|
|
|
|
self.pmap = {}
|
2004-05-12 09:28:14 +05:30
|
|
|
|
2004-12-29 10:36:10 +05:30
|
|
|
self.dp = DateHandler.parser
|
|
|
|
self.dd = DateHandler.displayer
|
2004-09-17 09:00:04 +05:30
|
|
|
|
2005-08-03 01:09:53 +05:30
|
|
|
# build list for menu
|
|
|
|
values = sets.Set(elist)
|
|
|
|
values.union(self.get_event_names())
|
|
|
|
self.elist = list(values)
|
2004-05-12 09:28:14 +05:30
|
|
|
self.elist.sort()
|
2004-02-19 10:35:43 +05:30
|
|
|
|
2004-08-13 10:04:07 +05:30
|
|
|
for key in self.parent.db.get_place_handles():
|
2005-04-12 20:46:04 +05:30
|
|
|
title = self.parent.db.get_place_from_handle(key).get_title()
|
|
|
|
self.pmap[title] = key
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if event:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.srcreflist = self.event.get_source_references()
|
2003-02-24 10:21:57 +05:30
|
|
|
self.witnesslist = self.event.get_witness_list()
|
|
|
|
if not self.witnesslist:
|
|
|
|
self.witnesslist = []
|
2004-02-14 11:10:30 +05:30
|
|
|
self.date = Date.Date(self.event.get_date_object())
|
|
|
|
transname = const.display_event(event.get_name())
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
self.srcreflist = []
|
2003-02-24 10:21:57 +05:30
|
|
|
self.witnesslist = []
|
2003-01-10 10:51:32 +05:30
|
|
|
self.date = Date.Date(None)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-08-17 07:44:33 +05:30
|
|
|
self.top = gtk.glade.XML(const.dialogFile, "event_edit","gramps")
|
2003-03-05 11:31:31 +05:30
|
|
|
|
2003-03-06 11:42:51 +05:30
|
|
|
self.window = self.top.get_widget("event_edit")
|
2003-03-05 11:31:31 +05:30
|
|
|
title_label = self.top.get_widget('title')
|
2003-03-06 11:42:51 +05:30
|
|
|
|
2003-06-03 08:24:56 +05:30
|
|
|
if name == ", ":
|
|
|
|
etitle = _('Event Editor')
|
|
|
|
else:
|
|
|
|
etitle = _('Event Editor for %s') % name
|
|
|
|
|
|
|
|
Utils.set_titles(self.window,title_label, etitle,
|
2003-03-06 11:42:51 +05:30
|
|
|
_('Event Editor'))
|
2003-03-05 11:31:31 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.place_field = self.top.get_widget("eventPlace")
|
2005-02-19 10:11:59 +05:30
|
|
|
self.place_field.set_editable(not noedit)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.cause_field = self.top.get_widget("eventCause")
|
2005-02-19 10:11:59 +05:30
|
|
|
self.cause_field.set_editable(not noedit)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.slist = self.top.get_widget("slist")
|
2003-02-24 10:21:57 +05:30
|
|
|
self.wlist = self.top.get_widget("wlist")
|
2002-10-20 19:55:16 +05:30
|
|
|
self.place_combo = self.top.get_widget("eventPlace_combo")
|
|
|
|
self.date_field = self.top.get_widget("eventDate")
|
2005-02-19 10:11:59 +05:30
|
|
|
self.date_field.set_editable(not noedit)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.descr_field = self.top.get_widget("event_description")
|
2005-02-19 10:11:59 +05:30
|
|
|
self.descr_field.set_editable(not noedit)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.note_field = self.top.get_widget("eventNote")
|
2005-02-19 10:11:59 +05:30
|
|
|
self.note_field.set_editable(not noedit)
|
2005-08-05 09:11:23 +05:30
|
|
|
self.spell = Spell.Spell(self.note_field)
|
2004-08-04 10:23:29 +05:30
|
|
|
self.event_menu = self.top.get_widget("personal_events")
|
2002-10-20 19:55:16 +05:30
|
|
|
self.priv = self.top.get_widget("priv")
|
2005-02-19 10:11:59 +05:30
|
|
|
self.priv.set_sensitive(not noedit)
|
2003-11-13 00:15:07 +05:30
|
|
|
self.sources_label = self.top.get_widget("sourcesEvent")
|
|
|
|
self.notes_label = self.top.get_widget("notesEvent")
|
2003-12-16 01:30:47 +05:30
|
|
|
self.flowed = self.top.get_widget("eventflowed")
|
2005-02-19 10:11:59 +05:30
|
|
|
self.flowed.set_sensitive(not noedit)
|
2003-12-16 01:30:47 +05:30
|
|
|
self.preform = self.top.get_widget("eventpreform")
|
2005-02-19 10:11:59 +05:30
|
|
|
self.preform.set_sensitive(not noedit)
|
2004-06-03 11:05:30 +05:30
|
|
|
self.gallery_label = self.top.get_widget("galleryEvent")
|
2003-11-13 00:15:07 +05:30
|
|
|
self.witnesses_label = self.top.get_widget("witnessesEvent")
|
2005-03-24 03:31:22 +05:30
|
|
|
self.ok = self.top.get_widget('ok')
|
|
|
|
|
|
|
|
self.ok.set_sensitive(not noedit)
|
2005-02-19 10:11:59 +05:30
|
|
|
|
2005-02-25 22:59:39 +05:30
|
|
|
if read_only or noedit:
|
2005-02-19 10:11:59 +05:30
|
|
|
self.event_menu.set_sensitive(False)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.date_field.grab_focus()
|
|
|
|
|
2005-02-19 10:11:59 +05:30
|
|
|
add_src = self.top.get_widget('add_src')
|
|
|
|
add_src.set_sensitive(not noedit)
|
|
|
|
del_src = self.top.get_widget('del_src')
|
|
|
|
del_src.set_sensitive(not noedit)
|
|
|
|
|
2005-02-27 11:21:59 +05:30
|
|
|
self.sourcetab = Sources.SourceTab(
|
|
|
|
self.srcreflist, self, self.top, self.window, self.slist,
|
|
|
|
add_src, self.top.get_widget('edit_src'), del_src,
|
2005-04-01 11:03:22 +05:30
|
|
|
self.db.readonly)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-02-19 10:11:59 +05:30
|
|
|
add_witness = self.top.get_widget('add_witness')
|
|
|
|
add_witness.set_sensitive(not noedit)
|
|
|
|
edit_witness = self.top.get_widget('edit_witness')
|
|
|
|
del_witness = self.top.get_widget('del_witness')
|
|
|
|
del_witness.set_sensitive(not noedit)
|
|
|
|
|
2005-02-27 11:21:59 +05:30
|
|
|
self.witnesstab = Witness.WitnessTab(
|
|
|
|
self.witnesslist, self, self.top, self.window, self.wlist,
|
|
|
|
add_witness, edit_witness, del_witness)
|
2003-02-24 10:21:57 +05:30
|
|
|
|
2004-08-04 10:23:29 +05:30
|
|
|
AutoComp.fill_combo(self.event_menu,self.elist)
|
|
|
|
AutoComp.fill_entry(self.place_field,self.pmap.keys())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if event != None:
|
2004-08-04 10:23:29 +05:30
|
|
|
self.event_menu.child.set_text(transname)
|
2002-10-20 19:55:16 +05:30
|
|
|
if (def_placename):
|
|
|
|
self.place_field.set_text(def_placename)
|
|
|
|
else:
|
2004-07-28 07:59:07 +05:30
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if not place_handle:
|
2004-02-19 10:35:43 +05:30
|
|
|
place_name = u""
|
|
|
|
else:
|
2004-08-07 10:46:57 +05:30
|
|
|
place_name = self.db.get_place_from_handle(place_handle).get_title()
|
2004-02-19 10:35:43 +05:30
|
|
|
self.place_field.set_text(place_name)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-09-17 09:00:04 +05:30
|
|
|
self.date_field.set_text(self.dd.display(self.date))
|
2004-02-14 11:10:30 +05:30
|
|
|
self.cause_field.set_text(event.get_cause())
|
|
|
|
self.descr_field.set_text(event.get_description())
|
|
|
|
self.priv.set_active(event.get_privacy())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
self.note_field.get_buffer().set_text(event.get_note())
|
|
|
|
if event.get_note():
|
2005-02-25 22:59:39 +05:30
|
|
|
self.note_field.get_buffer().set_text(event.get_note())
|
2003-12-16 01:30:47 +05:30
|
|
|
Utils.bold_label(self.notes_label)
|
2005-02-25 22:59:39 +05:30
|
|
|
if event.get_note_format() == 1:
|
2003-12-16 01:30:47 +05:30
|
|
|
self.preform.set_active(1)
|
2005-02-25 22:59:39 +05:30
|
|
|
else:
|
2003-12-16 01:30:47 +05:30
|
|
|
self.flowed.set_active(1)
|
2004-06-03 11:05:30 +05:30
|
|
|
if event.get_media_list():
|
|
|
|
Utils.bold_label(self.gallery_label)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2003-05-14 02:20:58 +05:30
|
|
|
if def_event:
|
2004-08-04 10:23:29 +05:30
|
|
|
self.event_menu.child.set_text(def_event)
|
2003-05-14 02:20:58 +05:30
|
|
|
if def_placename:
|
2002-10-20 19:55:16 +05:30
|
|
|
self.place_field.set_text(def_placename)
|
2004-09-19 20:47:57 +05:30
|
|
|
self.date_check = DateEdit.DateEdit(self.date,
|
|
|
|
self.date_field,
|
2005-02-25 22:59:39 +05:30
|
|
|
self.top.get_widget("date_stat"),
|
|
|
|
self.window)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-06-03 11:05:30 +05:30
|
|
|
if not event:
|
|
|
|
event = RelLib.Event()
|
|
|
|
self.icon_list = self.top.get_widget("iconlist")
|
2005-02-19 10:11:59 +05:30
|
|
|
self.gallery = ImageSelect.Gallery(event, self.db.commit_event,
|
|
|
|
self.path, self.icon_list,
|
2004-06-03 11:05:30 +05:30
|
|
|
self.db,self,self.window)
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.top.signal_autoconnect({
|
2005-04-11 03:38:11 +05:30
|
|
|
"on_switch_page" : self.on_switch_page,
|
|
|
|
"on_help_event_clicked" : self.on_help_clicked,
|
|
|
|
"on_ok_event_clicked" : self.on_event_edit_ok_clicked,
|
|
|
|
"on_cancel_event_clicked" : self.close,
|
|
|
|
"on_event_edit_delete_event": self.on_delete_event,
|
2004-06-03 11:05:30 +05:30
|
|
|
"on_addphoto_clicked" : self.gallery.on_add_media_clicked,
|
|
|
|
"on_selectphoto_clicked" : self.gallery.on_select_media_clicked,
|
|
|
|
"on_deletephoto_clicked" : self.gallery.on_delete_media_clicked,
|
|
|
|
"on_edit_properties_clicked": self.gallery.popup_change_description,
|
|
|
|
"on_editphoto_clicked" : self.gallery.on_edit_media_clicked,
|
2002-10-20 19:55:16 +05:30
|
|
|
})
|
|
|
|
|
2005-02-19 10:11:59 +05:30
|
|
|
self.top.get_widget('del_obj').set_sensitive(not noedit)
|
|
|
|
self.top.get_widget('sel_obj').set_sensitive(not noedit)
|
|
|
|
self.top.get_widget('add_obj').set_sensitive(not noedit)
|
|
|
|
|
2005-04-14 05:56:38 +05:30
|
|
|
try:
|
|
|
|
self.window.set_transient_for(self.parent.window)
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
2004-02-20 07:56:47 +05:30
|
|
|
self.add_itself_to_menu()
|
|
|
|
self.window.show()
|
|
|
|
|
|
|
|
def on_delete_event(self,obj,b):
|
2004-08-04 10:23:29 +05:30
|
|
|
self.gallery.close()
|
2004-02-20 07:56:47 +05:30
|
|
|
self.close_child_windows()
|
|
|
|
self.remove_itself_from_menu()
|
|
|
|
|
2004-08-04 10:23:29 +05:30
|
|
|
def close(self,obj):
|
|
|
|
self.gallery.close()
|
2004-02-20 07:56:47 +05:30
|
|
|
self.close_child_windows()
|
|
|
|
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()
|
|
|
|
|
2004-02-20 07:56:47 +05:30
|
|
|
def close_child_windows(self):
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
for child_window in self.child_windows.values():
|
2004-02-20 07:56:47 +05:30
|
|
|
child_window.close(None)
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
self.child_windows = {}
|
2004-02-20 07:56:47 +05:30
|
|
|
|
|
|
|
def add_itself_to_menu(self):
|
* src/AddrEdit.py, src/AttrEdit.py, src/EditPerson.py,
src/EditSource.py, src/EventEdit.py, src/ImageSelect.py,
src/Marriage.py, src/NameEdit.py, src/NoteEdit.py,
src/Sources.py, src/UrlEdit.py, src/Witness.py:
Register windows opened for existing objects. Prevent editing
same object twice.
svn: r2905
2004-02-24 11:07:06 +05:30
|
|
|
self.parent.child_windows[self.win_key] = self
|
2004-02-20 07:56:47 +05:30
|
|
|
if not self.event:
|
|
|
|
label = _("New Event")
|
|
|
|
else:
|
|
|
|
label = self.event.get_name()
|
|
|
|
if not label.strip():
|
|
|
|
label = _("New Event")
|
|
|
|
label = "%s: %s" % (_('Event'),label)
|
|
|
|
self.parent_menu_item = gtk.MenuItem(label)
|
|
|
|
self.parent_menu_item.set_submenu(gtk.Menu())
|
|
|
|
self.parent_menu_item.show()
|
2004-02-25 08:50:53 +05:30
|
|
|
self.parent.winsmenu.append(self.parent_menu_item)
|
|
|
|
self.winsmenu = self.parent_menu_item.get_submenu()
|
2004-02-20 07:56:47 +05:30
|
|
|
self.menu_item = gtk.MenuItem(_('Event Editor'))
|
|
|
|
self.menu_item.connect("activate",self.present)
|
|
|
|
self.menu_item.show()
|
2004-02-25 08:50:53 +05:30
|
|
|
self.winsmenu.append(self.menu_item)
|
2004-02-20 07:56:47 +05:30
|
|
|
|
|
|
|
def remove_itself_from_menu(self):
|
2005-04-14 05:56:38 +05:30
|
|
|
if self.window:
|
|
|
|
del self.parent.child_windows[self.win_key]
|
2004-02-20 07:56:47 +05:30
|
|
|
self.menu_item.destroy()
|
2004-02-25 08:50:53 +05:30
|
|
|
self.winsmenu.destroy()
|
2004-02-20 07:56:47 +05:30
|
|
|
self.parent_menu_item.destroy()
|
|
|
|
|
|
|
|
def present(self,obj):
|
|
|
|
self.window.present()
|
|
|
|
|
2003-11-18 09:56:06 +05:30
|
|
|
def on_help_clicked(self,obj):
|
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
2005-05-03 07:43:44 +05:30
|
|
|
gnome.help_display('gramps-manual','adv-ev')
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-04-11 03:38:11 +05:30
|
|
|
def get_place(self,field,trans):
|
|
|
|
text = unicode(field.get_text().strip())
|
|
|
|
if text:
|
|
|
|
if self.pmap.has_key(text):
|
2005-04-12 21:53:07 +05:30
|
|
|
return self.db.get_place_from_handle(self.pmap[text])
|
2005-04-11 03:38:11 +05:30
|
|
|
else:
|
|
|
|
place = RelLib.Place()
|
|
|
|
place.set_title(text)
|
|
|
|
self.db.add_place(place,trans)
|
|
|
|
return place
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
2004-02-20 07:56:47 +05:30
|
|
|
def on_event_edit_ok_clicked(self,obj):
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-08-04 10:23:29 +05:30
|
|
|
ename = unicode(self.event_menu.child.get_text())
|
2005-03-24 04:28:46 +05:30
|
|
|
|
|
|
|
if not ename.strip():
|
|
|
|
ErrorDialog(_("Event does not have a type"),
|
|
|
|
_("You must specify an event type "
|
|
|
|
"before you can save the event"))
|
|
|
|
return
|
|
|
|
|
|
|
|
trans = self.db.transaction_begin()
|
2004-09-19 20:47:57 +05:30
|
|
|
#self.date = self.dp.parse(unicode(self.date_field.get_text()))
|
2003-12-17 10:53:16 +05:30
|
|
|
ecause = unicode(self.cause_field.get_text())
|
2005-04-11 03:38:11 +05:30
|
|
|
eplace_obj = self.get_place(self.place_field,trans)
|
2002-10-20 19:55:16 +05:30
|
|
|
buf = self.note_field.get_buffer()
|
|
|
|
|
2005-01-16 09:30:35 +05:30
|
|
|
start = buf.get_start_iter()
|
|
|
|
stop = buf.get_end_iter()
|
|
|
|
enote = unicode(buf.get_text(start,stop,False))
|
2003-12-16 01:30:47 +05:30
|
|
|
eformat = self.preform.get_active()
|
2003-12-17 10:53:16 +05:30
|
|
|
edesc = unicode(self.descr_field.get_text())
|
2002-10-20 19:55:16 +05:30
|
|
|
epriv = self.priv.get_active()
|
|
|
|
|
2005-03-14 03:40:40 +05:30
|
|
|
if ename not in self.elist + [_("Birth") , _("Death")]:
|
2005-02-27 11:21:59 +05:30
|
|
|
WarningDialog(
|
|
|
|
_('New event type created'),
|
|
|
|
_('The "%s" event type has been added to this database.\n'
|
|
|
|
'It will now appear in the event menus for this database') % ename)
|
2003-11-27 23:31:20 +05:30
|
|
|
self.elist.append(ename)
|
|
|
|
self.elist.sort()
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.event == None:
|
2003-01-10 10:51:32 +05:30
|
|
|
self.event = RelLib.Event()
|
2004-04-04 10:09:52 +05:30
|
|
|
self.db.add_event(self.event,trans)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.event.set_source_reference_list(self.srcreflist)
|
2003-02-24 10:21:57 +05:30
|
|
|
self.event.set_witness_list(self.witnesslist)
|
2004-07-28 07:59:07 +05:30
|
|
|
self.parent.elist.append(self.event.get_handle())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-04-04 10:09:52 +05:30
|
|
|
self.update_event(ename,self.date,eplace_obj,edesc,enote,eformat,
|
|
|
|
epriv,ecause,trans)
|
2004-08-13 10:04:07 +05:30
|
|
|
self.db.transaction_commit(trans,_("Edit Event"))
|
2004-08-04 10:23:29 +05:30
|
|
|
self.close(obj)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.parent.redraw_event_list()
|
2005-04-14 05:56:38 +05:30
|
|
|
if self.callback:
|
|
|
|
self.callback(self.event)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-04-04 10:09:52 +05:30
|
|
|
def update_event(self,name,date,place,desc,note,format,priv,cause,trans):
|
2004-02-19 10:35:43 +05:30
|
|
|
if place:
|
2004-07-28 07:59:07 +05:30
|
|
|
if self.event.get_place_handle() != place.get_handle():
|
|
|
|
self.event.set_place_handle(place.get_handle())
|
2004-02-19 10:35:43 +05:30
|
|
|
self.parent.lists_changed = 1
|
|
|
|
else:
|
2004-07-28 07:59:07 +05:30
|
|
|
if self.event.get_place_handle():
|
|
|
|
self.event.set_place_handle("")
|
2004-02-19 10:35:43 +05:30
|
|
|
self.parent.lists_changed = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-03-14 03:40:40 +05:30
|
|
|
if self.event.get_name() not in [self.trans.find_key(name),
|
|
|
|
"Birth","Death"]:
|
2004-08-21 02:56:51 +05:30
|
|
|
self.event.set_name(self.trans.find_key(name))
|
2002-10-20 19:55:16 +05:30
|
|
|
self.parent.lists_changed = 1
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if self.event.get_description() != desc:
|
|
|
|
self.event.set_description(desc)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.parent.lists_changed = 1
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if self.event.get_note() != note:
|
|
|
|
self.event.set_note(note)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.parent.lists_changed = 1
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if self.event.get_note_format() != format:
|
|
|
|
self.event.set_note_format(format)
|
2003-12-16 01:30:47 +05:30
|
|
|
self.parent.lists_changed = 1
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
dobj = self.event.get_date_object()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
self.event.set_source_reference_list(self.srcreflist)
|
2003-02-24 10:21:57 +05:30
|
|
|
self.event.set_witness_list(self.witnesslist)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-10-07 18:08:31 +05:30
|
|
|
if not dobj.is_equal(date):
|
2004-02-14 11:10:30 +05:30
|
|
|
self.event.set_date_object(date)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.parent.lists_changed = 1
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if self.event.get_cause() != cause:
|
|
|
|
self.event.set_cause(cause)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.parent.lists_changed = 1
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if self.event.get_privacy() != priv:
|
|
|
|
self.event.set_privacy(priv)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.parent.lists_changed = 1
|
2005-08-03 01:09:53 +05:30
|
|
|
self.commit(self.event,trans)
|
2003-11-13 00:15:07 +05:30
|
|
|
|
|
|
|
def on_switch_page(self,obj,a,page):
|
|
|
|
buf = self.note_field.get_buffer()
|
2005-02-24 05:55:34 +05:30
|
|
|
text = unicode(buf.get_text(buf.get_start_iter(),buf.get_end_iter(),False))
|
2003-11-13 00:15:07 +05:30
|
|
|
if text:
|
|
|
|
Utils.bold_label(self.notes_label)
|
|
|
|
else:
|
|
|
|
Utils.unbold_label(self.notes_label)
|
2005-08-03 01:09:53 +05:30
|
|
|
|
|
|
|
def commit(self,event,trans):
|
|
|
|
self.db.commit_event(event,trans)
|
|
|
|
|
|
|
|
def get_event_names(self):
|
|
|
|
data = sets.Set(self.db.get_family_event_types())
|
|
|
|
data.union(self.db.get_person_event_types())
|
|
|
|
return list(data)
|
|
|
|
|
|
|
|
class FamilyEventEditor(EventEditor):
|
|
|
|
|
|
|
|
def __init__(self,parent,name,event,def_placename,
|
|
|
|
read_only, cb, def_event=None, noedit=False):
|
|
|
|
|
|
|
|
EventEditor.__init__(self, parent, name, const.marriageEvents,
|
|
|
|
const.family_events, event, def_placename,
|
|
|
|
read_only, cb, def_event, noedit)
|
|
|
|
|
|
|
|
def commit(self,event,trans):
|
|
|
|
self.db.commit_family_event(event,trans)
|
|
|
|
|
|
|
|
def get_event_names(self):
|
|
|
|
return self.db.get_family_event_types()
|
|
|
|
|
|
|
|
class PersonEventEditor(EventEditor):
|
|
|
|
|
|
|
|
def __init__(self,parent,name,event,def_placename,
|
|
|
|
read_only, cb, def_event=None, noedit=False):
|
|
|
|
|
|
|
|
EventEditor.__init__(self, parent, name, const.personalEvents,
|
|
|
|
const.personal_events, event, def_placename,
|
|
|
|
read_only, cb, def_event, noedit)
|
|
|
|
|
|
|
|
def commit(self,event,trans):
|
|
|
|
self.db.commit_personal_event(event,trans)
|
|
|
|
|
|
|
|
def get_event_names(self):
|
|
|
|
return self.db.get_person_event_types()
|