2003-07-15 18:39:49 +05:30
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-03-10 02:19:29 +05:30
|
|
|
# Copyright (C) 2003-2006 Donald N. Allingham
|
2008-05-19 00:54:28 +05:30
|
|
|
# Copyright (C) 2008 Brian G. Matherly
|
2003-07-15 18:39:49 +05:30
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
|
|
|
|
# Written by Alex Roitman,
|
|
|
|
# largely based on the SimpleBookTitle.py by Don Allingham
|
2005-01-09 01:49:06 +05:30
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# python modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2005-01-09 01:49:06 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
2003-07-15 18:39:49 +05:30
|
|
|
#
|
2005-01-09 01:49:06 +05:30
|
|
|
# gtk
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2003-07-15 18:39:49 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2008-09-27 19:26:17 +05:30
|
|
|
from PluginUtils import PluginManager
|
|
|
|
from gen.plug.menu import TextOption
|
2008-01-06 02:12:05 +05:30
|
|
|
from ReportBase import Report, MenuReportOptions, CATEGORY_TEXT, MODE_BKI
|
2003-09-02 06:17:09 +05:30
|
|
|
import BaseDoc
|
2003-07-15 18:39:49 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# CustomText
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2006-06-01 10:09:40 +05:30
|
|
|
class CustomText(Report):
|
2003-07-15 18:39:49 +05:30
|
|
|
|
2008-02-20 10:22:10 +05:30
|
|
|
def __init__(self, database, options_class):
|
2005-01-09 01:49:06 +05:30
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
Create CustomText object that produces the report.
|
2003-07-15 18:39:49 +05:30
|
|
|
|
2005-01-09 01:49:06 +05:30
|
|
|
The arguments are:
|
2003-07-15 18:39:49 +05:30
|
|
|
|
2005-01-09 01:49:06 +05:30
|
|
|
database - the GRAMPS database instance
|
|
|
|
person - currently selected person
|
|
|
|
options_class - instance of the Options class for this report
|
2003-07-15 18:39:49 +05:30
|
|
|
|
2005-01-09 01:49:06 +05:30
|
|
|
This report needs the following parameters (class variables)
|
|
|
|
that come in the options class.
|
|
|
|
|
|
|
|
top - Text on the top.
|
|
|
|
mid - Text in the middle.
|
|
|
|
bot - Text on the bottom.
|
|
|
|
"""
|
2008-02-20 10:22:10 +05:30
|
|
|
Report.__init__(self, database, options_class)
|
2005-01-09 01:49:06 +05:30
|
|
|
|
2008-01-23 11:11:46 +05:30
|
|
|
menu = options_class.menu
|
|
|
|
self.top_text = menu.get_option_by_name('top').get_value()
|
|
|
|
self.middle_text = menu.get_option_by_name('mid').get_value()
|
|
|
|
self.bottom_text = menu.get_option_by_name('bot').get_value()
|
2005-01-09 01:49:06 +05:30
|
|
|
|
|
|
|
def write_report(self):
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_paragraph('CBT-Initial')
|
2008-01-06 02:12:05 +05:30
|
|
|
for line in self.top_text:
|
|
|
|
self.doc.write_text(line)
|
|
|
|
self.doc.write_text("\n")
|
2003-07-15 18:39:49 +05:30
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_paragraph('CBT-Middle')
|
2008-01-06 02:12:05 +05:30
|
|
|
for line in self.middle_text:
|
|
|
|
self.doc.write_text(line)
|
|
|
|
self.doc.write_text("\n")
|
2003-07-15 18:39:49 +05:30
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_paragraph('CBT-Final')
|
2008-01-06 02:12:05 +05:30
|
|
|
for line in self.bottom_text:
|
|
|
|
self.doc.write_text(line)
|
|
|
|
self.doc.write_text("\n")
|
2003-07-15 18:39:49 +05:30
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2008-01-06 02:12:05 +05:30
|
|
|
# CustomTextOptions
|
2003-07-15 18:39:49 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2008-01-06 02:12:05 +05:30
|
|
|
class CustomTextOptions(MenuReportOptions):
|
2005-01-09 01:49:06 +05:30
|
|
|
|
|
|
|
"""
|
|
|
|
Defines options and provides handling interface.
|
|
|
|
"""
|
2008-01-06 02:12:05 +05:30
|
|
|
|
2008-01-24 18:20:33 +05:30
|
|
|
def __init__(self, name, dbase):
|
|
|
|
MenuReportOptions.__init__(self, name, dbase)
|
2007-12-13 07:22:03 +05:30
|
|
|
|
2008-01-24 18:20:33 +05:30
|
|
|
def add_menu_options(self, menu):
|
2008-01-06 02:12:05 +05:30
|
|
|
|
|
|
|
category_name = _("Text")
|
|
|
|
|
|
|
|
top = TextOption(_("Initial Text"), [""] )
|
|
|
|
top.set_help(_("Text to display at the top."))
|
|
|
|
menu.add_option(category_name,"top",top)
|
|
|
|
|
|
|
|
mid = TextOption(_("Middle Text"), [""] )
|
|
|
|
mid.set_help(_("Text to display in the middle"))
|
|
|
|
menu.add_option(category_name,"mid",mid)
|
|
|
|
|
|
|
|
bot = TextOption(_("Final Text"), [""] )
|
|
|
|
bot.set_help(_("Text to display last."))
|
|
|
|
menu.add_option(category_name,"bot",bot)
|
2005-01-09 01:49:06 +05:30
|
|
|
|
|
|
|
def make_default_style(self,default_style):
|
|
|
|
"""Make the default output style for the Custom Text report."""
|
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set(face=BaseDoc.FONT_SANS_SERIF,size=12,bold=0,italic=0)
|
|
|
|
para = BaseDoc.ParagraphStyle()
|
|
|
|
para.set_font(font)
|
|
|
|
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
|
|
|
para.set(pad=0.5)
|
|
|
|
para.set_description(_('The style used for the first portion of the custom text.'))
|
2007-12-13 07:22:03 +05:30
|
|
|
default_style.add_paragraph_style("CBT-Initial",para)
|
2005-01-09 01:49:06 +05:30
|
|
|
|
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set(face=BaseDoc.FONT_SANS_SERIF,size=12,bold=0,italic=0)
|
|
|
|
para = BaseDoc.ParagraphStyle()
|
|
|
|
para.set_font(font)
|
|
|
|
para.set(pad=0.5)
|
|
|
|
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
|
|
|
para.set_description(_('The style used for the middle portion of the custom text.'))
|
2007-12-13 07:22:03 +05:30
|
|
|
default_style.add_paragraph_style("CBT-Middle",para)
|
2005-01-09 01:49:06 +05:30
|
|
|
|
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set(face=BaseDoc.FONT_SANS_SERIF,size=12,bold=0,italic=0)
|
|
|
|
para = BaseDoc.ParagraphStyle()
|
|
|
|
para.set_font(font)
|
|
|
|
para.set_alignment(BaseDoc.PARA_ALIGN_CENTER)
|
|
|
|
para.set(pad=0.5)
|
|
|
|
para.set_description(_('The style used for the last portion of the custom text.'))
|
2007-12-13 07:22:03 +05:30
|
|
|
default_style.add_paragraph_style("CBT-Final",para)
|
2003-07-15 18:39:49 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2008-05-19 00:54:28 +05:30
|
|
|
pmgr = PluginManager.get_instance()
|
|
|
|
pmgr.register_report(
|
2005-01-09 01:49:06 +05:30
|
|
|
name = 'custom_text',
|
2006-06-01 10:09:40 +05:30
|
|
|
category = CATEGORY_TEXT,
|
2005-01-09 01:49:06 +05:30
|
|
|
report_class = CustomText,
|
|
|
|
options_class = CustomTextOptions,
|
2006-06-01 10:09:40 +05:30
|
|
|
modes = MODE_BKI,
|
2005-01-09 01:49:06 +05:30
|
|
|
translated_name = _("Custom Text"),
|
|
|
|
)
|