2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-04-24 03:48:01 +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$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2005-12-22 17:32:06 +05:30
|
|
|
|
2006-01-09 16:58:44 +05:30
|
|
|
import logging
|
|
|
|
log = logging.getLogger(".")
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
2005-12-07 01:24:16 +05:30
|
|
|
import RelLib
|
2006-03-04 12:04:48 +05:30
|
|
|
from _EditPrimary import EditPrimary
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-02-06 00:30:25 +05:30
|
|
|
from DisplayTabs import *
|
2006-02-23 08:43:15 +05:30
|
|
|
from GrampsWidgets import *
|
2005-03-26 02:35:09 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# EditPlace
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2006-03-04 12:04:48 +05:30
|
|
|
class EditPlace(EditPrimary):
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def __init__(self,dbstate,uistate,track,place,callback=None):
|
2006-03-04 12:04:48 +05:30
|
|
|
EditPrimary.__init__(self, dbstate, uistate, track, place,
|
|
|
|
dbstate.db.get_place_from_handle, callback)
|
2005-09-16 09:37:53 +05:30
|
|
|
|
2006-04-01 01:16:41 +05:30
|
|
|
def empty_object(self):
|
|
|
|
return RelLib.Place()
|
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def _local_init(self):
|
|
|
|
self.top = gtk.glade.XML(const.gladeFile,"place_editor","gramps")
|
2006-02-23 08:43:15 +05:30
|
|
|
|
2006-04-24 03:48:01 +05:30
|
|
|
self.set_window(self.top.get_widget("place_editor"),
|
|
|
|
self.top.get_widget('title'),
|
|
|
|
_('Place Editor'))
|
2006-02-23 08:43:15 +05:30
|
|
|
|
|
|
|
def _connect_signals(self):
|
2006-03-01 10:38:11 +05:30
|
|
|
self.define_ok_button(self.top.get_widget('ok'),self.save)
|
|
|
|
self.define_cancel_button(self.top.get_widget('cancel'))
|
|
|
|
self.define_help_button(self.top.get_widget('help'),'adv-plc')
|
2006-02-23 08:43:15 +05:30
|
|
|
|
|
|
|
def _setup_fields(self):
|
2006-03-01 10:38:11 +05:30
|
|
|
mloc = self.obj.get_main_location()
|
2006-02-23 08:43:15 +05:30
|
|
|
|
|
|
|
self.title = MonitoredEntry(
|
|
|
|
self.top.get_widget("place_title"),
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj.set_title, self.obj.get_title,
|
2006-02-23 08:43:15 +05:30
|
|
|
self.db.readonly)
|
|
|
|
|
2006-09-24 10:07:59 +05:30
|
|
|
self.city = MonitoredEntry(
|
|
|
|
self.top.get_widget("street"),
|
|
|
|
mloc.set_street, mloc.get_street, self.db.readonly)
|
|
|
|
|
2006-02-23 08:43:15 +05:30
|
|
|
self.city = MonitoredEntry(
|
|
|
|
self.top.get_widget("city"),
|
|
|
|
mloc.set_city, mloc.get_city, self.db.readonly)
|
|
|
|
|
2006-05-05 18:55:24 +05:30
|
|
|
self.gid = MonitoredEntry(
|
|
|
|
self.top.get_widget("gid"),
|
|
|
|
self.obj.set_gramps_id,
|
|
|
|
self.obj.get_gramps_id, self.db.readonly)
|
|
|
|
|
2006-08-30 05:15:07 +05:30
|
|
|
self.privacy = PrivacyButton(
|
|
|
|
self.top.get_widget("private"),
|
|
|
|
self.obj, self.db.readonly)
|
|
|
|
|
2006-02-23 08:43:15 +05:30
|
|
|
self.parish = MonitoredEntry(
|
|
|
|
self.top.get_widget("parish"),
|
|
|
|
mloc.set_parish, mloc.get_parish, self.db.readonly)
|
|
|
|
|
|
|
|
self.county = MonitoredEntry(
|
|
|
|
self.top.get_widget("county"),
|
|
|
|
mloc.set_county, mloc.get_county, self.db.readonly)
|
|
|
|
|
|
|
|
self.state = MonitoredEntry(
|
|
|
|
self.top.get_widget("state"),
|
|
|
|
mloc.set_state, mloc.get_state, self.db.readonly)
|
|
|
|
|
|
|
|
self.phone = MonitoredEntry(
|
|
|
|
self.top.get_widget("phone"),
|
|
|
|
mloc.set_phone, mloc.get_phone, self.db.readonly)
|
|
|
|
|
|
|
|
self.postal = MonitoredEntry(
|
|
|
|
self.top.get_widget("postal"),
|
|
|
|
mloc.set_postal_code, mloc.get_postal_code, self.db.readonly)
|
|
|
|
|
|
|
|
self.country = MonitoredEntry(
|
|
|
|
self.top.get_widget("country"),
|
2006-05-03 22:29:22 +05:30
|
|
|
mloc.set_country, mloc.get_country, self.db.readonly)
|
2006-02-23 08:43:15 +05:30
|
|
|
|
|
|
|
self.longitude = MonitoredEntry(
|
|
|
|
self.top.get_widget("longitude"),
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj.set_longitude, self.obj.get_longitude,
|
2006-02-23 08:43:15 +05:30
|
|
|
self.db.readonly)
|
|
|
|
|
|
|
|
self.latitude = MonitoredEntry(
|
|
|
|
self.top.get_widget("latitude"),
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj.set_latitude, self.obj.get_latitude,
|
2006-02-23 08:43:15 +05:30
|
|
|
self.db.readonly)
|
2005-07-09 01:54:54 +05:30
|
|
|
|
2005-12-23 05:13:32 +05:30
|
|
|
def build_menu_names(self,place):
|
|
|
|
win_menu_label = place.get_title()
|
|
|
|
if not win_menu_label.strip():
|
|
|
|
win_menu_label = _("New Place")
|
|
|
|
return (win_menu_label, _('Edit Place'))
|
|
|
|
|
2006-02-06 00:30:25 +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 = self.top.get_widget('notebook3')
|
2006-02-06 00:30:25 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
self.loc_list = self._add_tab(
|
|
|
|
notebook,
|
|
|
|
LocationEmbedList(self.dbstate,self.uistate, self.track,
|
|
|
|
self.obj.alt_loc))
|
|
|
|
|
|
|
|
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()))
|
|
|
|
|
|
|
|
self.web_list = self._add_tab(
|
|
|
|
notebook,
|
|
|
|
WebEmbedList(self.dbstate,self.uistate,self.track,
|
|
|
|
self.obj.get_url_list()))
|
|
|
|
|
|
|
|
self.backref_list = self._add_tab(
|
|
|
|
notebook,
|
|
|
|
PlaceBackRefList(self.dbstate,self.uistate,self.track,
|
2006-04-22 01:26:16 +05:30
|
|
|
self.db.find_backlink_handles(self.obj.handle)))
|
2003-11-19 23:30:58 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def _cleanup_on_exit(self):
|
|
|
|
self.backref_list.close()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
def save(self,*obj):
|
|
|
|
title = self.obj.get_title()
|
2005-07-09 01:54:54 +05:30
|
|
|
|
2004-08-13 10:04:07 +05:30
|
|
|
trans = self.db.transaction_begin()
|
2006-03-01 10:38:11 +05:30
|
|
|
if self.obj.get_handle():
|
|
|
|
self.db.commit_place(self.obj,trans)
|
2004-08-30 09:20:33 +05:30
|
|
|
else:
|
2006-03-01 10:38:11 +05:30
|
|
|
self.db.add_place(self.obj,trans)
|
2006-06-23 09:43:06 +05:30
|
|
|
self.db.transaction_commit(
|
|
|
|
trans, _("Edit Place (%s)") % self.obj.get_title())
|
2004-03-30 10:20:24 +05:30
|
|
|
|
2006-05-18 01:02:19 +05:30
|
|
|
if self.callback:
|
|
|
|
self.callback(self.obj)
|
2006-04-22 08:53:57 +05:30
|
|
|
self.close()
|
2004-02-26 09:04:19 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# DeletePlaceQuery
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class DeletePlaceQuery:
|
|
|
|
|
2005-04-01 11:03:22 +05:30
|
|
|
def __init__(self,place,db):
|
2002-10-20 19:55:16 +05:30
|
|
|
self.db = db
|
2006-03-01 10:38:11 +05:30
|
|
|
self.obj = place
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def query_response(self):
|
2004-08-13 10:04:07 +05:30
|
|
|
trans = self.db.transaction_begin()
|
2005-06-05 09:31:56 +05:30
|
|
|
self.db.disable_signals()
|
2004-03-30 10:20:24 +05:30
|
|
|
|
2006-03-01 10:38:11 +05:30
|
|
|
place_handle = self.obj.get_handle()
|
2005-04-04 05:57:06 +05:30
|
|
|
|
|
|
|
for handle in self.db.get_person_handles(sort_handles=False):
|
|
|
|
person = self.db.get_person_from_handle(handle)
|
|
|
|
if person.has_handle_reference('Place',place_handle):
|
|
|
|
person.remove_handle_references('Place',place_handle)
|
|
|
|
self.db.commit_person(person,trans)
|
|
|
|
|
|
|
|
for handle in self.db.get_family_handles():
|
|
|
|
family = self.db.get_family_from_handle(handle)
|
|
|
|
if family.has_handle_reference('Place',place_handle):
|
|
|
|
family.remove_handle_references('Place',place_handle)
|
|
|
|
self.db.commit_family(family,trans)
|
|
|
|
|
|
|
|
for handle in self.db.get_event_handles():
|
|
|
|
event = self.db.get_event_from_handle(handle)
|
|
|
|
if event.has_handle_reference('Place',place_handle):
|
|
|
|
event.remove_handle_references('Place',place_handle)
|
|
|
|
self.db.commit_event(event,trans)
|
2002-10-21 06:48:07 +05:30
|
|
|
|
2005-06-05 09:31:56 +05:30
|
|
|
self.db.enable_signals()
|
|
|
|
self.db.remove_place(place_handle,trans)
|
2005-04-01 11:03:22 +05:30
|
|
|
self.db.transaction_commit(trans,
|
2006-03-01 10:38:11 +05:30
|
|
|
_("Delete Place (%s)") % self.obj.get_title())
|