* src/EditPerson.py: Support for keeping track of names, addresses,

and urls after they are edited
* src/NameEdit.py: Support for keeping track of names after they are edited
* src/AddrEdit.py: Support for keeping track of names after they are edited
* src/UrlEdit.py: Support for keeping track of names after they are edited


svn: r1697
This commit is contained in:
Don Allingham 2003-06-11 03:26:02 +00:00
parent e8422b3b09
commit cd9c84a212
4 changed files with 38 additions and 19 deletions

View File

@ -52,7 +52,7 @@ class AddressEditor:
""" """
Displays a dialog that allows the user to edit an address. Displays a dialog that allows the user to edit an address.
""" """
def __init__(self,parent,addr): def __init__(self,parent,addr,callback):
""" """
Displays the dialog box. Displays the dialog box.
@ -74,9 +74,8 @@ class AddressEditor:
self.parent = parent self.parent = parent
self.addr = addr self.addr = addr
self.callback = callback
name = parent.person.getPrimaryName().getName() name = parent.person.getPrimaryName().getName()
print "'%s'" % name
if name == ", ": if name == ", ":
text = _("Address Editor") text = _("Address Editor")
else: else:
@ -135,7 +134,7 @@ class AddressEditor:
self.addr.setSourceRefList(self.srcreflist) self.addr.setSourceRefList(self.srcreflist)
self.update(date,street,city,state,country,postal,note,priv) self.update(date,street,city,state,country,postal,note,priv)
self.parent.redraw_addr_list() self.callback(self.addr)
Utils.destroy_passed_object(obj) Utils.destroy_passed_object(obj)
def check(self,get,set,data): def check(self,get,set,data):

View File

@ -624,8 +624,10 @@ class EditPerson:
def redraw_name_list(self): def redraw_name_list(self):
"""redraws the name list""" """redraws the name list"""
self.ntree.clear() self.ntree.clear()
self.nmap = {}
for name in self.nlist: for name in self.nlist:
self.ntree.add([name.getName(),_(name.getType())],name) iter = self.ntree.add([name.getName(),_(name.getType())],name)
self.nmap[str(name)] = iter
if self.ntree: if self.ntree:
self.ntree.select_row(0) self.ntree.select_row(0)
@ -633,8 +635,10 @@ class EditPerson:
"""redraws the url list, disabling the go button if no url """redraws the url list, disabling the go button if no url
is selected""" is selected"""
self.wtree.clear() self.wtree.clear()
self.wmap = {}
for url in self.ulist: for url in self.ulist:
self.wtree.add([url.get_path(),url.get_description()],url) iter = self.wtree.add([url.get_path(),url.get_description()],url)
self.wmap[str(url)] = iter
if len(self.ulist) > 0: if len(self.ulist) > 0:
self.web_go.set_sensitive(0) self.web_go.set_sensitive(0)
@ -647,10 +651,12 @@ class EditPerson:
def redraw_addr_list(self): def redraw_addr_list(self):
"""Redraws the address list""" """Redraws the address list"""
self.ptree.clear() self.ptree.clear()
self.pmap = {}
for addr in self.plist: for addr in self.plist:
location = "%s %s %s %s" % (addr.getStreet(),addr.getCity(), location = "%s %s %s %s" % (addr.getStreet(),addr.getCity(),
addr.getState(),addr.getCountry()) addr.getState(),addr.getCountry())
self.ptree.add([addr.getDate(),location],addr) iter = self.ptree.add([addr.getDate(),location],addr)
self.pmap[str(addr)] = iter
if self.plist: if self.plist:
self.ptree.select_row(0) self.ptree.select_row(0)
@ -664,6 +670,18 @@ class EditPerson:
if self.alist: if self.alist:
self.atree.select_row(0) self.atree.select_row(0)
def name_edit_callback(self,name):
self.redraw_name_list()
self.ntree.select_iter(self.nmap[str(name)])
def addr_edit_callback(self,addr):
self.redraw_addr_list()
self.ptree.select_iter(self.pmap[str(addr)])
def url_edit_callback(self,url):
self.redraw_url_list()
self.wtree.select_iter(self.wmap[str(url)])
def event_edit_callback(self,event): def event_edit_callback(self,event):
"""Birth and death events may not be in the map""" """Birth and death events may not be in the map"""
self.redraw_event_list() self.redraw_event_list()
@ -721,18 +739,18 @@ class EditPerson:
def on_add_addr_clicked(self,obj): def on_add_addr_clicked(self,obj):
"""Invokes the address editor to add a new address""" """Invokes the address editor to add a new address"""
import AddrEdit import AddrEdit
AddrEdit.AddressEditor(self,None) AddrEdit.AddressEditor(self,None,self.addr_edit_callback)
def on_add_aka_clicked(self,obj): def on_add_aka_clicked(self,obj):
"""Invokes the name editor to add a new name""" """Invokes the name editor to add a new name"""
import NameEdit import NameEdit
NameEdit.NameEditor(self,None) NameEdit.NameEditor(self,None,self.name_edit_callback)
def on_add_url_clicked(self,obj): def on_add_url_clicked(self,obj):
"""Invokes the url editor to add a new name""" """Invokes the url editor to add a new name"""
import UrlEdit import UrlEdit
pname = self.person.getPrimaryName().getName() pname = self.person.getPrimaryName().getName()
UrlEdit.UrlEditor(self,pname,None) UrlEdit.UrlEditor(self,pname,None,self.url_edit_callback)
def on_add_attr_clicked(self,obj): def on_add_attr_clicked(self,obj):
"""Brings up the AttributeEditor for a new attribute""" """Brings up the AttributeEditor for a new attribute"""
@ -1023,15 +1041,15 @@ class EditPerson:
import AddrEdit import AddrEdit
store,iter = self.ptree.get_selected() store,iter = self.ptree.get_selected()
if iter: if iter:
AddrEdit.AddressEditor(self,self.ptree.get_object(iter)) AddrEdit.AddressEditor(self,self.ptree.get_object(iter),self.addr_edit_callback)
def on_update_url_clicked(self,obj): def on_update_url_clicked(self,obj):
import UrlEdit import UrlEdit
store,iter = self.wtree.get_selected() store,iter = self.wtree.get_selected()
if iter: if iter:
pname = self.person.getPrimaryName().getName() pname = self.person.getPrimaryName().getName()
url = obj.get_row_data(obj.selection[0]) url = self.wtree.get_object(iter)
UrlEdit.UrlEditor(self,pname,url) UrlEdit.UrlEditor(self,pname,url,self.url_edit_callback)
def on_event_update_clicked(self,obj): def on_event_update_clicked(self,obj):
import EventEdit import EventEdit
@ -1194,7 +1212,7 @@ class EditPerson:
import NameEdit import NameEdit
store,iter = self.ntree.get_selected() store,iter = self.ntree.get_selected()
if iter: if iter:
NameEdit.NameEditor(self,self.ntree.get_object(iter)) NameEdit.NameEditor(self,self.ntree.get_object(iter),self.name_edit_callback)
def load_photo(self,photo): def load_photo(self,photo):
"""loads, scales, and displays the person's main photo""" """loads, scales, and displays the person's main photo"""

