From 34f42ec646c39559f70332ac28ee0c757f217fa3 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Sun, 8 Jun 2003 20:32:17 +0000 Subject: [PATCH] * src/Report.py: De-uglify center_person frame. * src/plugins/BookReport.py: Add a center person column to a book * src/plugins/FtmStyleDescendants.py: Get the style right. svn: r1674 --- gramps2/ChangeLog | 6 + gramps2/src/Report.py | 148 ++++++++++++--------- gramps2/src/plugins/BookReport.py | 20 +-- gramps2/src/plugins/FtmStyleDescendants.py | 15 ++- 4 files changed, 116 insertions(+), 73 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 9b9e06812..218aa32d0 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,9 @@ +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 + selector dialog. + * src/plugins/FtmStyleDescendants.py: Get the style right. + 2003-06-08 Alex Roitman * src/Report.py, src/plugins/BookReport.py, src/plugins/FtmStyleDescendants.py: Fix changing center person -- only diff --git a/gramps2/src/Report.py b/gramps2/src/Report.py index cdb7bb07e..3109d21aa 100644 --- a/gramps2/src/Report.py +++ b/gramps2/src/Report.py @@ -219,6 +219,7 @@ class BareReportDialog: self.tbl.set_border_width(6) self.col = 0 self.window.vbox.add(self.tbl) + self.setup_center_person() self.setup_target_frame() self.setup_format_frame() self.setup_style_frame() @@ -227,22 +228,8 @@ class BareReportDialog: self.setup_html_frame() self.setup_report_options_frame() self.setup_other_frames() - self.setup_center_person() self.window.show_all() - #------------------------------------------------------------------------ - # - # Customization hooks for stand-alone reports (subclass ReportDialog) - # - #------------------------------------------------------------------------ - def setup_target_frame(self): pass - def setup_format_frame(self): pass - def setup_style_frame(self): pass - def setup_paper_frame(self): pass - def setup_html_frame(self): pass - def setup_paper_frame(self): pass - def setup_output_notebook(self): pass - #------------------------------------------------------------------------ # # Customization hooks for subclasses @@ -395,7 +382,70 @@ class BareReportDialog: label.set_use_markup(gtk.TRUE) self.window.vbox.pack_start(label,gtk.TRUE,gtk.TRUE,ReportDialog.border_pad) - + def setup_target_frame(self): + """Bare report dialog only uses Doc Options header.""" + + label = gtk.Label("%s" % _('Document Options')) + label.set_use_markup(1) + label.set_alignment(0.0,0.5) + self.tbl.set_border_width(12) + self.tbl.attach(label,0,4,self.col,self.col+1) + self.col += 1 + + def setup_center_person(self): + """Set up center person labels and change button. + Should be overwritten by standalone report dialogs. """ + + center_label = gtk.Label("%s" % _("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,self.col,self.col+1) + self.col += 1 + + name = self.person.getPrimaryName().getRegularName() + self.person_label = gtk.Label( "%s" % name ) + self.person_label.set_alignment(0.0,0.5) + self.tbl.attach(self.person_label,2,3,self.col,self.col+1) + + change_button = gtk.Button("%s..." % _('C_hange') ) + change_button.connect('clicked',self.on_center_person_change_clicked) + self.tbl.attach(change_button,3,4,self.col,self.col+1,gtk.SHRINK|gtk.SHRINK) + self.col += 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_report_options_frame(self): """Set up the report options frame of the dialog. This function relies on several report_xxx() customization @@ -545,57 +595,31 @@ 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.""" + #------------------------------------------------------------------------ + # + # Customization hooks for stand-alone reports (subclass ReportDialog) + # + #------------------------------------------------------------------------ + def setup_format_frame(self): + """Not used in bare report dialogs. Override in the subclass.""" + pass - # Styles Frame - label = gtk.Label("%s:" % _("Styles")) - label.set_alignment(0.0,0.5) + def setup_paper_frame(self): + """Not used in bare report dialogs. Override in the subclass.""" + pass - 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("%s" % _("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( "%s" % 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) + def setup_html_frame(self): + """Not used in bare report dialogs. Override in the subclass.""" + pass + def setup_paper_frame(self): + """Not used in bare report dialogs. Override in the subclass.""" + pass + def setup_output_notebook(self): + """Not used in bare report dialogs. Override in the subclass.""" + pass + #------------------------------------------------------------------------ # # Functions related to retrieving data from the dialog window diff --git a/gramps2/src/plugins/BookReport.py b/gramps2/src/plugins/BookReport.py index a395bed34..152877bd9 100644 --- a/gramps2/src/plugins/BookReport.py +++ b/gramps2/src/plugins/BookReport.py @@ -107,7 +107,8 @@ class BookReportSelector: self.max_key = 0 av_titles = [(_('Name'),2,150),(_('Type'),1,50)] - bk_titles = [(_('Item name'),-1,150),(_('Type'),1,50),('',-1,0)] #,('',-1,0) + 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) @@ -142,6 +143,7 @@ class BookReportSelector: if not iter: return data = self.av_model.get_data(iter,range(self.av_ncols)) + data.append(self.person.getPrimaryName().getRegularName()) self.max_key = self.max_key + 1 newkey = str(self.max_key) data.append(newkey) @@ -155,7 +157,7 @@ class BookReportSelector: if not iter: return data = self.bk_model.get_data(iter,range(self.bk_ncols)) - key = data[2] + key = data[self.bk_ncols-1] del self.item_storage[key] self.bk_model.remove(iter) @@ -186,17 +188,18 @@ class BookReportSelector: if not iter: return data = self.bk_model.get_data(iter,range(self.bk_ncols)) - key = data[2] + key = data[self.bk_ncols-1] 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) + if opt_dlg.person: + self.bk_model.model.set_value(iter,2, + opt_dlg.person.getPrimaryName().getRegularName()) 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: @@ -213,7 +216,7 @@ class BookReportSelector: 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] + key = data[self.bk_ncols-1] book_item = self.item_storage[key] item_list.append(book_item) BookReportDialog(self.db,self.person,item_list) @@ -264,9 +267,8 @@ class BookReportDialog(Report.ReportDialog): 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.""" + """The actual book report. Start it out, then go through the item list + and call each item's write_book_item method.""" self.doc.start_paragraph("Title") title = _("Book Report") self.doc.write_text(title) diff --git a/gramps2/src/plugins/FtmStyleDescendants.py b/gramps2/src/plugins/FtmStyleDescendants.py index 35cc7810b..b12b78538 100644 --- a/gramps2/src/plugins/FtmStyleDescendants.py +++ b/gramps2/src/plugins/FtmStyleDescendants.py @@ -1177,7 +1177,6 @@ def _make_default_style(self): class FtmDescendantReportDialog(Report.TextReportDialog): def __init__(self,database,person): Report.TextReportDialog.__init__(self,database,person) - self.make_default_style = _make_default_style #------------------------------------------------------------------------ # @@ -1201,6 +1200,9 @@ class FtmDescendantReportDialog(Report.TextReportDialog): """Where to save styles for this report.""" return "ftm_descendant_report.xml" + def make_default_style(self): + _make_default_style(self) + 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 @@ -1277,6 +1279,8 @@ class FtmDescendantBareReportDialog(Report.BareReportDialog): self.generations_spinbox.set_value(self.max_gen) self.pagebreak_checkbox.set_active(self.pg_brk) + self.window.run() + #------------------------------------------------------------------------ # # Customization hooks @@ -1294,6 +1298,9 @@ class FtmDescendantBareReportDialog(Report.BareReportDialog): """Where to save styles for this report.""" return "ftm_descendant_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.""" @@ -1308,9 +1315,13 @@ class FtmDescendantBareReportDialog(Report.BareReportDialog): 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 @@ -1451,4 +1462,4 @@ register_book_item( write_book_item, get_options, get_style -) + )