Cleaned up more code, broke LocationEditor into its own file

svn: r475
This commit is contained in:
Don Allingham 2001-10-16 03:50:33 +00:00
parent 014ea4f3a1
commit de04ab2ae3
9 changed files with 408 additions and 559 deletions

View File

@ -41,9 +41,8 @@ import utils
# Constants # Constants
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
OBJECT = "o" _TOPINST = "top"
TOPINST = "top" _NAMEINST = "namelist"
NAMEINST = "namelist"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -119,88 +118,51 @@ class Bookmarks :
# #
#--------------------------------------------------------------------- #---------------------------------------------------------------------
def edit(self): def edit(self):
top = libglade.GladeXML(const.bookFile,TOPINST) top = libglade.GladeXML(const.bookFile,_TOPINST)
namelist = top.get_widget(NAMEINST) self.namelist = top.get_widget(_NAMEINST)
index = 0 index = 0
for person in self.bookmarks: for person in self.bookmarks:
namelist.append([person.getPrimaryName().getName()]) self.namelist.append([person.getPrimaryName().getName()])
namelist.set_row_data(index,person) self.namelist.set_row_data(index,person)
index = index + 1 index = index + 1
top.signal_autoconnect({ top.signal_autoconnect({
"on_ok_clicked" : on_ok_clicked, "on_ok_clicked" : self.on_ok_clicked,
"on_down_clicked" : on_down_clicked, "on_down_clicked" : self.on_down_clicked,
"on_up_clicked" : on_up_clicked, "on_up_clicked" : self.on_up_clicked,
"on_delete_clicked" : on_delete_clicked, "on_delete_clicked" : self.on_delete_clicked,
"on_cancel_clicked" : on_cancel_clicked "on_cancel_clicked" : self.on_cancel_clicked
}) })
topBox = top.get_widget(TOPINST) def on_delete_clicked(self,obj):
topBox.set_data(OBJECT,self) if len(obj.selection) > 0:
topBox.set_data(NAMEINST,namelist) index = obj.selection[0]
topBox.show() obj.remove(index)
#------------------------------------------------------------------------- def on_up_clicked(self,obj):
# if len(obj.selection) > 0:
# on_delete_clicked - gets the selected row and number of rows that have index = obj.selection[0]
# been attached to the namelist. If the selected row is greater than 0, obj.swap_rows(index-1,index)
# then the row is deleted from the list. The number of rows is then
# decremented.
#
#-------------------------------------------------------------------------
def on_delete_clicked(obj):
if len(obj.selection) > 0:
index = obj.selection[0]
obj.remove(index)
#------------------------------------------------------------------------- def on_down_clicked(self,obj):
# if len(obj.selection) > 0:
# on_up_clicked - swap rows if the selected row is greater than 0 index = obj.selection[0]
# if index != obj.rows-1:
#------------------------------------------------------------------------- obj.swap_rows(index+1,index)
def on_up_clicked(obj):
if len(obj.selection) > 0:
index = obj.selection[0]
obj.swap_rows(index-1,index)
#------------------------------------------------------------------------- def on_ok_clicked(self,obj):
# del self.bookmarks[0:]
# on_down_clicked - swap rows if the selected index is not the last index
#
#-------------------------------------------------------------------------
def on_down_clicked(obj):
if len(obj.selection) > 0:
index = obj.selection[0]
if index != obj.rows-1:
obj.swap_rows(index+1,index)
#-------------------------------------------------------------------------
#
# on_ok_clicked - loop through the name list, extracting the attached
# person from list, and building up the new bookmark list. The menu is
# then redrawn.
#
#-------------------------------------------------------------------------
def on_ok_clicked(obj):
bkmarks = obj.get_data(OBJECT)
namelist = obj.get_data(NAMEINST)
del bkmarks.bookmarks[0:]
for index in range(0,bkmarks.index): for index in range(0,self.index):
person = namelist.get_row_data(index) person = self.namelist.get_row_data(index)
if person: if person:
bkmarks.bookmarks.append(person) self.bookmarks.append(person)
bkmarks.redraw() self.redraw()
obj.destroy() obj.destroy()
#------------------------------------------------------------------------- def on_cancel_clicked(self,obj):
# obj.destroy()
# on_cancel_clicked - destroy the bookmark editor
#
#-------------------------------------------------------------------------
def on_cancel_clicked(obj):
obj.destroy()

