* src/plugins/BookReport.py, src/plugins/FtmStyleDescendants.py:

Minor fixes.
* src/plugins/book.glade: Add Open and Save buttons.
* src/plugins/FtmStyleAncestors.py: Enable book item functionality.


svn: r1676
This commit is contained in:
Alex Roitman 2003-06-09 00:07:31 +00:00
parent ea68bc176b
commit 76262483e2
4 changed files with 250 additions and 57 deletions

View File

@ -1,3 +1,9 @@
2003-06-08 Alex Roitman <shura@alex.neuro.umn.edu>
* src/plugins/BookReport.py, src/plugins/FtmStyleDescendants.py:
Minor fixes.
* src/plugins/book.glade: Add Open and Save buttons.
* src/plugins/FtmStyleAncestors.py: Enable book item functionality.
2003-06-08 Alex Roitman <shura@alex.neuro.umn.edu> 2003-06-08 Alex Roitman <shura@alex.neuro.umn.edu>
* src/Report.py: De-uglify center_person frame. * src/Report.py: De-uglify center_person frame.
* src/plugins/BookReport.py: Add a center person column to a book * src/plugins/BookReport.py: Add a center person column to a book

View File

@ -84,6 +84,8 @@ class BookReportSelector:
"on_down_clicked" : self.on_down_clicked, "on_down_clicked" : self.on_down_clicked,
"on_setup_clicked" : self.on_setup_clicked, "on_setup_clicked" : self.on_setup_clicked,
"on_clear_clicked" : self.on_clear_clicked, "on_clear_clicked" : self.on_clear_clicked,
"on_save_clicked" : self.on_save_clicked,
"on_open_clicked" : self.on_open_clicked,
"on_book_ok_clicked" : self.on_book_ok_clicked, "on_book_ok_clicked" : self.on_book_ok_clicked,
"destroy_passed_object" : self.close "destroy_passed_object" : self.close
}) })
@ -106,9 +108,9 @@ class BookReportSelector:
self.item_storage = {} self.item_storage = {}
self.max_key = 0 self.max_key = 0
av_titles = [(_('Name'),2,150),(_('Type'),1,50)] av_titles = [(_('Name'),0,150),(_('Type'),1,50)]
bk_titles = [(_('Item name'),-1,150),(_('Type'),1,50), bk_titles = [(_('Item name'),-1,150),(_('Type'),-1,50),
(_('Center person'),1,50),('',-1,0)] (_('Center person'),-1,50),('',-1,0)]
self.av_ncols = len(av_titles) self.av_ncols = len(av_titles)
self.bk_ncols = len(bk_titles) self.bk_ncols = len(bk_titles)
@ -222,6 +224,12 @@ class BookReportSelector:
BookReportDialog(self.db,self.person,item_list) BookReportDialog(self.db,self.person,item_list)
self.top.destroy() self.top.destroy()
def on_save_clicked(self,obj):
pass
def on_open_clicked(self,obj):
pass
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# The final dialog - paper, format, target, etc. # The final dialog - paper, format, target, etc.
@ -263,7 +271,7 @@ class BookReportDialog(Report.ReportDialog):
def make_document(self): def make_document(self):
"""Create a document of the type requested by the user.""" """Create a document of the type requested by the user."""
self.doc = self.format(self.selected_style,self.paper, self.doc = self.format(self.selected_style,self.paper,
self.template_name,self.orien) self.template_name,self.orien)
self.doc.open(self.target_path) self.doc.open(self.target_path)
def make_report(self): def make_report(self):

View File

