diff --git a/src/RelLib.py b/src/RelLib.py
index 8b7478403..04400d5f1 100644
--- a/src/RelLib.py
+++ b/src/RelLib.py
@@ -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"""
diff --git a/src/plugins/ChangeTypes.py b/src/plugins/ChangeTypes.py
index 3967f37bf..5ad50a2b9 100644
--- a/src/plugins/ChangeTypes.py
+++ b/src/plugins/ChangeTypes.py
@@ -33,60 +33,55 @@ 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)
+
#------------------------------------------------------------------------
#
#
diff --git a/src/plugins/PatchNames.py b/src/plugins/PatchNames.py
index b80e3fae5..24233b497 100644
--- a/src/plugins/PatchNames.py
+++ b/src/plugins/PatchNames.py
@@ -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"(.+)[(\"](.*)[)\"]")
-
- personMap = database.getPersonMap()
- for key in personMap.keys():
+ def __init__(self,db,callback):
+ self.cb = callback
+ self.db = db
+ self.title_list = []
+ self.nick_list = []
- 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]))
+ 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()
+ 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)
#------------------------------------------------------------------------
#
diff --git a/src/plugins/RelCalc.py b/src/plugins/RelCalc.py
index 6f3a6f4b0..3b01de59d 100644
--- a/src/plugins/RelCalc.py
+++ b/src/plugins/RelCalc.py
@@ -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)
-
#-------------------------------------------------------------------------
#
#
@@ -188,7 +73,7 @@ def cousin(level,removed):
root = root + " %d times removed of " % removed
return root
-
+
#-------------------------------------------------------------------------
#
#
@@ -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
+
+ base = os.path.dirname(__file__)
+ glade_file = base + os.sep + "relcalc.glade"
+ self.glade = GladeXML(glade_file,"relcalc")
+
+ name = self.person.getPrimaryName().getRegularName()
- topDialog.get_widget("name").set_text(_("Relationship to %s") % name)
- peopleList = topDialog.get_widget("peopleList")
+ self.glade.get_widget("name").set_text(_("Relationship to %s") % name)
+ self.people = self.glade.get_widget("peopleList")
- 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_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
+ })
- topDialog.signal_autoconnect({
- "on_close_clicked" : on_close_clicked,
- "on_peopleList_select_row" : on_peopleList_select_row,
- "on_apply_clicked" : 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)
#-------------------------------------------------------------------------
#
diff --git a/src/plugins/ReorderIds.py b/src/plugins/ReorderIds.py
index 6c9ad14fb..671c41fbf 100644
--- a/src/plugins/ReorderIds.py
+++ b/src/plugins/ReorderIds.py
@@ -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)
diff --git a/src/plugins/changetype.glade b/src/plugins/changetype.glade
index f0d22fc62..3e5389549 100644
--- a/src/plugins/changetype.glade
+++ b/src/plugins/changetype.glade
@@ -13,30 +13,40 @@
- GtkDialog
+ GnomeDialog
top
- Change Event Types
+ Gramps - Change Event Types
GTK_WINDOW_TOPLEVEL
GTK_WIN_POS_NONE
False
- True
+ False
True
False
+ False
+ False
GtkVBox
- Dialog:vbox
- dialog-vbox1
+ GnomeDialog:vbox
+ dialog-vbox2
False
- 0
+ 8
+
+ 4
+ True
+ True
+
- GtkHBox
- Dialog:action_area
- dialog-action_area1
- 10
- True
- 5
+ GtkHButtonBox
+ GnomeDialog:action_area
+ dialog-action_area2
+ GTK_BUTTONBOX_END
+ 8
+ 85
+ 27
+ 7
+ 0
0
False
@@ -45,58 +55,31 @@
- GtkHButtonBox
- hbuttonbox1
- GTK_BUTTONBOX_DEFAULT_STYLE
- 30
- 85
- 27
- 7
- 0
-
- 0
- True
- True
-
+ GtkButton
+ button3
+ True
+ True
+
+ clicked
+ on_apply_clicked
+
+ Sat, 27 Oct 2001 23:16:31 GMT
+
+ GNOME_STOCK_BUTTON_OK
+
-
- GtkButton
- button1
- True
- True
-
- clicked
- on_apply_clicked
-
- Fri, 09 Mar 2001 17:49:10 GMT
-
- GNOME_STOCK_BUTTON_OK
- GTK_RELIEF_NORMAL
-
-
-
- GtkButton
- button2
- True
- True
-
- clicked
- on_close_clicked
-
- Fri, 09 Mar 2001 17:48:57 GMT
-
- GNOME_STOCK_BUTTON_CANCEL
- GTK_RELIEF_NORMAL
-
-
-
- GtkButton
- button3
- True
- True
- GNOME_STOCK_BUTTON_HELP
- GTK_RELIEF_NORMAL
-
+
+ GtkButton
+ button5
+ True
+ True
+
+ clicked
+ on_close_clicked
+
+ Sat, 27 Oct 2001 23:16:19 GMT
+
+ GNOME_STOCK_BUTTON_CANCEL
@@ -132,6 +115,7 @@
GtkCombo
original
+ 250
True
True
True
@@ -149,6 +133,12 @@
GtkCombo:entry
original_text
True
+
+ insert_text
+ on_combo_insert_text
+
+ Sat, 27 Oct 2001 23:12:54 GMT
+
True
True
0
@@ -193,6 +183,12 @@
GtkCombo:entry
new_text
True
+
+ insert_text
+ on_combo_insert_text
+
+ Sat, 27 Oct 2001 23:13:20 GMT
+
True
True
0
diff --git a/src/plugins/relcalc.glade b/src/plugins/relcalc.glade
index de2dd9774..ebd21bef5 100644
--- a/src/plugins/relcalc.glade
+++ b/src/plugins/relcalc.glade
@@ -70,6 +70,7 @@
Tue, 06 Feb 2001 23:47:29 GMT
GNOME_STOCK_BUTTON_APPLY
+ GTK_RELIEF_NORMAL
@@ -84,14 +85,7 @@
Tue, 06 Feb 2001 23:47:17 GMT
GNOME_STOCK_BUTTON_CLOSE
-
-
-
- GtkButton
- button3
- True
- True
- GNOME_STOCK_BUTTON_HELP
+ GTK_RELIEF_NORMAL
@@ -150,7 +144,7 @@
GtkCList
peopleList
- 400
+ 500
150
True
@@ -158,8 +152,8 @@
on_peopleList_select_row
Wed, 07 Feb 2001 00:05:39 GMT
- 2
- 241,83
+ 3
+ 250,75,150
GTK_SELECTION_SINGLE
True
GTK_SHADOW_IN
@@ -177,6 +171,19 @@
0
+
+ GtkLabel
+ CList:title
+ label4x
+
+ GTK_JUSTIFY_CENTER
+ False
+ 0.5
+ 0.5
+ 0
+ 0
+
+
GtkLabel
CList:title
@@ -197,7 +204,7 @@
hseparator2
5
- True
+ False
True
diff --git a/src/plugins/soundex.glade b/src/plugins/soundex.glade
index 781720f95..8ca0aab34 100644
--- a/src/plugins/soundex.glade
+++ b/src/plugins/soundex.glade
@@ -83,15 +83,6 @@
GNOME_STOCK_BUTTON_CLOSE
-
-
- GtkButton
- help
- Help is not implemented yet
- True
- True
- GNOME_STOCK_BUTTON_HELP
-
@@ -254,6 +245,12 @@
name
Name used to generate SoundEx code
True
+
+ insert_text
+ on_combo_insert_text
+
+ Sat, 27 Oct 2001 19:28:10 GMT
+
True
True
0
diff --git a/src/plugins/soundgen.py b/src/plugins/soundgen.py
index da5a3c1e6..22b44e0b6 100644
--- a/src/plugins/soundgen.py
+++ b/src/plugins/soundgen.py
@@ -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
-
- base = os.path.dirname(__file__)
- glade_file = base + os.sep + "soundex.glade"
+ SoundGen(database,active_person)
- 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()
- topDialog.get_widget("nameList").set_popdown_strings(names)
- topDialog.get_widget("name").set_text("")
- topDialog.get_widget("soundEx").show()
+ 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))
+
#-------------------------------------------------------------------------
#