View File

@ -114,27 +114,26 @@ class EditPlace:
self.top_window.signal_autoconnect({ self.top_window.signal_autoconnect({
"destroy_passed_object" : utils.destroy_passed_object, "destroy_passed_object" : utils.destroy_passed_object,
"on_source_clicked" : on_source_clicked, "on_source_clicked" : self.on_source_clicked,
"on_photolist_select_icon" : self.gallery.on_photo_select_icon, "on_photolist_select_icon" : self.gallery.on_photo_select_icon,
"on_photolist_button_press_event" : self.gallery.on_photolist_button_press_event, "on_photolist_button_press_event" : self.gallery.on_photolist_button_press_event,
"on_switch_page" : on_switch_page, "on_switch_page" : self.on_switch_page,
"on_addphoto_clicked" : self.gallery.on_add_photo_clicked, "on_addphoto_clicked" : self.gallery.on_add_photo_clicked,
"on_deletephoto_clicked" : self.gallery.on_delete_photo_clicked, "on_deletephoto_clicked" : self.gallery.on_delete_photo_clicked,
"on_edit_properties_clicked": self.gallery.popup_change_description, "on_edit_properties_clicked": self.gallery.popup_change_description,
"on_add_url_clicked" : on_add_url_clicked, "on_add_url_clicked" : self.on_add_url_clicked,
"on_delete_url_clicked" : on_delete_url_clicked, "on_delete_url_clicked" : self.on_delete_url_clicked,
"on_update_url_clicked" : on_update_url_clicked, "on_update_url_clicked" : self.on_update_url_clicked,
"on_add_loc_clicked" : on_add_loc_clicked, "on_add_loc_clicked" : self.on_add_loc_clicked,
"on_delete_loc_clicked" : on_delete_loc_clicked, "on_delete_loc_clicked" : self.on_delete_loc_clicked,
"on_update_loc_clicked" : on_update_loc_clicked, "on_update_loc_clicked" : self.on_update_loc_clicked,
"on_web_list_select_row" : on_web_list_select_row, "on_web_list_select_row" : self.on_web_list_select_row,
"on_web_go_clicked": on_web_go_clicked, "on_web_go_clicked": self.on_web_go_clicked,
"on_loc_list_select_row" : on_loc_list_select_row, "on_loc_list_select_row" : self.on_loc_list_select_row,
"on_apply_clicked" : on_place_apply_clicked "on_apply_clicked" : self.on_place_apply_clicked
}) })
self.top = self.top_window.get_widget("placeEditor") self.top = self.top_window.get_widget("placeEditor")
self.top.set_data(_PLACE,self)
# Typing CR selects OK button # Typing CR selects OK button
self.top.editable_enters(self.title); self.top.editable_enters(self.title);
@ -149,28 +148,15 @@ class EditPlace:
self.top_window.get_widget("add_photo").set_sensitive(0) self.top_window.get_widget("add_photo").set_sensitive(0)
self.top_window.get_widget("delete_photo").set_sensitive(0) self.top_window.get_widget("delete_photo").set_sensitive(0)
self.web_list.set_data(_PLACE,self)
self.redraw_url_list() self.redraw_url_list()
self.loc_list.set_data(_PLACE,self)
self.redraw_location_list() self.redraw_location_list()
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def update_lists(self): def update_lists(self):
self.place.setUrlList(self.ulist) self.place.setUrlList(self.ulist)
self.place.set_alternate_locations(self.llist) self.place.set_alternate_locations(self.llist)
if self.lists_changed: if self.lists_changed:
utils.modified() utils.modified()
#---------------------------------------------------------------------
#
# redraw_url_list - redraws the altername name list for the person
#
#---------------------------------------------------------------------
def redraw_url_list(self): def redraw_url_list(self):
length = utils.redraw_list(self.ulist,self.web_list,disp_url) length = utils.redraw_list(self.ulist,self.web_list,disp_url)
if length > 0: if length > 0:
@ -180,307 +166,135 @@ class EditPlace:
self.web_url.set_text("") self.web_url.set_text("")
self.web_description.set_text("") self.web_description.set_text("")
#---------------------------------------------------------------------
#
# redraw_location_list
#
#---------------------------------------------------------------------
def redraw_location_list(self): def redraw_location_list(self):
utils.redraw_list(self.llist,self.loc_list,disp_loc) utils.redraw_list(self.llist,self.loc_list,disp_loc)
def on_web_go_clicked(obj): def on_web_go_clicked(self,obj):
import gnome.url import gnome.url
text = obj.get() text = obj.get()
if text != "": if text != "":
gnome.url.show(text) gnome.url.show(text)
#----------------------------------------------------------------------------- def on_place_apply_clicked(self,obj):
#
#
#
#-----------------------------------------------------------------------------
def on_place_apply_clicked(obj):
edit = obj.get_data(_PLACE) title = self.title.get_text()
title = edit.title.get_text() city = self.city.get_text()
city = edit.city.get_text() county = self.county.get_text()
county = edit.county.get_text() state = self.state.get_text()
state = edit.state.get_text() country = self.country.get_text()
country = edit.country.get_text() longitude = self.longitude.get_text()
longitude = edit.longitude.get_text() latitude = self.latitude.get_text()
latitude = edit.latitude.get_text() note = self.note.get_chars(0,-1)
note = edit.note.get_chars(0,-1)
mloc = edit.place.get_main_location() mloc = self.place.get_main_location()
if city != mloc.get_city(): if city != mloc.get_city():
mloc.set_city(city) mloc.set_city(city)
utils.modified() utils.modified()
if edit.lists_changed: if self.lists_changed:
edit.place.setSourceRefList(edit.srcreflist) self.place.setSourceRefList(self.srcreflist)
utils.modified() utils.modified()
if state != mloc.get_state(): if state != mloc.get_state():
mloc.set_state(state) mloc.set_state(state)
utils.modified() utils.modified()
if county != mloc.get_county(): if county != mloc.get_county():
mloc.set_county(county) mloc.set_county(county)
utils.modified() utils.modified()
if country != mloc.get_country(): if country != mloc.get_country():
mloc.set_country(country) mloc.set_country(country)
utils.modified() utils.modified()
if title != edit.place.get_title(): if title != self.place.get_title():
edit.place.set_title(title) self.place.set_title(title)
utils.modified() utils.modified()
if longitude != edit.place.get_longitude(): if longitude != self.place.get_longitude():
edit.place.set_longitude(longitude) self.place.set_longitude(longitude)
utils.modified() utils.modified()
if latitude != edit.place.get_latitude(): if latitude != self.place.get_latitude():
edit.place.set_latitude(latitude) self.place.set_latitude(latitude)
utils.modified() utils.modified()
if note != edit.place.getNote(): if note != self.place.getNote():
edit.place.setNote(note) self.place.setNote(note)
utils.modified() utils.modified()
edit.update_lists() self.update_lists()
utils.destroy_passed_object(edit.top) utils.destroy_passed_object(self.top)
edit.callback(edit.place) 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()
#-------------------------------------------------------------------------
def on_switch_page(obj,a,page):
src = obj.get_data(_PLACE)
if page == 3 and src.not_loaded:
src.not_loaded = 0
src.gallery.load_images()
#------------------------------------------------------------------------- def on_update_url_clicked(self,obj):
# import UrlEdit
# if len(obj.selection) > 0:
# row = obj.selection[0]
#------------------------------------------------------------------------- if self.place:
def on_update_url_clicked(obj): name = _("Internet Address Editor for %s") % self.place.get_title()
import UrlEdit else:
if len(obj.selection) > 0: name = _("Internet Address Editor")
row = obj.selection[0] UrlEdit.UrlEditor(self,name,obj.get_row_data(row))
mobj = obj.get_data(_PLACE)
if mobj.place: def on_update_loc_clicked(self,obj):
name = _("Internet Address Editor for %s") % mobj.place.get_title() 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: else:
name = _("Internet Address Editor") name = _("Internet Address Editor")
UrlEdit.UrlEditor(mobj,name,obj.get_row_data(row)) UrlEdit.UrlEditor(self,name,None)
#------------------------------------------------------------------------- def on_add_loc_clicked(self,obj):
# import LocEdit
# LocEdit.LocationEditor(self,None)
#
#-------------------------------------------------------------------------
def on_update_loc_clicked(obj):
if len(obj.selection) > 0:
row = obj.selection[0]
LocationEditor(obj.get_data(_PLACE),obj.get_row_data(row))
#------------------------------------------------------------------------- def on_source_clicked(self,obj):
# Sources.SourceSelector(self.srcreflist,self,src_changed)
#
#
#-------------------------------------------------------------------------
def on_delete_url_clicked(obj):
epo = obj.get_data(_PLACE)
if utils.delete_selected(obj,epo.ulist):
epo.lists_changed = 1
epo.redraw_url_list()
#------------------------------------------------------------------------- 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)
def on_delete_loc_clicked(obj): self.web_description.set_text("")
epo = obj.get_data(_PLACE)
if utils.delete_selected(obj,epo.llist):
epo.lists_changed = 1
epo.redraw_location_list()
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def on_add_url_clicked(obj):
import UrlEdit
mobj = obj.get_data(_PLACE)
if mobj.place:
name = _("Internet Address Editor for %s") % mobj.place.get_title()
else:
name = _("Internet Address Editor")
UrlEdit.UrlEditor(mobj,name,None)
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def on_add_loc_clicked(obj):
LocationEditor(obj.get_data(_PLACE),None)
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def on_source_clicked(obj):
epo = obj.get_data(_PLACE)
Sources.SourceSelector(epo.srcreflist,epo,src_changed)
def src_changed(parent):
parent.lists_changed = 1
#-------------------------------------------------------------------------
#
# on_web_list_select_row - sets the row object attached to the passed
# object, and then updates the display with the data corresponding to
# the row.
#
#-------------------------------------------------------------------------
def on_web_list_select_row(obj,row,b,c):
epo = obj.get_data(_PLACE)
url = obj.get_row_data(row)
if url == None:
epo.web_url.set_text("")
epo.web_go.set_sensitive(0)
epo.web_description.set_text("")
else:
path = url.get_path()
epo.web_url.set_text(path)
epo.web_go.set_sensitive(1)
epo.web_description.set_text(url.get_description())
#-------------------------------------------------------------------------
#
# on_loclist_select_row - sets the row object attached to the passed
# object, and then updates the display with the data corresponding to
# the row.
#
#-------------------------------------------------------------------------
def on_loc_list_select_row(obj,row,b,c):
epo = obj.get_data(_PLACE)
loc = obj.get_row_data(row)
epo.loc_city.set_text(loc.get_city())
epo.loc_county.set_text(loc.get_county())
epo.loc_state.set_text(loc.get_state())
epo.loc_country.set_text(loc.get_country())
#-------------------------------------------------------------------------
#
# update_location
#
# Updates the specified event with the specified date. Compares against
# the previous value, so the that modified flag is not set if nothing has
# actually changed.
#
#-------------------------------------------------------------------------
def update_location(loc,city,county,state,country):
changed = 0
if loc.get_city() != city:
loc.set_city(city)
changed = 1
if loc.get_county() != county:
loc.set_county(county)
changed = 1
if loc.get_state() != state:
loc.set_state(state)
changed = 1
if loc.get_country() != country:
loc.set_country(country)
changed = 1
return changed
#-------------------------------------------------------------------------
#
# LocationEditor class
#
#-------------------------------------------------------------------------
class LocationEditor:
def __init__(self,parent,location):
self.parent = parent
self.location = location
self.top = libglade.GladeXML(const.dialogFile, "loc_edit")
self.window = self.top.get_widget("loc_edit")
self.city = self.top.get_widget("city")
self.state = self.top.get_widget("state")
self.county = self.top.get_widget("county")
self.country = self.top.get_widget("country")
# Typing CR selects OK button
self.window.editable_enters(self.city);
self.window.editable_enters(self.county);
self.window.editable_enters(self.state);
self.window.editable_enters(self.country);
if parent.place:
name = _("Location Editor for %s") % parent.place.get_title()
else: else:
name = _("Location Editor") path = url.get_path()
self.web_url.set_text(path)
self.top.get_widget("locationTitle").set_text(name) self.web_go.set_sensitive(1)
self.web_description.set_text(url.get_description())
if location != None: def on_loc_list_select_row(self,obj,row,b,c):
self.city.set_text(location.get_city()) loc = obj.get_row_data(row)
self.county.set_text(location.get_county())
self.country.set_text(location.get_country())
self.state.set_text(location.get_state())
self.window.set_data("o",self) self.loc_city.set_text(loc.get_city())
self.top.signal_autoconnect({ self.loc_county.set_text(loc.get_county())
"destroy_passed_object" : utils.destroy_passed_object, self.loc_state.set_text(loc.get_state())
"on_loc_edit_ok_clicked" : on_location_edit_ok_clicked self.loc_country.set_text(loc.get_country())
})
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def on_location_edit_ok_clicked(obj):
ee = obj.get_data("o")
loc = ee.location
city = ee.city.get_text()
county = ee.county.get_text()
country = ee.country.get_text()
state = ee.state.get_text()
if loc == None:
loc = Location()
ee.parent.llist.append(loc)
if update_location(loc,city,county,state,country):
ee.parent.lists_changed = 1
ee.parent.redraw_location_list()
utils.destroy_passed_object(obj)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -498,3 +312,5 @@ def disp_url(url):
def disp_loc(loc): def disp_loc(loc):
return [loc.get_city(),loc.get_county(),loc.get_state(),loc.get_country()] return [loc.get_city(),loc.get_county(),loc.get_state(),loc.get_country()]
def src_changed(parent):
parent.lists_changed = 1

