* 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:
parent
5200bc703c
commit
5147048755
@ -52,7 +52,7 @@ class AddressEditor:
|
||||
"""
|
||||
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.
|
||||
|
||||
@ -74,9 +74,8 @@ class AddressEditor:
|
||||
|
||||
self.parent = parent
|
||||
self.addr = addr
|
||||
|
||||
self.callback = callback
|
||||
name = parent.person.getPrimaryName().getName()
|
||||
print "'%s'" % name
|
||||
if name == ", ":
|
||||
text = _("Address Editor")
|
||||
else:
|
||||
@ -135,7 +134,7 @@ class AddressEditor:
|
||||
self.addr.setSourceRefList(self.srcreflist)
|
||||
|
||||
self.update(date,street,city,state,country,postal,note,priv)
|
||||
self.parent.redraw_addr_list()
|
||||
self.callback(self.addr)
|
||||
Utils.destroy_passed_object(obj)
|
||||
|
||||
def check(self,get,set,data):
|
||||
|
@ -624,8 +624,10 @@ class EditPerson:
|
||||
def redraw_name_list(self):
|
||||
"""redraws the name list"""
|
||||
self.ntree.clear()
|
||||
self.nmap = {}
|
||||
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:
|
||||
self.ntree.select_row(0)
|
||||
|
||||
@ -633,9 +635,11 @@ class EditPerson:
|
||||
"""redraws the url list, disabling the go button if no url
|
||||
is selected"""
|
||||
self.wtree.clear()
|
||||
self.wmap = {}
|
||||
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:
|
||||
self.web_go.set_sensitive(0)
|
||||
self.wtree.select_row(0)
|
||||
@ -647,10 +651,12 @@ class EditPerson:
|
||||
def redraw_addr_list(self):
|
||||
"""Redraws the address list"""
|
||||
self.ptree.clear()
|
||||
self.pmap = {}
|
||||
for addr in self.plist:
|
||||
location = "%s %s %s %s" % (addr.getStreet(),addr.getCity(),
|
||||
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:
|
||||
self.ptree.select_row(0)
|
||||
|
||||
@ -664,6 +670,18 @@ class EditPerson:
|
||||
if self.alist:
|
||||
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):
|
||||
"""Birth and death events may not be in the map"""
|
||||
self.redraw_event_list()
|
||||
@ -721,18 +739,18 @@ class EditPerson:
|
||||
def on_add_addr_clicked(self,obj):
|
||||
"""Invokes the address editor to add a new address"""
|
||||
import AddrEdit
|
||||
AddrEdit.AddressEditor(self,None)
|
||||
AddrEdit.AddressEditor(self,None,self.addr_edit_callback)
|
||||
|
||||
def on_add_aka_clicked(self,obj):
|
||||
"""Invokes the name editor to add a new name"""
|
||||
import NameEdit
|
||||
NameEdit.NameEditor(self,None)
|
||||
NameEdit.NameEditor(self,None,self.name_edit_callback)
|
||||
|
||||
def on_add_url_clicked(self,obj):
|
||||
"""Invokes the url editor to add a new name"""
|
||||
import UrlEdit
|
||||
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):
|
||||
"""Brings up the AttributeEditor for a new attribute"""
|
||||
@ -1023,15 +1041,15 @@ class EditPerson:
|
||||
import AddrEdit
|
||||
store,iter = self.ptree.get_selected()
|
||||
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):
|
||||
import UrlEdit
|
||||
store,iter = self.wtree.get_selected()
|
||||
if iter:
|
||||
pname = self.person.getPrimaryName().getName()
|
||||
url = obj.get_row_data(obj.selection[0])
|
||||
UrlEdit.UrlEditor(self,pname,url)
|
||||
url = self.wtree.get_object(iter)
|
||||
UrlEdit.UrlEditor(self,pname,url,self.url_edit_callback)
|
||||
|
||||
def on_event_update_clicked(self,obj):
|
||||
import EventEdit
|
||||
@ -1194,7 +1212,7 @@ class EditPerson:
|
||||
import NameEdit
|
||||
store,iter = self.ntree.get_selected()
|
||||
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):
|
||||
"""loads, scales, and displays the person's main photo"""
|
||||
|
@ -45,9 +45,10 @@ from intl import gettext as _
|
||||
#-------------------------------------------------------------------------
|
||||
class NameEditor:
|
||||
|
||||
def __init__(self,parent,name):
|
||||
def __init__(self,parent,name,callback):
|
||||
self.parent = parent
|
||||
self.name = name
|
||||
self.callback = callback
|
||||
self.top = gtk.glade.XML(const.dialogFile, "name_edit")
|
||||
self.window = self.top.get_widget("name_edit")
|
||||
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.parent.lists_changed = 1
|
||||
|
||||
self.parent.redraw_name_list()
|
||||
self.callback(self.name)
|
||||
Utils.destroy_passed_object(obj)
|
||||
|
||||
def update_name(self,first,last,suffix,title,type,note,priv):
|
||||
|
@ -42,9 +42,10 @@ from intl import gettext as _
|
||||
#-------------------------------------------------------------------------
|
||||
class UrlEditor:
|
||||
|
||||
def __init__(self,parent,name,url):
|
||||
def __init__(self,parent,name,url,callback):
|
||||
self.parent = parent
|
||||
self.url = url
|
||||
self.callback = callback
|
||||
self.top = gtk.glade.XML(const.dialogFile, "url_edit")
|
||||
self.window = self.top.get_widget("url_edit")
|
||||
self.des = self.top.get_widget("url_des")
|
||||
@ -80,7 +81,7 @@ class UrlEditor:
|
||||
self.parent.ulist.append(self.url)
|
||||
|
||||
self.update_url(des,addr,priv)
|
||||
self.parent.redraw_url_list()
|
||||
self.callback(self.url)
|
||||
Utils.destroy_passed_object(obj)
|
||||
|
||||
def update_url(self,des,addr,priv):
|
||||
|
Loading…
Reference in New Issue
Block a user