From 3afbd461c010ac69ebb3242cad980999042243ed Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Sun, 18 May 2008 19:24:28 +0000 Subject: [PATCH] Put all the plugin management and registration stuff into a class. This new class is named PluginManager. It is a Singleton so that everyone gets access to the same plugin information. svn: r10741 --- src/ArgHandler.py | 14 +- src/DbLoader.py | 11 +- src/DisplayState.py | 7 +- src/ExportAssistant.py | 10 +- src/GrampsDbUtils/_GrampsDbWRFactories.py | 6 +- src/GrampsDbUtils/_WriteGedcom.py | 6 +- src/GrampsDbUtils/_WriteXML.py | 6 +- src/PluginUtils/_PluginMgr.py | 965 +++++++++++----------- src/PluginUtils/_PluginWindows.py | 17 +- src/PluginUtils/_Plugins.py | 23 +- src/PluginUtils/__init__.py | 21 +- src/QuickReports.py | 16 +- src/ReportBase/_BookFormatComboBox.py | 10 +- src/ReportBase/_CommandLineReport.py | 24 +- src/ReportBase/_DrawFormatComboBox.py | 24 +- src/ReportBase/_TextFormatComboBox.py | 24 +- src/ViewManager.py | 28 +- src/docgen/AsciiDoc.py | 9 +- src/docgen/GtkPrint.py | 10 +- src/docgen/HtmlDoc.py | 9 +- src/docgen/LaTeXDoc.py | 7 +- src/docgen/ODFDoc.py | 14 +- src/docgen/PSDrawDoc.py | 7 +- src/docgen/PdfDoc.py | 9 +- src/docgen/RTFDoc.py | 9 +- src/docgen/SvgDrawDoc.py | 8 +- src/docgen/TextBufDoc.py | 3 +- src/plugins/AgeOnDate.py | 5 +- src/plugins/AncestorReport.py | 5 +- src/plugins/AncestorTree.py | 7 +- src/plugins/BookReport.py | 15 +- src/plugins/CalculateEstimatedDates.py | 5 +- src/plugins/Calendar.py | 11 +- src/plugins/ChangeNames.py | 6 +- src/plugins/ChangeTypes.py | 6 +- src/plugins/Check.py | 6 +- src/plugins/CmdRef.py | 22 +- src/plugins/CustomBookText.py | 6 +- src/plugins/DateParserDisplayTest.py | 17 +- src/plugins/Desbrowser.py | 6 +- src/plugins/DescendReport.py | 5 +- src/plugins/DescendTree.py | 5 +- src/plugins/DetAncestralReport.py | 5 +- src/plugins/DetDescendantReport.py | 5 +- src/plugins/DumpGenderStats.py | 8 +- src/plugins/EndOfLineReport.py | 5 +- src/plugins/Eval.py | 6 +- src/plugins/EventCmp.py | 6 +- src/plugins/EventNames.py | 6 +- src/plugins/ExportCSV.py | 8 +- src/plugins/ExportVCalendar.py | 6 +- src/plugins/ExportVCard.py | 6 +- src/plugins/ExtractCity.py | 6 +- src/plugins/FamilyGroup.py | 7 +- src/plugins/FanChart.py | 5 +- src/plugins/FilterByName.py | 7 +- src/plugins/FindDupes.py | 6 +- src/plugins/GVFamilyLines.py | 7 +- src/plugins/GVHourGlass.py | 5 +- src/plugins/GVRelGraph.py | 5 +- src/plugins/ImportCSV.py | 13 +- src/plugins/ImportGeneWeb.py | 6 +- src/plugins/ImportProGen.py | 6 +- src/plugins/ImportvCard.py | 6 +- src/plugins/IndivComplete.py | 5 +- src/plugins/KinshipReport.py | 9 +- src/plugins/Leak.py | 6 +- src/plugins/MarkerReport.py | 5 +- src/plugins/MediaManager.py | 8 +- src/plugins/NarrativeWeb.py | 6 +- src/plugins/NotRelated.py | 5 +- src/plugins/NumberOfAncestorsReport.py | 5 +- src/plugins/OnThisDay.py | 7 +- src/plugins/OwnerEditor.py | 6 +- src/plugins/PatchNames.py | 6 +- src/plugins/Query.py | 6 +- src/plugins/ReadGrdb.py | 6 +- src/plugins/ReadPkg.py | 6 +- src/plugins/Rebuild.py | 6 +- src/plugins/RebuildRefMap.py | 6 +- src/plugins/References.py | 6 +- src/plugins/RelCalc.py | 9 +- src/plugins/RemoveUnused.py | 6 +- src/plugins/ReorderIds.py | 6 +- src/plugins/SameSurnames.py | 7 +- src/plugins/SimpleBookTitle.py | 5 +- src/plugins/SoundGen.py | 6 +- src/plugins/StatisticsChart.py | 5 +- src/plugins/Summary.py | 5 +- src/plugins/TestcaseGenerator.py | 6 +- src/plugins/TimeLine.py | 5 +- src/plugins/Verify.py | 6 +- src/plugins/WebCal.py | 5 +- src/plugins/WriteCD.py | 6 +- src/plugins/WriteFtree.py | 6 +- src/plugins/WriteGeneWeb.py | 6 +- src/plugins/WritePkg.py | 6 +- src/plugins/all_events.py | 10 +- src/plugins/all_relations.py | 11 +- src/plugins/lineage.py | 8 +- src/plugins/rel_cs.py | 6 +- src/plugins/rel_da.py | 6 +- src/plugins/rel_de.py | 6 +- src/plugins/rel_es.py | 6 +- src/plugins/rel_fi.py | 6 +- src/plugins/rel_fr.py | 6 +- src/plugins/rel_hu.py | 6 +- src/plugins/rel_it.py | 6 +- src/plugins/rel_nl.py | 6 +- src/plugins/rel_no.py | 6 +- src/plugins/rel_pl.py | 6 +- src/plugins/rel_pt.py | 6 +- src/plugins/rel_ru.py | 6 +- src/plugins/rel_sk.py | 6 +- src/plugins/rel_sv.py | 6 +- src/plugins/siblings.py | 11 +- 116 files changed, 1058 insertions(+), 835 deletions(-) diff --git a/src/ArgHandler.py b/src/ArgHandler.py index 2a4b78a76..02c45061a 100644 --- a/src/ArgHandler.py +++ b/src/ArgHandler.py @@ -5,6 +5,7 @@ # Copyright (C) 2007-2008 B. Malengier # Copyright (C) 2008 Lukasz Rymarczyk # Copyright (C) 2008 Raphael Ackermann +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -60,7 +61,7 @@ import Utils import gen.db.exceptions as GX from DbManager import CLIDbManager, NAME_FILE, find_locker_name -from PluginUtils import Tool, cl_list, cli_tool_list +from PluginUtils import Tool, PluginManager from ReportBase import CATEGORY_BOOK, CATEGORY_CODE, CATEGORY_WEB, cl_report IMPORT_TYPES = (const.APP_GRAMPS_XML, const.APP_GEDCOM, @@ -721,6 +722,7 @@ class ArgHandler: """ Command-line action routine. Try to perform specified action. """ + pmgr = PluginManager.get_instance() if action == 'check': import Check checker = Check.CheckIntegrity(self.state.db, None, None) @@ -744,8 +746,9 @@ class ArgHandler: print "Ignoring invalid options string." name = options_str_dict.pop('name', None) + _cl_list = pmgr.get_cl_list() if name: - for item in cl_list: + for item in _cl_list: if name == item[0]: category = item[1] report_class = item[2] @@ -763,7 +766,7 @@ class ArgHandler: msg = "Report name not given. Please use -p name=reportname." print "%s\n Available names are:" % msg - for item in cl_list: + for item in _cl_list: # Print cli report name ([item[0]) and GUI report name (item[4]) if len(item[0]) <= 25: print " %s%s- %s" % (item[0], @@ -780,8 +783,9 @@ class ArgHandler: print "Ignoring invalid options string." name = options_str_dict.pop('name', None) + _cli_tool_list = pmgr.get_cl_tool_list() if name: - for item in cli_tool_list: + for item in _cli_tool_list: if name == item[0]: category = item[1] tool_class = item[2] @@ -794,7 +798,7 @@ class ArgHandler: msg = "Tool name not given. Please use -p name=toolname." print "%s\n Available names are:" % msg - for item in cli_tool_list: + for item in _cli_tool_list: print " %s" % item[0] else: print "Unknown action: %s." % action diff --git a/src/DbLoader.py b/src/DbLoader.py index b0cdcb4dd..ffb1e6c6d 100644 --- a/src/DbLoader.py +++ b/src/DbLoader.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2005-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -59,7 +60,7 @@ import Mime import gen.db import GrampsDbUtils import Utils -from PluginUtils import import_list +from PluginUtils import PluginManager from QuestionDialog import (DBErrorDialog, ErrorDialog, QuestionDialog2, WarningDialog) import Errors @@ -106,7 +107,9 @@ class DbLoader: self.uistate.window) if not warn_dialog.run(): return False - + + pmgr = PluginManager.get_instance() + choose_db_dialog = gtk.FileChooserDialog(_('GRAMPS: Import database'), self.uistate.window, gtk.FILE_CHOOSER_ACTION_OPEN, @@ -123,7 +126,7 @@ class DbLoader: format_list = OPEN_FORMATS[:] # Add more data type selections if opening existing db - for data in import_list: + for data in pmgr.get_import_list(): mime_filter = data[1] mime_types = data[2] native_format = data[3] @@ -178,7 +181,7 @@ class DbLoader: Config.set(Config.RECENT_IMPORT_DIR, the_path) # Then we try all the known plugins for (importData, mime_filter, mime_types, native_format, - format_name) in import_list: + format_name) in pmgr.get_import_list(): if filetype in mime_types: self.do_import(choose_db_dialog, importData, filename) return True diff --git a/src/DisplayState.py b/src/DisplayState.py index 8503741df..04a5a16d0 100644 --- a/src/DisplayState.py +++ b/src/DisplayState.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -55,7 +56,7 @@ import Config from BasicUtils import name_displayer import const import ManagedWindow -from PluginUtils import _PluginMgr +from PluginUtils import PluginManager DISABLED = -1 @@ -299,7 +300,6 @@ class DisplayState(gen.utils.Callback): 'filters-changed' : (str, ), 'filter-name-changed' : (str, unicode, unicode), 'nameformat-changed' : None, - 'plugins-reloaded' : (list, list), } def __init__(self, window, status, progress, warnbtn, uimanager, @@ -344,7 +344,8 @@ class DisplayState(gen.utils.Callback): """method that rebinds the relationship to the current rel calc Should be called after load or reload of plugins """ - self.relationship = _PluginMgr.relationship_class() + pmgr = PluginManager.get_instance() + self.relationship = pmgr.get_relationship_calculator() def set_gendepth(self, value): """ Set the generations we search back for showing relationships diff --git a/src/ExportAssistant.py b/src/ExportAssistant.py index 3caf4dcf8..11b491a92 100644 --- a/src/ExportAssistant.py +++ b/src/ExportAssistant.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2004-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -51,7 +52,7 @@ import gtk import const import Config -from PluginUtils import export_list +from PluginUtils import PluginManager import Utils import ManagedWindow @@ -509,11 +510,12 @@ class ExportAssistant(gtk.Assistant, ManagedWindow.ManagedWindow) : """ This method builds its own list of available exports. - The list is built from the PluginMgr.export_list list and from the - locally defined exports (i.e. native export defined here). + The list is built from the list of exporters in the PluginManager and + from the locally defined exports (i.e. native export defined here). """ - self.exportformats = [item for item in export_list] + pmgr = PluginManager.get_instance() + self.exportformats = [item for item in pmgr.get_export_list()] def get_intro_text(self): return _('Under normal circumstances, GRAMPS does not require you ' diff --git a/src/GrampsDbUtils/_GrampsDbWRFactories.py b/src/GrampsDbUtils/_GrampsDbWRFactories.py index c4c613164..f1bdbd991 100644 --- a/src/GrampsDbUtils/_GrampsDbWRFactories.py +++ b/src/GrampsDbUtils/_GrampsDbWRFactories.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2004-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -43,7 +44,7 @@ import logging log = logging.getLogger(".GrampDb") from gen.db import GrampsDbException -from PluginUtils import import_list +from PluginUtils import PluginManager def gramps_db_reader_factory(db_type): """Factory class for obtaining a Gramps database importer. @@ -65,7 +66,8 @@ def gramps_db_reader_factory(db_type): else: #see if registered importer found = False - for data in import_list: + pmgr = PluginManager.get_instance() + for data in pmgr.get_import_list(): if db_type in data[2]: print "Found import plugin for %s" % data[4] found = True diff --git a/src/GrampsDbUtils/_WriteGedcom.py b/src/GrampsDbUtils/_WriteGedcom.py index b36f30f74..004a4a1d1 100644 --- a/src/GrampsDbUtils/_WriteGedcom.py +++ b/src/GrampsDbUtils/_WriteGedcom.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -1474,5 +1475,6 @@ DESCRIPTION = _('GEDCOM is used to transfer data between genealogy programs. ' CONFIG = (_('GEDCOM export options'), ExportOptions.WriterOptionBox) FILENAME = 'ged' -from PluginUtils import register_export -register_export(export_data, TITLE, DESCRIPTION, CONFIG, FILENAME) +from PluginUtils import PluginManager +pmgr = PluginManager.get_instance() +pmgr.register_export(export_data, TITLE, DESCRIPTION, CONFIG, FILENAME) diff --git a/src/GrampsDbUtils/_WriteXML.py b/src/GrampsDbUtils/_WriteXML.py index ddeb425a6..299ada0c3 100644 --- a/src/GrampsDbUtils/_WriteXML.py +++ b/src/GrampsDbUtils/_WriteXML.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -133,5 +134,6 @@ DESCRIPTION = _('The GRAMPS XML database is a text version of a family tree. ' CONFIG = (_('GRAMPS XML export options'), ExportOptions.WriterOptionBox) FILENAME = 'gramps' -from PluginUtils import register_export -register_export(export_data, TITLE, DESCRIPTION, CONFIG, FILENAME) +from PluginUtils import PluginManager +pmgr = PluginManager.get_instance() +pmgr.register_export(export_data, TITLE, DESCRIPTION, CONFIG, FILENAME) diff --git a/src/PluginUtils/_PluginMgr.py b/src/PluginUtils/_PluginMgr.py index c52650268..32eacb98b 100644 --- a/src/PluginUtils/_PluginMgr.py +++ b/src/PluginUtils/_PluginMgr.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2005 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -44,522 +45,536 @@ from gettext import gettext as _ # #------------------------------------------------------------------------- from ReportBase import MODE_GUI, MODE_CLI, MODE_BKI, book_categories - -#------------------------------------------------------------------------- -# -# Global lists -# -#------------------------------------------------------------------------- -report_list = [] -quick_report_list = [] -tool_list = [] -import_list = [] -export_list = [] -attempt_list = [] -loaddir_list = [] -textdoc_list = [] -bookdoc_list = [] -drawdoc_list = [] -failmsg_list = [] -bkitems_list = [] -cl_list = [] -cli_tool_list = [] -success_list = [] - -mod2text = {} - -#------------------------------------------------------------------------- -# -# Default relationship calculator -# -#------------------------------------------------------------------------- +import gen import Relationship -_relcalc_class = Relationship.RelationshipCalculator #------------------------------------------------------------------------- # # Constants # #------------------------------------------------------------------------- -_unavailable = _("No description was provided"), +_UNAVAILABLE = _("No description was provided"), #------------------------------------------------------------------------- # -# load_plugins +# PluginManager # #------------------------------------------------------------------------- -def load_plugins(direct): - """Searches the specified directory, and attempts to load any python - modules that it finds, adding name to the attempt_lists list. If the module - successfully loads, it is added to the success_list list. Each plugin is - responsible for registering itself in the correct manner. No attempt - is done in this routine to register the tasks. Returns True on error. """ - - # if the directory does not exist, do nothing - if not os.path.isdir(direct): - return False # return value is True for error - - # if the path has not already been loaded, save it in the loaddir_list - # list for use on reloading - - if direct not in loaddir_list: - loaddir_list.append(direct) - - # add the directory to the python search path - sys.path.append(direct) - - pymod = re.compile(r"^(.*)\.py$") - - # loop through each file in the directory, looking for files that - # have a .py extention, and attempt to load the file. If it succeeds, - # add it to the success_list list. If it fails, add it to the _failure - # list +class PluginManager(gen.utils.Callback): + """ PluginManager is a Singleton which manages plugins """ + __instance = None - for filename in os.listdir(direct): - name = os.path.split(filename) - match = pymod.match(name[1]) - if not match: - continue - attempt_list.append(filename) - plugin = match.groups()[0] - try: - _module = __import__(plugin) - success_list.append((filename, _module)) - except: - failmsg_list.append((filename, sys.exc_info())) - - return len(failmsg_list) != 0 # return True if there are errors - -#------------------------------------------------------------------------- -# -# reload_plugins -# -#------------------------------------------------------------------------- -def reload_plugins(): - """ Reload previously loaded plugins """ - global failmsg_list + __signals__ = { 'plugins-reloaded' : None } - pymod = re.compile(r"^(.*)\.py$") + def get_instance(): + """ Use this function to get the instance of the PluginManager """ + if PluginManager.__instance is None: + PluginManager.__instance = 1 # Set to 1 for __init__() + PluginManager.__instance = PluginManager() + return PluginManager.__instance + get_instance = staticmethod(get_instance) + + def __init__(self): + """ This function should only be run once by get_instance() """ + if PluginManager.__instance is not 1: + raise Exception("This class is a singleton. " + "Use the get_instance() method") + + gen.utils.Callback.__init__(self) + + self.__report_list = [] + self.__quick_report_list = [] + self.__tool_list = [] + self.__import_list = [] + self.__export_list = [] + self.__attempt_list = [] + self.__loaddir_list = [] + self.__textdoc_list = [] + self.__bookdoc_list = [] + self.__drawdoc_list = [] + self.__failmsg_list = [] + self.__bkitems_list = [] + self.__cl_list = [] + self.__cli_tool_list = [] + self.__success_list = [] + self.__relcalc_class = Relationship.RelationshipCalculator - oldfailmsg = failmsg_list[:] - failmsg_list = [] - - # attempt to reload all plugins that have succeeded in the past - for plugin in success_list: - filename = plugin[0] - filename = filename.replace('pyc','py') - filename = filename.replace('pyo','py') - try: - reload(plugin[1]) - except: - failmsg_list.append((filename, sys.exc_info())) + self.__mod2text = {} - # Remove previously good plugins that are now bad - # from the registered lists - purge_failed() - - # attempt to load the plugins that have failed in the past - for (filename, message) in oldfailmsg: - name = os.path.split(filename) - match = pymod.match(name[1]) - if not match: - continue - attempt_list.append(filename) - plugin = match.groups()[0] - try: - # For some strange reason second importing of a failed plugin - # results in success. Then reload reveals the actual error. - # Looks like a bug in Python. - _module = __import__(plugin) - reload(_module) - success_list.append((filename, _module)) - except: - failmsg_list.append((filename, sys.exc_info())) - - # attempt to load any new files found - for directory in loaddir_list: - for filename in os.listdir(directory): + def load_plugins(self, direct): + """ + Searches the specified directory, and attempts to load any python + modules that it finds, adding name to the attempt_lists list. If the + module successfully loads, it is added to the success_list list. + Each plugin is responsible for registering itself in the correct + manner. No attempt is done in this routine to register the tasks. + Returns True on error. + """ + + # if the directory does not exist, do nothing + if not os.path.isdir(direct): + return False # return value is True for error + + # if the path has not already been loaded, save it in the loaddir_list + # list for use on reloading + + if direct not in self.__loaddir_list: + self.__loaddir_list.append(direct) + + # add the directory to the python search path + sys.path.append(direct) + + pymod = re.compile(r"^(.*)\.py$") + + # loop through each file in the directory, looking for files that + # have a .py extention, and attempt to load the file. If it succeeds, + # add it to the success_list list. If it fails, add it to the _failure + # list + + for filename in os.listdir(direct): name = os.path.split(filename) match = pymod.match(name[1]) if not match: continue - if filename in attempt_list: - continue - attempt_list.append(filename) + self.__attempt_list.append(filename) plugin = match.groups()[0] try: _module = __import__(plugin) - if _module not in [plugin[1] - for plugin in success_list]: - success_list.append((filename, _module)) + self.__success_list.append((filename, _module)) except: - failmsg_list.append((filename, sys.exc_info())) + self.__failmsg_list.append((filename, sys.exc_info())) + + return len(self.__failmsg_list) != 0 # return True if there are errors -#------------------------------------------------------------------------- -# -# Plugin registering -# -#------------------------------------------------------------------------- -def register_export(exportData, title, description='', config=None, - filename=''): - """ - Register an export filter, taking the task, file filter, - and the list of patterns for the filename matching. - """ - if description and filename: + def reload_plugins(self): + """ Reload previously loaded plugins """ + pymod = re.compile(r"^(.*)\.py$") + + oldfailmsg = self.__failmsg_list[:] + self.__failmsg_list = [] + + # attempt to reload all plugins that have succeeded in the past + for plugin in self.__success_list: + filename = plugin[0] + filename = filename.replace('pyc','py') + filename = filename.replace('pyo','py') + try: + reload(plugin[1]) + except: + self.__failmsg_list.append((filename, sys.exc_info())) + + # Remove previously good plugins that are now bad + # from the registered lists + self.__purge_failed() + + # attempt to load the plugins that have failed in the past + for (filename, message) in oldfailmsg: + name = os.path.split(filename) + match = pymod.match(name[1]) + if not match: + continue + self.__attempt_list.append(filename) + plugin = match.groups()[0] + try: + # For some strange reason second importing of a failed plugin + # results in success. Then reload reveals the actual error. + # Looks like a bug in Python. + _module = __import__(plugin) + reload(_module) + self.__success_list.append((filename, _module)) + except: + self.__failmsg_list.append((filename, sys.exc_info())) + + # attempt to load any new files found + for directory in self.__loaddir_list: + for filename in os.listdir(directory): + name = os.path.split(filename) + match = pymod.match(name[1]) + if not match: + continue + if filename in self.__attempt_list: + continue + self.__attempt_list.append(filename) + plugin = match.groups()[0] + try: + _module = __import__(plugin) + if _module not in [plugin[1] + for plugin in self.__success_list]: + self.__success_list.append((filename, _module)) + except: + self.__failmsg_list.append((filename, sys.exc_info())) + + self.emit('plugins-reloaded') + + def get_fail_list(self): + """ Return the list of failed plugins. """ + return self.__failmsg_list + + def get_success_list(self): + """ Return the list of succeeded plugins. """ + return self.__success_list + + def get_report_list(self): + """ Return the list of report plugins. """ + return self.__report_list + + def get_tool_list(self): + """ Return the list of tool plugins. """ + return self.__tool_list + + def get_quick_report_list(self): + """ Return the list of quick report plugins. """ + return self.__quick_report_list + + def get_book_item_list(self): + """ Return the list of book plugins. """ + return self.__bkitems_list + + def get_text_doc_list(self): + """ Return the list of text document generator plugins. """ + return self.__textdoc_list + + def get_draw_doc_list(self): + """ Return the list of graphical document generator plugins. """ + return self.__drawdoc_list + + def get_book_doc_list(self): + """ Return the list of book document generator plugins. """ + return self.__bookdoc_list + + def get_cl_list(self): + """ Return the list of command line report plugins. """ + return self.__cl_list + + def get_cl_tool_list(self): + """ Return the list of command line tool plugins. """ + return self.__cli_tool_list + + def get_import_list(self): + """ Return the list of import plugins. """ + return self.__import_list + + def get_export_list(self): + """ Return the list of export plugins. """ + return self.__export_list + + def get_module_description(self, module): + """ Given a module name, return the module description. """ + return self.__mod2text.get(module, '') + + def register_export(self, export_data, title, description='', config=None, + filename=''): + """ + Register an export filter, taking the task, file filter, + and the list of patterns for the filename matching. + """ + if description and filename: + del_index = -1 + for i in range(0, len(self.__export_list)): + if self.__export_list[i][1] == title: + del_index = i + if del_index != -1: + del self.__export_list[del_index] + + self.__export_list.append( + (export_data, title, description, config, filename)) + self.__mod2text[export_data.__module__] = description + + def register_import(self, task, ffilter, mime=None, native_format=0, + format_name=""): + """Register an import filter, taking the task and file filter""" + if mime: + del_index = -1 + for i in range(0, len(self.__import_list)): + if self.__import_list[i][2] == mime: + del_index = i + if del_index != -1: + del self.__import_list[del_index] + + self.__import_list.append( + (task, ffilter, mime, native_format, format_name)) + self.__mod2text[task.__module__] = format_name + + def register_tool(self, name, category, tool_class, options_class, + modes, translated_name, status=_("Unknown"), + description=_UNAVAILABLE, author_name=_("Unknown"), + author_email=_("Unknown"), unsupported=False, + require_active=True ): + """ + Register a tool with the plugin system. + + This function should be used to register tool in GUI and/or + command-line mode. + """ + + import _Tool + + (junk, gui_task) = divmod(modes, 2**_Tool.MODE_GUI) + if gui_task: + self.__register_gui_tool(tool_class, options_class, translated_name, + name, category, description, + status, author_name, author_email, unsupported, + require_active) + + (junk, cli_task) = divmod(modes-gui_task, 2**_Tool.MODE_CLI) + if cli_task: + self.__register_cli_tool(name, category, tool_class, options_class, + translated_name, unsupported) + + def __register_gui_tool(self, tool_class, options_class, translated_name, + name, category, description=_UNAVAILABLE, + status=_("Unknown"), author_name=_("Unknown"), + author_email=_("Unknown"), unsupported=False, + require_active=True): + """ + Register a GUI tool. + """ del_index = -1 - for i in range(0, len(export_list)): - if export_list[i][1] == title: + for i in range(0, len(self.__tool_list)): + val = self.__tool_list[i] + if val[4] == name: del_index = i if del_index != -1: - del export_list[del_index] + del self.__tool_list[del_index] + self.__mod2text[tool_class.__module__] = description + self.__tool_list.append( (tool_class, options_class, translated_name, + category, name, description, status, + author_name, author_email, unsupported, + require_active) ) - export_list.append((exportData, title, description, config, filename)) - mod2text[exportData.__module__] = description - -def register_import(task, ffilter, mime=None, native_format=0, format_name=""): - """Register an import filter, taking the task and file filter""" - if mime: + def __register_cli_tool(self, name, category, tool_class, options_class, + translated_name, unsupported=False): + """ + Register a CLI tool. + """ del_index = -1 - for i in range(0, len(import_list)): - if import_list[i][2] == mime: + for i in range(0, len(self.__cli_tool_list)): + val = self.__cli_tool_list[i] + if val[0] == name: del_index = i if del_index != -1: - del import_list[del_index] + del self.__cli_tool_list[del_index] + self.__cli_tool_list.append( (name, category, tool_class, options_class, + translated_name, unsupported, None) ) - import_list.append((task, ffilter, mime, native_format, format_name)) - mod2text[task.__module__] = format_name - -#------------------------------------------------------------------------- -# -# Tool registration -# -#------------------------------------------------------------------------- -def register_tool( - name, - category, - tool_class, - options_class, - modes, - translated_name, - status=_("Unknown"), - description=_unavailable, - author_name=_("Unknown"), - author_email=_("Unknown"), - unsupported=False, - require_active=True, - ): - """ - Register a tool with the plugin system. - - This function should be used to register tool in GUI and/or - command-line mode. The low-level functions (starting with '_') - should not be used on their own. Instead, this functino will call - them as needed. - """ - - import _Tool - - (junk, gui_task) = divmod(modes, 2**_Tool.MODE_GUI) - if gui_task: - _register_gui_tool(tool_class, options_class, translated_name, - name, category, description, - status, author_name, author_email, unsupported, - require_active) - - (junk, cli_task) = divmod(modes-gui_task, 2**_Tool.MODE_CLI) - if cli_task: - _register_cli_tool(name, category, tool_class, options_class, - translated_name, unsupported) - -def _register_gui_tool(tool_class, options_class, translated_name, - name,category, - description=_unavailable, - status=_("Unknown"), - author_name=_("Unknown"), - author_email=_("Unknown"), - unsupported=False, - require_active=True): - del_index = -1 - for i in range(0, len(tool_list)): - val = tool_list[i] - if val[4] == name: - del_index = i - if del_index != -1: - del tool_list[del_index] - mod2text[tool_class.__module__] = description - tool_list.append((tool_class, options_class, translated_name, - category, name, description, status, - author_name, author_email, unsupported, require_active)) - -def _register_cli_tool(name, category, tool_class, options_class, - translated_name, unsupported=False): - del_index = -1 - for i in range(0, len(cli_tool_list)): - val = cli_tool_list[i] - if val[0] == name: - del_index = i - if del_index != -1: - del cli_tool_list[del_index] - cli_tool_list.append((name, category, tool_class, options_class, - translated_name, unsupported, None)) - -#------------------------------------------------------------------------- -# -# Report registration -# -#------------------------------------------------------------------------- -def register_report( - name, - category, - report_class, - options_class, - modes, - translated_name, - status=_("Unknown"), - description=_unavailable, - author_name=_("Unknown"), - author_email=_("Unknown"), - unsupported=False, - require_active=True, - ): - """ - Registers report for all possible flavors. - - This function should be used to register report as a stand-alone, - book item, or command-line flavor in any combination of those. - The low-level functions (starting with '_') should not be used - on their own. Instead, this function will call them as needed. - """ - (junk, standalone_task) = divmod(modes, 2**MODE_GUI) - if standalone_task: - _register_standalone(report_class, options_class, translated_name, - name, category, description, - status, author_name, author_email, unsupported, - require_active) - - (junk, book_item_task) = divmod(modes-standalone_task, 2**MODE_BKI) - if book_item_task: - book_item_category = book_categories[category] - register_book_item(translated_name, book_item_category, - report_class, options_class, name, unsupported, - require_active) - - (junk, command_line_task) = divmod(modes-standalone_task-book_item_task, - 2**MODE_CLI) - if command_line_task: - _register_cl_report(name, category, report_class, options_class, - translated_name, unsupported, require_active) - -def _register_standalone(report_class, options_class, translated_name, name, - category, description=_unavailable, - status=_("Unknown"), author_name=_("Unknown"), - author_email=_("Unknown"), unsupported=False, - require_active=True): - """Register a report with the plugin system.""" + def register_report(self, name, category, report_class, options_class, + modes, translated_name, status=_("Unknown"), + description=_UNAVAILABLE, author_name=_("Unknown"), + author_email=_("Unknown"), unsupported=False, + require_active=True): + """ + Registers report for all possible flavors. - del_index = -1 - for i in range(0, len(report_list)): - val = report_list[i] - if val[4] == name: - del_index = i - if del_index != -1: - del report_list[del_index] - - report_list.append((report_class, options_class, translated_name, - category, name, description, status, author_name, - author_email, unsupported, require_active)) - mod2text[report_class.__module__] = description - -def register_book_item(translated_name, category, report_class, - option_class, name, unsupported, require_active): - """Register a book item.""" + This function should be used to register report as a stand-alone, + book item, or command-line flavor in any combination of those. + The low-level functions (starting with '_') should not be used + on their own. Instead, this function will call them as needed. + """ + (junk, standalone_task) = divmod(modes, 2**MODE_GUI) + if standalone_task: + self.__register_standalone(report_class, options_class, + translated_name, name, category, + description, status, author_name, + author_email, unsupported, + require_active) - del_index = -1 - for i in range(0, len(bkitems_list)): - val = bkitems_list[i] - if val[4] == name: - del_index = i - if del_index != -1: - del bkitems_list[del_index] + (junk, book_item_task) = divmod(modes-standalone_task, 2**MODE_BKI) + if book_item_task: + book_item_category = book_categories[category] + self.__register_book_item(translated_name, book_item_category, + report_class, options_class, name, + unsupported, require_active) + + (junk, command_line_task) = divmod(modes-standalone_task-book_item_task, + 2**MODE_CLI) + if command_line_task: + self.__register_cl_report(name, category, report_class, + options_class, translated_name, + unsupported, require_active) - bkitems_list.append((translated_name, category, report_class, - option_class, name, unsupported, require_active)) + def __register_standalone(self, report_class, options_class, + translated_name, name, category, + description=_UNAVAILABLE, status=_("Unknown"), + author_name=_("Unknown"), + author_email=_("Unknown"), unsupported=False, + require_active=True): + """ + Register a report with the plugin system. + """ + del_index = -1 + for i in range(0, len(self.__report_list)): + val = self.__report_list[i] + if val[4] == name: + del_index = i + if del_index != -1: + del self.__report_list[del_index] + + self.__report_list.append( (report_class, options_class, + translated_name, category, name, + description, status, author_name, + author_email, unsupported, require_active) ) + self.__mod2text[report_class.__module__] = description -def _register_cl_report(name, category, report_class, options_class, - translated_name, unsupported, require_active): - del_index = -1 - for i in range(0, len(cl_list)): - val = cl_list[i] - if val[0] == name: - del_index = i - if del_index != -1: - del cl_list[del_index] - cl_list.append((name, category, report_class, options_class, - translated_name, unsupported, require_active)) + def __register_book_item(self, translated_name, category, report_class, + option_class, name, unsupported, require_active): + """ + Register a book item. + """ + del_index = -1 + for i in range(0, len(self.__bkitems_list)): + val = self.__bkitems_list[i] + if val[4] == name: + del_index = i + if del_index != -1: + del self.__bkitems_list[del_index] + + self.__bkitems_list.append( (translated_name, category, report_class, + option_class, name, unsupported, + require_active) ) -#------------------------------------------------------------------------- -# -# Text document generator registration -# -#------------------------------------------------------------------------- -def register_text_doc(name, classref, table, paper, style, ext, - print_report_label=None, clname=''): - """Register a text document generator.""" - del_index = -1 - for i in range(0, len(textdoc_list)): - val = textdoc_list[i] - if val[0] == name: - del_index = i - if del_index != -1: - del textdoc_list[del_index] + def __register_cl_report(self, name, category, report_class, options_class, + translated_name, unsupported, require_active): + """ + Register a command line report. + """ + del_index = -1 + for i in range(0, len(self.__cl_list)): + val = self.__cl_list[i] + if val[0] == name: + del_index = i + if del_index != -1: + del self.__cl_list[del_index] + self.__cl_list.append( (name, category, report_class, options_class, + translated_name, unsupported, require_active) ) - if not clname: - clname = ext[1:] + def register_text_doc(self, name, classref, table, paper, style, ext, + print_report_label=None, clname=''): + """ + Register a text document generator. + """ + del_index = -1 + for i in range(0, len(self.__textdoc_list)): + val = self.__textdoc_list[i] + if val[0] == name: + del_index = i + if del_index != -1: + del self.__textdoc_list[del_index] + + if not clname: + clname = ext[1:] + + self.__textdoc_list.append( (name, classref, table, paper, style, + ext, print_report_label, clname) ) + self.__mod2text[classref.__module__] = name - textdoc_list.append( - (name, classref, table, paper, style, - ext, print_report_label, clname)) - mod2text[classref.__module__] = name + def register_book_doc(self, name, classref, table, paper, style, ext, + print_report_label=None, clname=''): + """ + Register a text document generator. + """ + del_index = -1 + for i in range(0, len(self.__bookdoc_list)): + val = self.__bookdoc_list[i] + if val[0] == name: + del_index = i + if del_index != -1: + del self.__bookdoc_list[del_index] + + if not clname: + clname = ext[1:] + self.__bookdoc_list.append( (name, classref, table, paper, style, ext, + print_report_label, clname) ) -#------------------------------------------------------------------------- -# -# Book document generator registration -# -#------------------------------------------------------------------------- -def register_book_doc(name, classref, table, paper, style, ext, - print_report_label=None, clname=''): - """Register a text document generator""" - del_index = -1 - for i in range(0, len(bookdoc_list)): - val = bookdoc_list[i] - if val[0] == name: - del_index = i - if del_index != -1: - del bookdoc_list[del_index] + def register_draw_doc(self, name, classref, paper, style, ext, + print_report_label=None, clname=''): + """ + Register a drawing document generator. + """ + del_index = -1 + for i in range(0, len(self.__drawdoc_list)): + val = self.__drawdoc_list[i] + if val[0] == name: + del_index = i + if del_index != -1: + del self.__drawdoc_list[del_index] + if not clname: + clname = ext[1:] + self.__drawdoc_list.append( (name, classref, paper, style, ext, + print_report_label, clname) ) + self.__mod2text[classref.__module__] = name - if not clname: - clname = ext[1:] - bookdoc_list.append((name, classref, table, paper, style, ext, - print_report_label, clname)) + def register_quick_report(self, name, category, run_func, translated_name, + status=_("Unknown"), description=_UNAVAILABLE, + author_name=_("Unknown"), + author_email=_("Unknown"), unsupported=False ): + """ + Registers quick report for all possible objects. + + This function should be used to register a quick report + so it appears in the quick report context menu of the object it is + attached to. + The low-level functions (starting with '_') should not be used + on their own. Instead, this function will call them as needed. + """ + del_index = -1 + for i in range(0, len(self.__quick_report_list)): + val = self.__quick_report_list[i] + if val[3] == name: + del_index = i + if del_index != -1: + del self.__quick_report_list[del_index] + + self.__quick_report_list.append( (run_func, translated_name, + category, name, description, status, + author_name, author_email, unsupported)) + + self.__mod2text[run_func.__module__] = description -#------------------------------------------------------------------------- -# -# Drawing document generator registration -# -#------------------------------------------------------------------------- -def register_draw_doc(name, classref, paper, style, ext, - print_report_label=None, clname=''): - """Register a drawing document generator""" - del_index = -1 - for i in range(0, len(drawdoc_list)): - val = drawdoc_list[i] - if val[0] == name: - del_index = i - if del_index != -1: - del drawdoc_list[del_index] - if not clname: - clname = ext[1:] - drawdoc_list.append((name, classref, paper, style, ext, - print_report_label, clname)) - mod2text[classref.__module__] = name + def __purge_failed(self): + """ + Purge the failed plugins from the corresponding lists. + """ + failed_module_names = [ + os.path.splitext(os.path.basename(filename))[0] + for filename, junk in self.__failmsg_list + ] + + self.__export_list[:] = [ item for item in self.__export_list + if item[0].__module__ not in failed_module_names ][:] + self.__import_list[:] = [ item for item in self.__import_list + if item[0].__module__ not in failed_module_names ][:] + self.__tool_list[:] = [ item for item in self.__tool_list + if item[0].__module__ not in failed_module_names ][:] + self.__cli_tool_list[:] = [ item for item in self.__cli_tool_list + if item[2].__module__ not in failed_module_names ][:] + self.__report_list[:] = [ item for item in self.__report_list + if item[0].__module__ not in failed_module_names ][:] + self.__quick_report_list[:] = \ + [ item for item in self.__quick_report_list + if item[0].__module__ not in failed_module_names ][:] + self.__bkitems_list[:] = [ item for item in self.__bkitems_list + if item[2].__module__ not in failed_module_names ][:] + self.__cl_list[:] = [ item for item in self.__cl_list + if item[2].__module__ not in failed_module_names ][:] + self.__textdoc_list[:] = [ item for item in self.__textdoc_list + if item[1].__module__ not in failed_module_names ][:] + self.__bookdoc_list[:] = [ item for item in self.__bookdoc_list + if item[1].__module__ not in failed_module_names ][:] + self.__drawdoc_list[:] = [ item for item in self.__drawdoc_list + if item[1].__module__ not in failed_module_names ][:] -#------------------------------------------------------------------------- -# -# Quick Report registration -# -#------------------------------------------------------------------------- -def register_quick_report( - name, - category, - run_func, - translated_name, - status=_("Unknown"), - description=_unavailable, - author_name=_("Unknown"), - author_email=_("Unknown"), - unsupported=False, - ): - """ - Registers quick report for all possible objects. - - This function should be used to register a quick report - so it appears in the quick report context menu of the object it is - attached to. - The low-level functions (starting with '_') should not be used - on their own. Instead, this function will call them as needed. - """ - del_index = -1 - for i in range(0, len(quick_report_list)): - val = quick_report_list[i] - if val[3] == name: - del_index = i - if del_index != -1: - del quick_report_list[del_index] - - quick_report_list.append((run_func, translated_name, - category, name, description, status, - author_name, author_email, unsupported)) - - mod2text[run_func.__module__] = description - -#------------------------------------------------------------------------- -# -# Remove plugins whose reloading failed from the already-registered lists -# -#------------------------------------------------------------------------- -def purge_failed(): - - global report_list, quick_report_list, tool_list, import_list, export_list,\ - textdoc_list, bookdoc_list, drawdoc_list, bkitems_list, cl_list, \ - cli_tool_list, failmsg_list - - failed_module_names = [ - os.path.splitext(os.path.basename(filename))[0] - for filename, junk in failmsg_list - ] - - #although these are global variables, we may not change the pointer of - # the list, as __init__.py already contains these, see comment there - export_list[:] = [ item for item in export_list - if item[0].__module__ not in failed_module_names ][:] - import_list[:] = [ item for item in import_list - if item[0].__module__ not in failed_module_names ][:] - tool_list[:] = [ item for item in tool_list - if item[0].__module__ not in failed_module_names ][:] - cli_tool_list[:] = [ item for item in cli_tool_list - if item[2].__module__ not in failed_module_names ][:] - report_list[:] = [ item for item in report_list - if item[0].__module__ not in failed_module_names ][:] - quick_report_list[:] = [ item for item in quick_report_list - if item[0].__module__ not in failed_module_names ][:] - bkitems_list[:] = [ item for item in bkitems_list - if item[2].__module__ not in failed_module_names ][:] - cl_list[:] = [ item for item in cl_list - if item[2].__module__ not in failed_module_names ][:] - textdoc_list[:] = [ item for item in textdoc_list - if item[1].__module__ not in failed_module_names ][:] - bookdoc_list[:] = [ item for item in bookdoc_list - if item[1].__module__ not in failed_module_names ][:] - drawdoc_list[:] = [ item for item in drawdoc_list - if item[1].__module__ not in failed_module_names ][:] - - -#------------------------------------------------------------------------- -# -# Relationship calculator registration -# -#------------------------------------------------------------------------- -def register_relcalc(relclass, languages): - """Register a relationshp calculator""" - global _relcalc_class - - try: - if os.environ["LANG"] in languages: - _relcalc_class = relclass - except: - pass - -def relationship_class(): - global _relcalc_class - return _relcalc_class() + def register_relcalc(self, relclass, languages): + """ + Register a relationship calculator. + """ + try: + if os.environ["LANG"] in languages: + self.__relcalc_class = relclass + except: + pass + + def get_relationship_calculator(self): + """ + Return the relationship calculator for the current language + """ + return self.__relcalc_class() diff --git a/src/PluginUtils/_PluginWindows.py b/src/PluginUtils/_PluginWindows.py index f86c5c306..12d99c91b 100644 --- a/src/PluginUtils/_PluginWindows.py +++ b/src/PluginUtils/_PluginWindows.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -44,7 +45,7 @@ import gobject #------------------------------------------------------------------------- import ManagedWindow import Errors -import _PluginMgr as PluginMgr +from PluginUtils import PluginManager import _Tool as Tool #------------------------------------------------------------------------- @@ -61,6 +62,7 @@ class PluginStatus(ManagedWindow.ManagedWindow): ManagedWindow.ManagedWindow.__init__(self, uistate, track, self.__class__) + self.__pmgr = PluginManager.get_instance() self.set_window(gtk.Dialog("", uistate.window, gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)), @@ -102,7 +104,9 @@ class PluginStatus(ManagedWindow.ManagedWindow): def __populate_list(self): """ Build the list of plugins """ - for i in PluginMgr.failmsg_list: + fail_list = self.__pmgr.get_fail_list() + + for i in fail_list: err = i[1][0] if err == Errors.UnavailableError: @@ -114,9 +118,10 @@ class PluginStatus(ManagedWindow.ManagedWindow): '%s' % _('Fail'), i[0], str(i[1][1]), i[1]]) - for i in PluginMgr.success_list: + success_list = self.__pmgr.get_success_list() + for i in success_list: modname = i[1].__name__ - descr = PluginMgr.mod2text.get(modname,'') + descr = self.__pmgr.get_module_description(modname) self.model.append(row=[ '%s' % _("OK"), i[0], descr, None]) @@ -135,9 +140,7 @@ class PluginStatus(ManagedWindow.ManagedWindow): def __reload(self, obj): """ Callback function from the "Reload" button """ - PluginMgr.reload_plugins() - self.__uistate.emit('plugins-reloaded', - (PluginMgr.tool_list, PluginMgr.report_list)) + self.__pmgr.reload_plugins() self.model.clear() self.__populate_list() diff --git a/src/PluginUtils/_Plugins.py b/src/PluginUtils/_Plugins.py index fda833398..e437afc39 100644 --- a/src/PluginUtils/_Plugins.py +++ b/src/PluginUtils/_Plugins.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -51,7 +52,7 @@ from gettext import gettext as _ import const from ReportBase import report, standalone_categories import _Tool -import _PluginMgr +from PluginUtils import PluginManager import ManagedWindow #------------------------------------------------------------------------- @@ -131,10 +132,9 @@ class PluginDialog(ManagedWindow.ManagedWindow): self.item = None self.build_plugin_tree(item_list, categories) - uistate.connect('plugins-reloaded', self.rebuild) self.show() - def rebuild(self, tool_list, report_list): + def rebuild(self): # This method needs to be overridden in the subclass assert False, "This method needs to be overridden in the subclass." @@ -254,20 +254,24 @@ class ReportPlugins(PluginDialog): """Display the dialog box, and build up the list of available reports. This is used to build the selection tree on the left hand side of the dailog box.""" + self.__pmgr = PluginManager.get_instance() PluginDialog.__init__( self, dbstate, uistate, track, - _PluginMgr.report_list, + self.__pmgr.get_report_list(), standalone_categories, _("Report Selection"), _("Select a report from those available on the left."), _("_Generate"), _("Generate selected report"), REPORTS) + + self.__pmgr.connect('plugins-reloaded', self.rebuild) - def rebuild(self, tool_list, report_list): + def rebuild(self): + report_list = self.__pmgr.get_report_list() self.build_plugin_tree(report_list, standalone_categories) #------------------------------------------------------------------------- @@ -279,20 +283,18 @@ class ToolPlugins(PluginDialog): """Displays the dialog box that allows the user to select the tool that is desired.""" - __signals__ = { - 'plugins-reloaded' : (list,list), - } def __init__(self, dbstate, uistate, track): """Display the dialog box, and build up the list of available reports. This is used to build the selection tree on the left hand side of the dailog box.""" + self.__pmgr = PluginManager.get_instance() PluginDialog.__init__( self, dbstate, uistate, track, - _PluginMgr.tool_list, + self.__pmgr.get_tool_list(), _Tool.tool_categories, _("Tool Selection"), _("Select a tool from those available on the left."), @@ -300,5 +302,6 @@ class ToolPlugins(PluginDialog): _("Run selected tool"), TOOLS) - def rebuild(self, tool_list, report_list): + def rebuild(self): + tool_list = self.__pmgr.get_tool_list() self.build_plugin_tree(tool_list, _Tool.tool_categories) diff --git a/src/PluginUtils/__init__.py b/src/PluginUtils/__init__.py index 90d3f27b8..52b1e3242 100644 --- a/src/PluginUtils/__init__.py +++ b/src/PluginUtils/__init__.py @@ -18,33 +18,18 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # - # $Id$ - -#The following is bad, we import lists here, and obtain pointers to them -#If in _PluginMgr the list changes, that is ok, if however the list is -#assigned to another pointer eg export_list = then in this module we -#still retain the old pointer! ==> all actions may not change the pointer -#Better would be to do: import _PluginMgr as PluginMgr and then access -# the list as PluginUtils.PluginMgr, or use a function that returns the pointer -# of the list. +# from _MenuOptions import (NumberOption, BooleanOption, TextOption, EnumeratedListOption, FilterOption, StringOption, ColourOption, PersonOption, PersonListOption, SurnameColourOption, FamilyOption, DestinationOption, NoteOption, MediaOption, StyleOption) from _GuiOptions import GuiMenuOptions, make_gui_option -from _PluginMgr import (register_export, register_import, register_tool, - register_report, register_relcalc, relationship_class, - textdoc_list, drawdoc_list, bookdoc_list, - bkitems_list, cl_list, cli_tool_list, load_plugins, - import_list, export_list, report_list, - quick_report_list, tool_list, register_text_doc, - register_draw_doc, register_book_doc, - register_quick_report) - from _Options import Options, OptionListCollection, OptionList, OptionHandler +from _PluginMgr import PluginManager + import _Tool as Tool import _Plugins as Plugins import _PluginWindows as PluginWindows diff --git a/src/QuickReports.py b/src/QuickReports.py index dfaa9f11e..78e338443 100644 --- a/src/QuickReports.py +++ b/src/QuickReports.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2007 B. Malengier +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -53,15 +54,13 @@ import gtk # #------------------------------------------------------------------------- -#from PluginUtils import Plugins +from PluginUtils import PluginManager from ReportBase import (CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE, CATEGORY_QR_MISC, CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY) def create_quickreport_menu(category,dbstate,uistate, handle) : - #import present version of the - from PluginUtils import quick_report_list """ This functions querries the registered quick reports with quick_report_list of _PluginMgr.py It collects the reports of the requested category, which must be one of @@ -86,7 +85,8 @@ def create_quickreport_menu(category,dbstate,uistate, handle) : #select the reports to show showlst = [] - for item in quick_report_list: + pmgr = PluginManager.get_instance() + for item in pmgr.get_quick_report_list(): if not item[8] and item[2] == category : #add tuple function, translated name, name, status showlst.append((item[0], item[1], item[3], item[5])) @@ -109,14 +109,14 @@ def make_quick_report_callback(lst, category, dbstate, uistate, handle): return lambda x: run_report(dbstate, uistate, category, handle, lst[0]) def run_quick_report_by_name(dbstate, uistate, report_name, handle, **kwargs): - from PluginUtils import quick_report_list # [0] - function # [1] - translated name # [2] - category # [3] - name # [5] - status report = None - for item in quick_report_list: + pmgr = PluginManager.get_instance() + for item in pmgr.get_quick_report_list(): if item[3] == report_name: report = item break @@ -129,11 +129,11 @@ def run_quick_report_by_name_direct(report_name, database, document, handle): """ Useful for running one quick report from another """ - from PluginUtils import quick_report_list from docgen import TextBufDoc from Simple import make_basic_stylesheet report = None - for item in quick_report_list: + pmgr = PluginManager.get_instance() + for item in pmgr.get_quick_report_list(): if item[3] == report_name: report = item break diff --git a/src/ReportBase/_BookFormatComboBox.py b/src/ReportBase/_BookFormatComboBox.py index 1133ef5f4..70dbbee7c 100644 --- a/src/ReportBase/_BookFormatComboBox.py +++ b/src/ReportBase/_BookFormatComboBox.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2001-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -43,6 +44,12 @@ import PluginUtils #------------------------------------------------------------------------- class BookFormatComboBox(gtk.ComboBox): + def __init__(self): + pmgr = PluginUtils.PluginManager.get_instance() + self.__book_doc_list = pmgr.get_book_doc_list() + self.__book_doc_list.sort() + gtk.ComboBox.__init__(self) + def set(self,tables,callback, obj=None,active=None): self.store = gtk.ListStore(gobject.TYPE_STRING) self.set_model(self.store) @@ -52,10 +59,9 @@ class BookFormatComboBox(gtk.ComboBox): out_pref = Config.get(Config.OUTPUT_PREFERENCE) index = 0 - PluginUtils.drawdoc_list.sort() active_index = 0 self.data = [] - for item in PluginUtils.bookdoc_list: + for item in self.__book_doc_list: if tables and item[2] == 0: continue self.data.append(item) diff --git a/src/ReportBase/_CommandLineReport.py b/src/ReportBase/_CommandLineReport.py index 39fb36b26..829409603 100644 --- a/src/ReportBase/_CommandLineReport.py +++ b/src/ReportBase/_CommandLineReport.py @@ -4,6 +4,7 @@ # Copyright (C) 2001-2007 Donald N. Allingham # Copyright (C) 2008 Lukasz Rymarczyk # Copyright (C) 2008 Raphael Ackermann +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -124,6 +125,11 @@ class CommandLineReport: """ Initialize the options that are hard-coded into the report system. """ + pmgr = PluginUtils.PluginManager.get_instance() + _textdoc_list = pmgr.get_text_doc_list() + _drawdoc_list = pmgr.get_draw_doc_list() + _bookdoc_list = pmgr.get_book_doc_list() + self.options_dict = { 'of' : self.option_class.handler.module_name, 'off' : self.option_class.handler.get_format_name(), @@ -151,34 +157,34 @@ class CommandLineReport: "whatever_name")) if self.category == CATEGORY_TEXT: - for item in PluginUtils.textdoc_list: + for item in _textdoc_list: if item[7] == self.options_dict['off']: self.format = item[1] if self.format is None: # Pick the first one as the default. - self.format = PluginUtils.textdoc_list[0][1] + self.format = _textdoc_list[0][1] self.options_help['off'][2] = \ - [ item[7] for item in PluginUtils.textdoc_list ] + [ item[7] for item in _textdoc_list ] self.options_help['off'][3] = False elif self.category == CATEGORY_DRAW: - for item in PluginUtils.drawdoc_list: + for item in _drawdoc_list: if item[6] == self.options_dict['off']: self.format = item[1] if self.format is None: # Pick the first one as the default. - self.format = PluginUtils.drawdoc_list[0][1] + self.format = _drawdoc_list[0][1] self.options_help['off'][2] = \ - [ item[6] for item in PluginUtils.drawdoc_list ] + [ item[6] for item in _drawdoc_list ] self.options_help['off'][3] = False elif self.category == CATEGORY_BOOK: - for item in PluginUtils.bookdoc_list: + for item in _bookdoc_list: if item[6] == self.options_dict['off']: self.format = item[1] if self.format is None: # Pick the first one as the default. - self.format = PluginUtils.bookdoc_list[0][1] + self.format = _bookdoc_list[0][1] self.options_help['off'][2] = \ - [ item[6] for item in PluginUtils.bookdoc_list ] + [ item[6] for item in _bookdoc_list ] self.options_help['off'][3] = False else: self.format = None diff --git a/src/ReportBase/_DrawFormatComboBox.py b/src/ReportBase/_DrawFormatComboBox.py index 3a08ceabc..db86cc80b 100644 --- a/src/ReportBase/_DrawFormatComboBox.py +++ b/src/ReportBase/_DrawFormatComboBox.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2001-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -32,6 +33,12 @@ import PluginUtils #------------------------------------------------------------------------- class DrawFormatComboBox(gtk.ComboBox): + def __init__(self): + pmgr = PluginUtils.PluginManager.get_instance() + self.__draw_doc_list = pmgr.get_draw_doc_list() + self.__draw_doc_list.sort() + gtk.ComboBox.__init__(self) + def set(self,tables,callback, obj=None,active=None): self.store = gtk.ListStore(gobject.TYPE_STRING) self.set_model(self.store) @@ -41,9 +48,8 @@ class DrawFormatComboBox(gtk.ComboBox): out_pref = Config.get(Config.OUTPUT_PREFERENCE) index = 0 - PluginUtils.drawdoc_list.sort() active_index = 0 - for item in PluginUtils.drawdoc_list: + for item in self.__drawdoc_list: if tables and item[2] == 0: continue name = item[0] @@ -58,22 +64,22 @@ class DrawFormatComboBox(gtk.ComboBox): self.set_active(active_index) def get_reference(self): - return PluginUtils.drawdoc_list[self.get_active()][1] + return self.__drawdoc_list[self.get_active()][1] def get_label(self): - return PluginUtils.drawdoc_list[self.get_active()][0] + return self.__drawdoc_list[self.get_active()][0] def get_paper(self): - return PluginUtils.drawdoc_list[self.get_active()][2] + return self.__drawdoc_list[self.get_active()][2] def get_styles(self): - return PluginUtils.drawdoc_list[self.get_active()][3] + return self.__drawdoc_list[self.get_active()][3] def get_ext(self): - return PluginUtils.drawdoc_list[self.get_active()][4] + return self.__drawdoc_list[self.get_active()][4] def get_printable(self): - return PluginUtils.drawdoc_list[self.get_active()][5] + return self.__drawdoc_list[self.get_active()][5] def get_clname(self): - return PluginUtils.drawdoc_list[self.get_active()][6] + return self.__drawdoc_list[self.get_active()][6] diff --git a/src/ReportBase/_TextFormatComboBox.py b/src/ReportBase/_TextFormatComboBox.py index c7ec0aad9..9e29276fb 100644 --- a/src/ReportBase/_TextFormatComboBox.py +++ b/src/ReportBase/_TextFormatComboBox.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2001-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -32,6 +33,12 @@ import PluginUtils #------------------------------------------------------------------------- class TextFormatComboBox(gtk.ComboBox): + def __init__(self): + pmgr = PluginUtils.PluginManager.get_instance() + self.__text_doc_list = pmgr.get_text_doc_list() + self.__text_doc_list.sort() + gtk.ComboBox.__init__(self) + def set(self,tables,callback, obj=None,active=None): self.store = gtk.ListStore(gobject.TYPE_STRING) self.set_model(self.store) @@ -41,9 +48,8 @@ class TextFormatComboBox(gtk.ComboBox): out_pref = Config.get(Config.OUTPUT_PREFERENCE) index = 0 - PluginUtils.textdoc_list.sort() active_index = 0 - for item in PluginUtils.textdoc_list: + for item in self.__text_doc_list: if tables and item[2] == 0: continue name = item[0] @@ -56,22 +62,22 @@ class TextFormatComboBox(gtk.ComboBox): self.set_active(active_index) def get_label(self): - return PluginUtils.textdoc_list[self.get_active()][0] + return self.__text_doc_list[self.get_active()][0] def get_reference(self): - return PluginUtils.textdoc_list[self.get_active()][1] + return self.__text_doc_list[self.get_active()][1] def get_paper(self): - return PluginUtils.textdoc_list[self.get_active()][3] + return self.__text_doc_list[self.get_active()][3] def get_styles(self): - return PluginUtils.textdoc_list[self.get_active()][4] + return self.__text_doc_list[self.get_active()][4] def get_ext(self): - return PluginUtils.textdoc_list[self.get_active()][5] + return self.__text_doc_list[self.get_active()][5] def get_printable(self): - return PluginUtils.textdoc_list[self.get_active()][6] + return self.__text_doc_list[self.get_active()][6] def get_clname(self): - return PluginUtils.textdoc_list[self.get_active()][7] + return self.__text_doc_list[self.get_active()][7] diff --git a/src/ViewManager.py b/src/ViewManager.py index 0bf4983c8..11c56a96b 100644 --- a/src/ViewManager.py +++ b/src/ViewManager.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2005-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -54,9 +55,7 @@ import gtk # GRAMPS modules # #------------------------------------------------------------------------- -from PluginUtils import Plugins, Tool, PluginWindows, \ - relationship_class, load_plugins, \ - tool_list, report_list +from PluginUtils import Plugins, Tool, PluginWindows, PluginManager import ReportBase import DisplayState @@ -223,6 +222,8 @@ class ViewManager: self.show_sidebar = Config.get(Config.VIEW) self.show_toolbar = Config.get(Config.TOOLBAR_ON) self.show_filter = Config.get(Config.FILTER) + + self.__pmgr = PluginManager.get_instance() self.__build_main_window() self.__connect_signals() @@ -239,7 +240,7 @@ class ViewManager: self.window.set_icon_from_file(const.ICON) self.window.set_default_size(width, height) - self.rel_class = relationship_class + self.rel_class = self.__pmgr.get_relationship_calculator() vbox = gtk.VBox() self.window.add(vbox) @@ -538,10 +539,10 @@ class ViewManager: self.actiongroup.set_visible(False) self.readonlygroup.set_visible(False) self.fileactions.set_sensitive(False) - self.__build_tools_menu(tool_list) - self.__build_report_menu(report_list) + self.__build_tools_menu(self.__pmgr.get_tool_list()) + self.__build_report_menu(self.__pmgr.get_report_list()) self.uistate.set_relationship_class() - self.uistate.connect('plugins-reloaded', + self.__pmgr.connect('plugins-reloaded', self.__rebuild_report_and_tool_menus) self.fileactions.set_sensitive(True) self.uistate.widget.set_sensitive(True) @@ -589,16 +590,15 @@ class ViewManager: generators and the plugins. The plugin status window is opened on an error if the user has requested. """ - # load document generators self.uistate.status_text(_('Loading document formats...')) - error = load_plugins(const.DOCGEN_DIR) - error |= load_plugins(const.USER_DOCGEN) + error = self.__pmgr.load_plugins(const.DOCGEN_DIR) + error |= self.__pmgr.load_plugins(const.USER_DOCGEN) # load plugins self.uistate.status_text(_('Loading plugins...')) - error |= load_plugins(const.PLUGINS_DIR) - error |= load_plugins(const.USER_PLUGINS) + error |= self.__pmgr.load_plugins(const.PLUGINS_DIR) + error |= self.__pmgr.load_plugins(const.USER_PLUGINS) # get to ssee if we need to open the plugin status window if error and Config.get(Config.POP_PLUGIN_STATUS): @@ -1311,10 +1311,12 @@ class ViewManager: except Errors.WindowActiveError: return - def __rebuild_report_and_tool_menus(self, tool_menu_list, report_menu_list): + def __rebuild_report_and_tool_menus(self): """ Callback that rebuilds the tools and reports menu """ + tool_menu_list = self.__pmgr.get_tool_list() + report_menu_list = self.__pmgr.get_report_list() self.__build_tools_menu(tool_menu_list) self.__build_report_menu(report_menu_list) self.uistate.set_relationship_class() diff --git a/src/docgen/AsciiDoc.py b/src/docgen/AsciiDoc.py index 6db2f23e6..5cdee7f57 100644 --- a/src/docgen/AsciiDoc.py +++ b/src/docgen/AsciiDoc.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham -# Copyright (C) 2007 Brian G. Matherly +# Copyright (C) 2007-2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -34,7 +34,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------ import BaseDoc -from PluginUtils import register_text_doc +from PluginUtils import PluginManager import Errors import Mime import Utils @@ -374,6 +374,7 @@ class AsciiDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc): # #------------------------------------------------------------------------ print_label = None +pmgr = PluginManager.get_instance() try: mprog = Mime.get_application("text/plain") mtype = Mime.get_description('text/plain') @@ -383,7 +384,7 @@ try: else: print_label=None - register_text_doc(mtype,AsciiDoc,1,1,1,".txt", print_label) + pmgr.register_text_doc(mtype, AsciiDoc, 1, 1, 1, ".txt", print_label) except: - register_text_doc(_("Plain Text"),AsciiDoc,1,1,1,".txt", None) + pmgr.register_text_doc(_("Plain Text"), AsciiDoc, 1, 1, 1, ".txt", None) diff --git a/src/docgen/GtkPrint.py b/src/docgen/GtkPrint.py index 182e7d702..4f692048e 100644 --- a/src/docgen/GtkPrint.py +++ b/src/docgen/GtkPrint.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2007 Zsolt Foldvari +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -43,7 +44,7 @@ import os #------------------------------------------------------------------------ import BaseDoc from CairoDoc import CairoDoc -from PluginUtils import register_text_doc, register_draw_doc, register_book_doc +from PluginUtils import PluginManager import Errors #------------------------------------------------------------------------ @@ -618,6 +619,7 @@ class GtkPrint(CairoDoc): # Register the document generator with the GRAMPS plugin system # #------------------------------------------------------------------------ -register_text_doc(_('Print...'), GtkPrint, 1, 1, 1, "", None) -register_draw_doc(_('Print...'), GtkPrint, 1, 1, "", None) -register_book_doc(_('Print...'), GtkPrint, 1, 1, 1, "", None) +pmgr = PluginManager.get_instance() +pmgr.register_text_doc(_('Print...'), GtkPrint, 1, 1, 1, "", None) +pmgr.register_draw_doc(_('Print...'), GtkPrint, 1, 1, "", None) +pmgr.register_book_doc(_('Print...'), GtkPrint, 1, 1, 1, "", None) diff --git a/src/docgen/HtmlDoc.py b/src/docgen/HtmlDoc.py index 6aa01d9c4..41263dc6f 100644 --- a/src/docgen/HtmlDoc.py +++ b/src/docgen/HtmlDoc.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham -# Copyright (C) 2007 Brian G. Matherly +# Copyright (C) 2007-2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -36,7 +36,7 @@ from gettext import gettext as _ # GRAMPS modules # #------------------------------------------------------------------------ -from PluginUtils import register_text_doc +from PluginUtils import PluginManager import ImgManip import tarfile import const @@ -481,6 +481,7 @@ class HtmlDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc): # #------------------------------------------------------------------------ print_label = None +pmgr = PluginManager.get_instance() try: prog = Mime.get_application("text/html") mtype = Mime.get_description("text/html") @@ -493,6 +494,6 @@ try: if mtype == _("unknown"): mtype = _('HTML') - register_text_doc(mtype,HtmlDoc,1,0,1,".html", print_label) + pmgr.register_text_doc(mtype, HtmlDoc, 1, 0, 1, ".html", print_label) except: - register_text_doc(_('HTML'),HtmlDoc,1,0,1,".html", None) + pmgr.register_text_doc(_('HTML'), HtmlDoc, 1, 0, 1, ".html", None) diff --git a/src/docgen/LaTeXDoc.py b/src/docgen/LaTeXDoc.py index 5d333ee3d..2a1402ddf 100644 --- a/src/docgen/LaTeXDoc.py +++ b/src/docgen/LaTeXDoc.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham -# Copyright (C) 2007 Brian G. Matherly +# Copyright (C) 2007-2008 Brian G. Matherly # Copyright (C) 2008 Raphael Ackermann # # Modifications and feature additions: @@ -43,7 +43,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------ import BaseDoc -from PluginUtils import register_text_doc +from PluginUtils import PluginManager import ImgManip import Errors import Mime @@ -522,6 +522,7 @@ class LaTeXDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc): # #------------------------------------------------------------------------ print_label = None +pmgr = PluginManager.get_instance() try: mprog = Mime.get_application(_apptype) @@ -533,4 +534,4 @@ try: except: print_label = None -register_text_doc(_('LaTex'), LaTeXDoc, 1, 1, 0, ".tex", print_label) +pmgr.register_text_doc(_('LaTex'), LaTeXDoc, 1, 1, 0, ".tex", print_label) diff --git a/src/docgen/ODFDoc.py b/src/docgen/ODFDoc.py index e488558ed..f0f1d0ef0 100644 --- a/src/docgen/ODFDoc.py +++ b/src/docgen/ODFDoc.py @@ -3,7 +3,7 @@ # # Copyright (C) 2000-2006 Donald N. Allingham # Copyright (C) 2005-2006 Serge Noiraud -# Copyright (C) 2007 Brian G. Matherly +# Copyright (C) 2007-2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -43,7 +43,7 @@ from xml.sax.saxutils import escape #------------------------------------------------------------------------- import BaseDoc import const -from PluginUtils import register_text_doc, register_draw_doc, register_book_doc +from PluginUtils import PluginManager from ReportBase import ReportUtils import ImgManip import FontScale @@ -1145,6 +1145,7 @@ class ODFDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc): # #-------------------------------------------------------------------------- print_label = None +pmgr = PluginManager.get_instance() try: mprog = Mime.get_application(_apptype) @@ -1156,6 +1157,9 @@ try: except: print_label = None -register_text_doc(_('Open Document Text'), ODFDoc, 1, 1, 1, ".odt", print_label) -register_book_doc(_("Open Document Text"), ODFDoc, 1, 1, 1, ".odt", print_label) -register_draw_doc(_("Open Document Text"), ODFDoc, 1, 1, ".odt", print_label); +pmgr.register_text_doc(_('Open Document Text'), + ODFDoc, 1, 1, 1, ".odt", print_label) +pmgr.register_book_doc(_("Open Document Text"), + ODFDoc, 1, 1, 1, ".odt", print_label) +pmgr.register_draw_doc(_("Open Document Text"), + ODFDoc, 1, 1, ".odt", print_label); diff --git a/src/docgen/PSDrawDoc.py b/src/docgen/PSDrawDoc.py index 96dd5a784..321be39af 100644 --- a/src/docgen/PSDrawDoc.py +++ b/src/docgen/PSDrawDoc.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham -# Copyright (C) 2007 Brian G. Matherly +# Copyright (C) 2007-2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -32,7 +32,7 @@ from gettext import gettext as _ #Gramps modules #------------------------------------------------------------------------- from ReportBase import ReportUtils, run_print_dialog, get_print_dialog_app -from PluginUtils import register_draw_doc +from PluginUtils import PluginManager import BaseDoc import Errors @@ -367,4 +367,5 @@ class PSDrawDoc(BaseDoc.BaseDoc,BaseDoc.DrawDoc): self.f.write("(%s) show\n" % lines[i]) self.f.write('grestore\n') -register_draw_doc(_("PostScript"),PSDrawDoc,1,1,".ps", print_label); +pmgr = PluginManager.get_instance() +pmgr.register_draw_doc(_("PostScript"), PSDrawDoc, 1, 1, ".ps", print_label); diff --git a/src/docgen/PdfDoc.py b/src/docgen/PdfDoc.py index b91cea61e..5923afc07 100644 --- a/src/docgen/PdfDoc.py +++ b/src/docgen/PdfDoc.py @@ -37,7 +37,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------ from CairoDoc import CairoDoc -from PluginUtils import register_text_doc, register_draw_doc, register_book_doc +from PluginUtils import PluginManager import Utils import Mime @@ -149,8 +149,9 @@ def register_docgen(): mtype = _('PDF document') print_label = None - register_text_doc(mtype, PdfDoc, 1, 1, 1, ".pdf", print_label) - register_draw_doc(mtype, PdfDoc, 1, 1, ".pdf", print_label) - register_book_doc(mtype, PdfDoc, 1, 1, 1, ".pdf", print_label) + pmgr = PluginManager.get_instance() + pmgr.register_text_doc(mtype, PdfDoc, 1, 1, 1, ".pdf", print_label) + pmgr.register_draw_doc(mtype, PdfDoc, 1, 1, ".pdf", print_label) + pmgr.register_book_doc(mtype, PdfDoc, 1, 1, 1, ".pdf", print_label) register_docgen() \ No newline at end of file diff --git a/src/docgen/RTFDoc.py b/src/docgen/RTFDoc.py index 124900722..9ce73667d 100644 --- a/src/docgen/RTFDoc.py +++ b/src/docgen/RTFDoc.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham -# Copyright (C) 2007 Brian G. Matherly +# Copyright (C) 2007-2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -34,7 +34,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------ import BaseDoc -from PluginUtils import register_text_doc +from PluginUtils import PluginManager import ImgManip import Errors import Mime @@ -440,6 +440,7 @@ class RTFDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc): # Register the document generator with the GRAMPS plugin system # #------------------------------------------------------------------------ +pmgr = PluginManager.get_instance() try: mprog = Mime.get_application(mime_type) mtype = Mime.get_description(mime_type) @@ -448,6 +449,6 @@ try: print_label=_("Open in %s") % mprog[1] else: print_label=None - register_text_doc(mtype, RTFDoc, 1, 1, 1, ".rtf", print_label) + pmgr.register_text_doc(mtype, RTFDoc, 1, 1, 1, ".rtf", print_label) except: - register_text_doc(_('RTF document'), RTFDoc, 1, 1, 1, ".rtf", None) + pmgr.register_text_doc(_('RTF document'), RTFDoc, 1, 1, 1, ".rtf", None) diff --git a/src/docgen/SvgDrawDoc.py b/src/docgen/SvgDrawDoc.py index 42ec8e468..486264f46 100644 --- a/src/docgen/SvgDrawDoc.py +++ b/src/docgen/SvgDrawDoc.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham -# Copyright (C) 2007 Brian G. Matherly +# Copyright (C) 2007-2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -34,7 +34,7 @@ import StringIO # Gramps modules # #------------------------------------------------------------------------- -from PluginUtils import register_draw_doc +from PluginUtils import PluginManager import BaseDoc import Errors @@ -262,4 +262,6 @@ def units(val): # Register document generator # #------------------------------------------------------------------------- -register_draw_doc(_("SVG (Scalable Vector Graphics)"),SvgDrawDoc,1,1,".svg"); +pmgr = PluginManager.get_instance() +pmgr.register_draw_doc(_("SVG (Scalable Vector Graphics)"), + SvgDrawDoc, 1, 1, ".svg"); diff --git a/src/docgen/TextBufDoc.py b/src/docgen/TextBufDoc.py index edbebc0c9..7ef36554a 100644 --- a/src/docgen/TextBufDoc.py +++ b/src/docgen/TextBufDoc.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham -# Copyright (C) 2007 Brian G. Matherly +# Copyright (C) 2007-2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -36,7 +36,6 @@ import pango # #------------------------------------------------------------------------ import BaseDoc -from PluginUtils import register_text_doc import ManagedWindow try: diff --git a/src/plugins/AgeOnDate.py b/src/plugins/AgeOnDate.py index 19434f6c9..1b4e9e5e1 100644 --- a/src/plugins/AgeOnDate.py +++ b/src/plugins/AgeOnDate.py @@ -25,7 +25,7 @@ Display references for any object from Simple import SimpleAccess, SimpleDoc, SimpleTable from gettext import gettext as _ -from PluginUtils import register_quick_report +from PluginUtils import PluginManager from ReportBase import CATEGORY_QR_DATE import DateHandler import gen.lib @@ -94,7 +94,8 @@ def get_event_date_from_ref(database, ref): # #------------------------------------------------------------------------ -register_quick_report( +pmgr = PluginManager.get_instance() +pmgr.register_quick_report( name = 'ageondate', category = CATEGORY_QR_DATE, run_func = run, diff --git a/src/plugins/AncestorReport.py b/src/plugins/AncestorReport.py index 3045081eb..1efdcace4 100644 --- a/src/plugins/AncestorReport.py +++ b/src/plugins/AncestorReport.py @@ -36,7 +36,7 @@ from gettext import gettext as _ # gramps modules # #------------------------------------------------------------------------ -from PluginUtils import register_report, NumberOption, \ +from PluginUtils import PluginManager, NumberOption, \ BooleanOption, PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI @@ -334,7 +334,8 @@ class AncestorOptions(MenuReportOptions): # Register the plugin # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'ancestor_report', category = CATEGORY_TEXT, report_class = AncestorReport, diff --git a/src/plugins/AncestorTree.py b/src/plugins/AncestorTree.py index b49a8601e..629511c45 100644 --- a/src/plugins/AncestorTree.py +++ b/src/plugins/AncestorTree.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham -# Copyright (C) 2007 Brian G. Matherly +# Copyright (C) 2007-2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -38,7 +38,7 @@ from gettext import gettext as _ #------------------------------------------------------------------------ import BaseDoc from SubstKeywords import SubstKeywords -from PluginUtils import register_report, \ +from PluginUtils import PluginManager, \ NumberOption, BooleanOption, TextOption, PersonOption from ReportBase import Report, ReportUtils, CATEGORY_DRAW, MenuReportOptions, \ MODE_GUI, MODE_BKI, MODE_CLI @@ -525,7 +525,8 @@ class AncestorTreeOptions(MenuReportOptions): # # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'ancestor_chart', category = CATEGORY_DRAW, report_class = AncestorTree, diff --git a/src/plugins/BookReport.py b/src/plugins/BookReport.py index b0da7f319..ef9221c0f 100644 --- a/src/plugins/BookReport.py +++ b/src/plugins/BookReport.py @@ -72,7 +72,7 @@ import ListModel import Errors import BaseDoc from QuestionDialog import WarningDialog, ErrorDialog -from PluginUtils import bkitems_list, register_report, Plugins +from PluginUtils import PluginManager, Plugins from PluginUtils import PersonOption, FilterOption, FamilyOption import ManagedWindow @@ -189,7 +189,9 @@ class BookItem: """ self.dbase = dbase self.style_name = "default" - for item in bkitems_list: + pmgr = PluginManager.get_instance() + + for item in pmgr.get_book_item_list(): if item[4] == name: self.translated_name = item[0] if item[5]: @@ -740,11 +742,11 @@ class BookReportSelector(ManagedWindow.ManagedWindow): The selections are read from the book item registry. """ - - if not bkitems_list: + pmgr = PluginManager.get_instance() + if not pmgr.get_book_item_list(): return - for book_item in bkitems_list: + for book_item in pmgr.get_book_item_list(): if book_item[5]: category = Plugins.UNSUPPORTED else: @@ -1234,7 +1236,8 @@ def write_book_item(database, report_class, options_class): # # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'book', category = CATEGORY_BOOK, report_class = BookReportSelector, diff --git a/src/plugins/CalculateEstimatedDates.py b/src/plugins/CalculateEstimatedDates.py index ad6650227..da8ec5ba4 100644 --- a/src/plugins/CalculateEstimatedDates.py +++ b/src/plugins/CalculateEstimatedDates.py @@ -36,7 +36,7 @@ import time # GRAMPS modules # #------------------------------------------------------------------------ -from PluginUtils import Tool, register_tool, PluginWindows, \ +from PluginUtils import Tool, PluginManager, PluginWindows, \ MenuToolOptions, BooleanOption, FilterOption, StringOption, \ NumberOption, PersonOption import gen.lib @@ -482,7 +482,8 @@ class CalcToolManagedWindow(PluginWindows.ToolManagedWindowBatch): # Register the tool # #------------------------------------------------------------------------- -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'calculateestimateddates', category = Tool.TOOL_DBPROC, tool_class = CalcToolManagedWindow, diff --git a/src/plugins/Calendar.py b/src/plugins/Calendar.py index 8822a517a..75f1bb16c 100644 --- a/src/plugins/Calendar.py +++ b/src/plugins/Calendar.py @@ -37,7 +37,7 @@ import os #------------------------------------------------------------------------ import BaseDoc from BasicUtils import name_displayer -from PluginUtils import register_report, relationship_class +from PluginUtils import PluginManager from ReportBase import (Report, ReportUtils, MenuReportOptions, CATEGORY_DRAW, CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI) @@ -314,7 +314,9 @@ class Calendar(Report): self.progress.set_pass(_('Filtering data...'), 0) people = self.filter.apply(self.database, self.database.get_person_handles(sort_handles=False)) - rel_calc = relationship_class() + pmgr = PluginManager.get_instance() + rel_calc = pmgr.get_relationship_calculator() + self.progress.set_pass(_('Filtering data...'), len(people)) for person_handle in people: self.progress.step() @@ -916,7 +918,8 @@ _countries = get_countries() # Register the plugins # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'calendar', category = CATEGORY_DRAW, report_class = Calendar, @@ -929,7 +932,7 @@ register_report( description = _("Produces a graphical calendar"), ) -register_report( +pmgr.register_report( name = 'birthday_report', category = CATEGORY_TEXT, report_class = CalendarReport, diff --git a/src/plugins/ChangeNames.py b/src/plugins/ChangeNames.py index 6e1b909c7..883abe907 100644 --- a/src/plugins/ChangeNames.py +++ b/src/plugins/ChangeNames.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -48,7 +49,7 @@ import GrampsDisplay import ManagedWindow from QuestionDialog import OkDialog -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager from TransUtils import sgettext as _ #------------------------------------------------------------------------- # @@ -279,7 +280,8 @@ class ChangeNamesOptions(Tool.ToolOptions): # # #------------------------------------------------------------------------ -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'chname', category = Tool.TOOL_DBPROC, tool_class = ChangeNames, diff --git a/src/plugins/ChangeTypes.py b/src/plugins/ChangeTypes.py index aaede1495..95e8c18c2 100644 --- a/src/plugins/ChangeTypes.py +++ b/src/plugins/ChangeTypes.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -48,7 +49,7 @@ import ManagedWindow import AutoComp from gen.lib import EventType from QuestionDialog import OkDialog -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager #------------------------------------------------------------------------- # @@ -195,7 +196,8 @@ class ChangeTypesOptions(Tool.ToolOptions): # # #------------------------------------------------------------------------ -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'chtype', category = Tool.TOOL_DBPROC, tool_class = ChangeTypes, diff --git a/src/plugins/Check.py b/src/plugins/Check.py index fa7f8fc5c..d1d4bb2c8 100644 --- a/src/plugins/Check.py +++ b/src/plugins/Check.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -59,7 +60,7 @@ import Utils #import const import ManagedWindow -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager from QuestionDialog import OkDialog, MissingMediaDialog from BasicUtils import name_displayer as _nd @@ -1507,7 +1508,8 @@ class CheckOptions(Tool.ToolOptions): # # #------------------------------------------------------------------------ -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'check', category = Tool.TOOL_DBFIX, tool_class = Check, diff --git a/src/plugins/CmdRef.py b/src/plugins/CmdRef.py index 026751f56..68a78c101 100644 --- a/src/plugins/CmdRef.py +++ b/src/plugins/CmdRef.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -37,7 +38,7 @@ from gettext import gettext as _ # GRAMPS modules # #------------------------------------------------------------------------- -from PluginUtils import Tool, cl_list, cli_tool_list, register_tool +from PluginUtils import Tool, PluginManager from ReportBase import CATEGORY_BOOK, CATEGORY_WEB from ReportBase._CommandLineReport import CommandLineReport @@ -55,7 +56,7 @@ _tags = [ #------------------------------------------------------------------------- # -# +# CmdRef # #------------------------------------------------------------------------- class CmdRef(Tool.Tool): @@ -94,12 +95,14 @@ class CmdRef(Tool.Tool): f.write(' Reports\n') # Common report options - item = cl_list[0] + pmgr = PluginManager.get_instance() + _cl_list = pmgr.get_cl_list() + item = _cl_list[0] clr = CommandLineReport(self.__db, item[0], item[1], item[3], {}, True) self.write_ref(f,clr,level+2,id_counter,True) id_counter = id_counter + 1 - for item in cl_list: + for item in _cl_list: unsupported = item[5] if unsupported is True: continue @@ -116,13 +119,14 @@ class CmdRef(Tool.Tool): f.write(' Tools\n') # Common tool options - item = cli_tool_list[0] + _cl_tool_list = pmgr.get_cl_tool_list() + item = _cl_tool_list[0] clr = Tool.CommandLineTool(self.__db, item[0], item[1], item[3], {}, True) self.write_ref(f,clr,level+2,id_counter,True) id_counter = id_counter + 1 - for item in cli_tool_list: + for item in _cl_tool_list: self.write_ref(f,item,level+2,id_counter) id_counter = id_counter + 1 f.write(' \n' % _tags[level+1] ) @@ -202,7 +206,7 @@ class CmdRef(Tool.Tool): #------------------------------------------------------------------------ # -# +# CmdRefOptions # #------------------------------------------------------------------------ class CmdRefOptions(Tool.ToolOptions): @@ -231,10 +235,10 @@ class CmdRefOptions(Tool.ToolOptions): # # #------------------------------------------------------------------------ - if __debug__: - register_tool( + pmgr = PluginManager.get_instance() + pmgr.register_tool( name = 'cmdref', category = Tool.TOOL_DEBUG, tool_class = CmdRef, diff --git a/src/plugins/CustomBookText.py b/src/plugins/CustomBookText.py index 3c634a345..9869092d4 100644 --- a/src/plugins/CustomBookText.py +++ b/src/plugins/CustomBookText.py @@ -1,6 +1,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -40,7 +41,7 @@ from gettext import gettext as _ # gramps modules # #------------------------------------------------------------------------ -from PluginUtils import register_report, TextOption +from PluginUtils import PluginManager, TextOption from ReportBase import Report, MenuReportOptions, CATEGORY_TEXT, MODE_BKI import BaseDoc @@ -158,7 +159,8 @@ class CustomTextOptions(MenuReportOptions): # # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'custom_text', category = CATEGORY_TEXT, report_class = CustomText, diff --git a/src/plugins/DateParserDisplayTest.py b/src/plugins/DateParserDisplayTest.py index 0e2ad3e40..2af370c57 100644 --- a/src/plugins/DateParserDisplayTest.py +++ b/src/plugins/DateParserDisplayTest.py @@ -3,6 +3,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Martin Hawlisch, Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -34,6 +35,7 @@ Tools/Debug/Check Localized Date Parser and Displayer #------------------------------------------------------------------------- import traceback import sys +from gettext import gettext as _ #------------------------------------------------------------------------- # @@ -41,7 +43,7 @@ import sys # #------------------------------------------------------------------------- import gen.lib -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager import Utils from QuestionDialog import QuestionDialog from DateHandler import parser as _dp @@ -226,7 +228,8 @@ class DateParserDisplayTest(Tool.Tool): # #------------------------------------------------------------------------- -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'test_for_date_parser_and_displayer', category = Tool.TOOL_DEBUG, tool_class = DateParserDisplayTest, @@ -236,9 +239,9 @@ register_tool( status = _("Beta"), author_name = "Martin Hawlisch", author_email = "martin@hawlisch.de", - description = _("This test tool will create many people showing all different" - " date variants as birth. The death date is created by" - " parsing the result of the date displayer for the birth" - " date. This way you can ensure that dates printed can" - " be parsed back in correctly.") + description = _("This test tool will create many people showing all" + " different date variants as birth. The death date is" + " created by parsing the result of the date displayer for" + " the birth date. This way you can ensure that dates" + " printed can be parsed back in correctly.") ) diff --git a/src/plugins/Desbrowser.py b/src/plugins/Desbrowser.py index 77099aa2f..cf503ba87 100644 --- a/src/plugins/Desbrowser.py +++ b/src/plugins/Desbrowser.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -43,7 +44,7 @@ from gtk import glade # #------------------------------------------------------------------------ from BasicUtils import name_displayer -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager import GrampsDisplay import ManagedWindow from TransUtils import sgettext as _ @@ -157,7 +158,8 @@ class DesBrowseOptions(Tool.ToolOptions): # # #------------------------------------------------------------------------ -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'dbrowse', category = Tool.TOOL_ANAL, tool_class = DesBrowse, diff --git a/src/plugins/DescendReport.py b/src/plugins/DescendReport.py index 35942bb0a..4471dbc0c 100644 --- a/src/plugins/DescendReport.py +++ b/src/plugins/DescendReport.py @@ -35,7 +35,7 @@ from gettext import gettext as _ # GRAMPS modules # #------------------------------------------------------------------------ -from PluginUtils import register_report, NumberOption, PersonOption +from PluginUtils import PluginManager, NumberOption, PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI import BaseDoc @@ -245,7 +245,8 @@ class DescendantOptions(MenuReportOptions): # # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'descend_report', category = CATEGORY_TEXT, report_class = DescendantReport, diff --git a/src/plugins/DescendTree.py b/src/plugins/DescendTree.py index 976bb7202..54b6271c7 100644 --- a/src/plugins/DescendTree.py +++ b/src/plugins/DescendTree.py @@ -29,7 +29,7 @@ # #------------------------------------------------------------------------ from BasicUtils import name_displayer -from PluginUtils import register_report, NumberOption, BooleanOption, \ +from PluginUtils import PluginManager, NumberOption, BooleanOption, \ TextOption, PersonOption from ReportBase import Report, MenuReportOptions, \ ReportUtils, CATEGORY_DRAW, MODE_GUI, MODE_BKI, MODE_CLI @@ -479,7 +479,8 @@ class DescendTreeOptions(MenuReportOptions): # # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'descend_chart', category = CATEGORY_DRAW, report_class = DescendTree, diff --git a/src/plugins/DetAncestralReport.py b/src/plugins/DetAncestralReport.py index c2a4faaf3..4cc1b190a 100644 --- a/src/plugins/DetAncestralReport.py +++ b/src/plugins/DetAncestralReport.py @@ -37,7 +37,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------ import gen.lib -from PluginUtils import register_report, NumberOption, \ +from PluginUtils import PluginManager, NumberOption, \ BooleanOption, PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI @@ -856,7 +856,8 @@ class DetAncestorOptions(MenuReportOptions): # # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'det_ancestor_report', category = CATEGORY_TEXT, report_class = DetAncestorReport, diff --git a/src/plugins/DetDescendantReport.py b/src/plugins/DetDescendantReport.py index 6d09a82a3..a94b0ba12 100644 --- a/src/plugins/DetDescendantReport.py +++ b/src/plugins/DetDescendantReport.py @@ -38,7 +38,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------ import gen.lib -from PluginUtils import register_report, NumberOption, \ +from PluginUtils import PluginManager, NumberOption, \ BooleanOption, PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI @@ -821,7 +821,8 @@ class DetDescendantOptions(MenuReportOptions): # # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'det_descendant_report', category = CATEGORY_TEXT, report_class = DetDescendantReport, diff --git a/src/plugins/DumpGenderStats.py b/src/plugins/DumpGenderStats.py index a411d6214..f63759e04 100644 --- a/src/plugins/DumpGenderStats.py +++ b/src/plugins/DumpGenderStats.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Martin Hawlisch, Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,12 +25,12 @@ Tools/Debug/Dump Gender Statistics """ - +from gettext import gettext as _ import gtk import ListModel import ManagedWindow -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager _GENDER = [ _(u'female'), _(u'male'), _(u'unknown') ] #------------------------------------------------------------------------- @@ -108,7 +109,8 @@ class DumpGenderStatsOptions(Tool.ToolOptions): if __debug__: - register_tool( + pmgr = PluginManager.get_instance() + pmgr.register_tool( name = 'dgenstats', category = Tool.TOOL_DEBUG, tool_class = DumpGenderStats, diff --git a/src/plugins/EndOfLineReport.py b/src/plugins/EndOfLineReport.py index 0fb27f077..84569c15c 100644 --- a/src/plugins/EndOfLineReport.py +++ b/src/plugins/EndOfLineReport.py @@ -34,7 +34,7 @@ from gettext import gettext as _ # gramps modules # #------------------------------------------------------------------------ -from PluginUtils import register_report, PersonOption +from PluginUtils import PluginManager, PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI import BaseDoc @@ -307,7 +307,8 @@ class EndOfLineOptions(MenuReportOptions): # Register the plugin # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'endofline_report', category = CATEGORY_TEXT, report_class = EndOfLineReport, diff --git a/src/plugins/Eval.py b/src/plugins/Eval.py index 180b710dc..410dc8be5 100644 --- a/src/plugins/Eval.py +++ b/src/plugins/Eval.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -45,7 +46,7 @@ from gtk import glade # GRAMPS modules # #------------------------------------------------------------------------ -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager import ManagedWindow #------------------------------------------------------------------------- @@ -119,7 +120,8 @@ class EvalOptions(Tool.ToolOptions): #------------------------------------------------------------------------ if __debug__: - register_tool( + pmgr = PluginManager.get_instance() + pmgr.register_tool( name = 'eval', category = Tool.TOOL_DEBUG, tool_class = Eval, diff --git a/src/plugins/EventCmp.py b/src/plugins/EventCmp.py index ceb91f37f..3ff573509 100644 --- a/src/plugins/EventCmp.py +++ b/src/plugins/EventCmp.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -51,7 +52,7 @@ import const import Errors import DateHandler from QuestionDialog import WarningDialog -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager from ReportBase import ReportUtils import GrampsDisplay import ManagedWindow @@ -455,7 +456,8 @@ class EventComparisonOptions(Tool.ToolOptions): # # #------------------------------------------------------------------------- -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'eventcmp', category = Tool.TOOL_ANAL, tool_class = EventComparison, diff --git a/src/plugins/EventNames.py b/src/plugins/EventNames.py index f55c7786d..9c5313ccc 100644 --- a/src/plugins/EventNames.py +++ b/src/plugins/EventNames.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -44,7 +45,7 @@ import ManagedWindow import gen.lib import Utils -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager from BasicUtils import name_displayer #------------------------------------------------------------------------- @@ -151,7 +152,8 @@ class EventNamesOptions(Tool.ToolOptions): # # #------------------------------------------------------------------------ -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'evname', category = Tool.TOOL_DBPROC, tool_class = EventNames, diff --git a/src/plugins/ExportCSV.py b/src/plugins/ExportCSV.py index 48c6542fd..c7c086e2d 100644 --- a/src/plugins/ExportCSV.py +++ b/src/plugins/ExportCSV.py @@ -1,8 +1,9 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2007-2008 Douglas S. Blank +# Copyright (C) 2007-2008 Douglas S. Blank # Copyright (C) 2004-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -58,7 +59,7 @@ from Filters import GenericFilter, Rules, build_filter_menu import Utils import Errors from QuestionDialog import ErrorDialog -from PluginUtils import register_export +from PluginUtils import PluginManager import DateHandler #------------------------------------------------------------------------- @@ -504,4 +505,5 @@ _description = _('CSV is a common spreadsheet format.') _config = (_('CSV spreadsheet options'),CSVWriterOptionBox) _filename = 'csv' -register_export(exportData,_title,_description,_config,_filename) +pmgr = PluginManager.get_instance() +pmgr.register_export(exportData,_title,_description,_config,_filename) diff --git a/src/plugins/ExportVCalendar.py b/src/plugins/ExportVCalendar.py index 8c368876c..4157687d2 100644 --- a/src/plugins/ExportVCalendar.py +++ b/src/plugins/ExportVCalendar.py @@ -3,6 +3,7 @@ # # Copyright (C) 2004 Martin Hawlisch # Copyright (C) 2005-2006, 2008 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -58,7 +59,7 @@ import Utils from gen.lib import Date, EventType import Errors from QuestionDialog import ErrorDialog -from PluginUtils import register_export +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -355,4 +356,5 @@ _description = _('vCalendar is used in many calendaring and pim applications.') _config = (_('vCalendar export options'), CalendarWriterOptionBox) _filename = 'vcs' -register_export(exportData, _title, _description, _config, _filename) +pmgr = PluginManager.get_instance() +pmgr.register_export(exportData, _title, _description, _config, _filename) diff --git a/src/plugins/ExportVCard.py b/src/plugins/ExportVCard.py index 9609e8e3f..64f04138c 100644 --- a/src/plugins/ExportVCard.py +++ b/src/plugins/ExportVCard.py @@ -3,6 +3,7 @@ # # Copyright (C) 2004 Martin Hawlisch # Copyright (C) 2005-2008 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -55,7 +56,7 @@ from Filters import GenericFilter, Rules, build_filter_menu from gen.lib import Date import Errors from QuestionDialog import ErrorDialog -from PluginUtils import register_export +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -271,4 +272,5 @@ _description = _('vCard is used in many addressbook and pim applications.') _config = (_('vCard export options'), CardWriterOptionBox) _filename = 'vcf' -register_export(exportData, _title, _description, _config, _filename) +pmgr = PluginManager.get_instance() +pmgr.register_export(exportData, _title, _description, _config, _filename) diff --git a/src/plugins/ExtractCity.py b/src/plugins/ExtractCity.py index 07bab165c..d162217e1 100644 --- a/src/plugins/ExtractCity.py +++ b/src/plugins/ExtractCity.py @@ -3,6 +3,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -49,7 +50,7 @@ import gobject import ManagedWindow import GrampsDisplay -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager import Utils CITY_STATE_ZIP = re.compile("((\w|\s)+)\s*,\s*((\w|\s)+)\s*(,\s*((\d|-)+))", re.UNICODE) @@ -621,7 +622,8 @@ class ExtractCityOptions(Tool.ToolOptions): # # #------------------------------------------------------------------------ -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'excity', category = Tool.TOOL_DBPROC, tool_class = ExtractCity, diff --git a/src/plugins/FamilyGroup.py b/src/plugins/FamilyGroup.py index 8eb5d594a..b8e28a75f 100644 --- a/src/plugins/FamilyGroup.py +++ b/src/plugins/FamilyGroup.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham -# Copyright (C) 2007 Brian G. Matherly +# Copyright (C) 2007-2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -29,7 +29,7 @@ # #------------------------------------------------------------------------ import gen.lib -from PluginUtils import register_report, BooleanOption, FamilyOption +from PluginUtils import PluginManager, BooleanOption, FamilyOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI import BaseDoc @@ -762,7 +762,8 @@ class FamilyGroupOptions(MenuReportOptions): # # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'family_group', category = CATEGORY_TEXT, report_class = FamilyGroup, diff --git a/src/plugins/FanChart.py b/src/plugins/FanChart.py index beb5ded54..92678e16a 100644 --- a/src/plugins/FanChart.py +++ b/src/plugins/FanChart.py @@ -34,7 +34,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------ import BaseDoc -from PluginUtils import register_report +from PluginUtils import PluginManager from PluginUtils import NumberOption, EnumeratedListOption, PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_DRAW, \ MODE_GUI, MODE_BKI, MODE_CLI @@ -433,7 +433,8 @@ class FanChartOptions(MenuReportOptions): # # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'fan_chart', category = CATEGORY_DRAW, report_class = FanChart, diff --git a/src/plugins/FilterByName.py b/src/plugins/FilterByName.py index 5b4169a37..e9ab70a1e 100644 --- a/src/plugins/FilterByName.py +++ b/src/plugins/FilterByName.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham -# Copyright (C) 2007 Brian G. Matherly +# Copyright (C) 2007-2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ Display filtered data """ from Simple import SimpleAccess, SimpleDoc, SimpleTable -from PluginUtils import register_quick_report +from PluginUtils import PluginManager from Utils import media_path_full from QuickReports import run_quick_report_by_name_direct from gen.lib import Person @@ -226,7 +226,8 @@ def run(database, document, filter_name, *args, **kwargs): # # #------------------------------------------------------------------------ -register_quick_report( +pmgr = PluginManager.get_instance() +pmgr.register_quick_report( name = 'filterbyname', category = -1, # stand-alone run_func = run, diff --git a/src/plugins/FindDupes.py b/src/plugins/FindDupes.py index 71297dedb..fa587712b 100644 --- a/src/plugins/FindDupes.py +++ b/src/plugins/FindDupes.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -51,7 +52,7 @@ import Errors from Merge import PersonCompare import GrampsDisplay import ManagedWindow -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager from QuestionDialog import ErrorDialog, RunDatabaseRepair from TransUtils import sgettext as _ #------------------------------------------------------------------------- @@ -689,7 +690,8 @@ class MergeOptions(Tool.ToolOptions): # # #------------------------------------------------------------------------- -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'dupfind', category = Tool.TOOL_DBPROC, tool_class = Merge, diff --git a/src/plugins/GVFamilyLines.py b/src/plugins/GVFamilyLines.py index 0f575d1cc..01163c3c0 100644 --- a/src/plugins/GVFamilyLines.py +++ b/src/plugins/GVFamilyLines.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2007-2008 Stephane Charette -# Copyright (C) 2007 Brian G. Matherly +# Copyright (C) 2007-2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Pubilc License as published by @@ -51,7 +51,7 @@ import ThumbNails from DateHandler import displayer as _dd from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_GRAPHVIZ, MODE_GUI -from PluginUtils import register_report, EnumeratedListOption, BooleanOption, \ +from PluginUtils import PluginManager, EnumeratedListOption, BooleanOption, \ NumberOption, ColourOption, PersonListOption, SurnameColourOption #------------------------------------------------------------------------ @@ -1032,7 +1032,8 @@ class FamilyLinesReport(Report): # appears in the "Reports" menu options # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'familylines_graph', translated_name = _("Family Lines Graph"), category = CATEGORY_GRAPHVIZ, diff --git a/src/plugins/GVHourGlass.py b/src/plugins/GVHourGlass.py index 33a1411ff..d630d1c19 100644 --- a/src/plugins/GVHourGlass.py +++ b/src/plugins/GVHourGlass.py @@ -35,7 +35,7 @@ from gettext import gettext as _ # GRAMPS modules # #------------------------------------------------------------------------ -from PluginUtils import register_report, NumberOption, PersonOption, \ +from PluginUtils import PluginManager, NumberOption, PersonOption, \ EnumeratedListOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ MODE_GUI, MODE_CLI, CATEGORY_GRAPHVIZ @@ -273,7 +273,8 @@ class HourGlassOptions(MenuReportOptions): # # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'hourglass_graph', category = CATEGORY_GRAPHVIZ, report_class = HourGlassReport, diff --git a/src/plugins/GVRelGraph.py b/src/plugins/GVRelGraph.py index 54bdb45f5..886a886e5 100644 --- a/src/plugins/GVRelGraph.py +++ b/src/plugins/GVRelGraph.py @@ -42,7 +42,7 @@ from TransUtils import sgettext as _ # GRAMPS modules # #------------------------------------------------------------------------ -from PluginUtils import register_report, FilterOption, \ +from PluginUtils import PluginManager, FilterOption, \ EnumeratedListOption, BooleanOption, PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ MODE_GUI, MODE_CLI, CATEGORY_GRAPHVIZ @@ -551,7 +551,8 @@ class RelGraphOptions(MenuReportOptions): # # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'rel_graph', category = CATEGORY_GRAPHVIZ, report_class = RelGraphReport, diff --git a/src/plugins/ImportCSV.py b/src/plugins/ImportCSV.py index d01263721..e95bdf298 100644 --- a/src/plugins/ImportCSV.py +++ b/src/plugins/ImportCSV.py @@ -1,9 +1,10 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2007 Douglas S. Blank -# Copyright (C) 2000-2007 Donald N. Allingham -# Copyright (C) 2008 Raphael Ackerman +# Copyright (C) 2007 Douglas S. Blank +# Copyright (C) 2000-2007 Donald N. Allingham +# Copyright (C) 2008 Raphael Ackerman +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -58,7 +59,7 @@ import gtk import gen.lib from QuestionDialog import ErrorDialog from DateHandler import parser as _dp -from PluginUtils import register_import +from PluginUtils import PluginManager from Utils import gender as gender_map from Utils import ProgressMeter @@ -806,5 +807,7 @@ _filter.set_name(_('CSV spreadsheet files')) _filter.add_mime_type(_mime_type) _filter.add_mime_type(_mime_type_rfc_4180) _format_name = _('CSV Spreadheet') -register_import(importData, _filter, [_mime_type, _mime_type_rfc_4180], + +pmgr = PluginManager.get_instance() +pmgr.register_import(importData, _filter, [_mime_type, _mime_type_rfc_4180], 0, _format_name) diff --git a/src/plugins/ImportGeneWeb.py b/src/plugins/ImportGeneWeb.py index f8d7c72a7..be71abba5 100644 --- a/src/plugins/ImportGeneWeb.py +++ b/src/plugins/ImportGeneWeb.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Martin Hawlisch, Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -55,7 +56,7 @@ import Errors import gen.lib import const from QuestionDialog import ErrorDialog -from PluginUtils import register_import +from PluginUtils import PluginManager from htmlentitydefs import name2codepoint _date_parse = re.compile('([kmes~?<>]+)?([0-9/]+)([J|H|F])?(\.\.)?([0-9/]+)?([J|H|F])?') @@ -934,4 +935,5 @@ _filter.set_name(_('GeneWeb files')) _filter.add_mime_type(_mime_type) _format_name = _('GeneWeb') -register_import(importData, _filter, [_mime_type], 0, _format_name) +pmgr = PluginManager.get_instance() +pmgr.register_import(importData, _filter, [_mime_type], 0, _format_name) diff --git a/src/plugins/ImportProGen.py b/src/plugins/ImportProGen.py index b753cb11b..18bc2fba9 100644 --- a/src/plugins/ImportProGen.py +++ b/src/plugins/ImportProGen.py @@ -3,6 +3,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2008-2008 Kees Bakker +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -53,7 +54,7 @@ import Utils import gen.lib import const from QuestionDialog import ErrorDialog -from PluginUtils import register_import +from PluginUtils import PluginManager class ProgenError(Exception): @@ -1207,4 +1208,5 @@ _filter.set_name(_('Pro-Gen files')) _filter.add_mime_type(_mime_type) _format_name = _('Pro-Gen') -register_import(_importData, _filter, [_mime_type], 0, _format_name) +pmgr = PluginManager.get_instance() +pmgr.register_import(_importData, _filter, [_mime_type], 0, _format_name) diff --git a/src/plugins/ImportvCard.py b/src/plugins/ImportvCard.py index 3d7086f89..1d7606777 100644 --- a/src/plugins/ImportvCard.py +++ b/src/plugins/ImportvCard.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Martin Hawlisch, Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -55,7 +56,7 @@ import Errors import gen.lib import const from QuestionDialog import ErrorDialog -from PluginUtils import register_import +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -225,4 +226,5 @@ _filter.set_name(_('vCard files')) for mime in _mime_type: _filter.add_mime_type(mime) -register_import(importData, _filter, _mime_type, 1) +pmgr = PluginManager.get_instance() +pmgr.register_import(importData, _filter, _mime_type, 1) diff --git a/src/plugins/IndivComplete.py b/src/plugins/IndivComplete.py index 3d0184b53..38830714c 100644 --- a/src/plugins/IndivComplete.py +++ b/src/plugins/IndivComplete.py @@ -37,7 +37,7 @@ from gettext import gettext as _ import gen.lib import BaseDoc import DateHandler -from PluginUtils import register_report, FilterOption, BooleanOption, \ +from PluginUtils import PluginManager, FilterOption, BooleanOption, \ PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI @@ -633,7 +633,8 @@ class IndivCompleteOptions(MenuReportOptions): # # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'indiv_complete', category = CATEGORY_TEXT, report_class = IndivCompleteReport, diff --git a/src/plugins/KinshipReport.py b/src/plugins/KinshipReport.py index 828e44fa5..d2fdd96e3 100644 --- a/src/plugins/KinshipReport.py +++ b/src/plugins/KinshipReport.py @@ -35,7 +35,7 @@ from string import capitalize # gramps modules # #------------------------------------------------------------------------ -from PluginUtils import register_report, relationship_class, NumberOption, \ +from PluginUtils import PluginManager, NumberOption, \ BooleanOption, PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI @@ -82,7 +82,9 @@ class KinshipReport(Report): self.person = database.get_person_from_gramps_id(pid) self.__db = database - self.rel_calc = relationship_class() + pmgr = PluginManager.get_instance() + self.rel_calc = pmgr.get_relationship_calculator() + self.kinship_map = {} self.spouse_map = {} @@ -395,7 +397,8 @@ class KinshipOptions(MenuReportOptions): # Register the plugin # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'kinship_report', category = CATEGORY_TEXT, report_class = KinshipReport, diff --git a/src/plugins/Leak.py b/src/plugins/Leak.py index 102ced710..9d69167d9 100644 --- a/src/plugins/Leak.py +++ b/src/plugins/Leak.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -46,7 +47,7 @@ import gc # GRAMPS modules # #------------------------------------------------------------------------ -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager import ManagedWindow #------------------------------------------------------------------------- @@ -119,7 +120,8 @@ class LeakOptions(Tool.ToolOptions): #------------------------------------------------------------------------ if __debug__: - register_tool( + pmgr = PluginManager.get_instance() + pmgr.register_tool( name = 'leak', category = Tool.TOOL_DEBUG, tool_class = Leak, diff --git a/src/plugins/MarkerReport.py b/src/plugins/MarkerReport.py index 842044da5..55ff6882d 100644 --- a/src/plugins/MarkerReport.py +++ b/src/plugins/MarkerReport.py @@ -34,7 +34,7 @@ from gettext import gettext as _ # GRAMPS modules # #------------------------------------------------------------------------ -from PluginUtils import register_report, EnumeratedListOption +from PluginUtils import PluginManager, EnumeratedListOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI import BaseDoc @@ -515,7 +515,8 @@ class MarkerOptions(MenuReportOptions): # # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'marker_report', category = CATEGORY_TEXT, report_class = MarkerReport, diff --git a/src/plugins/MediaManager.py b/src/plugins/MediaManager.py index 1c5109ce2..74d1d2c94 100644 --- a/src/plugins/MediaManager.py +++ b/src/plugins/MediaManager.py @@ -2,7 +2,8 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham -# Copyright (C) 2008 B. Malengier +# Copyright (C) 2008 B. Malengier +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -50,7 +51,7 @@ import Assistant import Errors from gen.lib import MediaObject from BasicUtils import UpdateCallback -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager from Utils import media_path_full, relative_path, media_path from TransUtils import sgettext as _ @@ -584,7 +585,8 @@ class MediaManOptions(Tool.ToolOptions): # # #------------------------------------------------------------------------- -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'mediaman', category = Tool.TOOL_UTILS, tool_class = MediaMan, diff --git a/src/plugins/NarrativeWeb.py b/src/plugins/NarrativeWeb.py index 668df68fc..659a5edfc 100644 --- a/src/plugins/NarrativeWeb.py +++ b/src/plugins/NarrativeWeb.py @@ -4,6 +4,7 @@ # Copyright (C) 2000-2007 Donald N. Allingham # Copyright (C) 2007 Johan Gonqvist # Copyright (C) 2007 Gary Burton +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -70,7 +71,7 @@ import gen.lib import const from GrampsCfg import get_researcher import Sort -from PluginUtils import (register_report, FilterOption, EnumeratedListOption, +from PluginUtils import (PluginManager, FilterOption, EnumeratedListOption, PersonOption, BooleanOption, NumberOption, StringOption, DestinationOption, NoteOption, MediaOption) @@ -3152,7 +3153,8 @@ def sort_people(db, handle_list): sorted_lists.append((name, entries)) return sorted_lists -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'navwebpage', category = CATEGORY_WEB, report_class = NavWebReport, diff --git a/src/plugins/NotRelated.py b/src/plugins/NotRelated.py index 79da22001..fd7ffa01d 100644 --- a/src/plugins/NotRelated.py +++ b/src/plugins/NotRelated.py @@ -43,7 +43,7 @@ import gobject # GRAMPS modules # #------------------------------------------------------------------------ -from PluginUtils import register_tool, Tool +from PluginUtils import PluginManager, Tool from ReportBase import ReportUtils from Editors import EditPerson, EditFamily import ManagedWindow @@ -426,7 +426,8 @@ class NotRelatedOptions(Tool.ToolOptions): # # #------------------------------------------------------------------------- -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'not_related', category = Tool.TOOL_UTILS, tool_class = NotRelated, diff --git a/src/plugins/NumberOfAncestorsReport.py b/src/plugins/NumberOfAncestorsReport.py index dc35b0f6a..f67e10ace 100644 --- a/src/plugins/NumberOfAncestorsReport.py +++ b/src/plugins/NumberOfAncestorsReport.py @@ -38,7 +38,7 @@ import math # GRAMPS modules # #------------------------------------------------------------------------ -from PluginUtils import register_report, PersonOption +from PluginUtils import PluginManager, PersonOption from ReportBase import Report, MenuReportOptions, ReportUtils, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI from BasicUtils import name_displayer @@ -189,7 +189,8 @@ class NumberOfAncestorsOptions(MenuReportOptions): # register_report # #------------------------------------------------------------------------- -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'number_of_ancestors_report', category = CATEGORY_TEXT, report_class = NumberOfAncestorsReport, diff --git a/src/plugins/OnThisDay.py b/src/plugins/OnThisDay.py index 866bd412d..18329d894 100644 --- a/src/plugins/OnThisDay.py +++ b/src/plugins/OnThisDay.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham -# Copyright (C) 2007 Brian G. Matherly +# Copyright (C) 2007-2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ Display all events on a particular day. from Simple import SimpleAccess, SimpleDoc, SimpleTable from gettext import gettext as _ -from PluginUtils import register_quick_report +from PluginUtils import PluginManager from ReportBase import CATEGORY_QR_EVENT import gen.lib @@ -137,7 +137,8 @@ def run(database, document, main_event): # Register the report # #------------------------------------------------------------------------ -register_quick_report( +pmgr = PluginManager.get_instance() +pmgr.register_quick_report( name = 'onthisday', category = CATEGORY_QR_EVENT, run_func = run, diff --git a/src/plugins/OwnerEditor.py b/src/plugins/OwnerEditor.py index c70334137..644c2b650 100644 --- a/src/plugins/OwnerEditor.py +++ b/src/plugins/OwnerEditor.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -47,7 +48,7 @@ import GrampsCfg import GrampsDisplay from widgets import MonitoredEntry import ManagedWindow -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager from TransUtils import sgettext as _ #------------------------------------------------------------------------- @@ -189,7 +190,8 @@ class OwnerEditorOptions(Tool.ToolOptions): # Register the plugin tool to plugin manager # #------------------------------------------------------------------------- -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'editowner', category = Tool.TOOL_DBPROC, tool_class = OwnerEditor, diff --git a/src/plugins/PatchNames.py b/src/plugins/PatchNames.py index 9173fd519..5088914d8 100644 --- a/src/plugins/PatchNames.py +++ b/src/plugins/PatchNames.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -45,7 +46,7 @@ import gobject # #------------------------------------------------------------------------- import Utils -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager from QuestionDialog import OkDialog import ManagedWindow import GrampsDisplay @@ -362,7 +363,8 @@ class PatchNamesOptions(Tool.ToolOptions): Tool.ToolOptions.__init__(self, name, person_id) -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'patchnames', category = Tool.TOOL_DBPROC, tool_class = PatchNames, diff --git a/src/plugins/Query.py b/src/plugins/Query.py index 5ecb1e7cc..dda73e8b9 100644 --- a/src/plugins/Query.py +++ b/src/plugins/Query.py @@ -25,7 +25,7 @@ Run a query on the tables from Simple import SimpleAccess, SimpleDoc, SimpleTable from gettext import gettext as _ -from PluginUtils import register_quick_report +from PluginUtils import PluginManager import Utils from ReportBase import CATEGORY_QR_MISC import DateHandler @@ -427,8 +427,8 @@ def run(database, document, query): # Register the report # #------------------------------------------------------------------------ - -register_quick_report( +pmgr = PluginManager.get_instance() +pmgr.register_quick_report( name = 'query', category = CATEGORY_QR_MISC, run_func = run, diff --git a/src/plugins/ReadGrdb.py b/src/plugins/ReadGrdb.py index 3724b2768..ffcb16861 100644 --- a/src/plugins/ReadGrdb.py +++ b/src/plugins/ReadGrdb.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2005-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -50,7 +51,7 @@ from QuestionDialog import ErrorDialog from Errors import HandleError from BasicUtils import UpdateCallback from BasicUtils import name_displayer -from PluginUtils import register_import +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -326,4 +327,5 @@ _filter.set_name(_('GRAMPS 2.x database')) _filter.add_mime_type(_mime_type) _format_name = _('GRAMPS 2.x database') -register_import(importData, _filter, [_mime_type], 0, _format_name) +pmgr = PluginManager.get_instance() +pmgr.register_import(importData, _filter, [_mime_type], 0, _format_name) diff --git a/src/plugins/ReadPkg.py b/src/plugins/ReadPkg.py index 91997132f..7eb187c05 100644 --- a/src/plugins/ReadPkg.py +++ b/src/plugins/ReadPkg.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -56,7 +57,7 @@ import const from GrampsDbUtils import gramps_db_reader_factory from QuestionDialog import ErrorDialog, WarningDialog import Utils -from PluginUtils import register_import +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -154,4 +155,5 @@ _filter.set_name(_('GRAMPS packages')) _filter.add_mime_type(_mime_type) _format_name = _('GRAMPS package') -register_import(impData, _filter, [_mime_type], 0, _format_name) +pmgr = PluginManager.get_instance() +pmgr.register_import(impData, _filter, [_mime_type], 0, _format_name) diff --git a/src/plugins/Rebuild.py b/src/plugins/Rebuild.py index 62d2eb526..0c7b69c99 100644 --- a/src/plugins/Rebuild.py +++ b/src/plugins/Rebuild.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -48,7 +49,7 @@ log = logging.getLogger(".Rebuild") # GRAMPS modules # #------------------------------------------------------------------------- -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager from QuestionDialog import OkDialog from BasicUtils import UpdateCallback @@ -108,7 +109,8 @@ class RebuildOptions(Tool.ToolOptions): # # #------------------------------------------------------------------------- -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'rebuild', category = Tool.TOOL_DBFIX, tool_class = Rebuild, diff --git a/src/plugins/RebuildRefMap.py b/src/plugins/RebuildRefMap.py index a0101f76d..8d8f37786 100644 --- a/src/plugins/RebuildRefMap.py +++ b/src/plugins/RebuildRefMap.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -50,7 +51,7 @@ log = logging.getLogger(".RebuildRefMap") # GRAMPS modules # #------------------------------------------------------------------------- -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager from QuestionDialog import OkDialog from BasicUtils import UpdateCallback @@ -110,7 +111,8 @@ class RebuildRefMapOptions(Tool.ToolOptions): # # #------------------------------------------------------------------------- -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'rebuild_refmap', category = Tool.TOOL_DBFIX, tool_class = RebuildRefMap, diff --git a/src/plugins/References.py b/src/plugins/References.py index a899437b6..fd252af36 100644 --- a/src/plugins/References.py +++ b/src/plugins/References.py @@ -28,7 +28,7 @@ from ReportBase import (CATEGORY_QR_SOURCE, CATEGORY_QR_PERSON, from Simple import SimpleAccess, SimpleDoc, SimpleTable from gettext import gettext as _ -from PluginUtils import register_quick_report +from PluginUtils import PluginManager # mention so that will be translated for below [_('Person'), _('Family'), _('Event'), _('Source'), @@ -93,8 +93,10 @@ refitems = [(CATEGORY_QR_PERSON, 'person', _("Person")), (CATEGORY_QR_PLACE, 'place', _("Place")), (CATEGORY_QR_REPOSITORY, 'repository', _("Repository")), ] +pmgr = PluginManager.get_instance() + for (category,item,trans) in refitems: - register_quick_report( + pmgr.register_quick_report( name = item + 'refereneces', category = category, run_func = lambda db, doc, obj, item=item, trans=trans: \ diff --git a/src/plugins/RelCalc.py b/src/plugins/RelCalc.py index 034675036..b2f25296b 100644 --- a/src/plugins/RelCalc.py +++ b/src/plugins/RelCalc.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -48,7 +49,7 @@ import ManagedWindow from DisplayModels import PeopleModel from QuestionDialog import ErrorDialog -from PluginUtils import Tool, relationship_class, register_tool +from PluginUtils import Tool, PluginManager column_names = [ _('Name'), @@ -79,7 +80,8 @@ class RelCalc(Tool.Tool, ManagedWindow.ManagedWindow): ManagedWindow.ManagedWindow.__init__(self,uistate,[],self.__class__) self.dbstate = dbstate - self.relationship = relationship_class() + pmgr = PluginManager.get_instance() + self.relationship = pmgr.get_relationship_calculator() self.relationship.connect_db_signals(dbstate) base = os.path.dirname(__file__) @@ -257,7 +259,8 @@ class RelCalcOptions(Tool.ToolOptions): # # #------------------------------------------------------------------------- -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'relcalc', category = Tool.TOOL_UTILS, tool_class = RelCalc, diff --git a/src/plugins/RemoveUnused.py b/src/plugins/RemoveUnused.py index 372f6a2cb..00882e5a8 100644 --- a/src/plugins/RemoveUnused.py +++ b/src/plugins/RemoveUnused.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -56,7 +57,7 @@ from gen.lib import StyledText import Errors import ManagedWindow from BasicUtils import UpdateCallback -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager #------------------------------------------------------------------------- # @@ -425,7 +426,8 @@ class CheckOptions(Tool.ToolOptions): # # #------------------------------------------------------------------------ -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'remove_unused', category = Tool.TOOL_DBFIX, tool_class = RemoveUnused, diff --git a/src/plugins/ReorderIds.py b/src/plugins/ReorderIds.py index 2455851f1..51fb565bc 100644 --- a/src/plugins/ReorderIds.py +++ b/src/plugins/ReorderIds.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -40,7 +41,7 @@ from gettext import gettext as _ #------------------------------------------------------------------------ import Utils import gen.lib -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager _findint = re.compile('^[^\d]*(\d+)[^\d]*') @@ -227,7 +228,8 @@ class ReorderIdsOptions(Tool.ToolOptions): # # #------------------------------------------------------------------------- -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'reorder_ids', category = Tool.TOOL_DBPROC, tool_class = ReorderIds, diff --git a/src/plugins/SameSurnames.py b/src/plugins/SameSurnames.py index 512403e5f..e7454af2d 100644 --- a/src/plugins/SameSurnames.py +++ b/src/plugins/SameSurnames.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham -# Copyright (C) 2007 Brian G. Matherly +# Copyright (C) 2007-2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ Display a people who have a person's same surname from Simple import SimpleAccess, SimpleDoc, SimpleTable from gettext import gettext as _ -from PluginUtils import register_quick_report +from PluginUtils import PluginManager from ReportBase import CATEGORY_QR_PERSON from Filters.Rules import Rule from Filters import GenericFilterFactory @@ -95,7 +95,8 @@ def run(database, document, person): # # #------------------------------------------------------------------------ -register_quick_report( +pmgr = PluginManager.get_instance() +pmgr.register_quick_report( name = 'samesurnames', category = CATEGORY_QR_PERSON, run_func = run, diff --git a/src/plugins/SimpleBookTitle.py b/src/plugins/SimpleBookTitle.py index 02b3af14b..d3b628c27 100644 --- a/src/plugins/SimpleBookTitle.py +++ b/src/plugins/SimpleBookTitle.py @@ -33,7 +33,7 @@ from TransUtils import sgettext as _ # gramps modules # #------------------------------------------------------------------------ -from PluginUtils import register_report, NumberOption, StringOption, MediaOption +from PluginUtils import PluginManager, NumberOption, StringOption, MediaOption from Utils import media_path_full from ReportBase import Report, MenuReportOptions, CATEGORY_TEXT, MODE_BKI import BaseDoc @@ -177,7 +177,8 @@ class SimpleBookTitleOptions(MenuReportOptions): # register_report # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'simple_book_title', category = CATEGORY_TEXT, report_class = SimpleBookTitle, diff --git a/src/plugins/SoundGen.py b/src/plugins/SoundGen.py index f84bc8976..3ad09c176 100644 --- a/src/plugins/SoundGen.py +++ b/src/plugins/SoundGen.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -45,7 +46,7 @@ import GrampsDisplay import ManagedWindow import AutoComp from TransUtils import sgettext as _ -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager #------------------------------------------------------------------------- # @@ -142,7 +143,8 @@ class SoundGenOptions(Tool.ToolOptions): # # #------------------------------------------------------------------------- -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'soundgen', category = Tool.TOOL_UTILS, tool_class = SoundGen, diff --git a/src/plugins/StatisticsChart.py b/src/plugins/StatisticsChart.py index 78382cfdc..f6ba69727 100644 --- a/src/plugins/StatisticsChart.py +++ b/src/plugins/StatisticsChart.py @@ -44,7 +44,7 @@ from TransUtils import sgettext as _ from gen.lib import Person, FamilyRelType, EventType # gender and report type names import BaseDoc -from PluginUtils import register_report +from PluginUtils import PluginManager from PluginUtils import BooleanOption, FilterOption, PersonOption, \ EnumeratedListOption, NumberOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ @@ -891,7 +891,8 @@ class StatisticsChartOptions(MenuReportOptions): # Register report/options # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'statistics_chart', category = CATEGORY_DRAW, report_class = StatisticsChart, diff --git a/src/plugins/Summary.py b/src/plugins/Summary.py index c36ebc712..4121c6538 100644 --- a/src/plugins/Summary.py +++ b/src/plugins/Summary.py @@ -37,7 +37,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------ import gen.lib -from PluginUtils import register_report +from PluginUtils import PluginManager from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI import BaseDoc @@ -291,7 +291,8 @@ class SummaryOptions(MenuReportOptions): # register_report # #------------------------------------------------------------------------- -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'summary', category = CATEGORY_TEXT, report_class = SummaryReport, diff --git a/src/plugins/TestcaseGenerator.py b/src/plugins/TestcaseGenerator.py index 0e2504330..b371c1492 100644 --- a/src/plugins/TestcaseGenerator.py +++ b/src/plugins/TestcaseGenerator.py @@ -3,6 +3,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Martin Hawlisch, Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -44,7 +45,7 @@ import gtk # #------------------------------------------------------------------------- import gen.lib -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager import Utils import LdsUtils @@ -1389,7 +1390,8 @@ class TestcaseGeneratorOptions(Tool.ToolOptions): #------------------------------------------------------------------------- if __debug__: - register_tool( + pmgr = PluginManager.get_instance() + pmgr.register_tool( name = 'testcasegenerator', category = Tool.TOOL_DEBUG, tool_class = TestcaseGenerator, diff --git a/src/plugins/TimeLine.py b/src/plugins/TimeLine.py index 22fa653dc..c0aac65a6 100644 --- a/src/plugins/TimeLine.py +++ b/src/plugins/TimeLine.py @@ -37,7 +37,7 @@ from TransUtils import sgettext as _ # GRAMPS modules # #------------------------------------------------------------------------ -from PluginUtils import register_report +from PluginUtils import PluginManager from PluginUtils import FilterOption, EnumeratedListOption, \ PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ @@ -455,7 +455,8 @@ class TimeLineOptions(MenuReportOptions): # # #------------------------------------------------------------------------ -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'timeline', category = CATEGORY_DRAW, report_class = TimeLine, diff --git a/src/plugins/Verify.py b/src/plugins/Verify.py index acbaa63fb..a4f17f5fc 100644 --- a/src/plugins/Verify.py +++ b/src/plugins/Verify.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -55,7 +56,7 @@ import Utils import GrampsDisplay from ManagedWindow import ManagedWindow from BasicUtils import UpdateCallback -from PluginUtils import Tool, register_tool +from PluginUtils import Tool, PluginManager from TransUtils import sgettext as _ #------------------------------------------------------------------------- # @@ -1568,7 +1569,8 @@ class InvalidDeathDate(PersonRule): # # #------------------------------------------------------------------------- -register_tool( +pmgr = PluginManager.get_instance() +pmgr.register_tool( name = 'verify', category = Tool.TOOL_UTILS, tool_class = Verify, diff --git a/src/plugins/WebCal.py b/src/plugins/WebCal.py index 463ee4151..319e7b4b7 100644 --- a/src/plugins/WebCal.py +++ b/src/plugins/WebCal.py @@ -67,7 +67,7 @@ import gen.lib import const import BaseDoc from GrampsCfg import get_researcher -from PluginUtils import register_report +from PluginUtils import PluginManager from ReportBase import (Report, ReportUtils, MenuReportOptions, CATEGORY_WEB, MODE_GUI) from PluginUtils import FilterOption, EnumeratedListOption, PersonOption, \ @@ -1219,7 +1219,8 @@ _COUNTRIES = _get_countries() # # #------------------------------------------------------------------------- -register_report( +pmgr = PluginManager.get_instance() +pmgr.register_report( name = 'WebCal', category = CATEGORY_WEB, report_class = WebCalReport, diff --git a/src/plugins/WriteCD.py b/src/plugins/WriteCD.py index 728ffd9c3..50e4b68e2 100644 --- a/src/plugins/WriteCD.py +++ b/src/plugins/WriteCD.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2008 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -75,7 +76,7 @@ except: from GrampsDbUtils import XmlWriter from Utils import media_path_full from QuestionDialog import ErrorDialog, MissingMediaDialog -from PluginUtils import register_export +from PluginUtils import PluginManager _title_string = _("Export to CD") @@ -306,4 +307,5 @@ _description = _('Exporting to CD copies all your data and media ' _config = None _filename = 'burn' -register_export(writeData, _title, _description, _config, _filename) +pmgr = PluginManager.get_instance() +pmgr.register_export(writeData, _title, _description, _config, _filename) diff --git a/src/plugins/WriteFtree.py b/src/plugins/WriteFtree.py index b153bf8ac..9d935272c 100644 --- a/src/plugins/WriteFtree.py +++ b/src/plugins/WriteFtree.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2006, 2008 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -55,7 +56,7 @@ import Utils from Filters import GenericFilter, Rules, build_filter_menu import Errors from QuestionDialog import ErrorDialog -from PluginUtils import register_export +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -312,4 +313,5 @@ _description = _('Web Family Tree format.') _config = (_('Web Family Tree export options'), FtreeWriterOptionBox) _filename = 'wft' -register_export(writeData, _title, _description, _config,_filename) +pmgr = PluginManager.get_instance() +pmgr.register_export(writeData, _title, _description, _config,_filename) diff --git a/src/plugins/WriteGeneWeb.py b/src/plugins/WriteGeneWeb.py index c709595e9..68fbe7f93 100644 --- a/src/plugins/WriteGeneWeb.py +++ b/src/plugins/WriteGeneWeb.py @@ -3,6 +3,7 @@ # # Copyright (C) 2004 Martin Hawlisch # Copyright (C) 2004-2006, 2008 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -56,7 +57,7 @@ from Filters import GenericFilter, Rules, build_filter_menu import Utils import Errors from QuestionDialog import ErrorDialog -from PluginUtils import register_export +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -642,4 +643,5 @@ _description = _('GeneWeb is a web based genealogy program.') _config = (_('GeneWeb export options'), GeneWebWriterOptionBox) _filename = 'gw' -register_export(exportData, _title, _description, _config, _filename) +pmgr = PluginManager.get_instance() +pmgr.register_export(exportData, _title, _description, _config, _filename) diff --git a/src/plugins/WritePkg.py b/src/plugins/WritePkg.py index fd2afd456..175a7cdcd 100644 --- a/src/plugins/WritePkg.py +++ b/src/plugins/WritePkg.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2008 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -58,7 +59,7 @@ import gtk # #------------------------------------------------------------------------- from GrampsDbUtils import XmlWriter -from PluginUtils import register_export +from PluginUtils import PluginManager import Utils #------------------------------------------------------------------------- @@ -226,4 +227,5 @@ _description = _('GRAMPS package is an archived XML database together ' _config = (_('GRAMPS package export options'), ExportOptions.WriterOptionBox) _filename = 'gpkg' -register_export(writeData, _title, _description, _config, _filename) +pmgr = PluginManager.get_instance() +pmgr.register_export(writeData, _title, _description, _config, _filename) diff --git a/src/plugins/all_events.py b/src/plugins/all_events.py index fd43f4e1e..9a195187c 100644 --- a/src/plugins/all_events.py +++ b/src/plugins/all_events.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham -# Copyright (C) 2007 Brian G. Matherly +# Copyright (C) 2007-2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ Display a person's events, both personal and family from Simple import SimpleAccess, by_date, SimpleDoc, SimpleTable from gettext import gettext as _ -from PluginUtils import register_quick_report +from PluginUtils import PluginManager from ReportBase import CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY def run(database, document, person): @@ -137,7 +137,9 @@ def fam_sort(event1, event2): # # #------------------------------------------------------------------------ -register_quick_report( +pmgr = PluginManager.get_instance() + +pmgr.register_quick_report( name = 'all_events', category = CATEGORY_QR_PERSON, run_func = run, @@ -148,7 +150,7 @@ register_quick_report( author_email="don@gramps-project.org" ) -register_quick_report( +pmgr.register_quick_report( name = 'all_events_fam', category = CATEGORY_QR_FAMILY, run_func = run_fam, diff --git a/src/plugins/all_relations.py b/src/plugins/all_relations.py index 2530b211d..93d1c34b6 100644 --- a/src/plugins/all_relations.py +++ b/src/plugins/all_relations.py @@ -2,6 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2007 B. Malengier +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -29,7 +30,7 @@ Display a person's relations to the home person from Simple import SimpleAccess, SimpleDoc from gettext import gettext as _ -from PluginUtils import register_quick_report, relationship_class +from PluginUtils import PluginManager from ReportBase import CATEGORY_QR_PERSON # define the formatting string once as a constant. Since this is reused @@ -57,7 +58,10 @@ class AllRelReport(): self.person = person self.sdb = SimpleAccess(database) self.sdoc = SimpleDoc(document) - self.rel_class = relationship_class() + + pmgr = PluginManager.get_instance() + self.rel_class = pmgr.get_relationship_calculator() + self.msg_list = [] def run(self): @@ -342,7 +346,8 @@ class AllRelReport(): # # #------------------------------------------------------------------------ -register_quick_report( +pmgr = PluginManager.get_instance() +pmgr.register_quick_report( name = 'all_relations', category = CATEGORY_QR_PERSON, run_func = run, diff --git a/src/plugins/lineage.py b/src/plugins/lineage.py index ed3bf6e30..665bcaf00 100644 --- a/src/plugins/lineage.py +++ b/src/plugins/lineage.py @@ -3,6 +3,7 @@ # # Copyright (C) 2000-2007 Donald N. Allingham # Copyright (C) 2007 Jerome Rapinat, B. Malengier +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -34,7 +35,7 @@ Display a person's father or mother lineage import gen.lib from Simple import SimpleAccess, SimpleDoc, SimpleTable from gettext import gettext as _ -from PluginUtils import register_quick_report +from PluginUtils import PluginManager from ReportBase import CATEGORY_QR_PERSON __FMT = "%-30s\t%-12s\t%-12s" @@ -231,8 +232,9 @@ def add_rem(remark, text): # # #------------------------------------------------------------------------ +pmgr = PluginManager.get_instance() -register_quick_report( +pmgr.register_quick_report( name = 'father_lineage', category = CATEGORY_QR_PERSON, run_func = run_father, @@ -243,7 +245,7 @@ register_quick_report( author_email="benny.malengier@gramps-project.org" ) -register_quick_report( +pmgr.register_quick_report( name = 'mother_lineage', category = CATEGORY_QR_PERSON, run_func = run_mother, diff --git a/src/plugins/rel_cs.py b/src/plugins/rel_cs.py index 359837937..8a9888335 100644 --- a/src/plugins/rel_cs.py +++ b/src/plugins/rel_cs.py @@ -3,6 +3,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -31,7 +32,7 @@ import gen.lib import Relationship -from PluginUtils import register_relcalc +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -228,5 +229,6 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # Register this class with the Plugins system # #------------------------------------------------------------------------- -register_relcalc(RelationshipCalculator, +pmgr = PluginManager.get_instance() +pmgr.register_relcalc(RelationshipCalculator, ["cs", "CZ", "cs_CZ", "Ĩesky", "czech", "Czech", "cs_CZ.UTF8", "cs_CZ.UTF-8", "cs_CZ.utf-8", "cs_CZ.utf8"]) diff --git a/src/plugins/rel_da.py b/src/plugins/rel_da.py index 3625f8e06..b08ecef91 100644 --- a/src/plugins/rel_da.py +++ b/src/plugins/rel_da.py @@ -3,6 +3,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2005 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -33,7 +34,7 @@ import gen.lib import Relationship import types -from PluginUtils import register_relcalc +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -204,7 +205,8 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # Register this class with the Plugins system # #------------------------------------------------------------------------- -register_relcalc(RelationshipCalculator, +pmgr = PluginManager.get_instance() +pmgr.register_relcalc(RelationshipCalculator, [ "da", "DA", "da_DK", "danish", "Danish", "da_DK.UTF8", "da_DK@euro", "da_DK.UTF8@euro", "dansk", "Dansk", "da_DK.UTF-8", "da_DK.utf-8", "da_DK.utf8", diff --git a/src/plugins/rel_de.py b/src/plugins/rel_de.py index d0891bb55..e611af110 100644 --- a/src/plugins/rel_de.py +++ b/src/plugins/rel_de.py @@ -4,6 +4,7 @@ # # Copyright (C) 2003-2005 Donald N. Allingham # Copyright (C) 2008 Stefan Siegel +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -45,7 +46,7 @@ import re import gen.lib import Relationship -from PluginUtils import register_relcalc +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -282,7 +283,8 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # #------------------------------------------------------------------------- -register_relcalc(RelationshipCalculator, +pmgr = PluginManager.get_instance() +pmgr.register_relcalc(RelationshipCalculator, ["de","DE","de_DE","deutsch","Deutsch","de_DE.UTF8","de_DE@euro","de_DE.UTF8@euro", "german","German", "de_DE.UTF-8", "de_DE.utf-8", "de_DE.utf8"]) diff --git a/src/plugins/rel_es.py b/src/plugins/rel_es.py index e1765eb3b..a31e8dc62 100644 --- a/src/plugins/rel_es.py +++ b/src/plugins/rel_es.py @@ -3,6 +3,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2005 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -32,7 +33,7 @@ import gen.lib import Relationship import types -from PluginUtils import register_relcalc +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -334,6 +335,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # Register this function with the Plugins system # #------------------------------------------------------------------------- -register_relcalc(RelationshipCalculator, +pmgr = PluginManager.get_instance() +pmgr.register_relcalc(RelationshipCalculator, ["es","ES","es_ES","espanol","Espanol","es_ES.UTF8","es_ES@euro","es_ES.UTF8@euro", "spanish","Spanish", "es_ES.UTF-8", "es_ES.utf-8", "es_ES.utf8"]) diff --git a/src/plugins/rel_fi.py b/src/plugins/rel_fi.py index 8eacb9b1a..7d5df5b87 100644 --- a/src/plugins/rel_fi.py +++ b/src/plugins/rel_fi.py @@ -3,6 +3,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2005 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -33,7 +34,7 @@ import gen.lib import Relationship import types -from PluginUtils import register_relcalc +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -221,6 +222,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # Register this class with the Plugins system # #------------------------------------------------------------------------- -register_relcalc(RelationshipCalculator, +pmgr = PluginManager.get_instance() +pmgr.register_relcalc(RelationshipCalculator, ["fi","FI","fi_FI","finnish","Finnish","fi_FI.UTF8","fi_FI@euro","fi_FI.UTF8@euro", "suomi","Suomi", "fi_FI.UTF-8", "fi_FI.utf-8", "fi_FI.utf8"]) diff --git a/src/plugins/rel_fr.py b/src/plugins/rel_fr.py index c48e6bfad..232e854ae 100644 --- a/src/plugins/rel_fr.py +++ b/src/plugins/rel_fr.py @@ -3,6 +3,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2007 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -29,7 +30,7 @@ import gen.lib import Relationship -from PluginUtils import register_relcalc +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -584,7 +585,8 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # #------------------------------------------------------------------------- -register_relcalc(RelationshipCalculator, +pmgr = PluginManager.get_instance() +pmgr.register_relcalc(RelationshipCalculator, ["fr", "FR", "fr_FR", "fr_CA", "francais", "Francais", "fr_FR.UTF8", "fr_FR@euro", "fr_FR.UTF8@euro", "french","French", "fr_FR.UTF-8", "fr_FR.utf-8", "fr_FR.utf8", diff --git a/src/plugins/rel_hu.py b/src/plugins/rel_hu.py index 39a3bc002..38a753a67 100644 --- a/src/plugins/rel_hu.py +++ b/src/plugins/rel_hu.py @@ -3,6 +3,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -32,7 +33,7 @@ import gen.lib import Relationship -from PluginUtils import register_relcalc +from PluginUtils import PluginManager import types #------------------------------------------------------------------------- @@ -354,7 +355,8 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # #------------------------------------------------------------------------- -register_relcalc(RelationshipCalculator, +pmgr = PluginManager.get_instance() +pmgr.register_relcalc(RelationshipCalculator, ["hu", "HU", "hu_HU", "hu_HU.utf8", "hu_HU.UTF8"]) # Local variables: diff --git a/src/plugins/rel_it.py b/src/plugins/rel_it.py index d8d0073d3..8ff52d1aa 100644 --- a/src/plugins/rel_it.py +++ b/src/plugins/rel_it.py @@ -4,6 +4,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2005 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -37,7 +38,7 @@ import gen.lib import Relationship import types -from PluginUtils import register_relcalc +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -510,7 +511,8 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # Function registration # #------------------------------------------------------------------------- -register_relcalc(RelationshipCalculator, +pmgr = PluginManager.get_instance() +pmgr.register_relcalc(RelationshipCalculator, ["it", "IT", "it_IT", "it_IT@euro", "it_IT.utf8"]) if __name__ == "__main__": diff --git a/src/plugins/rel_nl.py b/src/plugins/rel_nl.py index 046b1ba6e..6151c4cd2 100644 --- a/src/plugins/rel_nl.py +++ b/src/plugins/rel_nl.py @@ -3,6 +3,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2005 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -29,7 +30,7 @@ import gen.lib import Relationship -from PluginUtils import register_relcalc +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -542,7 +543,8 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # Register this class with the Plugins system # #------------------------------------------------------------------------- -register_relcalc(RelationshipCalculator, +pmgr = PluginManager.get_instance() +pmgr.register_relcalc(RelationshipCalculator, ["nl", "NL", "nl_NL", "nl_BE", "nederlands", "Nederlands", "nl_NL.UTF8", "nl_BE.UTF8","nl_NL@euro", "nl_NL.UTF8@euro","nl_BE@euro", "dutch","Dutch", "nl_NL.UTF-8", "nl_BE.UTF-8","nl_NL.utf-8", diff --git a/src/plugins/rel_no.py b/src/plugins/rel_no.py index 038cb4247..faf747802 100644 --- a/src/plugins/rel_no.py +++ b/src/plugins/rel_no.py @@ -3,6 +3,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2005 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -33,7 +34,7 @@ import gen.lib import Relationship import types -from PluginUtils import register_relcalc +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -271,7 +272,8 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # Register this class with the Plugins system # #------------------------------------------------------------------------- -register_relcalc(RelationshipCalculator, +pmgr = PluginManager.get_instance() +pmgr.register_relcalc(RelationshipCalculator, ["nb","nn","no", "nb_NO","nn_NO","no_NO","nb_NO.UTF8","nn_NO.UTF8","no_NO.UTF8", "nb_NO.UTF-8","nn_NO.UTF-8","no_NO.UTF-8", "nb_NO.utf-8","nn_NO.utf-8","no_NO.utf-8", diff --git a/src/plugins/rel_pl.py b/src/plugins/rel_pl.py index 9eafed9a2..ad784ca63 100644 --- a/src/plugins/rel_pl.py +++ b/src/plugins/rel_pl.py @@ -3,6 +3,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2005 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -38,7 +39,7 @@ import gen.lib import Relationship import types from gettext import gettext as _ -from PluginUtils import register_relcalc +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -886,7 +887,8 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # Register this class with the Plugins system # #------------------------------------------------------------------------- -register_relcalc(RelationshipCalculator, +pmgr = PluginManager.get_instance() +pmgr.register_relcalc(RelationshipCalculator, ["pl", "PL", "pl_PL", "polski", "Polski", "pl_PL.UTF-8", "pl_PL.UTF8", "pl_PL.utf-8", "pl_PL.utf8", "pl_PL.iso-8859-2", "pl_PL.iso8859-2", diff --git a/src/plugins/rel_pt.py b/src/plugins/rel_pt.py index 0621c9561..63ce31da9 100644 --- a/src/plugins/rel_pt.py +++ b/src/plugins/rel_pt.py @@ -3,6 +3,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2005 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -34,7 +35,7 @@ import gen.lib import Relationship import types from gettext import gettext as _ -from PluginUtils import register_relcalc +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -326,7 +327,8 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # Register this function with the Plugins system # #------------------------------------------------------------------------- -register_relcalc(RelationshipCalculator, +pmgr = PluginManager.get_instance() +pmgr.register_relcalc(RelationshipCalculator, ["pt","PT","pt_PT","pt_BR","portugues","Portugues","pt_PT.UTF8","pt_BR.UTF8", "pt_PT@euro","pt_PT.UTF8@euro","pt_PT.UTF-8","pt_BR.UTF-8", "pt_PT.utf-8","pt_BR.utf-8","pt_PT.utf8","pt_BR.utf8"]) diff --git a/src/plugins/rel_ru.py b/src/plugins/rel_ru.py index fa81985e6..38540d272 100644 --- a/src/plugins/rel_ru.py +++ b/src/plugins/rel_ru.py @@ -3,6 +3,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2005 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -32,7 +33,7 @@ import gen.lib import Relationship import types -from PluginUtils import register_relcalc +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -265,5 +266,6 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # Register this class with the Plugins system # #------------------------------------------------------------------------- -register_relcalc(RelationshipCalculator, +pmgr = PluginManager.get_instance() +pmgr.register_relcalc(RelationshipCalculator, ["ru","RU","ru_RU","koi8r","ru_koi8r","russian","Russian","ru_RU.koi8r","ru_RU.KOI8-R","ru_RU.utf8","ru_RU.UTF8", "ru_RU.utf-8","ru_RU.UTF-8","ru_RU.iso88595","ru_RU.iso8859-5","ru_RU.iso-8859-5"]) diff --git a/src/plugins/rel_sk.py b/src/plugins/rel_sk.py index 6c470a899..a56c538ef 100644 --- a/src/plugins/rel_sk.py +++ b/src/plugins/rel_sk.py @@ -3,6 +3,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2005 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -31,7 +32,7 @@ import gen.lib import Relationship import types -from PluginUtils import register_relcalc +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -229,5 +230,6 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # Register this class with the Plugins system # #------------------------------------------------------------------------- -register_relcalc(RelationshipCalculator, +pmgr = PluginManager.get_instance() +pmgr.register_relcalc(RelationshipCalculator, ["sk", "SK", "sk_SK", "slovensky", "slovak", "Slovak", "sk_SK.UTF8", "sk_SK.UTF-8", "sk_SK.utf-8", "sk_SK.utf8"]) diff --git a/src/plugins/rel_sv.py b/src/plugins/rel_sv.py index 9f333b7a8..eb2c5e7a7 100644 --- a/src/plugins/rel_sv.py +++ b/src/plugins/rel_sv.py @@ -3,6 +3,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2006 Donald N. Allingham +# Copyright (C) 2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -33,7 +34,7 @@ import gen.lib import Relationship -from PluginUtils import register_relcalc +from PluginUtils import PluginManager #------------------------------------------------------------------------- # @@ -516,7 +517,8 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # Register this class with the Plugins system # #------------------------------------------------------------------------- -register_relcalc(RelationshipCalculator, +pmgr = PluginManager.get_instance() +pmgr.register_relcalc(RelationshipCalculator, ["sv","SV","sv_SE","swedish","Swedish","sv_SE.UTF8","sv_SE@euro","sv_SE.UTF8@euro", "svenska","Svenska", "sv_SE.UTF-8", "sv_SE.utf-8", "sv_SE.utf8"]) diff --git a/src/plugins/siblings.py b/src/plugins/siblings.py index 46c754f18..305a6c6c1 100644 --- a/src/plugins/siblings.py +++ b/src/plugins/siblings.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham -# Copyright (C) 2007 Brian G. Matherly +# Copyright (C) 2007-2008 Brian G. Matherly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ Display a person's siblings in a report window from Simple import SimpleAccess, SimpleDoc, SimpleTable from gettext import gettext as _ -from PluginUtils import register_quick_report, relationship_class +from PluginUtils import PluginManager from ReportBase import CATEGORY_QR_PERSON def run(database, document, person): @@ -37,7 +37,9 @@ def run(database, document, person): sdb = SimpleAccess(database) sdoc = SimpleDoc(document) stab = SimpleTable(sdb) - rel_class = relationship_class() + pmgr = PluginManager.get_instance() + rel_class = pmgr.get_relationship_calculator() + # display the title sdoc.title(_("Siblings of %s") % sdb.name(person)) sdoc.paragraph("") @@ -67,7 +69,8 @@ def run(database, document, person): # # #------------------------------------------------------------------------ -register_quick_report( +pmgr = PluginManager.get_instance() +pmgr.register_quick_report( name = 'siblings', category = CATEGORY_QR_PERSON, run_func = run,