From c3af4c65a0084d5d2bc77350acb56dc510e484dc Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Mon, 26 Sep 2005 21:03:31 +0000 Subject: [PATCH] * src/plugins/ChangeNames.py: Convert to the new scheme. svn: r5235 --- gramps2/ChangeLog | 3 ++ gramps2/src/plugins/ChangeNames.py | 60 +++++++++++++++++------------- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 5078877c8..235720e13 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,6 @@ +2005-09-26 Alex Roitman + * src/plugins/ChangeNames.py: Convert to the new scheme. + 2005-09-24 Don Allingham * src/data/tips.xml: removed the tip mentioning column sorting in people view. diff --git a/gramps2/src/plugins/ChangeNames.py b/gramps2/src/plugins/ChangeNames.py index d37913293..e6a7bd359 100644 --- a/gramps2/src/plugins/ChangeNames.py +++ b/gramps2/src/plugins/ChangeNames.py @@ -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.") )