View File

@ -53,7 +53,6 @@ _ = intl.gettext
# Constants # Constants
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
SOURCE = "s"
class EditSource: class EditSource:
@ -85,14 +84,13 @@ class EditSource:
"destroy_passed_object" : utils.destroy_passed_object, "destroy_passed_object" : utils.destroy_passed_object,
"on_photolist_select_icon" : self.gallery.on_photo_select_icon, "on_photolist_select_icon" : self.gallery.on_photo_select_icon,
"on_photolist_button_press_event" : self.gallery.on_photolist_button_press_event, "on_photolist_button_press_event" : self.gallery.on_photolist_button_press_event,
"on_switch_page" : on_switch_page, "on_switch_page" : self.on_switch_page,
"on_addphoto_clicked" : self.gallery.on_add_photo_clicked, "on_addphoto_clicked" : self.gallery.on_add_photo_clicked,
"on_deletephoto_clicked" : self.gallery.on_delete_photo_clicked, "on_deletephoto_clicked" : self.gallery.on_delete_photo_clicked,
"on_sourceapply_clicked" : on_source_apply_clicked "on_sourceapply_clicked" : self.on_source_apply_clicked
}) })
self.top = self.top_window.get_widget("sourceEditor") self.top = self.top_window.get_widget("sourceEditor")
self.top.set_data(SOURCE,self)
if self.source.getId() == "": if self.source.getId() == "":
self.top_window.get_widget("add_photo").set_sensitive(0) self.top_window.get_widget("add_photo").set_sensitive(0)
@ -102,47 +100,34 @@ class EditSource:
self.top.editable_enters(self.author); self.top.editable_enters(self.author);
self.top.editable_enters(self.pubinfo); self.top.editable_enters(self.pubinfo);
def on_source_apply_clicked(self,obj):
#----------------------------------------------------------------------------- title = self.title.get_text()
# author = self.author.get_text()
# pubinfo = self.pubinfo.get_text()
# note = self.note.get_chars(0,-1)
#-----------------------------------------------------------------------------
def on_source_apply_clicked(obj):
edit = obj.get_data(SOURCE)
title = edit.title.get_text()
author = edit.author.get_text()
pubinfo = edit.pubinfo.get_text()
note = edit.note.get_chars(0,-1)
if author != edit.source.getAuthor(): if author != self.source.getAuthor():
edit.source.setAuthor(author) self.source.setAuthor(author)
utils.modified() utils.modified()
if title != edit.source.getTitle(): if title != self.source.getTitle():
edit.source.setTitle(title) self.source.setTitle(title)
utils.modified() utils.modified()
if pubinfo != edit.source.getPubInfo(): if pubinfo != self.source.getPubInfo():
edit.source.setPubInfo(pubinfo) self.source.setPubInfo(pubinfo)
utils.modified() utils.modified()
if note != edit.source.getNote(): if note != self.source.getNote():
edit.source.setNote(note) self.source.setNote(note)
utils.modified() utils.modified()
utils.destroy_passed_object(edit.top) utils.destroy_passed_object(self.top)
edit.callback(edit.source) self.callback(self.source)
#------------------------------------------------------------------------- def on_switch_page(self,obj,a,page):
# if page == 2 and self.not_loaded:
# self.not_loaded = 0
# self.gallery.load_images()
#-------------------------------------------------------------------------
def on_switch_page(obj,a,page):
src = obj.get_data(SOURCE)
if page == 2 and src.not_loaded:
src.not_loaded = 0
src.gallery.load_images()

