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
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2006-02-08 10:38:28 +05:30
|
|
|
|
|
|
|
try:
|
|
|
|
set()
|
|
|
|
except:
|
|
|
|
from sets import Set as set
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
|
|
|
import Utils
|
|
|
|
import AutoComp
|
2003-01-10 10:51:32 +05:30
|
|
|
import RelLib
|
2005-12-07 01:24:16 +05:30
|
|
|
import GrampsDisplay
|
2006-03-04 12:04:48 +05:30
|
|
|
from _EditPrimary import EditPrimary
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2005-03-24 04:28:46 +05:30
|
|
|
from QuestionDialog import WarningDialog, ErrorDialog
|
2006-02-03 04:18:21 +05:30
|
|
|
from DisplayTabs import *
|
2006-02-08 10:38:28 +05:30
|
|
|
from GrampsWidgets import *
|
2004-09-19 20:47:57 +05:30
|
|
|
|
2005-06-09 02:47:18 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2006-03-04 10:00:05 +05:30
|
|
|
# EditEvent class
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-03-04 12:04:48 +05:30
|
|
|
class EditEvent(EditPrimary):
|
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-12-23 05:13:32 +05:30
|
|
|
|
2006-03-04 12:04:48 +05:30
|
|
|
EditPrimary.__init__(self, dbstate, uistate, track,
|
|
|
|
event, dbstate.db.get_event_from_handle)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-04-01 05:16:34 +05:30
|
|
|
self._init_event()
|
|
|
|
|
|
|
|
def _init_event(self):
|
|
|
|
self.commit_event = self.db.commit_event
|
|
|
|
|
2006-04-01 01:16:41 +05:30
|
|
|
def empty_object(self):
|
|
|
|
return RelLib.Event()
|
|
|
|
|
2006-04-01 05:16:34 +05:30
|
|
|
def get_custom_events(self):
|
|
|
|
return self.dbstate.db.get_person_event_type_list() + \
|
|
|
|
self.dbstate.db.get_family_event_types()
|
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def _local_init(self):
|
2006-01-17 10:33:30 +05:30
|
|
|
self.top = gtk.glade.XML(const.gladeFile, "event_edit","gramps")
|
2003-03-06 11:42:51 +05:30
|
|
|
self.window = self.top.get_widget("event_edit")
|
|
|
|
|
2005-06-07 10:38:50 +05:30
|
|
|
etitle = _('Event Editor')
|
2006-03-01 10:38:11 +05:30
|
|
|
Utils.set_titles(self.window, self.top.get_widget('title'),
|
|
|
|
etitle, etitle)
|
2005-06-07 05:20:33 +05:30
|
|
|
|
2006-02-23 08:43:15 +05:30
|
|
|
def _connect_signals(self):
|
2006-04-24 04:13:36 +05:30
|
|
|
self.top.get_widget('button111').connect('clicked',self.close)
|
2006-03-01 10:38:11 +05:30
|
|
|
self.top.get_widget('button126').connect('clicked',self.help_clicked)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-02-23 08:43:15 +05:30
|
|
|
ok = self.top.get_widget('ok')
|
|
|
|
ok.set_sensitive(not self.db.readonly)
|
2006-03-01 10:38:11 +05:30
|
|
|
ok.connect('clicked',self.save)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-02-23 08:43:15 +05:30
|
|
|
def _setup_fields(self):
|
2006-02-24 10:35:46 +05:30
|
|
|
self.place_field = PlaceEntry(
|
|
|
|
self.top.get_widget("eventPlace"),
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj.get_place_handle(),
|
2006-02-24 10:35:46 +05:30
|
|
|
self.dbstate.get_place_completion(),
|
|
|
|
self.db.readonly)
|
|
|
|
|
2006-02-23 08:43:15 +05:30
|
|
|
self.cause_monitor = MonitoredEntry(
|
|
|
|
self.top.get_widget("eventCause"),
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj.set_cause,
|
|
|
|
self.obj.get_cause, self.db.readonly)
|
2005-02-19 10:11:59 +05:30
|
|
|
|
2006-02-23 08:43:15 +05:30
|
|
|
self.descr_field = MonitoredEntry(
|
|
|
|
self.top.get_widget("event_description"),
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj.set_description,
|
|
|
|
self.obj.get_description, self.db.readonly)
|
2005-04-28 10:18:30 +05:30
|
|
|
|
2006-02-23 08:43:15 +05:30
|
|
|
self.priv = PrivacyButton(
|
|
|
|
self.top.get_widget("private"),
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj, self.db.readonly)
|
2006-02-23 08:43:15 +05:30
|
|
|
|
2006-04-20 04:29:33 +05:30
|
|
|
self.event_menu = MonitoredDataType(
|
2006-02-23 08:43:15 +05:30
|
|
|
self.top.get_widget("personal_events"),
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj.set_type,
|
|
|
|
self.obj.get_type,
|
2006-04-01 05:16:34 +05:30
|
|
|
custom_values=self.get_custom_events())
|
2006-02-23 08:43:15 +05:30
|
|
|
|
|
|
|
self.date_field = MonitoredDate(
|
|
|
|
self.top.get_widget("eventDate"),
|
|
|
|
self.top.get_widget("date_stat"),
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj.get_date_object(),
|
2006-02-23 08:43:15 +05:30
|
|
|
self.window, self.db.readonly)
|
2004-02-20 07:56:47 +05:30
|
|
|
|
2006-02-03 04:18:21 +05:30
|
|
|
def _create_tabbed_pages(self):
|
|
|
|
"""
|
|
|
|
Creates the notebook tabs and inserts them into the main
|
|
|
|
window.
|
|
|
|
"""
|
2006-03-01 10:38:11 +05:30
|
|
|
notebook = gtk.Notebook()
|
|
|
|
|
|
|
|
self.srcref_list = self._add_tab(
|
|
|
|
notebook,
|
|
|
|
SourceEmbedList(self.dbstate,self.uistate, self.track,
|
|
|
|
self.obj.source_list))
|
|
|
|
|
|
|
|
self.note_tab = self._add_tab(
|
|
|
|
notebook,
|
|
|
|
NoteTab(self.dbstate, self.uistate, self.track,
|
|
|
|
self.obj.get_note_object()))
|
|
|
|
|
|
|
|
self.gallery_tab = self._add_tab(
|
|
|
|
notebook,
|
|
|
|
GalleryTab(self.dbstate, self.uistate, self.track,
|
|
|
|
self.obj.get_media_list()))
|
2006-04-21 04:02:17 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
self.backref_tab = self._add_tab(
|
|
|
|
notebook,
|
|
|
|
EventBackRefList(self.dbstate, self.uistate, self.track,
|
2006-04-21 09:44:00 +05:30
|
|
|
self.dbstate.db.find_backlink_handles(self.obj.handle)))
|
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
notebook.show_all()
|
|
|
|
self.top.get_widget('vbox').pack_start(notebook,True)
|
|
|
|
|
|
|
|
def _cleanup_on_exit(self):
|
|
|
|
self.backref_tab.close()
|
2006-02-03 04:18:21 +05:30
|
|
|
|
2005-12-23 05:13:32 +05:30
|
|
|
def build_menu_names(self,event):
|
|
|
|
if event:
|
2006-04-20 04:29:33 +05:30
|
|
|
event_name = str(event.get_type())
|
2005-12-24 01:06:53 +05:30
|
|
|
submenu_label = _('Event: %s') % event_name
|
|
|
|
else:
|
|
|
|
submenu_label = _('New Event')
|
|
|
|
return (_('Event Editor'),submenu_label)
|
2005-12-23 05:13:32 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def help_clicked(self,obj):
|
2003-11-18 09:56:06 +05:30
|
|
|
"""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
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def save(self,*obj):
|
2006-04-01 01:16:41 +05:30
|
|
|
if self.object_is_empty():
|
|
|
|
ErrorDialog(_("Cannot save event"),
|
|
|
|
_("No data exists for this event. Please "
|
|
|
|
"enter data or cancel the edit."))
|
|
|
|
return
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-02-24 10:35:46 +05:30
|
|
|
(need_new, handle) = self.place_field.get_place_info()
|
|
|
|
if need_new:
|
|
|
|
place_obj = RelLib.Place()
|
|
|
|
place_obj.set_title(handle)
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj.set_place_handle(place_obj.get_handle())
|
2006-02-24 10:35:46 +05:30
|
|
|
else:
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj.set_place_handle(handle)
|
2006-02-24 10:35:46 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
if self.obj.handle == None:
|
2005-06-08 10:10:33 +05:30
|
|
|
trans = self.db.transaction_begin()
|
2006-02-24 10:35:46 +05:30
|
|
|
if need_new:
|
|
|
|
self.db.add_place(place_obj,trans)
|
2006-03-01 10:38:11 +05:30
|
|
|
self.db.add_event(self.obj,trans)
|
2005-06-08 10:10:33 +05:30
|
|
|
self.db.transaction_commit(trans,_("Add Event"))
|
2006-02-08 10:38:28 +05:30
|
|
|
else:
|
2006-03-01 10:38:11 +05:30
|
|
|
orig = self.dbstate.db.get_event_from_handle(self.obj.handle)
|
|
|
|
if cmp(self.obj.serialize(),orig.serialize()):
|
2006-02-08 10:38:28 +05:30
|
|
|
trans = self.db.transaction_begin()
|
2006-02-24 10:35:46 +05:30
|
|
|
if need_new:
|
|
|
|
self.db.add_place(place_obj,trans)
|
2006-04-01 05:16:34 +05:30
|
|
|
self.commit_event(self.obj,trans)
|
2006-02-08 10:38:28 +05:30
|
|
|
self.db.transaction_commit(trans,_("Edit Event"))
|
|
|
|
|
2006-02-04 04:01:46 +05:30
|
|
|
if self.callback:
|
2006-03-01 10:38:11 +05:30
|
|
|
self.callback(self.obj)
|
2006-04-22 08:53:57 +05:30
|
|
|
self.close()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def data_has_changed(self):
|
|
|
|
if self.db.readonly:
|
|
|
|
return False
|
|
|
|
elif self.obj.handle:
|
|
|
|
orig = self.db.get_event_from_handle(self.obj.handle)
|
|
|
|
return cmp(orig.serialize(),self.obj.serialize()) != 0
|
|
|
|
else:
|
|
|
|
return True
|
|
|
|
|
2006-04-01 05:16:34 +05:30
|
|
|
class EditPersonEvent(EditEvent):
|
|
|
|
|
|
|
|
def __init__(self, event, dbstate, uistate, track=[], callback=None):
|
|
|
|
EditEvent.__init__(self, event, dbstate, uistate, track,
|
|
|
|
callback)
|
|
|
|
|
|
|
|
def _init_event(self):
|
|
|
|
self.commit_event = self.db.commit_personal_event
|
|
|
|
|
|
|
|
def get_custom_events(self):
|
|
|
|
return self.dbstate.db.get_person_event_type_list()
|
|
|
|
|
|
|
|
class EditFamilyEvent(EditEvent):
|
|
|
|
|
|
|
|
def __init__(self, event, dbstate, uistate, track=[], callback=None):
|
|
|
|
EditEvent.__init__(self, event, dbstate, uistate, track,
|
|
|
|
callback)
|
|
|
|
|
|
|
|
def _init_event(self):
|
|
|
|
self.commit_event = self.db.commit_family_event
|
|
|
|
|
|
|
|
def get_custom_events(self):
|
|
|
|
return self.dbstate.db.get_family_event_types()
|
|
|
|
|
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())
|
2006-04-01 05:16:34 +05:30
|
|
|
|