From 95c876e51d79e0110f2bda9a24f2f39b365e4145 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Thu, 6 Oct 2005 19:15:49 +0000 Subject: [PATCH] * src/TreeTips.py: Typo. * src/plugins/ScratchPad.py: Convert to new API. * src/plugins/DumpGenderStats.py: Convert to new API. svn: r5279 --- gramps2/ChangeLog | 5 ++ gramps2/src/TreeTips.py | 2 +- gramps2/src/plugins/DumpGenderStats.py | 79 +++++++++++++++++++------- gramps2/src/plugins/ScratchPad.py | 38 +++++++++---- 4 files changed, 92 insertions(+), 32 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 045992eb7..dd741977a 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,8 @@ +2005-10-06 Alex Roitman + * src/TreeTips.py: Typo. + * src/plugins/ScratchPad.py: Convert to new API. + * src/plugins/DumpGenderStats.py: Convert to new API. + 2005-10-06 Stefan Bjork * src/plugins/rel_sv.py: Obviosly, level=1 to get_parents means parents, not level=0. diff --git a/gramps2/src/TreeTips.py b/gramps2/src/TreeTips.py index d570e4b52..655f4d6ea 100644 --- a/gramps2/src/TreeTips.py +++ b/gramps2/src/TreeTips.py @@ -256,5 +256,5 @@ class TreeTips(gtk.Widget): return x, y -if gtk.pygtk_version < (2.8.0): +if gtk.pygtk_version < (2,8,0): gobject.type_register(TreeTips) diff --git a/gramps2/src/plugins/DumpGenderStats.py b/gramps2/src/plugins/DumpGenderStats.py index 06b13a37e..42d3d0d6f 100644 --- a/gramps2/src/plugins/DumpGenderStats.py +++ b/gramps2/src/plugins/DumpGenderStats.py @@ -24,6 +24,7 @@ import gtk import ListModel +import Tool _GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ] #------------------------------------------------------------------------- @@ -31,24 +32,56 @@ _GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ] # # #------------------------------------------------------------------------- -def DumpGenderStatsPlugin(database,active_person,callback,parent=None): - stats_list = [] - for name in database.genderStats.stats.keys(): - stats_list.append((name,)+database.genderStats.stats[name]+(_GENDER[database.genderStats.guess_gender(name)],)) +class DumpGenderStats(Tool.Tool): + def __init__(self,db,person,options_class,name,callback=None,parent=None): + Tool.Tool.__init__(self,db,person,options_class,name) - titles = [(_('Name'),1,100), (_('Male'),2,70), - (_('Female'),3,70), ('Unknown',4,70), (_('Guess'),5,70) ] - treeview = gtk.TreeView() - model = ListModel.ListModel(treeview,titles) - for entry in stats_list: - model.add(entry,entry[0]) - w = gtk.Window() - w.set_position(gtk.WIN_POS_MOUSE) - w.set_default_size(400,300) - s=gtk.ScrolledWindow() - s.add(treeview) - w.add(s) - w.show_all() + stats_list = [] + + for name in db.genderStats.stats.keys(): + stats_list.append( + (name,) + + db.genderStats.stats[name] + + (_GENDER[db.genderStats.guess_gender(name)],) + ) + + if parent: + titles = [ + (_('Name'),1,100), (_('Male'),2,70), + (_('Female'),3,70), (_('Unknown'),4,70), + (_('Guess'),5,70) + ] + + treeview = gtk.TreeView() + model = ListModel.ListModel(treeview,titles) + for entry in stats_list: + model.add(entry,entry[0]) + w = gtk.Window() + w.set_transient_for(parent.topWindow) + w.set_position(gtk.WIN_POS_MOUSE) + w.set_default_size(400,300) + s = gtk.ScrolledWindow() + s.add(treeview) + w.add(s) + w.show_all() + else: + print "\t%s\t%s\t%s\t%s\t%s\n" % ( + 'Name','Male','Female','Unknown','Guess') + for entry in stats_list: + print "\t%s\t%s\t%s\t%s\t%s" % entry + +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +class DumpGenderStatsOptions(Tool.ToolOptions): + """ + Defines options and provides handling interface. + """ + + def __init__(self,name,person_id=None): + Tool.ToolOptions.__init__(self,name,person_id) #------------------------------------------------------------------------- # @@ -58,8 +91,12 @@ def DumpGenderStatsPlugin(database,active_person,callback,parent=None): from PluginMgr import register_tool register_tool( - DumpGenderStatsPlugin, - _("Dumps gender statistics"), - category=_("Debug"), - description=_("Will dump the statistics for the gender guessing from the first name.") + name = 'dgenstats', + category = Tool.TOOL_DEBUG, + tool_class = DumpGenderStats, + options_class = DumpGenderStatsOptions, + modes = Tool.MODE_GUI | Tool.MODE_CLI, + translated_name = _("Dumps gender statistics"), + description = _("Will dump the statistics for the gender guessing " + "from the first name.") ) diff --git a/gramps2/src/plugins/ScratchPad.py b/gramps2/src/plugins/ScratchPad.py index 882247ffb..82aeadaed 100644 --- a/gramps2/src/plugins/ScratchPad.py +++ b/gramps2/src/plugins/ScratchPad.py @@ -48,10 +48,9 @@ from gnome import help_display #------------------------------------------------------------------------- import const import TreeTips - +import Tool from DdTargets import DdTargets - #------------------------------------------------------------------------- # # icons used in the object listing @@ -891,9 +890,25 @@ def place_title(db,event): # # #------------------------------------------------------------------------- -def ScratchPad(database,person,callback,parent=None): - ScratchPadWindow(database,parent) - +class ScratchPad(Tool.Tool): + def __init__(self,db,person,options_class,name,callback=None,parent=None): + Tool.Tool.__init__(self,db,person,options_class,name) + + ScratchPadWindow(db,parent) + +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +class ScratchPadOptions(Tool.ToolOptions): + """ + Defines options and provides handling interface. + """ + + def __init__(self,name,person_id=None): + Tool.ToolOptions.__init__(self,name,person_id) + #------------------------------------------------------------------------- # # @@ -902,9 +917,12 @@ def ScratchPad(database,person,callback,parent=None): from PluginMgr import register_tool register_tool( - ScratchPad, - _("Scratch Pad"), - category=_("Utilities"), - description=_("The Scratch Pad provides a temporary note pad to store " - "objects for easy reuse.") + name = 'scratchpad', + category = Tool.TOOL_UTILS, + tool_class = ScratchPad, + options_class = ScratchPadOptions, + modes = Tool.MODE_GUI, + translated_name = _("Scratch Pad"), + description=_("The Scratch Pad provides a temporary note pad " + "to store objects for easy reuse.") )