View File

@ -29,8 +29,6 @@ import utils
import string import string
import gtk import gtk
_OBJECT = "o"
class Find: class Find:
"""Opens find person dialog for gramps""" """Opens find person dialog for gramps"""
@ -46,11 +44,10 @@ class Find:
self.xml = libglade.GladeXML(const.gladeFile,"find") self.xml = libglade.GladeXML(const.gladeFile,"find")
self.xml.signal_autoconnect({ self.xml.signal_autoconnect({
"destroy_passed_object" : utils.destroy_passed_object, "destroy_passed_object" : utils.destroy_passed_object,
"on_next_clicked" : on_next_clicked, "on_next_clicked" : self.on_next_clicked,
"on_prev_clicked" : on_prev_clicked, "on_prev_clicked" : self.on_prev_clicked,
}) })
self.top = self.xml.get_widget("find") self.top = self.xml.get_widget("find")
self.top.set_data(_OBJECT,self)
self.entry = self.xml.get_widget("entry1") self.entry = self.xml.get_widget("entry1")
self.top.editable_enters(self.entry) self.top.editable_enters(self.entry)
@ -108,11 +105,10 @@ class Find:
gtk.gdk_beep() gtk.gdk_beep()
def on_next_clicked(self,obj):
"""Callback for dialog box that causes the next person to be found"""
self.find_next()
def on_next_clicked(obj): def on_prev_clicked(self,obj):
"""Callback for dialog box that causes the next person to be found""" """Callback for dialog box that causes the previous person to be found"""
obj.get_data(_OBJECT).find_next() self.find_prev()
def on_prev_clicked(obj):
"""Callback for dialog box that causes the previous person to be found"""
obj.get_data(_OBJECT).find_prev()

