From 76262483e211b5491db90b90c7fd90194fc09643 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Mon, 9 Jun 2003 00:07:31 +0000 Subject: [PATCH] * 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 --- ChangeLog | 6 + src/plugins/BookReport.py | 16 ++- src/plugins/FtmStyleAncestors.py | 232 ++++++++++++++++++++++++------- src/plugins/book.glade | 53 ++++++- 4 files changed, 250 insertions(+), 57 deletions(-) diff --git a/ChangeLog b/ChangeLog index 20396737d..6ef33f3e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-06-08 Alex Roitman + * 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 * src/Report.py: De-uglify center_person frame. * src/plugins/BookReport.py: Add a center person column to a book diff --git a/src/plugins/BookReport.py b/src/plugins/BookReport.py index 152877bd9..c92ea3c6e 100644 --- a/src/plugins/BookReport.py +++ b/src/plugins/BookReport.py @@ -84,6 +84,8 @@ class BookReportSelector: "on_down_clicked" : self.on_down_clicked, "on_setup_clicked" : self.on_setup_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, "destroy_passed_object" : self.close }) @@ -106,9 +108,9 @@ class BookReportSelector: self.item_storage = {} self.max_key = 0 - av_titles = [(_('Name'),2,150),(_('Type'),1,50)] - bk_titles = [(_('Item name'),-1,150),(_('Type'),1,50), - (_('Center person'),1,50),('',-1,0)] + av_titles = [(_('Name'),0,150),(_('Type'),1,50)] + bk_titles = [(_('Item name'),-1,150),(_('Type'),-1,50), + (_('Center person'),-1,50),('',-1,0)] self.av_ncols = len(av_titles) self.bk_ncols = len(bk_titles) @@ -222,6 +224,12 @@ class BookReportSelector: BookReportDialog(self.db,self.person,item_list) self.top.destroy() + def on_save_clicked(self,obj): + pass + + def on_open_clicked(self,obj): + pass + #------------------------------------------------------------------------ # # The final dialog - paper, format, target, etc. @@ -263,7 +271,7 @@ class BookReportDialog(Report.ReportDialog): 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.template_name,self.orien) self.doc.open(self.target_path) def make_report(self): diff --git a/src/plugins/FtmStyleAncestors.py b/src/plugins/FtmStyleAncestors.py index 780db1060..bc29c933e 100644 --- a/src/plugins/FtmStyleAncestors.py +++ b/src/plugins/FtmStyleAncestors.py @@ -46,14 +46,20 @@ from intl import gettext as _ #------------------------------------------------------------------------ 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.database = database self.start = person 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 + if newpage: + self.doc.page_break() self.sref_map = {} self.sref_index = 1 @@ -182,7 +188,8 @@ class FtmAncestorReport(Report.Report): self.print_more_about(person) self.write_endnotes() - self.doc.close() + if self.standalone: + self.doc.close() def write_endnotes(self): keys = self.sref_map.keys() @@ -711,6 +718,49 @@ class FtmAncestorReport(Report.Report): 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" 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) - + _make_default_style(self) def make_report(self): """Create the object that will produce the FTM Style Ancestral Report. All user dialog has already been handled and the output file opened.""" try: - MyReport = FtmAncestorReport(self.db, self.person, self.target_path, - self.max_gen, self.doc, self.pg_brk) + MyReport = FtmAncestorReport(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() @@ -805,13 +815,129 @@ class FtmAncestorReportDialog(Report.TextReportDialog): #------------------------------------------------------------------------ # -# +# Standalone report function # #------------------------------------------------------------------------ def report(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( report, @@ -920,3 +1046,13 @@ register_report( 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 + ) + diff --git a/src/plugins/book.glade b/src/plugins/book.glade index 92ae5104c..ff57aeb8d 100644 --- a/src/plugins/book.glade +++ b/src/plugins/book.glade @@ -2,10 +2,11 @@ + 800 - 600 + 650 True Book GTK_WINDOW_TOPLEVEL @@ -102,7 +103,7 @@ True GTK_BUTTONBOX_SPREAD - 24 + 12 @@ -175,7 +176,7 @@ True - GTK_BUTTONBOX_END + GTK_BUTTONBOX_SPREAD 0 @@ -221,7 +222,7 @@ True - _Setup + Se_tup True False GTK_JUSTIFY_LEFT @@ -250,7 +251,7 @@ True - GTK_BUTTONBOX_START + GTK_BUTTONBOX_END 0 @@ -267,6 +268,48 @@ + + + + True + GTK_BUTTONBOX_SPREAD + 0 + + + + True + Save current set of configured selections + True + True + gtk-save + True + GTK_RELIEF_NORMAL + + + + + + + + + True + GTK_BUTTONBOX_START + 0 + + + + True + Open previously created book + True + True + gtk-open + True + GTK_RELIEF_NORMAL + + + + + 1