* src/Report.py: Clean up the split into BareReportDialog and

ReportDialog classes.
* src/Plugins.py: Enable book item registration.
* src/plugins/BookReport.py: lots of changes -- trying to get it work.
* src/plugins/FtmStyleDescendants.py: book item functionality.


svn: r1671
This commit is contained in:
Alex Roitman 2003-06-07 23:38:13 +00:00
parent 9f6ac2d474
commit 0df227aac6
5 changed files with 439 additions and 226 deletions

View File

@ -1,3 +1,10 @@
2003-06-07 Alex Roitman <shura@alex.neuro.umn.edu>
* src/Report.py: Clean up the split into BareReportDialog and
ReportDialog classes.
* src/Plugins.py: Enable book item registration.
* src/plugins/BookReport.py: lots of changes -- trying to get it work.
* src/plugins/FtmStyleDescendants.py: book item functionality.
2003-06-07 Don Allingham <dallingham@users.sourceforge.net>
* src/EditPerson.py: Allow a default gender to be specified if a new

View File

@ -78,6 +78,7 @@ _loaddir = []
_textdoc = []
_drawdoc = []
_failmsg = []
_bkitems = []
#-------------------------------------------------------------------------
#
@ -514,6 +515,20 @@ def relationship_function():
global _relcalc_task
return _relcalc_task
#-------------------------------------------------------------------------
#
# Book item registration
#
#-------------------------------------------------------------------------
def register_book_item(name,category,options_dialog,write_book_item,get_options,get_style):
"""Register a book item"""
for n in _bkitems:
if n[0] == name:
return
_bkitems.append((name,category,options_dialog,write_book_item,get_options,get_style))
#-------------------------------------------------------------------------
#
# Image attributes

View File