View File

@ -23,6 +23,7 @@ from RelLib import *
import string import string
import os import os
import sys import sys
import utils
import gnome.mime import gnome.mime
#------------------------------------------------------------------------- #-------------------------------------------------------------------------

126
gramps/src/LocEdit.py Normal file
View File

@ -0,0 +1,126 @@
#
# 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 os
import string
#-------------------------------------------------------------------------
#
# GTK/Gnome modules
#
#-------------------------------------------------------------------------
from gtk import *
from gnome.ui import *
import libglade
#-------------------------------------------------------------------------
#
# gramps modules
#
#-------------------------------------------------------------------------
import intl
import const
import utils
from RelLib import *
_ = intl.gettext
#-------------------------------------------------------------------------
#
# LocationEditor class
#
#-------------------------------------------------------------------------
class LocationEditor:
def __init__(self,parent,location):
self.parent = parent
self.location = location
self.top = libglade.GladeXML(const.dialogFile, "loc_edit")
self.window = self.top.get_widget("loc_edit")
self.city = self.top.get_widget("city")
self.state = self.top.get_widget("state")
self.county = self.top.get_widget("county")
self.country = self.top.get_widget("country")
# Typing CR selects OK button
self.window.editable_enters(self.city);
self.window.editable_enters(self.county);
self.window.editable_enters(self.state);
self.window.editable_enters(self.country);
if parent.place:
name = _("Location Editor for %s") % parent.place.get_title()
else:
name = _("Location Editor")
self.top.get_widget("locationTitle").set_text(name)
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())
self.window.set_data("o",self)
self.top.signal_autoconnect({
"destroy_passed_object" : utils.destroy_passed_object,
"on_loc_edit_ok_clicked" : self.on_location_edit_ok_clicked
})
def on_location_edit_ok_clicked(self,obj):
self.location = self.location
city = self.city.get_text()
county = self.county.get_text()
country = self.country.get_text()
state = self.state.get_text()
if self.location == None:
self.location = Location()
self.parent.llist.append(self.location)
self.update_location(city,county,state,country)
self.parent.redraw_location_list()
utils.destroy_passed_object(obj)
def update_location(self,city,county,state,country):
if self.location.get_city() != city:
self.location.set_city(city)
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
if self.location.get_country() != country:
self.location.set_country(country)
self.parent.lists_changed = 1

