Updated several more plugins, more flexibility in ID naming
svn: r513
This commit is contained in:
parent
b697bde6de
commit
a40acfdddb
@ -23,6 +23,7 @@
|
||||
__author__ = "Don Allingham"
|
||||
|
||||
|
||||
import re
|
||||
from Date import *
|
||||
|
||||
CONF_VERY_HIGH = 4
|
||||
@ -31,6 +32,8 @@ CONF_NORMAL = 2
|
||||
CONF_LOW = 1
|
||||
CONF_VERY_LOW = 0
|
||||
|
||||
_id_reg = re.compile("%\d+d")
|
||||
|
||||
class SourceNote:
|
||||
"""Base class for storing source references and notes"""
|
||||
|
||||
@ -1474,19 +1477,34 @@ class RelDataBase:
|
||||
self.fprefix = "F%d"
|
||||
|
||||
def set_iprefix(self,val):
|
||||
self.iprefix = val + "%d"
|
||||
if _id_reg.search(val):
|
||||
self.iprefix = val
|
||||
else:
|
||||
self.iprefix = val + "%d"
|
||||
|
||||
def set_sprefix(self,val):
|
||||
self.sprefix = val + "%d"
|
||||
if _id_reg.search(val):
|
||||
self.sprefix = val
|
||||
else:
|
||||
self.sprefix = val + "%d"
|
||||
|
||||
def set_oprefix(self,val):
|
||||
self.oprefix = val + "%d"
|
||||
if _id_reg.search(val):
|
||||
self.oprefix = val
|
||||
else:
|
||||
self.oprefix = val + "%d"
|
||||
|
||||
def set_pprefix(self,val):
|
||||
self.pprefix = val + "%d"
|
||||
if _id_reg.search(val):
|
||||
self.pprefix = val
|
||||
else:
|
||||
self.pprefix = val + "%d"
|
||||
|
||||
def set_fprefix(self,val):
|
||||
self.fprefix = val + "%d"
|
||||
if _id_reg.search(val):
|
||||
self.fprefix = val
|
||||
else:
|
||||
self.fprefix = val + "%d"
|
||||
|
||||
def new(self):
|
||||
"""initializes the RelDataBase to empty values"""
|
||||
|
@ -33,59 +33,54 @@ import intl
|
||||
|
||||
_ = intl.gettext
|
||||
|
||||
topDialog = None
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_apply_clicked(obj):
|
||||
original = topDialog.get_widget("original_text").get_text()
|
||||
new = topDialog.get_widget("new_text").get_text()
|
||||
|
||||
for person in db.getPersonMap().values():
|
||||
for event in person.getEventList():
|
||||
if event.getName() == original:
|
||||
event.setName(new)
|
||||
utils.modified()
|
||||
|
||||
on_close_clicked(obj)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_close_clicked(obj):
|
||||
obj.destroy()
|
||||
while events_pending():
|
||||
mainiteration()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def runTool(database,person,callback):
|
||||
global active_person
|
||||
global topDialog
|
||||
global glade_file
|
||||
global db
|
||||
ChangeTypes(database,person)
|
||||
|
||||
active_person = person
|
||||
db = database
|
||||
class ChangeTypes:
|
||||
def __init__(self,db,person):
|
||||
self.person = person
|
||||
self.db = db
|
||||
|
||||
base = os.path.dirname(__file__)
|
||||
glade_file = base + os.sep + "changetype.glade"
|
||||
topDialog = GladeXML(glade_file,"top")
|
||||
base = os.path.dirname(__file__)
|
||||
glade_file = "%s/%s" % (base,"changetype.glade")
|
||||
self.glade = GladeXML(glade_file,"top")
|
||||
|
||||
topDialog.get_widget("original").set_popdown_strings(const.personalEvents)
|
||||
topDialog.get_widget("new").set_popdown_strings(const.personalEvents)
|
||||
self.glade.get_widget("original").set_popdown_strings(const.personalEvents)
|
||||
self.glade.get_widget("new").set_popdown_strings(const.personalEvents)
|
||||
|
||||
topDialog.signal_autoconnect({
|
||||
"on_close_clicked" : on_close_clicked,
|
||||
"on_apply_clicked" : on_apply_clicked
|
||||
})
|
||||
self.glade.signal_autoconnect({
|
||||
"on_close_clicked" : utils.destroy_passed_object,
|
||||
"on_combo_insert_text" : utils.combo_insert_text,
|
||||
"on_apply_clicked" : self.on_apply_clicked
|
||||
})
|
||||
|
||||
def on_apply_clicked(self,obj):
|
||||
modified = 0
|
||||
original = self.glade.get_widget("original_text").get_text()
|
||||
new = self.glade.get_widget("new_text").get_text()
|
||||
|
||||
print original
|
||||
print new
|
||||
for person in self.db.getPersonMap().values():
|
||||
for event in person.getEventList():
|
||||
print event.getName()
|
||||
if event.getName() == original:
|
||||
event.setName(new)
|
||||
modified = modified + 1
|
||||
utils.modified()
|
||||
|
||||
if modified == 1:
|
||||
msg = _("1 event record was modified")
|
||||
else:
|
||||
msg = _("%d event records were modified") % modified
|
||||
|
||||
GnomeOkDialog(msg)
|
||||
utils.destroy_passed_object(obj)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -33,9 +33,9 @@ import libglade
|
||||
import RelLib
|
||||
import utils
|
||||
|
||||
title_list = []
|
||||
nick_list = []
|
||||
cb = None
|
||||
_title_re = re.compile(r"^([A-Za-z][A-Za-z]+\.)\s+(.*)$")
|
||||
_nick_re = re.compile(r"(.+)[(\"](.*)[)\"]")
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -45,73 +45,69 @@ cb = None
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def runTool(database,active_person,callback):
|
||||
PatchNames(database,callback)
|
||||
|
||||
global cb
|
||||
class PatchNames:
|
||||
|
||||
cb = callback
|
||||
title_re = re.compile(r"^([A-Za-z][A-Za-z]+\.)\s+(.*)$")
|
||||
nick_re = re.compile(r"(.+)[(\"](.*)[)\"]")
|
||||
def __init__(self,db,callback):
|
||||
self.cb = callback
|
||||
self.db = db
|
||||
self.title_list = []
|
||||
self.nick_list = []
|
||||
|
||||
personMap = database.getPersonMap()
|
||||
for key in personMap.keys():
|
||||
personMap = self.db.getPersonMap()
|
||||
for key in personMap.keys():
|
||||
|
||||
person = personMap[key]
|
||||
first = person.getPrimaryName().getFirstName()
|
||||
match = title_re.match(first)
|
||||
if match:
|
||||
groups = match.groups()
|
||||
title_list.append((person,groups[0],groups[1]))
|
||||
person = personMap[key]
|
||||
first = person.getPrimaryName().getFirstName()
|
||||
match = _title_re.match(first)
|
||||
if match:
|
||||
groups = match.groups()
|
||||
self.title_list.append((person,groups[0],groups[1]))
|
||||
|
||||
match = nick_re.match(first)
|
||||
if match:
|
||||
groups = match.groups()
|
||||
nick_list.append((person,groups[0],groups[1]))
|
||||
match = _nick_re.match(first)
|
||||
if match:
|
||||
groups = match.groups()
|
||||
self.nick_list.append((person,groups[0],groups[1]))
|
||||
|
||||
msg = ""
|
||||
if len(nick_list) > 0 or len(title_list) > 0:
|
||||
if len(nick_list) > 0:
|
||||
for name in nick_list:
|
||||
msg = ""
|
||||
if len(self.nick_list) > 0 or len(self.title_list) > 0:
|
||||
for name in self.nick_list:
|
||||
msg = msg + _("%s will be extracted as a nickname from %s\n") % \
|
||||
(name[2],name[0].getPrimaryName().getName())
|
||||
|
||||
if len(title_list) > 0:
|
||||
for name in title_list:
|
||||
for name in self.title_list:
|
||||
msg = msg + _("%s will be extracted as a title from %s\n") % \
|
||||
(name[0].getPrimaryName().getName(),name[1])
|
||||
|
||||
base = os.path.dirname(__file__)
|
||||
glade_file = base + os.sep + "patchnames.glade"
|
||||
base = os.path.dirname(__file__)
|
||||
glade_file = base + os.sep + "patchnames.glade"
|
||||
|
||||
top = libglade.GladeXML(glade_file,"summary")
|
||||
top.signal_autoconnect({
|
||||
"destroy_passed_object" : utils.destroy_passed_object,
|
||||
"on_ok_clicked" : on_ok_clicked
|
||||
})
|
||||
top.get_widget("textwindow").show_string(msg)
|
||||
else:
|
||||
GnomeOkDialog(_("No titles or nicknames were found"))
|
||||
callback(0)
|
||||
self.top = libglade.GladeXML(glade_file,"summary")
|
||||
self.top.signal_autoconnect({
|
||||
"destroy_passed_object" : utils.destroy_passed_object,
|
||||
"on_ok_clicked" : self.on_ok_clicked
|
||||
})
|
||||
self.top.get_widget("textwindow").show_string(msg)
|
||||
else:
|
||||
GnomeOkDialog(_("No titles or nicknames were found"))
|
||||
self.cb(0)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_ok_clicked(obj):
|
||||
for grp in nick_list:
|
||||
name = grp[0].getPrimaryName()
|
||||
name.setFirstName(grp[1])
|
||||
grp[0].setNickName(grp[2])
|
||||
utils.modified()
|
||||
def on_ok_clicked(self,obj):
|
||||
for grp in self.nick_list:
|
||||
name = grp[0].getPrimaryName()
|
||||
name.setFirstName(grp[1])
|
||||
grp[0].setNickName(grp[2])
|
||||
utils.modified()
|
||||
|
||||
for grp in title_list:
|
||||
name = grp[0].getPrimaryName()
|
||||
name.setFirstName(grp[2])
|
||||
name.setTitle(grp[1])
|
||||
utils.modified()
|
||||
for grp in self.title_list:
|
||||
name = grp[0].getPrimaryName()
|
||||
name.setFirstName(grp[2])
|
||||
name.setTitle(grp[1])
|
||||
utils.modified()
|
||||
|
||||
utils.destroy_passed_object(obj)
|
||||
cb(1)
|
||||
utils.destroy_passed_object(obj)
|
||||
self.cb(1)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -29,13 +29,10 @@ from libglade import *
|
||||
import RelLib
|
||||
import sort
|
||||
import intl
|
||||
import utils
|
||||
|
||||
_ = intl.gettext
|
||||
|
||||
topDialog = None
|
||||
other_person = None
|
||||
col2person = []
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
@ -51,118 +48,6 @@ def filter(person,index,list,map):
|
||||
filter(family.getFather(),index+1,list,map)
|
||||
filter(family.getMother(),index+1,list,map)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_peopleList_select_row(obj,a,b,c):
|
||||
global other_person
|
||||
|
||||
other_person = col2person[a]
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_apply_clicked(obj):
|
||||
firstMap = {}
|
||||
firstList = []
|
||||
secondMap = {}
|
||||
secondList = []
|
||||
common = []
|
||||
rank = 9999999
|
||||
|
||||
filter(active_person,0,firstList,firstMap)
|
||||
filter(other_person,0,secondList,secondMap)
|
||||
|
||||
for person in firstList:
|
||||
if person in secondList:
|
||||
new_rank = firstMap[person]
|
||||
if new_rank < rank:
|
||||
rank = new_rank
|
||||
common = [ person ]
|
||||
elif new_rank == rank:
|
||||
common.append(person)
|
||||
|
||||
firstRel = -1
|
||||
secondRel = -1
|
||||
|
||||
firstName = active_person.getPrimaryName().getRegularName()
|
||||
secondName = other_person.getPrimaryName().getRegularName()
|
||||
|
||||
length = len(common)
|
||||
if length == 1:
|
||||
person = common[0]
|
||||
secondRel = firstMap[person]
|
||||
firstRel = secondMap[person]
|
||||
commontext = " Their common ancestor is "
|
||||
commontext = commontext + person.getPrimaryName().getRegularName() + "."
|
||||
elif length > 1:
|
||||
index = 0
|
||||
commontext = " Their common ancestors are "
|
||||
for person in common:
|
||||
secondRel = firstMap[person]
|
||||
firstRel = secondMap[person]
|
||||
if length == index + 1:
|
||||
commontext = commontext + " and "
|
||||
elif index != 0:
|
||||
commontext = commontext + ", "
|
||||
commontext = commontext + person.getPrimaryName().getRegularName()
|
||||
index = index + 1
|
||||
else:
|
||||
commontext = ""
|
||||
|
||||
if firstRel == -1:
|
||||
text = "There is no relationship between " + firstName + " and " + secondName + "."
|
||||
elif firstRel == 0:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
root = "father"
|
||||
else:
|
||||
root = "mother"
|
||||
if secondRel == 0:
|
||||
text = firstName + " and " + secondName + " are the same person."
|
||||
else:
|
||||
text = secondName + get_prefix(secondRel,root) + firstName
|
||||
elif secondRel == 0:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
text = secondName + get_prefix(firstRel,"son") + firstName + "."
|
||||
else:
|
||||
text = secondName + get_prefix(firstRel,"daughter") + firstName + "."
|
||||
elif firstRel == 1:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
root = "uncle"
|
||||
else:
|
||||
root = "aunt"
|
||||
if secondRel == 1:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
text = secondName + " is the brother of " + firstName + "."
|
||||
else:
|
||||
text = secondName + " is the sister of " + firstName + "."
|
||||
else:
|
||||
text = secondName + get_prefix(secondRel-1,root) + firstName + "."
|
||||
elif secondRel == 1:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
text = secondName + get_prefix(firstRel-1,"nephew") + firstName + "."
|
||||
else:
|
||||
text = secondName + get_prefix(firstRel-1,"niece") + firstName + "."
|
||||
else:
|
||||
if secondRel > firstRel:
|
||||
text = secondName + cousin(secondRel-1,secondRel-firstRel) + firstName + "."
|
||||
else:
|
||||
text = secondName + cousin(firstRel-1,firstRel-secondRel) + firstName + "."
|
||||
|
||||
text1 = topDialog.get_widget("text1")
|
||||
text1.set_point(0)
|
||||
length = text1.get_length()
|
||||
text1.forward_delete(length)
|
||||
if firstRel == 0 or secondRel == 0:
|
||||
text1.insert_defaults(text)
|
||||
else:
|
||||
text1.insert_defaults(text + commontext)
|
||||
text1.set_word_wrap(1)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
@ -213,46 +98,147 @@ def get_prefix(level,root):
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_close_clicked(obj):
|
||||
obj.destroy()
|
||||
while events_pending():
|
||||
mainiteration()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def runTool(database,person,callback):
|
||||
global active_person
|
||||
global topDialog
|
||||
global glade_file
|
||||
global db
|
||||
|
||||
active_person = person
|
||||
db = database
|
||||
RelCalc(database,person)
|
||||
|
||||
base = os.path.dirname(__file__)
|
||||
glade_file = base + os.sep + "relcalc.glade"
|
||||
topDialog = GladeXML(glade_file,"relcalc")
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class RelCalc:
|
||||
|
||||
name = person.getPrimaryName().getRegularName()
|
||||
def __init__(self,database,person):
|
||||
self.person = person
|
||||
self.db = database
|
||||
|
||||
topDialog.get_widget("name").set_text(_("Relationship to %s") % name)
|
||||
peopleList = topDialog.get_widget("peopleList")
|
||||
base = os.path.dirname(__file__)
|
||||
glade_file = base + os.sep + "relcalc.glade"
|
||||
self.glade = GladeXML(glade_file,"relcalc")
|
||||
|
||||
name_list = database.getPersonMap().values()
|
||||
name_list.sort(sort.by_last_name)
|
||||
for per in name_list:
|
||||
col2person.append(per)
|
||||
name = per.getPrimaryName().getName()
|
||||
birthday = per.getBirth().getDate()
|
||||
peopleList.append([name,birthday])
|
||||
name = self.person.getPrimaryName().getRegularName()
|
||||
|
||||
topDialog.signal_autoconnect({
|
||||
"on_close_clicked" : on_close_clicked,
|
||||
"on_peopleList_select_row" : on_peopleList_select_row,
|
||||
"on_apply_clicked" : on_apply_clicked
|
||||
})
|
||||
self.glade.get_widget("name").set_text(_("Relationship to %s") % name)
|
||||
self.people = self.glade.get_widget("peopleList")
|
||||
|
||||
name_list = self.db.getPersonMap().values()
|
||||
name_list.sort(sort.by_last_name)
|
||||
index = 0
|
||||
for per in name_list:
|
||||
name = per.getPrimaryName().getName()
|
||||
birthday = per.getBirth().getDate()
|
||||
id = per.getId()
|
||||
self.people.append([name,id,birthday])
|
||||
self.people.set_row_data(index,per)
|
||||
index = index + 1
|
||||
|
||||
self.glade.signal_autoconnect({
|
||||
"on_close_clicked" : utils.destroy_passed_object,
|
||||
"on_apply_clicked" : self.on_apply_clicked
|
||||
})
|
||||
|
||||
def on_apply_clicked(self,obj):
|
||||
firstMap = {}
|
||||
firstList = []
|
||||
secondMap = {}
|
||||
secondList = []
|
||||
common = []
|
||||
rank = 9999999
|
||||
|
||||
if len(self.people.selection) == 0:
|
||||
return
|
||||
|
||||
other_person = self.people.get_row_data(self.people.selection[0])
|
||||
filter(self.person,0,firstList,firstMap)
|
||||
filter(other_person,0,secondList,secondMap)
|
||||
|
||||
for person in firstList:
|
||||
if person in secondList:
|
||||
new_rank = firstMap[person]
|
||||
if new_rank < rank:
|
||||
rank = new_rank
|
||||
common = [ person ]
|
||||
elif new_rank == rank:
|
||||
common.append(person)
|
||||
|
||||
firstRel = -1
|
||||
secondRel = -1
|
||||
|
||||
firstName = self.person.getPrimaryName().getRegularName()
|
||||
secondName = other_person.getPrimaryName().getRegularName()
|
||||
|
||||
length = len(common)
|
||||
if length == 1:
|
||||
person = common[0]
|
||||
secondRel = firstMap[person]
|
||||
firstRel = secondMap[person]
|
||||
name = person.getPrimaryName().getRegularName()
|
||||
commontext = " " + _("Their common ancestor is %s.") % name
|
||||
elif length > 1:
|
||||
index = 0
|
||||
commontext = " Their common ancestors are "
|
||||
for person in common:
|
||||
secondRel = firstMap[person]
|
||||
firstRel = secondMap[person]
|
||||
if length == index + 1:
|
||||
commontext = commontext + " and "
|
||||
elif index != 0:
|
||||
commontext = commontext + ", "
|
||||
commontext = commontext + person.getPrimaryName().getRegularName()
|
||||
index = index + 1
|
||||
else:
|
||||
commontext = ""
|
||||
|
||||
if firstRel == -1:
|
||||
msg = _("There is no relationship between %s and %s.")
|
||||
text = msg % (firstName,secondName)
|
||||
elif firstRel == 0:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
root = "father"
|
||||
else:
|
||||
root = "mother"
|
||||
if secondRel == 0:
|
||||
text = firstName + " and " + secondName + " are the same person."
|
||||
else:
|
||||
text = secondName + get_prefix(secondRel,root) + firstName
|
||||
elif secondRel == 0:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
text = secondName + get_prefix(firstRel,"son") + firstName + "."
|
||||
else:
|
||||
text = secondName + get_prefix(firstRel,"daughter") + firstName + "."
|
||||
elif firstRel == 1:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
root = "uncle"
|
||||
else:
|
||||
root = "aunt"
|
||||
if secondRel == 1:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
text = secondName + " is the brother of " + firstName + "."
|
||||
else:
|
||||
text = secondName + " is the sister of " + firstName + "."
|
||||
else:
|
||||
text = secondName + get_prefix(secondRel-1,root) + firstName + "."
|
||||
elif secondRel == 1:
|
||||
if other_person.getGender() == RelLib.Person.male:
|
||||
text = secondName + get_prefix(firstRel-1,"nephew") + firstName + "."
|
||||
else:
|
||||
text = secondName + get_prefix(firstRel-1,"niece") + firstName + "."
|
||||
else:
|
||||
if secondRel > firstRel:
|
||||
text = secondName + cousin(secondRel-1,secondRel-firstRel) + firstName + "."
|
||||
else:
|
||||
text = secondName + cousin(firstRel-1,firstRel-secondRel) + firstName + "."
|
||||
|
||||
text1 = self.glade.get_widget("text1")
|
||||
text1.set_point(0)
|
||||
length = text1.get_length()
|
||||
text1.forward_delete(length)
|
||||
if firstRel == 0 or secondRel == 0:
|
||||
text1.insert_defaults(text)
|
||||
else:
|
||||
text1.insert_defaults(text + commontext)
|
||||
text1.set_word_wrap(1)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -32,7 +32,7 @@ _ = intl.gettext
|
||||
#-------------------------------------------------------------------------
|
||||
def runTool(database,active_person,callback):
|
||||
|
||||
for prefix in ["xyzzytemporaryid%d", "I%d"] :
|
||||
for prefix in ["xyzzytemporaryid%d", database.iprefix] :
|
||||
index = 0
|
||||
pmap = database.getPersonMap()
|
||||
for id in pmap.keys():
|
||||
@ -43,7 +43,7 @@ def runTool(database,active_person,callback):
|
||||
del pmap[id]
|
||||
index = index + 1
|
||||
|
||||
for prefix in ["xyzzytemporaryid%d", "F%d"] :
|
||||
for prefix in ["xyzzytemporaryid%d", database.fprefix] :
|
||||
index = 0
|
||||
pmap = database.getFamilyMap()
|
||||
for id in pmap.keys():
|
||||
@ -54,7 +54,7 @@ def runTool(database,active_person,callback):
|
||||
del pmap[id]
|
||||
index = index + 1
|
||||
|
||||
for prefix in ["xyzzytemporaryid%d", "S%d"] :
|
||||
for prefix in ["xyzzytemporaryid%d", database.sprefix] :
|
||||
index = 0
|
||||
pmap = database.getSourceMap()
|
||||
for id in pmap.keys():
|
||||
@ -65,6 +65,28 @@ def runTool(database,active_person,callback):
|
||||
del pmap[id]
|
||||
index = index + 1
|
||||
|
||||
for prefix in ["xyzzytemporaryid%d", database.pprefix] :
|
||||
index = 0
|
||||
pmap = database.getPlaceMap()
|
||||
for id in pmap.keys():
|
||||
newid = prefix % index
|
||||
person = pmap[id]
|
||||
person.setId(newid)
|
||||
pmap[newid] = person
|
||||
del pmap[id]
|
||||
index = index + 1
|
||||
|
||||
for prefix in ["xyzzytemporaryid%d", database.oprefix] :
|
||||
index = 0
|
||||
pmap = database.getObjectMap()
|
||||
for id in pmap.keys():
|
||||
newid = prefix % index
|
||||
person = pmap[id]
|
||||
person.setId(newid)
|
||||
pmap[newid] = person
|
||||
del pmap[id]
|
||||
index = index + 1
|
||||
|
||||
utils.modified()
|
||||
callback(1)
|
||||
|
||||
|
@ -13,30 +13,40 @@
|
||||
</project>
|
||||
|
||||
<widget>
|
||||
<class>GtkDialog</class>
|
||||
<class>GnomeDialog</class>
|
||||
<name>top</name>
|
||||
<title>Change Event Types</title>
|
||||
<title>Gramps - Change Event Types</title>
|
||||
<type>GTK_WINDOW_TOPLEVEL</type>
|
||||
<position>GTK_WIN_POS_NONE</position>
|
||||
<modal>False</modal>
|
||||
<allow_shrink>True</allow_shrink>
|
||||
<allow_shrink>False</allow_shrink>
|
||||
<allow_grow>True</allow_grow>
|
||||
<auto_shrink>False</auto_shrink>
|
||||
<auto_close>False</auto_close>
|
||||
<hide_on_close>False</hide_on_close>
|
||||
|
||||
<widget>
|
||||
<class>GtkVBox</class>
|
||||
<child_name>Dialog:vbox</child_name>
|
||||
<name>dialog-vbox1</name>
|
||||
<child_name>GnomeDialog:vbox</child_name>
|
||||
<name>dialog-vbox2</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<spacing>8</spacing>
|
||||
<child>
|
||||
<padding>4</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<child_name>Dialog:action_area</child_name>
|
||||
<name>dialog-action_area1</name>
|
||||
<border_width>10</border_width>
|
||||
<homogeneous>True</homogeneous>
|
||||
<spacing>5</spacing>
|
||||
<class>GtkHButtonBox</class>
|
||||
<child_name>GnomeDialog:action_area</child_name>
|
||||
<name>dialog-action_area2</name>
|
||||
<layout_style>GTK_BUTTONBOX_END</layout_style>
|
||||
<spacing>8</spacing>
|
||||
<child_min_width>85</child_min_width>
|
||||
<child_min_height>27</child_min_height>
|
||||
<child_ipad_x>7</child_ipad_x>
|
||||
<child_ipad_y>0</child_ipad_y>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>False</expand>
|
||||
@ -45,58 +55,31 @@
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkHButtonBox</class>
|
||||
<name>hbuttonbox1</name>
|
||||
<layout_style>GTK_BUTTONBOX_DEFAULT_STYLE</layout_style>
|
||||
<spacing>30</spacing>
|
||||
<child_min_width>85</child_min_width>
|
||||
<child_min_height>27</child_min_height>
|
||||
<child_ipad_x>7</child_ipad_x>
|
||||
<child_ipad_y>0</child_ipad_y>
|
||||
<child>
|
||||
<padding>0</padding>
|
||||
<expand>True</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
<class>GtkButton</class>
|
||||
<name>button3</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>on_apply_clicked</handler>
|
||||
<object>top</object>
|
||||
<last_modification_time>Sat, 27 Oct 2001 23:16:31 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>button1</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>on_apply_clicked</handler>
|
||||
<object>top</object>
|
||||
<last_modification_time>Fri, 09 Mar 2001 17:49:10 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>button2</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>on_close_clicked</handler>
|
||||
<object>top</object>
|
||||
<last_modification_time>Fri, 09 Mar 2001 17:48:57 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>button3</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<stock_button>GNOME_STOCK_BUTTON_HELP</stock_button>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>button5</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>clicked</name>
|
||||
<handler>on_close_clicked</handler>
|
||||
<object>top</object>
|
||||
<last_modification_time>Sat, 27 Oct 2001 23:16:19 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
@ -132,6 +115,7 @@
|
||||
<widget>
|
||||
<class>GtkCombo</class>
|
||||
<name>original</name>
|
||||
<width>250</width>
|
||||
<value_in_list>True</value_in_list>
|
||||
<ok_if_empty>True</ok_if_empty>
|
||||
<case_sensitive>True</case_sensitive>
|
||||
@ -149,6 +133,12 @@
|
||||
<child_name>GtkCombo:entry</child_name>
|
||||
<name>original_text</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>insert_text</name>
|
||||
<handler>on_combo_insert_text</handler>
|
||||
<object>original</object>
|
||||
<last_modification_time>Sat, 27 Oct 2001 23:12:54 GMT</last_modification_time>
|
||||
</signal>
|
||||
<editable>True</editable>
|
||||
<text_visible>True</text_visible>
|
||||
<text_max_length>0</text_max_length>
|
||||
@ -193,6 +183,12 @@
|
||||
<child_name>GtkCombo:entry</child_name>
|
||||
<name>new_text</name>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>insert_text</name>
|
||||
<handler>on_combo_insert_text</handler>
|
||||
<object>new</object>
|
||||
<last_modification_time>Sat, 27 Oct 2001 23:13:20 GMT</last_modification_time>
|
||||
</signal>
|
||||
<editable>True</editable>
|
||||
<text_visible>True</text_visible>
|
||||
<text_max_length>0</text_max_length>
|
||||
|
@ -70,6 +70,7 @@
|
||||
<last_modification_time>Tue, 06 Feb 2001 23:47:29 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_APPLY</stock_button>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
@ -84,14 +85,7 @@
|
||||
<last_modification_time>Tue, 06 Feb 2001 23:47:17 GMT</last_modification_time>
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_CLOSE</stock_button>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>button3</name>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<stock_button>GNOME_STOCK_BUTTON_HELP</stock_button>
|
||||
<relief>GTK_RELIEF_NORMAL</relief>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -150,7 +144,7 @@
|
||||
<widget>
|
||||
<class>GtkCList</class>
|
||||
<name>peopleList</name>
|
||||
<width>400</width>
|
||||
<width>500</width>
|
||||
<height>150</height>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
@ -158,8 +152,8 @@
|
||||
<handler>on_peopleList_select_row</handler>
|
||||
<last_modification_time>Wed, 07 Feb 2001 00:05:39 GMT</last_modification_time>
|
||||
</signal>
|
||||
<columns>2</columns>
|
||||
<column_widths>241,83</column_widths>
|
||||
<columns>3</columns>
|
||||
<column_widths>250,75,150</column_widths>
|
||||
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
|
||||
<show_titles>True</show_titles>
|
||||
<shadow_type>GTK_SHADOW_IN</shadow_type>
|
||||
@ -177,6 +171,19 @@
|
||||
<ypad>0</ypad>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<child_name>CList:title</child_name>
|
||||
<name>label4x</name>
|
||||
<label>ID</label>
|
||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||
<wrap>False</wrap>
|
||||
<xalign>0.5</xalign>
|
||||
<yalign>0.5</yalign>
|
||||
<xpad>0</xpad>
|
||||
<ypad>0</ypad>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkLabel</class>
|
||||
<child_name>CList:title</child_name>
|
||||
@ -197,7 +204,7 @@
|
||||
<name>hseparator2</name>
|
||||
<child>
|
||||
<padding>5</padding>
|
||||
<expand>True</expand>
|
||||
<expand>False</expand>
|
||||
<fill>True</fill>
|
||||
</child>
|
||||
</widget>
|
||||
|
@ -83,15 +83,6 @@
|
||||
</signal>
|
||||
<stock_button>GNOME_STOCK_BUTTON_CLOSE</stock_button>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
<class>GtkButton</class>
|
||||
<name>help</name>
|
||||
<tooltip>Help is not implemented yet</tooltip>
|
||||
<can_default>True</can_default>
|
||||
<can_focus>True</can_focus>
|
||||
<stock_button>GNOME_STOCK_BUTTON_HELP</stock_button>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
@ -254,6 +245,12 @@
|
||||
<name>name</name>
|
||||
<tooltip>Name used to generate SoundEx code</tooltip>
|
||||
<can_focus>True</can_focus>
|
||||
<signal>
|
||||
<name>insert_text</name>
|
||||
<handler>on_combo_insert_text</handler>
|
||||
<object>nameList</object>
|
||||
<last_modification_time>Sat, 27 Oct 2001 19:28:10 GMT</last_modification_time>
|
||||
</signal>
|
||||
<editable>True</editable>
|
||||
<text_visible>True</text_visible>
|
||||
<text_max_length>0</text_max_length>
|
||||
|
@ -33,43 +33,53 @@ import intl
|
||||
|
||||
_ = intl.gettext
|
||||
|
||||
topDialog = None
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def on_apply_clicked(obj):
|
||||
|
||||
text = obj.get_text()
|
||||
value = topDialog.get_widget("value").set_text(soundex.soundex(text))
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def runTool(database,active_person,callback):
|
||||
global topDialog
|
||||
SoundGen(database,active_person)
|
||||
|
||||
base = os.path.dirname(__file__)
|
||||
glade_file = base + os.sep + "soundex.glade"
|
||||
|
||||
topDialog = GladeXML(glade_file,"soundEx")
|
||||
topDialog.signal_autoconnect({
|
||||
"destroy_passed_object" : utils.destroy_passed_object,
|
||||
"on_apply_clicked" : on_apply_clicked
|
||||
class SoundGen:
|
||||
def __init__(self,database,active_person):
|
||||
self.db = database
|
||||
|
||||
base = os.path.dirname(__file__)
|
||||
glade_file = base + os.sep + "soundex.glade"
|
||||
|
||||
self.glade = GladeXML(glade_file,"soundEx")
|
||||
self.glade.signal_autoconnect({
|
||||
"destroy_passed_object" : utils.destroy_passed_object,
|
||||
"on_combo_insert_text" : utils.combo_insert_text,
|
||||
"on_apply_clicked" : self.on_apply_clicked,
|
||||
})
|
||||
|
||||
names = []
|
||||
for person in database.getPersonMap().values():
|
||||
lastname = person.getPrimaryName().getSurname()
|
||||
if lastname not in names:
|
||||
names.append(lastname)
|
||||
self.value = self.glade.get_widget("value")
|
||||
self.name = self.glade.get_widget("name")
|
||||
names = []
|
||||
for person in self.db.getPersonMap().values():
|
||||
lastname = person.getPrimaryName().getSurname()
|
||||
if lastname not in names:
|
||||
names.append(lastname)
|
||||
|
||||
names.sort()
|
||||
self.glade.get_widget("nameList").set_popdown_strings(names)
|
||||
|
||||
if active_person:
|
||||
n = active_person.getPrimaryName().getSurname()
|
||||
self.name.set_text(n)
|
||||
self.value.set_text(soundex.soundex(n))
|
||||
else:
|
||||
self.name.set_text("")
|
||||
|
||||
self.glade.get_widget("soundEx").show()
|
||||
|
||||
def on_apply_clicked(self,obj):
|
||||
|
||||
text = obj.get_text()
|
||||
value = self.value.set_text(soundex.soundex(text))
|
||||
|
||||
names.sort()
|
||||
topDialog.get_widget("nameList").set_popdown_strings(names)
|
||||
topDialog.get_widget("name").set_text("")
|
||||
topDialog.get_widget("soundEx").show()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user