View File

@ -45,9 +45,10 @@ from intl import gettext as _
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class NameEditor: class NameEditor:
def __init__(self,parent,name): def __init__(self,parent,name,callback):
self.parent = parent self.parent = parent
self.name = name self.name = name
self.callback = callback
self.top = gtk.glade.XML(const.dialogFile, "name_edit") self.top = gtk.glade.XML(const.dialogFile, "name_edit")
self.window = self.top.get_widget("name_edit") self.window = self.top.get_widget("name_edit")
self.given_field = self.top.get_widget("alt_given") self.given_field = self.top.get_widget("alt_given")
@ -129,7 +130,7 @@ class NameEditor:
self.update_name(first,last,suffix,title,type,note,priv) self.update_name(first,last,suffix,title,type,note,priv)
self.parent.lists_changed = 1 self.parent.lists_changed = 1
self.parent.redraw_name_list() self.callback(self.name)
Utils.destroy_passed_object(obj) Utils.destroy_passed_object(obj)
def update_name(self,first,last,suffix,title,type,note,priv): def update_name(self,first,last,suffix,title,type,note,priv):

View File

@ -42,9 +42,10 @@ from intl import gettext as _
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class UrlEditor: class UrlEditor:
def __init__(self,parent,name,url): def __init__(self,parent,name,url,callback):
self.parent = parent self.parent = parent
self.url = url self.url = url
self.callback = callback
self.top = gtk.glade.XML(const.dialogFile, "url_edit") self.top = gtk.glade.XML(const.dialogFile, "url_edit")
self.window = self.top.get_widget("url_edit") self.window = self.top.get_widget("url_edit")
self.des = self.top.get_widget("url_des") self.des = self.top.get_widget("url_des")
@ -80,7 +81,7 @@ class UrlEditor:
self.parent.ulist.append(self.url) self.parent.ulist.append(self.url)
self.update_url(des,addr,priv) self.update_url(des,addr,priv)
self.parent.redraw_url_list() self.callback(self.url)
Utils.destroy_passed_object(obj) Utils.destroy_passed_object(obj)
def update_url(self,des,addr,priv): def update_url(self,des,addr,priv):