View File

@ -24,6 +24,10 @@ import os
import string import string
import shutil import shutil
import intl import intl
import libglade
import const
import utils
_ = intl.gettext _ = intl.gettext
try: try:
@ -38,6 +42,37 @@ _sep = '-' * 10
_end = "=" * 10 _end = "=" * 10
class RevisionSelect:
def __init__(self,db,filename,vc,load):
self.db = db
self.filename = filename
self.vc = vc
self.load = load
dialog = libglade.GladeXML(const.gladeFile, "revselect")
revsel = dialog.get_widget("revselect")
dialog.signal_autoconnect({
"destroy_passed_object" : utils.destroy_passed_object,
"on_loadrev_clicked" : self.on_loadrev_clicked,
})
self.revlist = dialog.get_widget("revlist")
l = self.vc.revision_list()
l.reverse()
index = 0
for f in l:
self.revlist.append([f[0],f[1],f[2]])
self.revlist.set_row_data(index,f[0])
index = index + 1
def on_loadrev_clicked(self,obj):
if len(self.revlist.selection) > 0:
rev = self.revlist.get_row_data(self.revlist.selection[0])
f = self.vc.get_version(rev)
self.load(f,self.filename,rev)
utils.destroy_passed_object(obj)
class VersionControl: class VersionControl:
"""Base class for revision control systems""" """Base class for revision control systems"""
def __init__(self,wd): def __init__(self,wd):