@ -46,14 +46,20 @@ from intl import gettext as _
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class FtmAncestorReport(Report.Report): class FtmAncestorReport(Report.Report):
def __init__(self,database,person,output,max,doc,pgbrk): def __init__(self,database,person,max,pgbrk,doc,output,newpage=0):
self.map = {} self.map = {}
self.database = database self.database = database
self.start = person self.start = person
self.max_generations = max self.max_generations = max
self.pgbrk = pgbrk self.pgbrk = pgbrk
self.doc = doc self.doc = doc
self.doc.open(output) if output:
self.standalone = 1
self.doc.open(output)
else:
self.standalone = 0
if newpage:
self.doc.page_break()
self.sref_map = {} self.sref_map = {}
self.sref_index = 1 self.sref_index = 1
@ -182,7 +188,8 @@ class FtmAncestorReport(Report.Report):
self.print_more_about(person) self.print_more_about(person)
self.write_endnotes() self.write_endnotes()
self.doc.close() if self.standalone:
self.doc.close()
def write_endnotes(self): def write_endnotes(self):
keys = self.sref_map.keys() keys = self.sref_map.keys()
@ -711,6 +718,49 @@ class FtmAncestorReport(Report.Report):
self.doc.write_text(' '); self.doc.write_text(' ');
def _make_default_style(self):
"""Make the default output style for the FTM Style Ancestral 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)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# #
@ -743,55 +793,15 @@ class FtmAncestorReportDialog(Report.TextReportDialog):
return "ftm_ancestor_report.xml" return "ftm_ancestor_report.xml"
def make_default_style(self): def make_default_style(self):
"""Make the default output style for the FTM Style Ancestral report.""" _make_default_style(self)
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): def make_report(self):
"""Create the object that will produce the FTM Style Ancestral Report. """Create the object that will produce the FTM Style Ancestral Report.
All user dialog has already been handled and the output file All user dialog has already been handled and the output file
opened.""" opened."""
try: try:
MyReport = FtmAncestorReport(self.db, self.person, self.target_path, MyReport = FtmAncestorReport(self.db, self.person,
self.max_gen, self.doc, self.pg_brk) self.max_gen, self.pg_brk, self.doc, self.target_path)
MyReport.write_report() MyReport.write_report()
except Errors.ReportError, msg: except Errors.ReportError, msg:
(m1,m2) = msg.messages() (m1,m2) = msg.messages()
@ -805,13 +815,129 @@ class FtmAncestorReportDialog(Report.TextReportDialog):
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# # Standalone report function
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
def report(database,person): def report(database,person):
FtmAncestorReportDialog(database,person) FtmAncestorReportDialog(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):
FtmAncestorBareReportDialog(database,person)
def get_style():
return _style
def get_options():
return [ None, _max_gen, _pg_brk ]
#------------------------------------------------------------------------
#
# Book Item Options dialog
#
#------------------------------------------------------------------------
class FtmAncestorBareReportDialog(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.new_person = None
self.generations_spinbox.set_value(self.max_gen)
self.pagebreak_checkbox.set_active(self.pg_brk)
self.window.run()
#------------------------------------------------------------------------
#
# Customization hooks
#
#------------------------------------------------------------------------
def get_title(self):
"""The window title for this dialog"""
return "%s - GRAMPS Book" % (_("FTM Style Ancestor Report"))
def get_header(self, name):
"""The header line at the top of the dialog contents"""
return _("FTM Style Ancestor Report for GRAMPS Book")
def get_stylesheet_savefile(self):
"""Where to save styles for this report."""
return "ftm_ancestor_report.xml"
def make_default_style(self):
_make_default_style(self)
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()
self.person = self.new_person
# Clean up the dialog object
self.window.destroy()
def get_options(self):
"""This function returns the options to be used for this book item."""
return [ self.person, self.max_gen, self.pg_brk ]
def get_style(self):
"""This function returns the style to be used for this book item."""
return self.selected_style
def write_book_item(database,person,doc,options,newpage=0):
"""Write the FTM Style Ancestor 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 = FtmAncestorReport(database, person,
max_gen, pg_brk, doc, None, newpage )
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()
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# #
@ -907,7 +1033,7 @@ def get_xpm_image():
# #
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from Plugins import register_report from Plugins import register_report, register_book_item
register_report( register_report(
report, report,
@ -920,3 +1046,13 @@ register_report(
author_email="dallingham@users.sourceforge.net" author_email="dallingham@users.sourceforge.net"
) )
# register_book_item( name, category, dialog, write_item, get_options, get_style)
register_book_item(
_("FTM Style Ancestor Report"),
_("Text"),
FtmAncestorBareReportDialog,
write_book_item,
get_options,
get_style
)

View File

@ -2,10 +2,11 @@
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface> <glade-interface>
<requires lib="gnome"/>
<widget class="GtkWindow" id="top"> <widget class="GtkWindow" id="top">
<property name="width_request">800</property> <property name="width_request">800</property>
<property name="height_request">600</property> <property name="height_request">650</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="title" translatable="yes">Book</property> <property name="title" translatable="yes">Book</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="type">GTK_WINDOW_TOPLEVEL</property>
@ -102,7 +103,7 @@
<widget class="GtkVButtonBox" id="vbuttonbox"> <widget class="GtkVButtonBox" id="vbuttonbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_SPREAD</property> <property name="layout_style">GTK_BUTTONBOX_SPREAD</property>
<property name="spacing">24</property> <property name="spacing">12</property>
<child> <child>
<widget class="GtkVButtonBox" id="vbuttonbox2"> <widget class="GtkVButtonBox" id="vbuttonbox2">
@ -175,7 +176,7 @@
<child> <child>
<widget class="GtkVButtonBox" id="vbuttonbox3"> <widget class="GtkVButtonBox" id="vbuttonbox3">
<property name="visible">True</property> <property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property> <property name="layout_style">GTK_BUTTONBOX_SPREAD</property>
<property name="spacing">0</property> <property name="spacing">0</property>
<child> <child>
@ -221,7 +222,7 @@
<child> <child>
<widget class="GtkLabel" id="label3"> <widget class="GtkLabel" id="label3">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">_Setup</property> <property name="label" translatable="yes">Se_tup</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property> <property name="justify">GTK_JUSTIFY_LEFT</property>
@ -250,7 +251,7 @@
<child> <child>
<widget class="GtkVButtonBox" id="vbuttonbox5"> <widget class="GtkVButtonBox" id="vbuttonbox5">
<property name="visible">True</property> <property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_START</property> <property name="layout_style">GTK_BUTTONBOX_END</property>
<property name="spacing">0</property> <property name="spacing">0</property>
<child> <child>
@ -267,6 +268,48 @@
</child> </child>
</widget> </widget>
</child> </child>
<child>
<widget class="GtkVButtonBox" id="vbuttonbox6">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_SPREAD</property>
<property name="spacing">0</property>
<child>
<widget class="GtkButton" id="button29">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Save current set of configured selections</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-save</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<signal name="clicked" handler="on_save_clicked" last_modification_time="Sun, 08 Jun 2003 23:49:42 GMT"/>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkVButtonBox" id="vbuttonbox7">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_START</property>
<property name="spacing">0</property>
<child>
<widget class="GtkButton" id="button30">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Open previously created book</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-open</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<signal name="clicked" handler="on_open_clicked" last_modification_time="Sun, 08 Jun 2003 23:59:36 GMT"/>
</widget>
</child>
</widget>
</child>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>