2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-02-04 03:33:53 +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.
|
|
|
|
#
|
|
|
|
# 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-18 11:28:28 +05:30
|
|
|
import sets
|
2005-12-07 01:24:16 +05:30
|
|
|
import gc
|
|
|
|
from cgi import escape
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# 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
|
2005-06-07 05:20:33 +05:30
|
|
|
from DateHandler import parser as _dp, displayer as _dd
|
2004-09-18 09:28:30 +05:30
|
|
|
import DateEdit
|
2005-12-07 01:24:16 +05:30
|
|
|
import GrampsDisplay
|
2005-12-14 12:24:02 +05:30
|
|
|
import DisplayState
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2005-03-24 04:28:46 +05:30
|
|
|
from QuestionDialog import WarningDialog, ErrorDialog
|
2005-12-07 01:24:16 +05:30
|
|
|
from WindowUtils import GladeIf
|
2006-02-03 04:18:21 +05:30
|
|
|
from DisplayTabs import *
|
2004-09-19 20:47:57 +05:30
|
|
|
|
2005-06-09 02:47:18 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
total_events = dict(Utils.personal_events)
|
|
|
|
for event_type in Utils.family_events.keys():
|
|
|
|
if not total_events.has_key(event_type):
|
|
|
|
total_events[event_type] = Utils.family_events[event_type]
|
|
|
|
|
2005-06-07 05:20:33 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# helper function
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def get_place(field,pmap,db):
|
|
|
|
text = unicode(field.get_text().strip())
|
|
|
|
if text:
|
|
|
|
if pmap.has_key(text):
|
|
|
|
return db.get_place_from_handle(pmap[text])
|
|
|
|
else:
|
|
|
|
place = RelLib.Place()
|
|
|
|
place.set_title(text)
|
|
|
|
trans = db.transaction_begin()
|
|
|
|
db.add_place(place,trans)
|
|
|
|
db.transaction_commit(trans,_("Add Place"))
|
|
|
|
return place
|
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# EventEditor class
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-12-23 05:13:32 +05:30
|
|
|
class EventEditor(DisplayState.ManagedWindow):
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-02-04 04:01:46 +05:30
|
|
|
def __init__(self,event,dbstate,uistate,track=[],callback=None):
|
2005-08-12 03:43:44 +05:30
|
|
|
self.db = dbstate.db
|
2005-12-23 05:13:32 +05:30
|
|
|
self.uistate = uistate
|
|
|
|
self.dbstate = dbstate
|
|
|
|
self.track = track
|
2006-02-04 04:01:46 +05:30
|
|
|
self.callback = callback
|
2005-12-23 05:13:32 +05:30
|
|
|
|
2005-06-07 10:38:50 +05:30
|
|
|
read_only = self.db.readonly
|
|
|
|
noedit = self.db.readonly
|
2002-10-20 19:55:16 +05:30
|
|
|
self.event = event
|
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
|
|
|
|
2005-08-19 21:21:14 +05:30
|
|
|
self.dp = _dp
|
|
|
|
self.dd = _dd
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2005-12-24 05:39:04 +05:30
|
|
|
DisplayState.ManagedWindow.__init__(self, uistate, self.track, event)
|
2005-12-23 05:13:32 +05:30
|
|
|
if self.already_exist:
|
|
|
|
return
|
|
|
|
|
2005-08-12 03:43:44 +05:30
|
|
|
for key in self.db.get_place_handles():
|
|
|
|
title = self.db.get_place_from_handle(key).get_title()
|
2005-04-12 20:46:04 +05:30
|
|
|
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()
|
2006-02-04 03:33:53 +05:30
|
|
|
self.date = RelLib.Date(self.event.get_date_object())
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
self.srcreflist = []
|
2006-02-04 03:33:53 +05:30
|
|
|
self.date = RelLib.Date(None)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-01-17 10:33:30 +05:30
|
|
|
self.top = gtk.glade.XML(const.gladeFile, "event_edit","gramps")
|
2005-12-07 01:24:16 +05:30
|
|
|
self.gladeif = GladeIf(self.top)
|
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
|
|
|
|
2005-06-07 10:38:50 +05:30
|
|
|
etitle = _('Event Editor')
|
2003-06-03 08:24:56 +05:30
|
|
|
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.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)
|
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)
|
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-06-02 10:14:51 +05:30
|
|
|
if event:
|
|
|
|
defval = event.get_type()[0]
|
|
|
|
else:
|
|
|
|
defval = None
|
|
|
|
|
2005-06-08 22:02:13 +05:30
|
|
|
self.type_selector = AutoComp.StandardCustomSelector(
|
2005-06-09 02:47:18 +05:30
|
|
|
total_events, self.event_menu,
|
2005-06-07 05:20:33 +05:30
|
|
|
RelLib.Event.CUSTOM, defval)
|
|
|
|
|
2004-08-04 10:23:29 +05:30
|
|
|
AutoComp.fill_entry(self.place_field,self.pmap.keys())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if event != None:
|
2005-06-07 10:38:50 +05:30
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if not place_handle:
|
|
|
|
place_name = u""
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2005-06-07 10:38:50 +05:30
|
|
|
place_name = self.db.get_place_from_handle(place_handle).get_title()
|
|
|
|
self.place_field.set_text(place_name)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-06-07 05:20:33 +05:30
|
|
|
self.date_field.set_text(_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
|
|
|
|
|
|
|
else:
|
2005-06-08 22:02:13 +05:30
|
|
|
event = RelLib.Event()
|
2005-12-07 01:24:16 +05:30
|
|
|
date_stat = self.top.get_widget("date_stat")
|
|
|
|
date_stat.set_sensitive(not self.db.readonly)
|
2004-09-19 20:47:57 +05:30
|
|
|
self.date_check = DateEdit.DateEdit(self.date,
|
|
|
|
self.date_field,
|
2005-12-07 01:24:16 +05:30
|
|
|
date_stat,
|
2005-02-25 22:59:39 +05:30
|
|
|
self.window)
|
2005-06-08 22:02:13 +05:30
|
|
|
|
2005-12-07 01:24:16 +05:30
|
|
|
self.gladeif.connect('button111','clicked',self.close)
|
|
|
|
self.gladeif.connect('ok','clicked',self.on_event_edit_ok_clicked)
|
|
|
|
self.gladeif.connect('button126','clicked',self.on_help_clicked)
|
2005-02-19 10:11:59 +05:30
|
|
|
|
2006-02-03 04:18:21 +05:30
|
|
|
self._create_tabbed_pages()
|
2005-04-28 10:18:30 +05:30
|
|
|
|
2005-12-24 01:46:43 +05:30
|
|
|
self.show()
|
2004-02-20 07:56:47 +05:30
|
|
|
|
2006-02-03 04:18:21 +05:30
|
|
|
def _add_page(self,page):
|
|
|
|
self.notebook.insert_page(page)
|
|
|
|
self.notebook.set_tab_label(page,page.get_tab_widget())
|
|
|
|
return page
|
|
|
|
|
|
|
|
def _create_tabbed_pages(self):
|
|
|
|
"""
|
|
|
|
Creates the notebook tabs and inserts them into the main
|
|
|
|
window.
|
|
|
|
|
|
|
|
"""
|
|
|
|
vbox = self.top.get_widget('vbox')
|
|
|
|
self.notebook = gtk.Notebook()
|
|
|
|
|
|
|
|
self.srcref_list = self._add_page(SourceEmbedList(
|
|
|
|
self.dbstate,self.uistate, self.track,
|
|
|
|
self.event.source_list))
|
|
|
|
self.note_tab = self._add_page(NoteTab(
|
|
|
|
self.dbstate, self.uistate, self.track,
|
|
|
|
self.event.get_note_object()))
|
|
|
|
self.gallery_tab = self._add_page(GalleryTab(
|
|
|
|
self.dbstate, self.uistate, self.track,
|
|
|
|
self.event.get_media_list()))
|
|
|
|
|
|
|
|
self.notebook.show_all()
|
|
|
|
vbox.pack_start(self.notebook,True)
|
|
|
|
|
2005-12-23 05:13:32 +05:30
|
|
|
def build_menu_names(self,event):
|
|
|
|
if event:
|
2005-12-24 01:06:53 +05:30
|
|
|
if event.get_type()[0] == RelLib.Event.CUSTOM:
|
|
|
|
event_name = event.get_type()[1]
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
event_name = Utils.personal_events[event.get_type()[0]]
|
|
|
|
except:
|
|
|
|
event_name = Utils.family_events[event.get_type()[0]]
|
|
|
|
submenu_label = _('Event: %s') % event_name
|
|
|
|
else:
|
|
|
|
submenu_label = _('New Event')
|
|
|
|
return (_('Event Editor'),submenu_label)
|
2005-12-23 05:13:32 +05:30
|
|
|
|
|
|
|
def build_window_key(self,obj):
|
|
|
|
if obj:
|
|
|
|
win_key = obj.get_handle()
|
|
|
|
else:
|
2005-12-24 01:39:02 +05:30
|
|
|
win_key = id(self)
|
2005-12-23 05:13:32 +05:30
|
|
|
|
2004-02-20 07:56:47 +05:30
|
|
|
def on_delete_event(self,obj,b):
|
2005-12-07 01:24:16 +05:30
|
|
|
self.gladeif.close()
|
2004-02-20 07:56:47 +05:30
|
|
|
|
2004-08-04 10:23:29 +05:30
|
|
|
def close(self,obj):
|
2005-12-07 01:24:16 +05:30
|
|
|
self.gladeif.close()
|
* 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()
|
|
|
|
|
2003-11-18 09:56:06 +05:30
|
|
|
def on_help_clicked(self,obj):
|
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
2005-12-07 01:24:16 +05:30
|
|
|
GrampsDisplay.help('adv-ev')
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-20 07:56:47 +05:30
|
|
|
def on_event_edit_ok_clicked(self,obj):
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-06-08 22:02:13 +05:30
|
|
|
event_data = self.type_selector.get_values()
|
2003-12-17 10:53:16 +05:30
|
|
|
ecause = unicode(self.cause_field.get_text())
|
2005-06-07 05:20:33 +05:30
|
|
|
eplace_obj = get_place(self.place_field,self.pmap,self.db)
|
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-06-02 08:50:42 +05:30
|
|
|
# if ename not in self.elist:
|
|
|
|
# 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)
|
|
|
|
# self.elist.append(ename)
|
|
|
|
# self.elist.sort()
|
2003-11-27 23:31:20 +05:30
|
|
|
|
2005-06-08 10:10:33 +05:30
|
|
|
just_added = self.event.handle == None
|
2005-06-08 22:02:13 +05:30
|
|
|
|
2005-06-02 08:50:42 +05:30
|
|
|
self.update_event(event_data,self.date,eplace_obj,edesc,enote,eformat,
|
2005-05-01 09:52:08 +05:30
|
|
|
epriv,ecause)
|
2006-02-04 04:01:46 +05:30
|
|
|
|
2005-06-08 10:10:33 +05:30
|
|
|
if just_added:
|
|
|
|
trans = self.db.transaction_begin()
|
|
|
|
self.db.add_event(self.event,trans)
|
|
|
|
self.db.transaction_commit(trans,_("Add Event"))
|
|
|
|
elif self.parent.lists_changed:
|
2005-06-07 10:38:50 +05:30
|
|
|
trans = self.db.transaction_begin()
|
|
|
|
self.db.commit_event(self.event,trans)
|
|
|
|
self.db.transaction_commit(trans,_("Edit Event"))
|
2006-02-04 04:01:46 +05:30
|
|
|
if self.callback:
|
|
|
|
self.callback(self.event)
|
2005-06-08 22:02:13 +05:30
|
|
|
|
2004-08-04 10:23:29 +05:30
|
|
|
self.close(obj)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-06-02 02:15:45 +05:30
|
|
|
def update_event(self,the_type,date,place,desc,note,format,priv,cause):
|
2005-08-19 21:21:14 +05:30
|
|
|
# FIXME: commented because we no longer have parent
|
|
|
|
#self.parent.lists_changed = 0
|
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())
|
2005-08-19 21:21:14 +05:30
|
|
|
#self.parent.lists_changed = 1
|
2004-02-19 10:35:43 +05:30
|
|
|
else:
|
2004-07-28 07:59:07 +05:30
|
|
|
if self.event.get_place_handle():
|
|
|
|
self.event.set_place_handle("")
|
2005-08-19 21:21:14 +05:30
|
|
|
#self.parent.lists_changed = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-06-02 02:15:45 +05:30
|
|
|
if self.event.get_type() != the_type:
|
|
|
|
self.event.set_type(the_type)
|
2005-08-19 21:21:14 +05:30
|
|
|
#self.parent.lists_changed = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if self.event.get_description() != desc:
|
|
|
|
self.event.set_description(desc)
|
2005-08-19 21:21:14 +05:30
|
|
|
#self.parent.lists_changed = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if self.event.get_note() != note:
|
|
|
|
self.event.set_note(note)
|
2005-08-19 21:21:14 +05:30
|
|
|
#self.parent.lists_changed = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if self.event.get_note_format() != format:
|
|
|
|
self.event.set_note_format(format)
|
2005-08-19 21:21:14 +05:30
|
|
|
#self.parent.lists_changed = 1
|
2003-12-16 01:30:47 +05:30
|
|
|
|
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)
|
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)
|
2005-08-19 21:21:14 +05:30
|
|
|
#self.parent.lists_changed = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if self.event.get_cause() != cause:
|
|
|
|
self.event.set_cause(cause)
|
2005-08-19 21:21:14 +05:30
|
|
|
#self.parent.lists_changed = 1
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if self.event.get_privacy() != priv:
|
|
|
|
self.event.set_privacy(priv)
|
2005-08-19 21:21:14 +05:30
|
|
|
#self.parent.lists_changed = 1
|
2003-11-13 00:15:07 +05:30
|
|
|
|
|
|
|
def on_switch_page(self,obj,a,page):
|
|
|
|
buf = self.note_field.get_buffer()
|
2005-05-01 09:52:08 +05:30
|
|
|
start = buf.get_start_iter()
|
|
|
|
stop = buf.get_end_iter()
|
|
|
|
text = unicode(buf.get_text(start,stop,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-06-02 02:15:45 +05:30
|
|
|
|
2005-08-18 11:28:28 +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)
|
|
|
|
|
|
|
|
|
2005-06-07 05:20:33 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# EventRefEditor class
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-12-14 12:24:02 +05:30
|
|
|
class EventRefEditor(DisplayState.ManagedWindow):
|
|
|
|
def __init__(self, state, uistate, track,
|
|
|
|
event, event_ref, referent, update):
|
|
|
|
self.db = state.db
|
|
|
|
self.state = state
|
|
|
|
self.uistate = uistate
|
2005-06-02 02:15:45 +05:30
|
|
|
self.referent = referent
|
2005-12-23 06:10:35 +05:30
|
|
|
self.event_ref = event_ref
|
|
|
|
self.event = event
|
2005-12-14 12:24:02 +05:30
|
|
|
|
2005-12-23 05:13:32 +05:30
|
|
|
DisplayState.ManagedWindow.__init__(self, uistate, track, event_ref)
|
2005-12-14 12:24:02 +05:30
|
|
|
if self.already_exist:
|
|
|
|
return
|
|
|
|
|
2005-06-02 02:15:45 +05:30
|
|
|
self.update = update
|
|
|
|
|
2005-06-07 05:20:33 +05:30
|
|
|
self.pmap = {}
|
2005-08-12 03:43:44 +05:30
|
|
|
for key in self.db.get_place_handles():
|
|
|
|
title = self.db.get_place_from_handle(key).get_title()
|
2005-06-07 05:20:33 +05:30
|
|
|
self.pmap[title] = key
|
|
|
|
|
2005-06-02 02:15:45 +05:30
|
|
|
self.title = _('Event Reference Editor')
|
|
|
|
|
2006-01-17 10:33:30 +05:30
|
|
|
self.top = gtk.glade.XML(const.gladeFile, "event_eref_edit","gramps")
|
2005-06-07 05:20:33 +05:30
|
|
|
self.window = self.top.get_widget('event_eref_edit')
|
|
|
|
self.ref_note_field = self.top.get_widget('eer_ref_note')
|
|
|
|
self.role_combo = self.top.get_widget('eer_role_combo')
|
|
|
|
self.ref_privacy = self.top.get_widget('eer_ref_priv')
|
|
|
|
|
|
|
|
self.place_field = self.top.get_widget("eer_place")
|
|
|
|
self.cause_field = self.top.get_widget("eer_cause")
|
|
|
|
self.slist = self.top.get_widget("eer_slist")
|
|
|
|
self.wlist = self.top.get_widget("eer_wlist")
|
|
|
|
self.date_field = self.top.get_widget("eer_date")
|
|
|
|
self.descr_field = self.top.get_widget("eer_description")
|
|
|
|
self.ev_note_field = self.top.get_widget("eer_ev_note")
|
|
|
|
self.type_combo = self.top.get_widget("eer_type_combo")
|
|
|
|
self.ev_privacy = self.top.get_widget("eer_ev_priv")
|
|
|
|
self.sources_label = self.top.get_widget("eer_sources_tab")
|
|
|
|
self.notes_label = self.top.get_widget("eer_note_tab")
|
|
|
|
self.general_label = self.top.get_widget("eer_general_tab")
|
|
|
|
self.gallery_label = self.top.get_widget("eer_gallery_tab")
|
|
|
|
self.witnesses_label = self.top.get_widget("eer_witness_tab")
|
|
|
|
self.flowed = self.top.get_widget("eer_ev_flowed")
|
|
|
|
self.preform = self.top.get_widget("eer_ev_preform")
|
|
|
|
self.ok = self.top.get_widget('ok')
|
|
|
|
self.expander = self.top.get_widget("eer_expander")
|
2005-06-16 21:09:19 +05:30
|
|
|
self.warning = self.top.get_widget("eer_warning")
|
2005-06-07 05:20:33 +05:30
|
|
|
|
|
|
|
add_src = self.top.get_widget('eer_add_src')
|
|
|
|
del_src = self.top.get_widget('eer_del_src')
|
|
|
|
|
|
|
|
add_witness = self.top.get_widget('eer_add_wit')
|
|
|
|
edit_witness = self.top.get_widget('eer_edit_wit')
|
|
|
|
del_witness = self.top.get_widget('eer_del_wit')
|
2005-06-02 02:15:45 +05:30
|
|
|
|
|
|
|
Utils.set_titles(self.window,
|
2005-06-07 05:20:33 +05:30
|
|
|
self.top.get_widget('eer_title'),
|
2005-06-02 02:15:45 +05:30
|
|
|
self.title)
|
|
|
|
|
|
|
|
self.top.signal_autoconnect({
|
2005-06-07 05:20:33 +05:30
|
|
|
"on_eer_help_clicked" : self.on_help_clicked,
|
|
|
|
"on_eer_ok_clicked" : self.on_ok_clicked,
|
|
|
|
"on_eer_cancel_clicked" : self.close,
|
2005-12-22 11:38:33 +05:30
|
|
|
"on_eer_delete_event" : self.close,
|
2005-06-02 02:15:45 +05:30
|
|
|
})
|
|
|
|
|
2005-06-07 05:20:33 +05:30
|
|
|
if self.referent.__class__.__name__ == 'Person':
|
|
|
|
default_type = RelLib.Event.BIRTH
|
2005-06-09 00:17:55 +05:30
|
|
|
default_role = RelLib.EventRef.PRIMARY
|
|
|
|
ev_dict = Utils.personal_events
|
|
|
|
role_dict = Utils.event_roles
|
2005-06-07 05:20:33 +05:30
|
|
|
elif self.referent.__class__.__name__ == 'Family':
|
|
|
|
default_type = RelLib.Event.MARRIAGE
|
2005-06-09 00:17:55 +05:30
|
|
|
default_role = RelLib.EventRef.FAMILY
|
|
|
|
ev_dict = Utils.family_events
|
|
|
|
role_dict = Utils.family_event_roles
|
|
|
|
|
|
|
|
self.role_selector = AutoComp.StandardCustomSelector(
|
|
|
|
role_dict,self.role_combo,
|
|
|
|
RelLib.EventRef.CUSTOM,default_role)
|
|
|
|
|
|
|
|
AutoComp.fill_entry(self.place_field,self.pmap.keys())
|
2005-06-07 05:20:33 +05:30
|
|
|
|
|
|
|
self.type_selector = AutoComp.StandardCustomSelector(
|
2005-06-09 00:17:55 +05:30
|
|
|
ev_dict,self.type_combo,
|
2005-06-07 05:20:33 +05:30
|
|
|
RelLib.Event.CUSTOM,default_type)
|
|
|
|
|
|
|
|
if self.event:
|
2005-06-16 21:09:19 +05:30
|
|
|
self.event_added = False
|
2006-02-04 03:33:53 +05:30
|
|
|
self.date = RelLib.Date(self.event.get_date_object())
|
2005-06-16 21:09:19 +05:30
|
|
|
if self.event_ref:
|
|
|
|
if self.event_ref.get_role()[0] == default_role:
|
|
|
|
self.expander.set_expanded(True)
|
|
|
|
self.warning.hide()
|
|
|
|
else:
|
|
|
|
self.expander.set_expanded(False)
|
|
|
|
self.warning.show_all()
|
2005-06-07 05:20:33 +05:30
|
|
|
else:
|
|
|
|
self.event = RelLib.Event()
|
2005-06-09 00:17:55 +05:30
|
|
|
self.event.set_type((default_type,ev_dict[default_type]))
|
2005-06-16 21:09:19 +05:30
|
|
|
self.event.set_handle(self.db.create_id())
|
|
|
|
self.event.set_gramps_id(self.db.find_next_event_gramps_id())
|
|
|
|
self.event_added = True
|
2006-02-04 03:33:53 +05:30
|
|
|
self.date = RelLib.Date(None)
|
2005-06-07 05:20:33 +05:30
|
|
|
self.expander.set_expanded(True)
|
2005-06-16 21:09:19 +05:30
|
|
|
self.warning.hide()
|
2005-06-02 02:15:45 +05:30
|
|
|
|
|
|
|
if not self.event_ref:
|
|
|
|
self.event_ref = RelLib.EventRef()
|
2005-06-09 00:17:55 +05:30
|
|
|
self.event_ref.set_role((default_role,role_dict[default_role]))
|
2005-06-07 05:20:33 +05:30
|
|
|
self.event_ref.set_reference_handle(self.event.get_handle())
|
2005-06-02 02:15:45 +05:30
|
|
|
|
2005-06-07 05:20:33 +05:30
|
|
|
self.srcreflist = self.event.get_source_references()
|
|
|
|
self.sourcetab = Sources.SourceTab(
|
2005-12-23 05:13:32 +05:30
|
|
|
self.state, self.uistate, self.track,
|
2005-06-07 05:20:33 +05:30
|
|
|
self.srcreflist, self, self.top, self.window, self.slist,
|
|
|
|
add_src, self.top.get_widget('eer_edit_src'), del_src,
|
|
|
|
self.db.readonly)
|
|
|
|
|
|
|
|
self.date_check = DateEdit.DateEdit(self.date,
|
|
|
|
self.date_field,
|
|
|
|
self.top.get_widget("eer_date_stat"),
|
|
|
|
self.window)
|
|
|
|
|
|
|
|
# set event_ref values
|
2005-06-02 02:15:45 +05:30
|
|
|
self.role_selector.set_values(self.event_ref.get_role())
|
2005-06-07 05:20:33 +05:30
|
|
|
self.ref_note_field.get_buffer().set_text(self.event_ref.get_note())
|
|
|
|
self.ref_privacy.set_active(self.event_ref.get_privacy())
|
|
|
|
|
|
|
|
# set event values
|
|
|
|
self.type_selector.set_values(self.event.get_type())
|
|
|
|
place_handle = self.event.get_place_handle()
|
|
|
|
if not place_handle:
|
|
|
|
place_name = u""
|
|
|
|
else:
|
|
|
|
place_name = self.db.get_place_from_handle(place_handle).get_title()
|
|
|
|
self.place_field.set_text(place_name)
|
|
|
|
self.date_field.set_text(_dd.display(self.date))
|
|
|
|
self.cause_field.set_text(self.event.get_cause())
|
|
|
|
self.descr_field.set_text(self.event.get_description())
|
|
|
|
self.ev_privacy.set_active(self.event.get_privacy())
|
|
|
|
if self.event.get_note():
|
|
|
|
self.ev_note_field.get_buffer().set_text(event.get_note())
|
|
|
|
Utils.bold_label(self.notes_label)
|
|
|
|
if event.get_note_format() == 1:
|
|
|
|
self.preform.set_active(1)
|
|
|
|
else:
|
|
|
|
self.flowed.set_active(1)
|
|
|
|
if self.event.get_media_list():
|
|
|
|
Utils.bold_label(self.gallery_label)
|
2005-06-02 02:15:45 +05:30
|
|
|
|
2005-12-24 01:46:43 +05:30
|
|
|
self.show()
|
2005-06-02 02:15:45 +05:30
|
|
|
|
2005-12-23 06:10:35 +05:30
|
|
|
def build_menu_names(self,eventref):
|
|
|
|
if self.event:
|
|
|
|
if self.event.get_type()[0] == RelLib.Event.CUSTOM:
|
|
|
|
event_name = self.event.get_type()[1]
|
2005-12-23 05:13:32 +05:30
|
|
|
else:
|
|
|
|
try:
|
2005-12-23 06:10:35 +05:30
|
|
|
event_name = Utils.personal_events[self.event.get_type()[0]]
|
2005-12-23 05:13:32 +05:30
|
|
|
except:
|
2005-12-23 06:10:35 +05:30
|
|
|
event_name = Utils.family_events[self.event.get_type()[0]]
|
2005-12-23 05:13:32 +05:30
|
|
|
submenu_label = _('Event: %s') % event_name
|
|
|
|
else:
|
|
|
|
submenu_label = _('New Event')
|
2005-12-24 01:06:53 +05:30
|
|
|
return (_('Event Reference Editor'),submenu_label)
|
2005-12-23 05:13:32 +05:30
|
|
|
|
2005-12-23 06:10:35 +05:30
|
|
|
def build_window_key(self,eventref):
|
|
|
|
if self.event:
|
|
|
|
return self.event.get_handle()
|
2005-12-23 05:13:32 +05:30
|
|
|
else:
|
2005-12-24 01:39:02 +05:30
|
|
|
return id(self)
|
2005-12-23 05:13:32 +05:30
|
|
|
|
2005-06-02 02:15:45 +05:30
|
|
|
def on_help_clicked(self,obj):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def on_ok_clicked(self,obj):
|
2005-06-07 05:20:33 +05:30
|
|
|
|
|
|
|
# first, save event if changed
|
|
|
|
etype = self.type_selector.get_values()
|
|
|
|
ecause = unicode(self.cause_field.get_text())
|
|
|
|
eplace_obj = get_place(self.place_field,self.pmap,self.db)
|
|
|
|
buf = self.ev_note_field.get_buffer()
|
|
|
|
start = buf.get_start_iter()
|
|
|
|
stop = buf.get_end_iter()
|
|
|
|
enote = unicode(buf.get_text(start,stop,False))
|
|
|
|
eformat = self.preform.get_active()
|
|
|
|
edesc = unicode(self.descr_field.get_text())
|
|
|
|
epriv = self.ev_privacy.get_active()
|
2005-12-22 11:38:33 +05:30
|
|
|
self.lists_changed = 0
|
2005-06-07 05:20:33 +05:30
|
|
|
self.update_event(etype,self.date,eplace_obj,edesc,enote,eformat,
|
|
|
|
epriv,ecause)
|
2006-02-04 04:01:46 +05:30
|
|
|
|
|
|
|
trans = self.db.transaction_begin()
|
|
|
|
self.db.commit_event(self.event,trans)
|
|
|
|
if self.event_added:
|
|
|
|
self.db.transaction_commit(trans,_("Add Event"))
|
|
|
|
else:
|
|
|
|
self.db.transaction_commit(trans,_("Modify Event"))
|
2005-06-07 05:20:33 +05:30
|
|
|
|
|
|
|
# then, set properties of the event_ref
|
2005-06-02 02:15:45 +05:30
|
|
|
self.event_ref.set_role(self.role_selector.get_values())
|
2005-06-07 05:20:33 +05:30
|
|
|
self.event_ref.set_privacy(self.ref_privacy.get_active())
|
|
|
|
buf = self.ref_note_field.get_buffer()
|
2005-06-02 02:15:45 +05:30
|
|
|
start = buf.get_start_iter()
|
|
|
|
stop = buf.get_end_iter()
|
|
|
|
note = unicode(buf.get_text(start,stop,False))
|
|
|
|
self.event_ref.set_note(note)
|
|
|
|
self.close(None)
|
2005-06-07 05:20:33 +05:30
|
|
|
|
|
|
|
if self.update:
|
|
|
|
self.update((self.event_ref,self.event))
|
|
|
|
|
|
|
|
def update_event(self,the_type,date,place,desc,note,format,priv,cause):
|
|
|
|
if place:
|
|
|
|
if self.event.get_place_handle() != place.get_handle():
|
|
|
|
self.event.set_place_handle(place.get_handle())
|
2005-12-22 11:38:33 +05:30
|
|
|
self.lists_changed = 1
|
2005-06-07 05:20:33 +05:30
|
|
|
else:
|
|
|
|
if self.event.get_place_handle():
|
|
|
|
self.event.set_place_handle("")
|
2005-12-22 11:38:33 +05:30
|
|
|
self.lists_changed = 1
|
2005-06-07 05:20:33 +05:30
|
|
|
|
|
|
|
if self.event.get_type() != the_type:
|
|
|
|
self.event.set_type(the_type)
|
2005-12-22 11:38:33 +05:30
|
|
|
self.lists_changed = 1
|
2005-06-07 05:20:33 +05:30
|
|
|
|
|
|
|
if self.event.get_description() != desc:
|
|
|
|
self.event.set_description(desc)
|
2005-12-22 11:38:33 +05:30
|
|
|
self.lists_changed = 1
|
2005-06-07 05:20:33 +05:30
|
|
|
|
|
|
|
if self.event.get_note() != note:
|
|
|
|
self.event.set_note(note)
|
2005-12-22 11:38:33 +05:30
|
|
|
self.lists_changed = 1
|
2005-06-07 05:20:33 +05:30
|
|
|
|
|
|
|
if self.event.get_note_format() != format:
|
|
|
|
self.event.set_note_format(format)
|
2005-12-22 11:38:33 +05:30
|
|
|
self.lists_changed = 1
|
2005-06-07 05:20:33 +05:30
|
|
|
|
|
|
|
dobj = self.event.get_date_object()
|
|
|
|
|
|
|
|
self.event.set_source_reference_list(self.srcreflist)
|
|
|
|
|
|
|
|
if not dobj.is_equal(date):
|
|
|
|
self.event.set_date_object(date)
|
2005-12-22 11:38:33 +05:30
|
|
|
self.lists_changed = 1
|
2005-06-07 05:20:33 +05:30
|
|
|
|
|
|
|
if self.event.get_cause() != cause:
|
|
|
|
self.event.set_cause(cause)
|
2005-12-22 11:38:33 +05:30
|
|
|
self.lists_changed = 1
|
2005-06-07 05:20:33 +05:30
|
|
|
|
|
|
|
if self.event.get_privacy() != priv:
|
|
|
|
self.event.set_privacy(priv)
|
2005-12-22 11:38:33 +05:30
|
|
|
self.lists_changed = 1
|
2005-06-07 05:20:33 +05:30
|
|
|
|
|
|
|
def on_switch_page(self,obj,a,page):
|
|
|
|
buf = self.ev_note_field.get_buffer()
|
|
|
|
start = buf.get_start_iter()
|
|
|
|
stop = buf.get_end_iter()
|
|
|
|
text = unicode(buf.get_text(start,stop,False))
|
|
|
|
if text:
|
|
|
|
Utils.bold_label(self.eer_notes_label)
|
|
|
|
else:
|
|
|
|
Utils.unbold_label(self.eer_notes_label)
|
2005-06-08 10:10:33 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Delete Query class
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class DelEventQuery:
|
|
|
|
def __init__(self,event,db,person_list,family_list):
|
|
|
|
self.event = event
|
|
|
|
self.db = db
|
|
|
|
self.person_list = person_list
|
|
|
|
self.family_list = family_list
|
|
|
|
|
|
|
|
def query_response(self):
|
|
|
|
trans = self.db.transaction_begin()
|
|
|
|
self.db.disable_signals()
|
|
|
|
|
|
|
|
ev_handle_list = [self.event.get_handle()]
|
|
|
|
|
|
|
|
for handle in self.person_list:
|
|
|
|
person = self.db.get_person_from_handle(handle)
|
|
|
|
person.remove_handle_references('Event',ev_handle_list)
|
|
|
|
self.db.commit_person(person,trans)
|
|
|
|
|
|
|
|
for handle in self.family_list:
|
|
|
|
family = self.db.get_family_from_handle(handle)
|
|
|
|
family.remove_handle_references('Event',ev_handle_list)
|
|
|
|
self.db.commit_family(family,trans)
|
|
|
|
|
|
|
|
self.db.enable_signals()
|
|
|
|
self.db.remove_event(self.event.get_handle(),trans)
|
|
|
|
self.db.transaction_commit(
|
|
|
|
trans,_("Delete Event (%s)") % self.event.get_gramps_id())
|