@ -227,6 +227,7 @@ class BareReportDialog:
self.setup_html_frame()
self.setup_report_options_frame()
self.setup_other_frames()
self.setup_center_person()
self.window.show_all()
#------------------------------------------------------------------------
@ -259,6 +260,14 @@ class BareReportDialog:
Report for %s'."""
return(name)
def get_stylesheet_savefile(self):
"""Where should new styles for this report be saved? This is
the name of an XML file that will be located in the ~/.gramps
directory. This file does not have to exist; it will be
created when needed. All subclasses should probably override
this function."""
return "basic_report.xml"
def get_report_filters(self):
"""Return the data used to fill out the 'filter' combo box in
the report options box. The return value is the list of
@ -334,6 +343,34 @@ class BareReportDialog:
if tooltip:
self.add_tooltip(widget,tooltip)
#------------------------------------------------------------------------
#
# Functions to create a default output style.
#
#------------------------------------------------------------------------
def make_default_style(self):
"""Create the default style to be used by the associated report. This
routine is a default implementation and should be overridden."""
font = TextDoc.FontStyle()
font.set(face=TextDoc.FONT_SANS_SERIF,size=16,bold=1)
para = TextDoc.ParagraphStyle()
para.set_font(font)
para.set_header_level(1)
para.set(pad=0.5)
self.default_style.add_style("Title",para)
def build_style_menu(self):
"""Build a menu of style sets that are available for use in
this report. This menu will always have a default style
available, and will have any other style set name that the
user has previously created for this report. This menu is
created here instead of inline with the rest of the style
frame, because it must be recreated to reflect any changes
whenever the user closes the style editor dialog."""
style_sheet_map = self.style_sheet_list.get_style_sheet_map()
myMenu = Utils.build_string_optmenu(style_sheet_map, "default")
self.style_menu.set_menu(myMenu)
#------------------------------------------------------------------------
#
# Functions related to setting up the dialog window.
@ -508,11 +545,70 @@ class BareReportDialog:
table.attach(widget,2,3,row,row+1)
row = row + 1
def setup_style_frame(self):
"""Set up the style frame of the dialog. This function relies
on other routines create the default style for this report,
and to read in any user defined styles for this report. It
the builds a menu of all the available styles for the user to
choose from."""
# Styles Frame
label = gtk.Label("%s:" % _("Styles"))
label.set_alignment(0.0,0.5)
self.style_menu = gtk.OptionMenu()
self.style_button = gtk.Button("%s..." % _("Style Editor"))
self.style_button.connect('clicked',self.on_style_edit_clicked)
self.tbl.attach(label,1,2,self.col,self.col+1,gtk.SHRINK|gtk.FILL)
self.tbl.attach(self.style_menu,2,3,self.col,self.col+1)
self.tbl.attach(self.style_button,3,4,self.col,self.col+1,gtk.SHRINK|gtk.FILL)
self.col += 1
# Build the default style set for this report.
self.default_style = TextDoc.StyleSheet()
self.make_default_style()
# Build the initial list of available styles sets. This
# includes the default style set and any style sets saved from
# previous invocations of gramps.
self.style_sheet_list = TextDoc.StyleSheetList(self.get_stylesheet_savefile(),
self.default_style)
# Now build the actual menu.
self.build_style_menu()
def setup_center_person(self):
center_label = gtk.Label("<b>%s</b>" % _("Center Person"))
center_label.set_use_markup(gtk.TRUE)
center_label.set_alignment(0.0,0.5)
self.tbl.set_border_width(12)
self.tbl.attach(center_label,0,4,1,2,gtk.SHRINK|gtk.FILL)
name = self.person.getPrimaryName().getRegularName()
self.person_label = gtk.Label( "<i>%s</i>" % name )
self.person_label.set_use_markup(gtk.TRUE)
self.person_label.set_alignment(0.0,0.5)
self.tbl.attach(self.person_label,2,3,2,3)
change_button = gtk.Button("%s..." % _('_Change') )
change_button.connect('clicked',self.on_center_person_change_clicked)
self.tbl.attach(change_button,3,4,2,3,gtk.SHRINK|gtk.SHRINK)
#------------------------------------------------------------------------
#
# Functions related to retrieving data from the dialog window
#
#------------------------------------------------------------------------
def parse_style_frame(self):
"""Parse the style frame of the dialog. Save the user
selected output style for later use. Note that this routine
retrieves a value whether or not the menu is displayed on the
screen. The subclass will know whether this menu was enabled.
This is for simplicity of programming."""
self.selected_style = self.style_menu.get_menu().get_active().get_data("d")
def parse_report_options_frame(self):
"""Parse the report options frame of the dialog. Save the
user selected choices for later use. Note that this routine
@ -563,34 +659,35 @@ class BareReportDialog:
self.window.destroy()
def on_ok_clicked(self, obj):
"""The user is satisfied with the dialog choices. Validate
the output file name before doing anything else. If there is
a file name, gather the options and create the report."""
# Is there a filename? This should also test file permissions, etc.
if not self.parse_target_frame():
return
"""The user is satisfied with the dialog choices. Parse all options
and close the window."""
# Preparation
self.parse_format_frame()
self.parse_style_frame()
self.parse_paper_frame()
self.parse_html_frame()
self.parse_report_options_frame()
self.parse_other_frames()
# Create the output document.
self.make_document()
# Create the report object and product the report.
try:
self.make_report()
except (IOError,OSError),msg:
ErrorDialog(str(msg))
# Clean up the dialog object
self.window.destroy()
def on_style_edit_clicked(self, obj):
"""The user has clicked on the 'Edit Styles' button. Create a
style sheet editor object and let them play. When they are
done, the previous routine will be called to update the dialog
menu for selecting a style."""
StyleEditor.StyleListDisplay(self.style_sheet_list,self.build_style_menu)
def on_center_person_change_clicked(self,obj):
import SelectPerson
sel_person = SelectPerson.SelectPerson(self.db,'Select Person')
new_person = sel_person.run()
if new_person:
self.person = new_person
new_name = new_person.getPrimaryName().getRegularName()
if new_name:
self.person_label.set_text( "<i>%s</i>" % new_name )
self.person_label.set_use_markup(gtk.TRUE)
#------------------------------------------------------------------------
#
# Functions related to creating the actual report document.
@ -642,6 +739,7 @@ class ReportDialog(BareReportDialog):
def setup_post_process(self):
pass
def setup_center_person(self): pass
#------------------------------------------------------------------------
#
@ -662,14 +760,6 @@ class ReportDialog(BareReportDialog):
may also control checking of the selected filename."""
return None
def get_stylesheet_savefile(self):
"""Where should new styles for this report be saved? This is
the name of an XML file that will be located in the ~/.gramps
directory. This file does not have to exist; it will be
created when needed. All subclasses should probably override
this function."""
return "basic_report.xml"
def get_default_basename(self):
"""What should the default name be?
"""
@ -706,34 +796,6 @@ class ReportDialog(BareReportDialog):
his/her preferences."""
GrampsCfg.report_dir = value
#------------------------------------------------------------------------
#
# Functions to create a default output style.
#
#------------------------------------------------------------------------
def make_default_style(self):
"""Create the default style to be used by the associated report. This
routine is a default implementation and should be overridden."""
font = TextDoc.FontStyle()
font.set(face=TextDoc.FONT_SANS_SERIF,size=16,bold=1)
para = TextDoc.ParagraphStyle()
para.set_font(font)
para.set_header_level(1)
para.set(pad=0.5)
self.default_style.add_style("Title",para)
def build_style_menu(self):
"""Build a menu of style sets that are available for use in
this report. This menu will always have a default style
available, and will have any other style set name that the
user has previously created for this report. This menu is
created here instead of inline with the rest of the style
frame, because it must be recreated to reflect any changes
whenever the user closes the style editor dialog."""
style_sheet_map = self.style_sheet_list.get_style_sheet_map()
myMenu = Utils.build_string_optmenu(style_sheet_map, "default")
self.style_menu.set_menu(myMenu)
#------------------------------------------------------------------------
#
# Functions related to selecting/changing the current file format.
@ -854,39 +916,6 @@ class ReportDialog(BareReportDialog):
self.target_fileentry.set_filename(path)
def setup_style_frame(self):
"""Set up the style frame of the dialog. This function relies
on other routines create the default style for this report,
and to read in any user defined styles for this report. It
the builds a menu of all the available styles for the user to
choose from."""
# Styles Frame
label = gtk.Label("%s:" % _("Styles"))
label.set_alignment(0.0,0.5)
self.style_menu = gtk.OptionMenu()
self.style_button = gtk.Button("%s..." % _("Style Editor"))
self.style_button.connect('clicked',self.on_style_edit_clicked)
self.tbl.attach(label,1,2,self.col,self.col+1,gtk.SHRINK|gtk.FILL)
self.tbl.attach(self.style_menu,2,3,self.col,self.col+1)
self.tbl.attach(self.style_button,3,4,self.col,self.col+1,gtk.SHRINK|gtk.FILL)
self.col += 1
# Build the default style set for this report.
self.default_style = TextDoc.StyleSheet()
self.make_default_style()
# Build the initial list of available styles sets. This
# includes the default style set and any style sets saved from
# previous invocations of gramps.
self.style_sheet_list = TextDoc.StyleSheetList(self.get_stylesheet_savefile(),
self.default_style)
# Now build the actual menu.
self.build_style_menu()
def setup_output_notebook(self):
"""Set up the output notebook of the dialog. This sole
purpose of this function is to grab a pointer for later use in
@ -1077,14 +1106,6 @@ class ReportDialog(BareReportDialog):
selected output format for later use."""
self.format = self.format_menu.get_menu().get_active().get_data("name")
def parse_style_frame(self):
"""Parse the style frame of the dialog. Save the user
selected output style for later use. Note that this routine
retrieves a value whether or not the menu is displayed on the
screen. The subclass will know whether this menu was enabled.
This is for simplicity of programming."""
self.selected_style = self.style_menu.get_menu().get_active().get_data("d")
def parse_paper_frame(self):
"""Parse the paper frame of the dialog. Save the user
selected choices for later use. Note that this routine
@ -1130,17 +1151,34 @@ class ReportDialog(BareReportDialog):
self.template_name = None
#------------------------------------------------------------------------
#
# Callback functions from the dialog
#
#------------------------------------------------------------------------
def on_style_edit_clicked(self, obj):
"""The user has clicked on the 'Edit Styles' button. Create a
style sheet editor object and let them play. When they are
done, the previous routine will be called to update the dialog
menu for selecting a style."""
StyleEditor.StyleListDisplay(self.style_sheet_list,self.build_style_menu)
def on_ok_clicked(self, obj):
"""The user is satisfied with the dialog choices. Validate
the output file name before doing anything else. If there is
a file name, gather the options and create the report."""
# Is there a filename? This should also test file permissions, etc.
if not self.parse_target_frame():
return
# Preparation
self.parse_format_frame()
self.parse_style_frame()
self.parse_paper_frame()
self.parse_html_frame()
self.parse_report_options_frame()
self.parse_other_frames()
# Create the output document.
self.make_document()
# Create the report object and product the report.
try:
self.make_report()
except (IOError,OSError),msg:
ErrorDialog(str(msg))
# Clean up the dialog object
self.window.destroy()
class TextReportDialog(ReportDialog):

View File

@ -57,7 +57,7 @@ import Report
#-------------------------------------------------------------------------
#
# ReportBook
# Book creation dialog class
#
#-------------------------------------------------------------------------
class BookReportSelector:
@ -103,10 +103,11 @@ class BookReportSelector:
book_label.set_text("<b>%s</b>" % "Current book")
book_label.set_use_markup(gtk.TRUE)
self.item_storage = {}
self.max_key = 0
av_titles = [(_('Name'),2,150),(_('Type'),1,50), ('',-1,0)]
bk_titles = [(_('Item name'),-1,150),(_('Type'),-1,50),
('',-1,0),('',-1,0)]
av_titles = [(_('Name'),2,150),(_('Type'),1,50)]
bk_titles = [(_('Item name'),-1,150),(_('Type'),1,50),('',-1,0)] #,('',-1,0)
self.av_ncols = len(av_titles)
self.bk_ncols = len(bk_titles)
@ -121,49 +122,46 @@ class BookReportSelector:
def draw_avail_list(self):
"""Draw the list with the selections available for the book."""
data = [_('Title Page'),_('Cover'),self.titlepage]
iter = self.av_model.add(data)
if not Plugins._bkitems:
return
data = [_('Table of Contents'),_('TOC'),self.toc]
new_iter = self.av_model.add(data)
reports = Plugins._reports
for report in reports:
if not self.ignore(report):
data = [report[2],string.split(report[1])[0],report[0]]
new_iter = self.av_model.add(data)
for book_item in Plugins._bkitems:
data = [ book_item[0], book_item[1] ]
new_iter = self.av_model.add(data)
self.av_model.connect_model()
if iter:
self.av_model.selection.select_iter(iter)
path = self.av_model.model.get_path(iter)
if new_iter:
self.av_model.selection.select_iter(new_iter)
path = self.av_model.model.get_path(new_iter)
col = self.avail_tree.get_column(0)
self.avail_tree.scroll_to_cell(path,col,1,1,0.0)
def ignore(self,report):
"""Returns true if the report is to be ignored for the book."""
ignore_names = [_('Book Report')]
ignore_categories = [_('View'),_('Web Page')]
return (report[2] in ignore_names) or (report[1] in ignore_categories)
def on_add_clicked(self,obj):
store,iter = self.av_model.get_selected()
if not iter:
return
data = self.av_model.get_data(iter,range(self.av_ncols))
data.append([])
self.max_key = self.max_key + 1
newkey = str(self.max_key)
data.append(newkey)
self.bk_model.add(data)
for book_item in Plugins._bkitems:
if book_item[0] == data[0]:
self.item_storage[newkey] = list(book_item)
def on_remove_clicked(self,obj):
store,iter = self.bk_model.get_selected()
if not iter:
return
data = self.bk_model.get_data(iter,range(self.bk_ncols))
key = data[2]
del self.item_storage[key]
self.bk_model.remove(iter)
def on_clear_clicked(self,obj):
self.bk_model.clear()
self.item_storage.clear()
def on_up_clicked(self,obj):
row = self.bk_model.get_selected_row()
@ -188,7 +186,17 @@ class BookReportSelector:
if not iter:
return
data = self.bk_model.get_data(iter,range(self.bk_ncols))
ReportOptionsDialog(self.db,self.person,data[0])
key = data[2]
book_item = self.item_storage[key]
options_dialog = book_item[2]
get_opt = book_item[4]
get_stl = book_item[5]
opt_dlg = options_dialog(self.db,self.person,get_opt,get_stl)
book_item[4] = opt_dlg.get_options
book_item[5] = opt_dlg.get_style
self.item_storage[key] = book_item
self.person = opt_dlg.person
#print opt_dlg.person.getPrimaryName().getRegularName()
def bk_double_click(self,obj,event):
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
@ -198,62 +206,83 @@ class BookReportSelector:
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
self.on_add_clicked(obj)
def on_book_ok_clicked(self,obj): pass
def titlepage(self): pass
def toc(self): pass
def on_book_ok_clicked(self,obj):
if self.bk_model.count:
item_list = []
for row in range(self.bk_model.count):
self.bk_model.select_row(row)
store,iter = self.bk_model.get_selected()
data = self.bk_model.get_data(iter,range(self.bk_ncols))
key = data[2]
book_item = self.item_storage[key]
item_list.append(book_item)
BookReportDialog(self.db,self.person,item_list)
self.top.destroy()
#------------------------------------------------------------------------
#
#
# The final dialog - paper, format, target, etc.
#
#------------------------------------------------------------------------
class ReportOptionsDialog(Report.BareReportDialog):
def __init__(self,database,person,rep_title):
self.rep_title = rep_title
class BookReportDialog(Report.ReportDialog):
def __init__(self,database,person,item_list):
Report.BareReportDialog.__init__(self,database,person)
self.item_list = item_list
book_item = item_list[0]
get_style = book_item[5]
self.selected_style = get_style()
self.database = database
self.person = person
def setup_style_frame(self): pass
def setup_report_options_frame(self): pass
def setup_other_frames(self): pass
def parse_style_frame(self): pass
def parse_report_options_frame(self): pass
def parse_other_frames(self): pass
def doc_uses_tables(self):
return 1
def get_title(self):
"""The window title for this dialog"""
return _("%s - GRAMPS Book") % self.rep_title
return _("Book Report")
def get_header(self, name):
"""The header line at the top of the dialog contents"""
return _("%s for GRAMPS Book") % self.rep_title
def get_header(self,name):
return _("Book Report")
def setup_format_frame(self):
center_label = gtk.Label("<b>%s</b>" % _("Center Person"))
center_label.set_use_markup(gtk.TRUE)
center_label.set_alignment(0.0,0.5)
self.tbl.set_border_width(12)
self.tbl.attach(center_label,0,4,1,2,gtk.SHRINK|gtk.FILL)
name = self.person.getPrimaryName().getRegularName()
self.person_label = gtk.Label( "<i>%s</i>" % name )
self.person_label.set_use_markup(gtk.TRUE)
self.person_label.set_alignment(0.0,0.5)
self.tbl.attach(self.person_label,2,3,2,3)
change_button = gtk.Button("%s..." % _('_Change') )
change_button.connect('clicked',self.on_change_clicked)
self.tbl.attach(change_button,3,4,2,3,gtk.SHRINK|gtk.SHRINK)
def on_change_clicked(self,obj):
import SelectPerson
sel_person = SelectPerson.SelectPerson(self.db,'Select Person')
new_person = sel_person.run()
if new_person:
new_name = new_person.getPrimaryName().getRegularName()
if new_name:
self.person_label.set_text( "<i>%s</i>" % new_name )
self.person_label.set_use_markup(gtk.TRUE)
def make_doc_menu(self):
"""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."""
Plugins.get_text_doc_menu(self.format_menu, self.doc_uses_tables(),
self.doc_type_changed)
def make_document(self):
"""Create a document of the type requested by the user."""
self.doc = self.format(self.selected_style,self.paper,
self.template_name,self.orien)
self.doc.open(self.target_path)
def make_report(self):
"""Create the contents of the report. This is a simple
default implementation suitable for testing. Is should be
overridden to produce a real report."""
self.doc.start_paragraph("Title")
title = _("Book Report")
self.doc.write_text(title)
self.doc.end_paragraph()
for book_item in self.item_list:
write_book_item = book_item[3]
get_options = book_item[4]
item_options = get_options()
if write_book_item:
write_book_item(self.database,self.person,self.doc,item_options)
self.doc.close()
#------------------------------------------------------------------------
#
#
# Function to register the overall book report
#
#------------------------------------------------------------------------
def report(database,person):

View File

@ -52,7 +52,7 @@ from intl import gettext as _
#------------------------------------------------------------------------
class FtmDescendantReport(Report.Report):
def __init__(self,database,person,output,max,doc,pgbrk):
def __init__(self,database,person,max,pgbrk,doc,output):
self.anc_map = {}
self.gen_map = {}
self.database = database
@ -60,7 +60,11 @@ class FtmDescendantReport(Report.Report):
self.max_generations = max
self.pgbrk = pgbrk
self.doc = doc
self.doc.open(output)
if output:
self.standalone = 1
self.doc.open(output)
else:
self.standalone = 0
self.sref_map = {}
self.sref_index = 1
@ -215,7 +219,8 @@ class FtmDescendantReport(Report.Report):
self.print_children(person)
self.write_endnotes()
self.doc.close()
if self.standalone:
self.doc.close()
def write_endnotes(self):
keys = self.sref_map.keys()
@ -1119,9 +1124,58 @@ class FtmDescendantReport(Report.Report):
#
#
#------------------------------------------------------------------------
def _make_default_style(self):
"""Make the default output style for the FTM Style Descendant report."""
font = TextDoc.FontStyle()
font.set(face=TextDoc.FONT_SANS_SERIF,size=16,bold=1,italic=1)
para = TextDoc.ParagraphStyle()
para.set_font(font)
para.set_header_level(1)
para.set_alignment(TextDoc.PARA_ALIGN_CENTER)
para.set(pad=0.5)
para.set_description(_('The style used for the title of the page.'))
self.default_style.add_style("Title",para)
font = TextDoc.FontStyle()
font.set(face=TextDoc.FONT_SANS_SERIF,size=14,italic=1)
para = TextDoc.ParagraphStyle()
para.set_font(font)
para.set_header_level(2)
para.set(pad=0.5)
para.set_alignment(TextDoc.PARA_ALIGN_CENTER)
para.set_description(_('The style used for the generation header.'))
self.default_style.add_style("Generation",para)
para = TextDoc.ParagraphStyle()
para.set(first_indent=-1.0,lmargin=1.0,pad=0.25)
para.set_description(_('The basic style used for the text display.'))
self.default_style.add_style("Entry",para)
para = TextDoc.ParagraphStyle()
para.set(lmargin=1.0,pad=0.05)
para.set_description(_('The basic style used for the text display.'))
self.default_style.add_style("Details",para)
para = TextDoc.ParagraphStyle()
para.set(lmargin=1.0,pad=0.25)
para.set_description(_('The basic style used for the text display.'))
self.default_style.add_style("SubEntry",para)
para = TextDoc.ParagraphStyle()
para.set(pad=0.05)
para.set_description(_('The basic style used for the text display.'))
self.default_style.add_style("Endnotes",para)
#------------------------------------------------------------------------
#
# Dialog for a standalone report
#
#------------------------------------------------------------------------
class FtmDescendantReportDialog(Report.TextReportDialog):
def __init__(self,database,person):
Report.TextReportDialog.__init__(self,database,person)
self.make_default_style = _make_default_style
#------------------------------------------------------------------------
#
@ -1145,56 +1199,13 @@ class FtmDescendantReportDialog(Report.TextReportDialog):
"""Where to save styles for this report."""
return "ftm_descendant_report.xml"
def make_default_style(self):
"""Make the default output style for the FTM Style Descendant report."""
font = TextDoc.FontStyle()
font.set(face=TextDoc.FONT_SANS_SERIF,size=16,bold=1,italic=1)
para = TextDoc.ParagraphStyle()
para.set_font(font)
para.set_header_level(1)
para.set_alignment(TextDoc.PARA_ALIGN_CENTER)
para.set(pad=0.5)
para.set_description(_('The style used for the title of the page.'))
self.default_style.add_style("Title",para)
font = TextDoc.FontStyle()
font.set(face=TextDoc.FONT_SANS_SERIF,size=14,italic=1)
para = TextDoc.ParagraphStyle()
para.set_font(font)
para.set_header_level(2)
para.set(pad=0.5)
para.set_alignment(TextDoc.PARA_ALIGN_CENTER)
para.set_description(_('The style used for the generation header.'))
self.default_style.add_style("Generation",para)
para = TextDoc.ParagraphStyle()
para.set(first_indent=-1.0,lmargin=1.0,pad=0.25)
para.set_description(_('The basic style used for the text display.'))
self.default_style.add_style("Entry",para)
para = TextDoc.ParagraphStyle()
para.set(lmargin=1.0,pad=0.05)
para.set_description(_('The basic style used for the text display.'))
self.default_style.add_style("Details",para)
para = TextDoc.ParagraphStyle()
para.set(lmargin=1.0,pad=0.25)
para.set_description(_('The basic style used for the text display.'))
self.default_style.add_style("SubEntry",para)
para = TextDoc.ParagraphStyle()
para.set(pad=0.05)
para.set_description(_('The basic style used for the text display.'))
self.default_style.add_style("Endnotes",para)
def make_report(self):
"""Create the object that will produce the FTM Style Descendant Report.
All user dialog has already been handled and the output file
opened."""
try:
MyReport = FtmDescendantReport(self.db, self.person, self.target_path,
self.max_gen, self.doc, self.pg_brk)
MyReport = FtmDescendantReport(self.db, self.person,
self.max_gen, self.pg_brk, self.doc, self.target_path)
MyReport.write_report()
except Errors.ReportError, msg:
(m1,m2) = msg.messages()
@ -1208,13 +1219,117 @@ class FtmDescendantReportDialog(Report.TextReportDialog):
#------------------------------------------------------------------------
#
#
# Standalone report function
#
#------------------------------------------------------------------------
def report(database,person):
FtmDescendantReportDialog(database,person)
#------------------------------------------------------------------------
#
# Set up sane defaults for the book_item
#
#------------------------------------------------------------------------
class FakeObj(object):
pass
fo = FakeObj()
fo.default_style = TextDoc.StyleSheet()
_make_default_style(fo)
_style = fo.default_style
_max_gen = 10
_pg_brk = 0
def options_dialog(database,person):
FtmDescendantBareReportDialog(database,person)
def get_style():
return _style
def get_options():
return [ None, _max_gen, _pg_brk ]
#------------------------------------------------------------------------
#
# Book Item Options dialog
#
#------------------------------------------------------------------------
class FtmDescendantBareReportDialog(Report.BareReportDialog):
def __init__(self,database,person,get_opt,get_stl):
options = get_opt()
if options[0]:
self.person = options[0]
else:
self.person = person
Report.BareReportDialog.__init__(self,database,self.person)
self.make_default_style = _make_default_style
self.max_gen = options[1]
self.pg_brk = options[2]
self.selected_style = get_stl()
self.generations_spinbox.set_value(self.max_gen)
self.pagebreak_checkbox.set_active(self.pg_brk)
#------------------------------------------------------------------------
#
# Customization hooks
#
#------------------------------------------------------------------------
def get_title(self):
"""The window title for this dialog"""
return "%s - GRAMPS Book" % (_("FTM Style Descendant Report"))
def get_header(self, name):
"""The header line at the top of the dialog contents"""
return _("FTM Style Descendant Report for GRAMPS Book")
def get_stylesheet_savefile(self):
"""Where to save styles for this report."""
return "ftm_descendant_report.xml"
def on_ok_clicked(self, obj):
"""The user is satisfied with the dialog choices. Parse all options
and close the window."""
# Preparation
self.parse_style_frame()
self.parse_report_options_frame()
# Clean up the dialog object
self.window.destroy()
def get_options(self):
return [ self.person, self.max_gen, self.pg_brk ]
def get_style(self):
return self.selected_style
def write_book_item(database,person,doc,options):
"""Write the FTM Style Descendant Report options set.
All user dialog has already been handled and the output file opened."""
try:
if options[0]:
person = options[0]
max_gen = options[1]
pg_brk = options[2]
MyReport = FtmDescendantReport(database, person,
max_gen, pg_brk, doc, None )
MyReport.write_report()
except Errors.ReportError, msg:
(m1,m2) = msg.messages()
ErrorDialog(m1,m2)
except Errors.FilterError, msg:
(m1,m2) = msg.messages()
ErrorDialog(m1,m2)
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
#------------------------------------------------------------------------
#
#
@ -1310,7 +1425,7 @@ def get_xpm_image():
#
#
#------------------------------------------------------------------------
from Plugins import register_report
from Plugins import register_report, register_book_item
register_report(
report,
@ -1323,3 +1438,12 @@ register_report(
author_email="shura@alex.neuro.umn.edu"
)
# register_book_item( name, category, dialog, write_item, get_options, get_style)
register_book_item(
_("FTM Style Descendant Report"),
_("Text"),
FtmDescendantBareReportDialog,
write_book_item,
get_options,
get_style
)