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:
@@ -5,11 +5,9 @@ pkgdatadir = $(datadir)/@PACKAGE@/ReportBase
|
||||
pkgdata_PYTHON = \
|
||||
__init__.py\
|
||||
_Bibliography.py\
|
||||
_BookFormatComboBox.py\
|
||||
_CommandLineReport.py\
|
||||
_Constants.py\
|
||||
_DocReportDialog.py\
|
||||
_DrawFormatComboBox.py\
|
||||
_DrawReportDialog.py\
|
||||
_Endnotes.py\
|
||||
_FileEntry.py\
|
||||
@@ -23,7 +21,6 @@ pkgdata_PYTHON = \
|
||||
_StyleComboBox.py\
|
||||
_StyleEditor.py\
|
||||
_TemplateParser.py\
|
||||
_TextFormatComboBox.py\
|
||||
_TextReportDialog.py\
|
||||
_WebReportDialog.py
|
||||
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id:_BookFormatComboBox.py 9912 2008-01-22 09:17:46Z acraphae $
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK libraries
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
import gobject
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS classes
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Config
|
||||
import PluginUtils
|
||||
import gen
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# get_text_doc_menu
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class BookFormatComboBox(gtk.ComboBox):
|
||||
|
||||
def __init__(self):
|
||||
pmgr = gen.plug.PluginManager.get_instance()
|
||||
self.__book_doc_list = pmgr.get_book_doc_list()
|
||||
self.__book_doc_list.sort()
|
||||
gtk.ComboBox.__init__(self)
|
||||
|
||||
def set(self, callback, obj=None, active=None):
|
||||
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)
|
||||
|
||||
out_pref = Config.get(Config.OUTPUT_PREFERENCE)
|
||||
index = 0
|
||||
active_index = 0
|
||||
self.data = []
|
||||
for item in self.__book_doc_list:
|
||||
self.data.append(item)
|
||||
name = item[0]
|
||||
self.store.append(row=[name])
|
||||
if item[5] == active:
|
||||
active_index = index
|
||||
elif not active and name == out_pref:
|
||||
active_index = index
|
||||
index += 1
|
||||
self.set_active(active_index)
|
||||
|
||||
def get_reference(self):
|
||||
return self.data[self.get_active()][1]
|
||||
|
||||
def get_label(self):
|
||||
return self.data[self.get_active()][0]
|
||||
|
||||
def get_paper(self):
|
||||
return self.data[self.get_active()][2]
|
||||
|
||||
def get_ext(self):
|
||||
return self.data[self.get_active()][4]
|
||||
|
||||
def is_file_output(self):
|
||||
return len(self.get_ext()) > 0
|
||||
|
||||
def get_clname(self):
|
||||
return self.data[self.get_active()][5]
|
||||
@@ -108,6 +108,21 @@ class CommandLineReport:
|
||||
|
||||
def __init__(self, database, name, category, option_class, options_str_dict,
|
||||
noopt=False):
|
||||
|
||||
pmgr = gen.plug.PluginManager.get_instance()
|
||||
self.__textdoc_plugins = []
|
||||
self.__drawdoc_plugins = []
|
||||
self.__bookdoc_plugins = []
|
||||
for plugin in pmgr.get_docgen_plugins():
|
||||
if plugin.get_text_support() and plugin.get_extension():
|
||||
self.__textdoc_plugins.append(plugin)
|
||||
if plugin.get_draw_support() and plugin.get_extension():
|
||||
self.__drawdoc_plugins.append(plugin)
|
||||
if plugin.get_text_support() and \
|
||||
plugin.get_draw_support() and \
|
||||
plugin.get_extension():
|
||||
self.__bookdoc_plugins.append(plugin)
|
||||
|
||||
self.database = database
|
||||
self.category = category
|
||||
self.format = None
|
||||
@@ -125,11 +140,6 @@ class CommandLineReport:
|
||||
"""
|
||||
Initialize the options that are hard-coded into the report system.
|
||||
"""
|
||||
pmgr = gen.plug.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(),
|
||||
@@ -142,7 +152,7 @@ class CommandLineReport:
|
||||
|
||||
self.options_help = {
|
||||
'of' : ["=filename", "Output file name. MANDATORY", ""],
|
||||
'off' : ["=format", "Output file format.", ""],
|
||||
'off' : ["=format", "Output file format.", []],
|
||||
'style' : ["=name", "Style name.", ""],
|
||||
'papers' : ["=name", "Paper size name.", ""],
|
||||
'papero' : ["=num", "Paper orientation number.", ""],
|
||||
@@ -156,14 +166,17 @@ class CommandLineReport:
|
||||
"whatever_name")
|
||||
|
||||
if self.category == CATEGORY_TEXT:
|
||||
self.options_help['off'][2] = \
|
||||
[ item[6] for item in _textdoc_list ]
|
||||
for plugin in self.__textdoc_plugins:
|
||||
self.options_help['off'][2].append(
|
||||
plugin.get_extension() + "\t" + plugin.get_description() )
|
||||
elif self.category == CATEGORY_DRAW:
|
||||
self.options_help['off'][2] = \
|
||||
[ item[6] for item in _drawdoc_list ]
|
||||
for plugin in self.__drawdoc_plugins:
|
||||
self.options_help['off'][2].append(
|
||||
plugin.get_extension() + "\t" + plugin.get_description() )
|
||||
elif self.category == CATEGORY_BOOK:
|
||||
self.options_help['off'][2] = \
|
||||
[ item[6] for item in _bookdoc_list ]
|
||||
for plugin in self.__bookdoc_plugins:
|
||||
self.options_help['off'][2].append(
|
||||
plugin.get_extension() + "\t" + plugin.get_description() )
|
||||
else:
|
||||
self.options_help['off'][2] = "NA"
|
||||
|
||||
@@ -284,29 +297,27 @@ class CommandLineReport:
|
||||
|
||||
self.option_class.handler.output = self.options_dict['of']
|
||||
|
||||
pmgr = gen.plug.PluginManager.get_instance()
|
||||
|
||||
if self.category == CATEGORY_TEXT:
|
||||
for item in pmgr.get_text_doc_list():
|
||||
if item[6] == self.options_dict['off']:
|
||||
self.format = item[1]
|
||||
for plugin in self.__textdoc_plugins:
|
||||
if plugin.get_extension() == self.options_dict['off']:
|
||||
self.format = plugin.get_basedoc()
|
||||
if self.format is None:
|
||||
# Pick the first one as the default.
|
||||
self.format = pmgr.get_text_doc_list()[0][1]
|
||||
self.format = self.__textdoc_plugins[0].get_basedoc()
|
||||
elif self.category == CATEGORY_DRAW:
|
||||
for item in pmgr.get_draw_doc_list():
|
||||
if item[6] == self.options_dict['off']:
|
||||
self.format = item[1]
|
||||
for plugin in self.__drawdoc_plugins:
|
||||
if plugin.get_extension() == self.options_dict['off']:
|
||||
self.format = plugin.get_basedoc()
|
||||
if self.format is None:
|
||||
# Pick the first one as the default.
|
||||
self.format = pmgr.get_draw_doc_list()[0][1]
|
||||
self.format = self.__drawdoc_plugins[0].get_basedoc()
|
||||
elif self.category == CATEGORY_BOOK:
|
||||
for item in pmgr.get_book_doc_list():
|
||||
if item[6] == self.options_dict['off']:
|
||||
self.format = item[1]
|
||||
for plugin in self.__bookdoc_plugins:
|
||||
if plugin.get_extension() == self.options_dict['off']:
|
||||
self.format = plugin.get_basedoc()
|
||||
if self.format is None:
|
||||
# Pick the first one as the default.
|
||||
self.format = pmgr.get_book_doc_list()[0][1]
|
||||
self.format = self.__bookdoc_plugins[0].get_basedoc()
|
||||
else:
|
||||
self.format = None
|
||||
|
||||
|
||||
@@ -104,7 +104,8 @@ class DocReportDialog(ReportDialog):
|
||||
file format. For example, a HTML document doesn't need any
|
||||
paper size/orientation options, but it does need a template
|
||||
file. Those chances are made here."""
|
||||
if obj.is_file_output():
|
||||
docgen_plugin = obj.get_active_plugin()
|
||||
if docgen_plugin.get_extension():
|
||||
self.open_with_app.set_sensitive (True)
|
||||
else:
|
||||
self.open_with_app.set_sensitive (False)
|
||||
@@ -114,7 +115,7 @@ class DocReportDialog(ReportDialog):
|
||||
|
||||
if self.page_html_added:
|
||||
self.notebook.remove_page(0)
|
||||
if obj.get_paper() == 1:
|
||||
if docgen_plugin.get_paper_used():
|
||||
self.paper_label = gtk.Label('<b>%s</b>'%_("Paper Options"))
|
||||
self.paper_label.set_use_markup(True)
|
||||
self.notebook.insert_page(self.paper_frame,self.paper_label,0)
|
||||
@@ -125,15 +126,12 @@ class DocReportDialog(ReportDialog):
|
||||
self.notebook.insert_page(self.html_table,self.html_label,0)
|
||||
self.html_table.show_all()
|
||||
|
||||
if obj.is_file_output():
|
||||
ext_val = docgen_plugin.get_extension()
|
||||
if ext_val:
|
||||
fname = self.target_fileentry.get_full_path(0)
|
||||
(spath, ext) = os.path.splitext(fname)
|
||||
|
||||
ext_val = obj.get_ext()
|
||||
if ext_val:
|
||||
fname = spath + ext_val
|
||||
else:
|
||||
fname = spath
|
||||
|
||||
fname = spath + "." + ext_val
|
||||
self.target_fileentry.set_filename(fname)
|
||||
self.target_fileentry.set_sensitive(True)
|
||||
else:
|
||||
@@ -142,8 +140,8 @@ class DocReportDialog(ReportDialog):
|
||||
|
||||
# Does this report format use styles?
|
||||
if self.style_button:
|
||||
self.style_button.set_sensitive(obj.get_styles())
|
||||
self.style_menu.set_sensitive(obj.get_styles())
|
||||
self.style_button.set_sensitive(docgen_plugin.get_style_support())
|
||||
self.style_menu.set_sensitive(docgen_plugin.get_style_support())
|
||||
self.page_html_added = True
|
||||
|
||||
def setup_format_frame(self):
|
||||
@@ -165,13 +163,13 @@ class DocReportDialog(ReportDialog):
|
||||
yoptions=gtk.SHRINK)
|
||||
self.row += 1
|
||||
|
||||
ext = self.format_menu.get_ext()
|
||||
ext = self.format_menu.get_active_plugin().get_extension()
|
||||
if ext is None:
|
||||
ext = ""
|
||||
else:
|
||||
spath = self.get_default_directory()
|
||||
base = self.get_default_basename()
|
||||
spath = os.path.normpath("%s/%s%s" % (spath, base, ext))
|
||||
spath = os.path.normpath("%s/%s.%s" % (spath, base, ext))
|
||||
self.target_fileentry.set_filename(spath)
|
||||
|
||||
def setup_report_options_frame(self):
|
||||
@@ -253,8 +251,9 @@ class DocReportDialog(ReportDialog):
|
||||
def parse_format_frame(self):
|
||||
"""Parse the format frame of the dialog. Save the user
|
||||
selected output format for later use."""
|
||||
self.format = self.format_menu.get_reference()
|
||||
format_name = self.format_menu.get_clname()
|
||||
docgen_plugin = self.format_menu.get_active_plugin()
|
||||
self.format = docgen_plugin.get_basedoc()
|
||||
format_name = docgen_plugin.get_extension()
|
||||
self.options.handler.set_format_name(format_name)
|
||||
|
||||
def parse_html_frame(self):
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id:_DrawFormatComboBox.py 9912 2008-01-22 09:17:46Z acraphae $
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
import Config
|
||||
import gen
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# get_text_doc_menu
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DrawFormatComboBox(gtk.ComboBox):
|
||||
|
||||
def __init__(self):
|
||||
pmgr = gen.plug.PluginManager.get_instance()
|
||||
self.__drawdoc_list = pmgr.get_draw_doc_list()
|
||||
self.__drawdoc_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)
|
||||
cell = gtk.CellRendererText()
|
||||
self.pack_start(cell,True)
|
||||
self.add_attribute(cell,'text',0)
|
||||
|
||||
out_pref = Config.get(Config.OUTPUT_PREFERENCE)
|
||||
index = 0
|
||||
active_index = 0
|
||||
for item in self.__drawdoc_list:
|
||||
if tables and item[2] == 0:
|
||||
continue
|
||||
name = item[0]
|
||||
self.store.append(row=[name])
|
||||
#if callback:
|
||||
# menuitem.connect("activate",callback)
|
||||
if item[5] == active:
|
||||
active_index = index
|
||||
elif not active and name == out_pref:
|
||||
active_index = index
|
||||
index = index + 1
|
||||
self.set_active(active_index)
|
||||
|
||||
def get_reference(self):
|
||||
return self.__drawdoc_list[self.get_active()][1]
|
||||
|
||||
def get_label(self):
|
||||
return self.__drawdoc_list[self.get_active()][0]
|
||||
|
||||
def get_paper(self):
|
||||
return self.__drawdoc_list[self.get_active()][2]
|
||||
|
||||
def get_styles(self):
|
||||
return self.__drawdoc_list[self.get_active()][3]
|
||||
|
||||
def get_ext(self):
|
||||
return self.__drawdoc_list[self.get_active()][4]
|
||||
|
||||
def is_file_output(self):
|
||||
return len(self.get_ext()) > 0
|
||||
|
||||
def get_clname(self):
|
||||
return self.__drawdoc_list[self.get_active()][5]
|
||||
@@ -20,32 +20,88 @@
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
import gobject
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from _Constants import CATEGORY_DRAW
|
||||
from _DocReportDialog import DocReportDialog
|
||||
from _DrawFormatComboBox import DrawFormatComboBox
|
||||
from gen.plug import PluginManager
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# _DrawFormatComboBox
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class _DrawFormatComboBox(gtk.ComboBox):
|
||||
"""
|
||||
This class is a combo box that allows the selection of a docgen plugin
|
||||
from all drawdoc plugins.
|
||||
"""
|
||||
def __init__(self, active):
|
||||
|
||||
gtk.ComboBox.__init__(self)
|
||||
|
||||
pmgr = PluginManager.get_instance()
|
||||
self.__drawdoc_plugins = []
|
||||
for plugin in pmgr.get_docgen_plugins():
|
||||
if plugin.get_draw_support():
|
||||
self.__drawdoc_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.__drawdoc_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.__drawdoc_plugins[self.get_active()]
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
#
|
||||
# Drawing reports
|
||||
# DrawReportDialog
|
||||
#
|
||||
#-----------------------------------------------------------------------
|
||||
class DrawReportDialog(DocReportDialog):
|
||||
"""A class of ReportDialog customized for drawing based reports."""
|
||||
"""
|
||||
A class of ReportDialog customized for drawing based reports.
|
||||
"""
|
||||
def __init__(self, dbstate, uistate, opt, 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 drawing report. See the ReportDialog class for
|
||||
more information."""
|
||||
more information.
|
||||
"""
|
||||
self.format_menu = None
|
||||
self.category = CATEGORY_DRAW
|
||||
DocReportDialog.__init__(self, dbstate, uistate, opt,
|
||||
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 drawing report."""
|
||||
self.format_menu = DrawFormatComboBox()
|
||||
self.format_menu.set(False,self.doc_type_changed, None, active)
|
||||
"""
|
||||
Build a menu of document types that are appropriate for
|
||||
this drawing report.
|
||||
"""
|
||||
self.format_menu = _DrawFormatComboBox( active )
|
||||
|
||||
@@ -860,7 +860,6 @@ class GraphvizFormatComboBox(gtk.ComboBox):
|
||||
self.pack_start(cell, True)
|
||||
self.add_attribute(cell, 'text', 0)
|
||||
|
||||
out_pref = Config.get(Config.OUTPUT_PREFERENCE)
|
||||
index = 0
|
||||
active_index = 0
|
||||
for item in _FORMATS:
|
||||
@@ -868,8 +867,6 @@ class GraphvizFormatComboBox(gtk.ComboBox):
|
||||
self.store.append(row=[name])
|
||||
if item['type'] == active:
|
||||
active_index = index
|
||||
elif not active and name == out_pref:
|
||||
active_index = index
|
||||
index = index + 1
|
||||
self.set_active(active_index)
|
||||
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id:_TextFormatComboBox.py 9912 2008-01-22 09:17:46Z acraphae $
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
import Config
|
||||
import gen
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# get_text_doc_menu
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class TextFormatComboBox(gtk.ComboBox):
|
||||
|
||||
def __init__(self):
|
||||
pmgr = gen.plug.PluginManager.get_instance()
|
||||
self.__text_doc_list = pmgr.get_text_doc_list()
|
||||
self.__text_doc_list.sort()
|
||||
gtk.ComboBox.__init__(self)
|
||||
|
||||
def set(self, callback, obj=None, active=None):
|
||||
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)
|
||||
|
||||
out_pref = Config.get(Config.OUTPUT_PREFERENCE)
|
||||
index = 0
|
||||
active_index = 0
|
||||
for item in self.__text_doc_list:
|
||||
name = item[0]
|
||||
self.store.append(row=[name])
|
||||
if item[5] == active:
|
||||
active_index = index
|
||||
elif not active and name == out_pref:
|
||||
active_index = index
|
||||
index = index + 1
|
||||
self.set_active(active_index)
|
||||
|
||||
def get_label(self):
|
||||
return self.__text_doc_list[self.get_active()][0]
|
||||
|
||||
def get_reference(self):
|
||||
return self.__text_doc_list[self.get_active()][1]
|
||||
|
||||
def get_paper(self):
|
||||
return self.__text_doc_list[self.get_active()][2]
|
||||
|
||||
def get_styles(self):
|
||||
return self.__text_doc_list[self.get_active()][3]
|
||||
|
||||
def get_ext(self):
|
||||
return self.__text_doc_list[self.get_active()][4]
|
||||
|
||||
def is_file_output(self):
|
||||
return len(self.get_ext()) > 0
|
||||
|
||||
def get_clname(self):
|
||||
return self.__text_doc_list[self.get_active()][5]
|
||||
@@ -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 )
|
||||
|
||||
Reference in New Issue
Block a user