Add DocGenPlugin to be used to register all docgen plugins. This replaces the array of variables which was more difficult to read.

svn: r12359
This commit is contained in:
Brian Matherly
2009-03-19 02:24:29 +00:00
parent 82f5f01a6a
commit c56c25b932
25 changed files with 545 additions and 497 deletions

View File

@@ -2,6 +2,7 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2001-2006 Donald N. Allingham
# Copyright (C) 2008-2009 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
@@ -20,34 +21,88 @@
# $Id$
#-------------------------------------------------------------------------
#
# GTK modules
#
#-------------------------------------------------------------------------
import gtk
import gobject
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from gen.plug import PluginManager
from _Constants import CATEGORY_TEXT
from _DocReportDialog import DocReportDialog
from _TextFormatComboBox import TextFormatComboBox
#-------------------------------------------------------------------------
#
# _TextFormatComboBox
#
#-------------------------------------------------------------------------
class _TextFormatComboBox(gtk.ComboBox):
"""
This class is a combo box that allows the selection of a docgen plugin
from all textdoc plugins.
"""
def __init__(self, active):
gtk.ComboBox.__init__(self)
pmgr = PluginManager.get_instance()
self.__textdoc_plugins = []
for plugin in pmgr.get_docgen_plugins():
if plugin.get_text_support():
self.__textdoc_plugins.append(plugin)
self.store = gtk.ListStore(gobject.TYPE_STRING)
self.set_model(self.store)
cell = gtk.CellRendererText()
self.pack_start(cell, True)
self.add_attribute(cell, 'text', 0)
index = 0
active_index = 0
for plugin in self.__textdoc_plugins:
name = plugin.get_name()
self.store.append(row=[name])
if plugin.get_extension() == active:
active_index = index
index = index + 1
self.set_active(active_index)
def get_active_plugin(self):
"""
Get the plugin represented by the currently active selection.
"""
return self.__textdoc_plugins[self.get_active()]
#-----------------------------------------------------------------------
#
# Textual reports
# TextReportDialog
#
#-----------------------------------------------------------------------
class TextReportDialog(DocReportDialog):
"""A class of ReportDialog customized for text based reports."""
"""
A class of ReportDialog customized for text based reports.
"""
def __init__(self, dbstate, uistate, options, name, translated_name):
"""Initialize a dialog to request that the user select options
"""
Initialize a dialog to request that the user select options
for a basic text report. See the ReportDialog class for more
information."""
information.
"""
self.format_menu = None
self.category = CATEGORY_TEXT
DocReportDialog.__init__(self, dbstate, uistate, options,
name, translated_name)
#------------------------------------------------------------------------
#
# Functions related to selecting/changing the current file format.
#
#------------------------------------------------------------------------
def make_doc_menu(self,active=None):
"""Build a menu of document types that are appropriate for
this text report. This menu will be generated based upon
whether the document requires table support, etc."""
self.format_menu = TextFormatComboBox()
self.format_menu.set(self.doc_type_changed, None, active)
def make_doc_menu(self, active=None):
"""
Build a menu of document types that are appropriate for
this text report.
"""
self.format_menu = _TextFormatComboBox( active )