2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2004-02-26 09:04:19 +05:30
|
|
|
# Copyright (C) 2000-2004 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-12-07 10:24:40 +05:30
|
|
|
# $Id$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/Gnome modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2003-01-12 10:52:21 +05:30
|
|
|
import gtk
|
2002-10-20 19:55:16 +05:30
|
|
|
import gtk.glade
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import const
|
|
|
|
import Utils
|
2003-01-10 10:51:32 +05:30
|
|
|
import RelLib
|
2005-12-06 12:08:09 +05:30
|
|
|
import GrampsDisplay
|
|
|
|
from WindowUtils import GladeIf
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-08-17 07:44:33 +05:30
|
|
|
from gettext import gettext as _
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# LocationEditor class
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class LocationEditor:
|
|
|
|
|
2003-12-07 10:24:40 +05:30
|
|
|
def __init__(self,parent,location,parent_window=None):
|
2002-10-20 19:55:16 +05:30
|
|
|
self.parent = parent
|
2004-02-26 09:04:19 +05:30
|
|
|
if location:
|
|
|
|
if self.parent.child_windows.has_key(location):
|
|
|
|
self.parent.child_windows[location].present(None)
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
self.win_key = location
|
|
|
|
else:
|
|
|
|
self.win_key = self
|
2002-10-20 19:55:16 +05:30
|
|
|
self.location = location
|
2003-08-17 07:44:33 +05:30
|
|
|
self.top = gtk.glade.XML(const.dialogFile, "loc_edit","gramps")
|
2005-12-06 12:08:09 +05:30
|
|
|
self.gladeif = GladeIf(self.top)
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.window = self.top.get_widget("loc_edit")
|
|
|
|
self.city = self.top.get_widget("city")
|
|
|
|
self.state = self.top.get_widget("state")
|
2003-12-09 11:30:51 +05:30
|
|
|
self.postal = self.top.get_widget("postal")
|
|
|
|
self.phone = self.top.get_widget("phone")
|
2002-10-20 19:55:16 +05:30
|
|
|
self.parish = self.top.get_widget("parish")
|
|
|
|
self.county = self.top.get_widget("county")
|
|
|
|
self.country = self.top.get_widget("country")
|
|
|
|
|
2003-03-06 11:42:51 +05:30
|
|
|
Utils.set_titles(self.window, self.top.get_widget('title'),
|
|
|
|
_('Location Editor'))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if location != None:
|
|
|
|
self.city.set_text(location.get_city())
|
|
|
|
self.county.set_text(location.get_county())
|
|
|
|
self.country.set_text(location.get_country())
|
|
|
|
self.state.set_text(location.get_state())
|
2003-12-09 11:30:51 +05:30
|
|
|
self.phone.set_text(location.get_phone())
|
|
|
|
self.postal.set_text(location.get_postal_code())
|
2002-10-20 19:55:16 +05:30
|
|
|
self.parish.set_text(location.get_parish())
|
|
|
|
|
|
|
|
self.window.set_data("o",self)
|
2003-12-07 10:24:40 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
self.gladeif.connect('loc_edit','delete_event',self.on_delete_event)
|
|
|
|
self.gladeif.connect('button119','clicked',self.close)
|
|
|
|
self.gladeif.connect('button118','clicked',self.on_ok_clicked)
|
|
|
|
self.gladeif.connect('button128','clicked',self.on_help_clicked)
|
|
|
|
|
2003-12-07 10:24:40 +05:30
|
|
|
if parent_window:
|
|
|
|
self.window.set_transient_for(parent_window)
|
2004-02-26 09:04:19 +05:30
|
|
|
self.add_itself_to_menu()
|
|
|
|
self.window.show()
|
|
|
|
|
|
|
|
def on_delete_event(self,obj,b):
|
2005-12-06 12:08:09 +05:30
|
|
|
self.gladeif.close()
|
2004-02-26 09:04:19 +05:30
|
|
|
self.remove_itself_from_menu()
|
|
|
|
|
|
|
|
def close(self,obj):
|
2005-12-06 12:08:09 +05:30
|
|
|
self.gladeif.close()
|
2004-02-26 09:04:19 +05:30
|
|
|
self.remove_itself_from_menu()
|
2003-12-07 10:24:40 +05:30
|
|
|
self.window.destroy()
|
2004-02-26 09:04:19 +05:30
|
|
|
|
|
|
|
def add_itself_to_menu(self):
|
|
|
|
self.parent.child_windows[self.win_key] = self
|
|
|
|
self.parent_menu_item = gtk.MenuItem(_('Location Editor'))
|
|
|
|
self.parent_menu_item.connect("activate",self.present)
|
|
|
|
self.parent_menu_item.show()
|
|
|
|
self.parent.winsmenu.append(self.parent_menu_item)
|
|
|
|
|
|
|
|
def remove_itself_from_menu(self):
|
|
|
|
del self.parent.child_windows[self.win_key]
|
|
|
|
self.parent_menu_item.destroy()
|
|
|
|
|
|
|
|
def present(self,obj):
|
|
|
|
self.window.present()
|
2003-12-07 10:24:40 +05:30
|
|
|
|
|
|
|
def on_help_clicked(self,obj):
|
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
2005-12-06 12:08:09 +05:30
|
|
|
GrampsDisplay.help('gramps-edit-complete')
|
2003-12-07 10:24:40 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
def on_ok_clicked(self,obj):
|
2003-12-17 10:53:16 +05:30
|
|
|
city = unicode(self.city.get_text())
|
|
|
|
county = unicode(self.county.get_text())
|
|
|
|
country = unicode(self.country.get_text())
|
|
|
|
state = unicode(self.state.get_text())
|
|
|
|
phone = unicode(self.phone.get_text())
|
|
|
|
postal = unicode(self.postal.get_text())
|
|
|
|
parish = unicode(self.parish.get_text())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if self.location == None:
|
2003-01-10 10:51:32 +05:30
|
|
|
self.location = RelLib.Location()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.parent.llist.append(self.location)
|
|
|
|
|
2003-12-09 11:30:51 +05:30
|
|
|
self.update_location(city,parish,county,state,phone,postal,country)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.parent.redraw_location_list()
|
2004-02-26 09:04:19 +05:30
|
|
|
self.close(obj)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-12-09 11:30:51 +05:30
|
|
|
def update_location(self,city,parish,county,state,phone,postal,country):
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.location.get_city() != city:
|
|
|
|
self.location.set_city(city)
|
|
|
|
self.parent.lists_changed = 1
|
|
|
|
|
|
|
|
if self.location.get_parish() != parish:
|
|
|
|
self.location.set_parish(parish)
|
|
|
|
self.parent.lists_changed = 1
|
|
|
|
|
|
|
|
if self.location.get_county() != county:
|
|
|
|
self.location.set_county(county)
|
|
|
|
self.parent.lists_changed = 1
|
|
|
|
|
|
|
|
if self.location.get_state() != state:
|
|
|
|
self.location.set_state(state)
|
|
|
|
self.parent.lists_changed = 1
|
|
|
|
|
2003-12-09 11:30:51 +05:30
|
|
|
if self.location.get_phone() != phone:
|
|
|
|
self.location.set_phone(phone)
|
|
|
|
self.parent.lists_changed = 1
|
|
|
|
|
|
|
|
if self.location.get_postal_code() != postal:
|
|
|
|
self.location.set_postal_code(postal)
|
|
|
|
self.parent.lists_changed = 1
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
if self.location.get_country() != country:
|
|
|
|
self.location.set_country(country)
|
|
|
|
self.parent.lists_changed = 1
|