View File

@ -56,7 +56,7 @@ def sortById(first,second):
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def fix(line): def fix(line):
l = string.stripline) l = string.stripline(line)
l = string.replace(l,'&','&') l = string.replace(l,'&','&')
l = string.replace(l,'>','>') l = string.replace(l,'>','>')
l = string.replace(l,'<','&lt;') l = string.replace(l,'<','&lt;')

View File

@ -1119,49 +1119,12 @@ def on_ok_button1_clicked(obj):
utils.destroy_passed_object(obj) utils.destroy_passed_object(obj)
if getoldrev.get_active(): if getoldrev.get_active():
dialog = libglade.GladeXML(const.gladeFile, "revselect")
revsel = dialog.get_widget("revselect")
dialog.signal_autoconnect({
"destroy_passed_object" : utils.destroy_passed_object,
"on_loadrev_clicked" : on_loadrev_clicked,
})
revlist = dialog.get_widget("revlist")
revsel.set_data("o",revlist)
vc = VersionControl.RcsVersionControl(filename) vc = VersionControl.RcsVersionControl(filename)
l = vc.revision_list() VersionControl.RevisionSelect(database,filename,vc,load_revision)
l.reverse()
index = 0
for f in l:
revlist.append([f[0],f[1],f[2]])
revlist.set_row_data(index,f[0])
index = index + 1
revlist.set_data("n",filename)
else: else:
if filename != "": if filename != "":
read_file(filename) read_file(filename)
def on_loadrev_clicked(obj):
clist = obj.get_data("o")
filename = clist.get_data("n")
if len(clist.selection) > 0:
rev = clist.get_row_data(clist.selection[0])
vc = VersionControl.RcsVersionControl(filename)
f = vc.get_version(rev)
load_revision(f,filename,rev)
utils.destroy_passed_object(obj)
active_person = None
for person in database.getPersonMap().values():
if active_person == None:
active_person = person
lastname = person.getPrimaryName().getSurname()
if lastname and lastname not in const.surnames:
const.surnames.append(lastname)
statusbar.set_progress(1.0)
full_update()
statusbar.set_progress(0.0)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# #
@ -3073,111 +3036,76 @@ def load_progress(value):
# #
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def load_database(name): def post_load(name):
global active_person global active_person
filename = name + os.sep + const.indexFile
database.setSavePath(name)
res = database.getResearcher()
if res.getName() == "" and Config.owner.getName() != "":
database.setResearcher(Config.owner)
utils.modified()
setup_bookmarks()
mylist = database.getPersonEventTypes()
for type in mylist:
ntype = const.display_pevent(type)
if ntype not in const.personalEvents:
const.personalEvents.append(ntype)
mylist = database.getFamilyEventTypes()
for type in mylist:
ntype = const.display_fevent(type)
if ntype not in const.marriageEvents:
const.marriageEvents.append(ntype)
mylist = database.getPersonAttributeTypes()
for type in mylist:
ntype = const.display_pattr(type)
if ntype not in const.personalAttributes:
const.personalAttributes.append(ntype)
mylist = database.getFamilyAttributeTypes()
for type in mylist:
if type not in const.familyAttributes:
const.familyAttributes.append(type)
mylist = database.getFamilyRelationTypes()
for type in mylist:
if type not in const.familyRelations:
const.familyRelations.append(type)
Config.save_last_file(name)
gtop.get_widget("filter").set_text("")
person = database.getDefaultPerson()
if person:
active_person = person
return 1
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def load_database(name):
filename = "%s/%s" % (name,const.indexFile)
if ReadXML.loadData(database,filename,load_progress) == 0: if ReadXML.loadData(database,filename,load_progress) == 0:
return 0 return 0
return post_load(name)
database.setSavePath(name) #-------------------------------------------------------------------------
#
res = database.getResearcher() #
if res.getName() == "" and Config.owner.getName() != "": #
database.setResearcher(Config.owner) #-------------------------------------------------------------------------
utils.modified()
setup_bookmarks()
mylist = database.getPersonEventTypes()
for type in mylist:
ntype = const.display_pevent(type)
if ntype not in const.personalEvents:
const.personalEvents.append(ntype)
mylist = database.getFamilyEventTypes()
for type in mylist:
ntype = const.display_fevent(type)
if ntype not in const.marriageEvents:
const.marriageEvents.append(ntype)
mylist = database.getPersonAttributeTypes()
for type in mylist:
ntype = const.display_pattr(type)
if ntype not in const.personalAttributes:
const.personalAttributes.append(ntype)
mylist = database.getFamilyAttributeTypes()
for type in mylist:
if type not in const.familyAttributes:
const.familyAttributes.append(type)
mylist = database.getFamilyRelationTypes()
for type in mylist:
if type not in const.familyRelations:
const.familyRelations.append(type)
Config.save_last_file(name)
gtop.get_widget("filter").set_text("")
person = database.getDefaultPerson()
if person:
active_person = person
return 1
def load_revision(f,name,revision): def load_revision(f,name,revision):
global active_person
filename = name + os.sep + const.indexFile
if ReadXML.loadRevision(database,f,filename, revision,load_progress) == 0: filename = "%s/%s" % (name,const.indexFile)
if ReadXML.loadRevision(database,f,filename,revision,load_progress) == 0:
return 0 return 0
return post_load(name)
database.setSavePath(name)
res = database.getResearcher()
if res.getName() == "" and Config.owner.getName() != "":
database.setResearcher(Config.owner)
utils.modified()
setup_bookmarks()
mylist = database.getPersonEventTypes()
for type in mylist:
ntype = const.display_pevent(type)
if ntype not in const.personalEvents:
const.personalEvents.append(ntype)
mylist = database.getFamilyEventTypes()
for type in mylist:
ntype = const.display_fevent(type)
if ntype not in const.marriageEvents:
const.marriageEvents.append(ntype)
mylist = database.getPersonAttributeTypes()
for type in mylist:
ntype = const.display_pattr(type)
if ntype not in const.personalAttributes:
const.personalAttributes.append(ntype)
mylist = database.getFamilyAttributeTypes()
for type in mylist:
if type not in const.familyAttributes:
const.familyAttributes.append(type)
mylist = database.getFamilyRelationTypes()
for type in mylist:
if type not in const.familyRelations:
const.familyRelations.append(type)
Config.save_last_file(name)
gtop.get_widget("filter").set_text("")
person = database.getDefaultPerson()
if person:
active_person = person
return 1
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #