* src/plugins/ChangeNames.py: Convert to the new scheme.

svn: r5235
This commit is contained in:
Alex Roitman 2005-09-26 21:03:31 +00:00
parent e93db84c8a
commit c3af4c65a0
2 changed files with 37 additions and 26 deletions

View File

@ -1,3 +1,6 @@
2005-09-26 Alex Roitman <shura@gramps-project.org>
* src/plugins/ChangeNames.py: Convert to the new scheme.
2005-09-24 Don Allingham <don@gramps-project.org>
* src/data/tips.xml: removed the tip mentioning column sorting
in people view.

View File

@ -46,48 +46,37 @@ from gnome import help_display
# gramps modules
#
#-------------------------------------------------------------------------
import const
import Utils
from QuestionDialog import OkDialog
#-------------------------------------------------------------------------
#
# Search each name in the database, and compare the firstname against the
# form of "Name (Nickname)". If it matches, change the first name entry
# to "Name" and add "Nickname" into the nickname field.
#
#-------------------------------------------------------------------------
def runTool(database,active_person,callback,parent=None):
try:
ChangeNames(database,callback,parent)
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
import Tool
#-------------------------------------------------------------------------
#
# ChangeNames
#
#-------------------------------------------------------------------------
class ChangeNames:
class ChangeNames(Tool.Tool):
def __init__(self,db,person,options_class,name,callback=None,parent=None):
Tool.Tool.__init__(self,db,person,options_class,name)
def __init__(self,db,callback,parent):
self.cb = callback
self.db = db
self.parent = parent
if self.parent.child_windows.has_key(self.__class__):
self.parent.child_windows[self.__class__].present(None)
return
self.win_key = self.__class__
self.name_list = []
self.progress = Utils.ProgressMeter(_('Checking family names'),'')
self.progress = Utils.ProgressMeter(_('Checking family names'),'')
self.progress.set_pass(_('Searching family names'),
len(self.db.get_surname_list()))
self.name_list = []
for name in self.db.get_surname_list():
if name != name.capitalize():
self.name_list.append(name)
self.progress.step()
if self.parent:
self.progress.step()
if self.name_list:
self.display()
@ -199,6 +188,19 @@ class ChangeNames:
self.close(obj)
self.cb(None,1)
#------------------------------------------------------------------------
#
#
#
#------------------------------------------------------------------------
class ChangeNamesOptions(Tool.ToolOptions):
"""
Defines options and provides handling interface.
"""
def __init__(self,name,person_id=None):
Tool.ToolOptions.__init__(self,name,person_id)
#------------------------------------------------------------------------
#
#
@ -207,9 +209,15 @@ class ChangeNames:
from PluginMgr import register_tool
register_tool(
runTool,
_("Fix capitalization of family names"),
category=_("Database Processing"),
description=_("Searches the entire database and attempts to "
"fix capitalization of the names.")
name = 'chname',
category = const.TOOL_DBPROC,
tool_class = ChangeNames,
options_class = ChangeNamesOptions,
modes = Tool.MODE_GUI,
translated_name = _("Fix capitalization of family names"),
status = _("Beta"),
author_name = "Donald N. Allingham",
author_email = "dallingham@users.sourceforge.net",
description = _("Searches the entire database and attempts to "
"fix capitalization of the names.")
)