2001-08-19 01:22:02 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2000 Donald N. Allingham
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Standard python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import string
|
2001-10-16 20:34:25 +05:30
|
|
|
import Config
|
2001-08-19 01:22:02 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
from gtk import *
|
|
|
|
from gnome.ui import *
|
|
|
|
|
|
|
|
import libglade
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import intl
|
|
|
|
import const
|
|
|
|
import utils
|
|
|
|
from RelLib import *
|
2001-08-21 21:10:37 +05:30
|
|
|
import Sources
|
2001-10-04 10:21:06 +05:30
|
|
|
import ImageSelect
|
2001-08-19 01:22:02 +05:30
|
|
|
|
|
|
|
_ = intl.gettext
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class EditPlace:
|
|
|
|
|
|
|
|
def __init__(self,place,db,func):
|
|
|
|
self.place = place
|
|
|
|
self.db = db
|
|
|
|
self.callback = func
|
|
|
|
self.path = db.getSavePath()
|
|
|
|
self.not_loaded = 1
|
2001-10-18 08:12:02 +05:30
|
|
|
self.ref_not_loaded = 1
|
2001-10-14 07:55:58 +05:30
|
|
|
self.lists_changed = 0
|
2001-10-06 23:55:31 +05:30
|
|
|
if place:
|
|
|
|
self.srcreflist = place.getSourceRefList()
|
|
|
|
else:
|
|
|
|
self.srcreflist = []
|
|
|
|
|
2001-08-19 01:22:02 +05:30
|
|
|
self.top_window = libglade.GladeXML(const.placesFile,"placeEditor")
|
2001-10-09 23:26:26 +05:30
|
|
|
idval = "p%s" % place.getId()
|
|
|
|
plwidget = self.top_window.get_widget("photolist")
|
|
|
|
self.gallery = ImageSelect.Gallery(place, self.path, idval, plwidget, db)
|
2001-08-19 01:22:02 +05:30
|
|
|
self.title = self.top_window.get_widget("place_title")
|
|
|
|
self.city = self.top_window.get_widget("city")
|
|
|
|
self.county = self.top_window.get_widget("county")
|
|
|
|
self.state = self.top_window.get_widget("state")
|
|
|
|
self.country = self.top_window.get_widget("country")
|
|
|
|
self.longitude = self.top_window.get_widget("longitude")
|
|
|
|
self.latitude = self.top_window.get_widget("latitude")
|
|
|
|
self.note = self.top_window.get_widget("place_note")
|
|
|
|
|
2001-08-19 23:01:52 +05:30
|
|
|
self.web_list = self.top_window.get_widget("web_list")
|
2001-08-22 04:12:33 +05:30
|
|
|
self.web_url = self.top_window.get_widget("web_url")
|
2001-09-09 02:32:53 +05:30
|
|
|
self.web_go = self.top_window.get_widget("web_go")
|
2001-08-19 23:01:52 +05:30
|
|
|
self.web_description = self.top_window.get_widget("url_des")
|
2001-08-21 21:10:37 +05:30
|
|
|
|
2001-08-20 10:28:38 +05:30
|
|
|
self.loc_list = self.top_window.get_widget("loc_list")
|
|
|
|
self.loc_city = self.top_window.get_widget("loc_city")
|
|
|
|
self.loc_county = self.top_window.get_widget("loc_county")
|
|
|
|
self.loc_state = self.top_window.get_widget("loc_state")
|
|
|
|
self.loc_country = self.top_window.get_widget("loc_country")
|
|
|
|
|
2001-08-31 09:10:23 +05:30
|
|
|
self.lists_changed = 0
|
2001-08-19 23:01:52 +05:30
|
|
|
self.ulist = place.getUrlList()[:]
|
2001-08-20 10:28:38 +05:30
|
|
|
self.llist = place.get_alternate_locations()[:]
|
2001-08-19 23:01:52 +05:30
|
|
|
|
2001-08-19 01:22:02 +05:30
|
|
|
self.title.set_text(place.get_title())
|
|
|
|
mloc = place.get_main_location()
|
|
|
|
self.city.set_text(mloc.get_city())
|
|
|
|
self.county.set_text(mloc.get_county())
|
|
|
|
self.state.set_text(mloc.get_state())
|
|
|
|
self.country.set_text(mloc.get_country())
|
|
|
|
self.longitude.set_text(place.get_longitude())
|
|
|
|
self.latitude.set_text(place.get_latitude())
|
2001-10-18 08:12:02 +05:30
|
|
|
self.refinfo = self.top_window.get_widget("refinfo")
|
2001-08-19 01:22:02 +05:30
|
|
|
|
|
|
|
self.note.set_point(0)
|
|
|
|
self.note.insert_defaults(place.getNote())
|
|
|
|
self.note.set_word_wrap(1)
|
|
|
|
|
|
|
|
self.top_window.signal_autoconnect({
|
|
|
|
"destroy_passed_object" : utils.destroy_passed_object,
|
2001-10-16 09:20:33 +05:30
|
|
|
"on_source_clicked" : self.on_source_clicked,
|
2001-10-09 23:26:26 +05:30
|
|
|
"on_photolist_select_icon" : self.gallery.on_photo_select_icon,
|
|
|
|
"on_photolist_button_press_event" : self.gallery.on_photolist_button_press_event,
|
2001-10-16 09:20:33 +05:30
|
|
|
"on_switch_page" : self.on_switch_page,
|
2001-10-09 23:26:26 +05:30
|
|
|
"on_addphoto_clicked" : self.gallery.on_add_photo_clicked,
|
|
|
|
"on_deletephoto_clicked" : self.gallery.on_delete_photo_clicked,
|
2001-10-14 07:55:58 +05:30
|
|
|
"on_edit_properties_clicked": self.gallery.popup_change_description,
|
2001-10-16 09:20:33 +05:30
|
|
|
"on_add_url_clicked" : self.on_add_url_clicked,
|
|
|
|
"on_delete_url_clicked" : self.on_delete_url_clicked,
|
|
|
|
"on_update_url_clicked" : self.on_update_url_clicked,
|
|
|
|
"on_add_loc_clicked" : self.on_add_loc_clicked,
|
|
|
|
"on_delete_loc_clicked" : self.on_delete_loc_clicked,
|
|
|
|
"on_update_loc_clicked" : self.on_update_loc_clicked,
|
|
|
|
"on_web_list_select_row" : self.on_web_list_select_row,
|
|
|
|
"on_web_go_clicked": self.on_web_go_clicked,
|
|
|
|
"on_loc_list_select_row" : self.on_loc_list_select_row,
|
|
|
|
"on_apply_clicked" : self.on_place_apply_clicked
|
2001-08-19 01:22:02 +05:30
|
|
|
})
|
|
|
|
|
|
|
|
self.top = self.top_window.get_widget("placeEditor")
|
|
|
|
|
2001-09-24 05:58:40 +05:30
|
|
|
# Typing CR selects OK button
|
|
|
|
self.top.editable_enters(self.title);
|
|
|
|
self.top.editable_enters(self.city);
|
|
|
|
self.top.editable_enters(self.county);
|
|
|
|
self.top.editable_enters(self.state);
|
|
|
|
self.top.editable_enters(self.country);
|
|
|
|
self.top.editable_enters(self.longitude);
|
|
|
|
self.top.editable_enters(self.latitude);
|
|
|
|
|
2001-08-19 01:22:02 +05:30
|
|
|
if self.place.getId() == "":
|
|
|
|
self.top_window.get_widget("add_photo").set_sensitive(0)
|
|
|
|
self.top_window.get_widget("delete_photo").set_sensitive(0)
|
|
|
|
|
2001-08-19 23:01:52 +05:30
|
|
|
self.redraw_url_list()
|
2001-08-20 10:28:38 +05:30
|
|
|
self.redraw_location_list()
|
2001-10-18 08:12:02 +05:30
|
|
|
|
2001-08-31 09:10:23 +05:30
|
|
|
def update_lists(self):
|
2001-08-19 23:01:52 +05:30
|
|
|
self.place.setUrlList(self.ulist)
|
2001-08-21 21:10:37 +05:30
|
|
|
self.place.set_alternate_locations(self.llist)
|
2001-08-31 09:10:23 +05:30
|
|
|
if self.lists_changed:
|
|
|
|
utils.modified()
|
|
|
|
|
2001-08-19 23:01:52 +05:30
|
|
|
def redraw_url_list(self):
|
2001-08-31 09:10:23 +05:30
|
|
|
length = utils.redraw_list(self.ulist,self.web_list,disp_url)
|
|
|
|
if length > 0:
|
2001-09-09 02:32:53 +05:30
|
|
|
self.web_go.set_sensitive(1)
|
2001-08-22 04:12:33 +05:30
|
|
|
else:
|
2001-09-09 02:32:53 +05:30
|
|
|
self.web_go.set_sensitive(0)
|
|
|
|
self.web_url.set_text("")
|
2001-08-22 04:12:33 +05:30
|
|
|
self.web_description.set_text("")
|
2001-08-19 23:01:52 +05:30
|
|
|
|
2001-08-20 10:28:38 +05:30
|
|
|
def redraw_location_list(self):
|
2001-08-31 09:10:23 +05:30
|
|
|
utils.redraw_list(self.llist,self.loc_list,disp_loc)
|
2001-08-20 10:28:38 +05:30
|
|
|
|
2001-10-04 10:21:06 +05:30
|
|
|
|
2001-10-16 09:20:33 +05:30
|
|
|
def on_web_go_clicked(self,obj):
|
|
|
|
import gnome.url
|
2001-08-19 23:01:52 +05:30
|
|
|
|
2001-10-16 09:20:33 +05:30
|
|
|
text = obj.get()
|
|
|
|
if text != "":
|
|
|
|
gnome.url.show(text)
|
2001-08-20 10:28:38 +05:30
|
|
|
|
2001-10-16 09:20:33 +05:30
|
|
|
def on_place_apply_clicked(self,obj):
|
2001-08-19 23:01:52 +05:30
|
|
|
|
2001-10-16 09:20:33 +05:30
|
|
|
title = self.title.get_text()
|
|
|
|
city = self.city.get_text()
|
|
|
|
county = self.county.get_text()
|
|
|
|
state = self.state.get_text()
|
|
|
|
country = self.country.get_text()
|
|
|
|
longitude = self.longitude.get_text()
|
|
|
|
latitude = self.latitude.get_text()
|
|
|
|
note = self.note.get_chars(0,-1)
|
2001-08-20 10:28:38 +05:30
|
|
|
|
2001-10-16 09:20:33 +05:30
|
|
|
mloc = self.place.get_main_location()
|
|
|
|
if city != mloc.get_city():
|
|
|
|
mloc.set_city(city)
|
|
|
|
utils.modified()
|
2001-08-20 10:28:38 +05:30
|
|
|
|
2001-10-16 09:20:33 +05:30
|
|
|
if self.lists_changed:
|
|
|
|
self.place.setSourceRefList(self.srcreflist)
|
|
|
|
utils.modified()
|
2001-08-19 23:01:52 +05:30
|
|
|
|
2001-10-16 09:20:33 +05:30
|
|
|
if state != mloc.get_state():
|
|
|
|
mloc.set_state(state)
|
|
|
|
utils.modified()
|
2001-08-19 23:01:52 +05:30
|
|
|
|
2001-10-16 09:20:33 +05:30
|
|
|
if county != mloc.get_county():
|
|
|
|
mloc.set_county(county)
|
|
|
|
utils.modified()
|
2001-08-19 23:01:52 +05:30
|
|
|
|
2001-10-16 09:20:33 +05:30
|
|
|
if country != mloc.get_country():
|
|
|
|
mloc.set_country(country)
|
|
|
|
utils.modified()
|
2001-08-19 23:01:52 +05:30
|
|
|
|
2001-10-16 09:20:33 +05:30
|
|
|
if title != self.place.get_title():
|
|
|
|
self.place.set_title(title)
|
|
|
|
utils.modified()
|
2001-08-20 10:28:38 +05:30
|
|
|
|
2001-10-16 09:20:33 +05:30
|
|
|
if longitude != self.place.get_longitude():
|
|
|
|
self.place.set_longitude(longitude)
|
|
|
|
utils.modified()
|
2001-08-20 10:28:38 +05:30
|
|
|
|
2001-10-16 09:20:33 +05:30
|
|
|
if latitude != self.place.get_latitude():
|
|
|
|
self.place.set_latitude(latitude)
|
|
|
|
utils.modified()
|
|
|
|
|
|
|
|
if note != self.place.getNote():
|
|
|
|
self.place.setNote(note)
|
|
|
|
utils.modified()
|
2001-08-20 10:28:38 +05:30
|
|
|
|
2001-10-16 09:20:33 +05:30
|
|
|
self.update_lists()
|
|
|
|
|
|
|
|
utils.destroy_passed_object(self.top)
|
|
|
|
self.callback(self.place)
|
|
|
|
|
|
|
|
def on_switch_page(self,obj,a,page):
|
|
|
|
if page == 3 and self.not_loaded:
|
|
|
|
self.not_loaded = 0
|
|
|
|
self.gallery.load_images()
|
2001-10-18 08:12:02 +05:30
|
|
|
elif page == 5 and self.ref_not_loaded:
|
|
|
|
self.ref_not_loaded = 0
|
|
|
|
self.display_references()
|
2001-10-16 09:20:33 +05:30
|
|
|
|
|
|
|
def on_update_url_clicked(self,obj):
|
|
|
|
import UrlEdit
|
|
|
|
if len(obj.selection) > 0:
|
|
|
|
row = obj.selection[0]
|
|
|
|
if self.place:
|
|
|
|
name = _("Internet Address Editor for %s") % self.place.get_title()
|
|
|
|
else:
|
|
|
|
name = _("Internet Address Editor")
|
|
|
|
UrlEdit.UrlEditor(self,name,obj.get_row_data(row))
|
|
|
|
|
|
|
|
def on_update_loc_clicked(self,obj):
|
|
|
|
import LocEdit
|
|
|
|
if len(obj.selection) > 0:
|
|
|
|
row = obj.selection[0]
|
|
|
|
LocEdit.LocationEditor(self,obj.get_row_data(row))
|
|
|
|
|
|
|
|
def on_delete_url_clicked(self,obj):
|
|
|
|
if utils.delete_selected(obj,self.ulist):
|
|
|
|
self.lists_changed = 1
|
|
|
|
self.redraw_url_list()
|
|
|
|
|
|
|
|
def on_delete_loc_clicked(self,obj):
|
|
|
|
if utils.delete_selected(obj,self.llist):
|
|
|
|
self.lists_changed = 1
|
|
|
|
self.redraw_location_list()
|
|
|
|
|
|
|
|
def on_add_url_clicked(self,obj):
|
|
|
|
import UrlEdit
|
|
|
|
if self.place:
|
|
|
|
name = _("Internet Address Editor for %s") % self.place.get_title()
|
|
|
|
else:
|
|
|
|
name = _("Internet Address Editor")
|
|
|
|
UrlEdit.UrlEditor(self,name,None)
|
2001-08-20 10:28:38 +05:30
|
|
|
|
2001-10-16 09:20:33 +05:30
|
|
|
def on_add_loc_clicked(self,obj):
|
|
|
|
import LocEdit
|
|
|
|
LocEdit.LocationEditor(self,None)
|
2001-08-20 10:28:38 +05:30
|
|
|
|
2001-10-16 09:20:33 +05:30
|
|
|
def on_source_clicked(self,obj):
|
|
|
|
Sources.SourceSelector(self.srcreflist,self,src_changed)
|
2001-09-24 05:58:40 +05:30
|
|
|
|
2001-10-16 09:20:33 +05:30
|
|
|
def on_web_list_select_row(self,obj,row,b,c):
|
|
|
|
url = obj.get_row_data(row)
|
|
|
|
if url == None:
|
|
|
|
self.web_url.set_text("")
|
|
|
|
self.web_go.set_sensitive(0)
|
|
|
|
self.web_description.set_text("")
|
2001-08-20 10:28:38 +05:30
|
|
|
else:
|
2001-10-16 09:20:33 +05:30
|
|
|
path = url.get_path()
|
|
|
|
self.web_url.set_text(path)
|
|
|
|
self.web_go.set_sensitive(1)
|
|
|
|
self.web_description.set_text(url.get_description())
|
2001-08-20 10:28:38 +05:30
|
|
|
|
2001-10-16 09:20:33 +05:30
|
|
|
def on_loc_list_select_row(self,obj,row,b,c):
|
|
|
|
loc = obj.get_row_data(row)
|
2001-08-20 10:28:38 +05:30
|
|
|
|
2001-10-16 09:20:33 +05:30
|
|
|
self.loc_city.set_text(loc.get_city())
|
|
|
|
self.loc_county.set_text(loc.get_county())
|
|
|
|
self.loc_state.set_text(loc.get_state())
|
|
|
|
self.loc_country.set_text(loc.get_country())
|
2001-08-20 10:28:38 +05:30
|
|
|
|
2001-10-18 08:12:02 +05:30
|
|
|
def display_references(self):
|
|
|
|
pevent = []
|
|
|
|
fevent = []
|
|
|
|
for p in self.db.getPersonMap().values():
|
|
|
|
for event in [p.getBirth(), p.getDeath()] + p.getEventList():
|
|
|
|
if event.getPlace() == self.place:
|
|
|
|
pevent.append((p,event))
|
|
|
|
for f in self.db.getFamilyMap().values():
|
|
|
|
for event in f.getEventList():
|
|
|
|
if event.getPlace() == self.place:
|
|
|
|
fevent.append((f,event))
|
|
|
|
|
|
|
|
self.refinfo.set_point(0)
|
|
|
|
self.refinfo.set_word_wrap(1)
|
|
|
|
|
|
|
|
if len(pevent) > 0:
|
|
|
|
self.refinfo.insert_defaults(_("People") + "\n")
|
|
|
|
self.refinfo.insert_defaults("_________________________\n\n")
|
|
|
|
t = _("%s [%s]: event %s\n")
|
|
|
|
|
|
|
|
for e in pevent:
|
|
|
|
msg = t % (Config.nameof(e[0]),e[0].getId(),e[1].getName())
|
|
|
|
self.refinfo.insert_defaults(msg)
|
|
|
|
|
|
|
|
if len(fevent) > 0:
|
|
|
|
self.refinfo.insert_defaults("\n%s\n" % _("Families"))
|
|
|
|
self.refinfo.insert_defaults("_________________________\n\n")
|
|
|
|
t = _("%s [%s]: event %s\n")
|
|
|
|
|
|
|
|
for e in fevent:
|
|
|
|
father = e[0].getFather()
|
|
|
|
mother = e[0].getMother()
|
|
|
|
if father and mother:
|
|
|
|
fname = "%s and %s" % (Config.nameof(father),Config.nameof(mother))
|
|
|
|
elif father:
|
|
|
|
fname = "%s" % Config.nameof(father)
|
|
|
|
else:
|
|
|
|
fname = "%s" % Config.nameof(mother)
|
|
|
|
|
|
|
|
msg = t % (fname,e[0].getId(),e[1].getName())
|
|
|
|
self.refinfo.insert_defaults(msg)
|
|
|
|
|
2001-08-20 10:28:38 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2001-08-31 09:10:23 +05:30
|
|
|
#
|
2001-08-20 10:28:38 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2001-08-31 09:10:23 +05:30
|
|
|
def disp_url(url):
|
|
|
|
return [url.get_path(),url.get_description()]
|
2001-08-20 10:28:38 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2001-08-31 09:10:23 +05:30
|
|
|
#
|
2001-08-20 10:28:38 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2001-08-31 09:10:23 +05:30
|
|
|
def disp_loc(loc):
|
|
|
|
return [loc.get_city(),loc.get_county(),loc.get_state(),loc.get_country()]
|
2001-08-20 10:28:38 +05:30
|
|
|
|
2001-10-16 09:20:33 +05:30
|
|
|
def src_changed(parent):
|
|
|
|
parent.lists_changed = 1
|
2001-10-16 20:34:25 +05:30
|
|
|
|
|
|
|
|
|
|
|
class DeletePlaceQuery:
|
|
|
|
|
2001-10-18 08:12:02 +05:30
|
|
|
def __init__(self,place,db,update):
|
2001-10-16 20:34:25 +05:30
|
|
|
self.db = db
|
|
|
|
self.place = place
|
|
|
|
self.update = update
|
|
|
|
|
2001-10-18 08:12:02 +05:30
|
|
|
def query_response(self,ans):
|
|
|
|
if ans == 1:
|
|
|
|
return
|
|
|
|
del self.db.getPlaceMap()[self.place.getId()]
|
2001-10-16 20:34:25 +05:30
|
|
|
utils.modified()
|
2001-10-18 08:12:02 +05:30
|
|
|
|
|
|
|
for p in self.db.getPersonMap().values():
|
|
|
|
for event in [p.getBirth(), p.getDeath()] + p.getEventList():
|
|
|
|
if event.getPlace() == self.place:
|
|
|
|
event.setPlace(None)
|
|
|
|
for f in self.db.getFamilyMap().values():
|
|
|
|
for event in f.getEventList():
|
|
|
|
if event.getPlace() == self.place:
|
|
|
|
event.setPlace(None)
|
2001-10-16 20:34:25 +05:30
|
|
|
self.update(0)
|