* 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
This commit is contained in:
Alex Roitman 2003-06-08 20:32:17 +00:00
parent 00eb8ef198
commit 34f42ec646
4 changed files with 116 additions and 73 deletions

View File

@ -1,3 +1,9 @@
2003-06-08 Alex Roitman <shura@alex.neuro.umn.edu>
* 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 <shura@alex.neuro.umn.edu> 2003-06-08 Alex Roitman <shura@alex.neuro.umn.edu>
* src/Report.py, src/plugins/BookReport.py, * src/Report.py, src/plugins/BookReport.py,
src/plugins/FtmStyleDescendants.py: Fix changing center person -- only src/plugins/FtmStyleDescendants.py: Fix changing center person -- only

View File

@ -219,6 +219,7 @@ class BareReportDialog:
self.tbl.set_border_width(6) self.tbl.set_border_width(6)
self.col = 0 self.col = 0
self.window.vbox.add(self.tbl) self.window.vbox.add(self.tbl)
self.setup_center_person()
self.setup_target_frame() self.setup_target_frame()
self.setup_format_frame() self.setup_format_frame()
self.setup_style_frame() self.setup_style_frame()
@ -227,22 +228,8 @@ class BareReportDialog:
self.setup_html_frame() self.setup_html_frame()
self.setup_report_options_frame() self.setup_report_options_frame()
self.setup_other_frames() self.setup_other_frames()
self.setup_center_person()
self.window.show_all() 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 # Customization hooks for subclasses
@ -395,6 +382,69 @@ class BareReportDialog:
label.set_use_markup(gtk.TRUE) label.set_use_markup(gtk.TRUE)
self.window.vbox.pack_start(label,gtk.TRUE,gtk.TRUE,ReportDialog.border_pad) 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("<b>%s</b>" % _('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("<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,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): def setup_report_options_frame(self):
"""Set up the report options frame of the dialog. This """Set up the report options frame of the dialog. This
@ -545,56 +595,30 @@ class BareReportDialog:
table.attach(widget,2,3,row,row+1) table.attach(widget,2,3,row,row+1)
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, # Customization hooks for stand-alone reports (subclass ReportDialog)
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.""" def setup_format_frame(self):
"""Not used in bare report dialogs. Override in the subclass."""
pass
# Styles Frame def setup_paper_frame(self):
label = gtk.Label("%s:" % _("Styles")) """Not used in bare report dialogs. Override in the subclass."""
label.set_alignment(0.0,0.5) pass
self.style_menu = gtk.OptionMenu() def setup_html_frame(self):
self.style_button = gtk.Button("%s..." % _("Style Editor")) """Not used in bare report dialogs. Override in the subclass."""
self.style_button.connect('clicked',self.on_style_edit_clicked) pass
self.tbl.attach(label,1,2,self.col,self.col+1,gtk.SHRINK|gtk.FILL) def setup_paper_frame(self):
self.tbl.attach(self.style_menu,2,3,self.col,self.col+1) """Not used in bare report dialogs. Override in the subclass."""
self.tbl.attach(self.style_button,3,4,self.col,self.col+1,gtk.SHRINK|gtk.FILL) pass
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)
def setup_output_notebook(self):
"""Not used in bare report dialogs. Override in the subclass."""
pass
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #

View File

@ -107,7 +107,8 @@ class BookReportSelector:
self.max_key = 0 self.max_key = 0
av_titles = [(_('Name'),2,150),(_('Type'),1,50)] 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.av_ncols = len(av_titles)
self.bk_ncols = len(bk_titles) self.bk_ncols = len(bk_titles)
@ -142,6 +143,7 @@ class BookReportSelector:
if not iter: if not iter:
return return
data = self.av_model.get_data(iter,range(self.av_ncols)) data = self.av_model.get_data(iter,range(self.av_ncols))
data.append(self.person.getPrimaryName().getRegularName())
self.max_key = self.max_key + 1 self.max_key = self.max_key + 1
newkey = str(self.max_key) newkey = str(self.max_key)
data.append(newkey) data.append(newkey)
@ -155,7 +157,7 @@ class BookReportSelector:
if not iter: if not iter:
return return
data = self.bk_model.get_data(iter,range(self.bk_ncols)) 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] del self.item_storage[key]
self.bk_model.remove(iter) self.bk_model.remove(iter)
@ -186,17 +188,18 @@ class BookReportSelector:
if not iter: if not iter:
return return
data = self.bk_model.get_data(iter,range(self.bk_ncols)) 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] book_item = self.item_storage[key]
options_dialog = book_item[2] options_dialog = book_item[2]
get_opt = book_item[4] get_opt = book_item[4]
get_stl = book_item[5] get_stl = book_item[5]
opt_dlg = options_dialog(self.db,self.person,get_opt,get_stl) 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[4] = opt_dlg.get_options
book_item[5] = opt_dlg.get_style book_item[5] = opt_dlg.get_style
self.item_storage[key] = book_item self.item_storage[key] = book_item
self.person = opt_dlg.person
#print opt_dlg.person.getPrimaryName().getRegularName()
def bk_double_click(self,obj,event): def bk_double_click(self,obj,event):
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
@ -213,7 +216,7 @@ class BookReportSelector:
self.bk_model.select_row(row) self.bk_model.select_row(row)
store,iter = self.bk_model.get_selected() store,iter = self.bk_model.get_selected()
data = self.bk_model.get_data(iter,range(self.bk_ncols)) 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] book_item = self.item_storage[key]
item_list.append(book_item) item_list.append(book_item)
BookReportDialog(self.db,self.person,item_list) BookReportDialog(self.db,self.person,item_list)
@ -264,9 +267,8 @@ class BookReportDialog(Report.ReportDialog):
self.doc.open(self.target_path) self.doc.open(self.target_path)
def make_report(self): def make_report(self):
"""Create the contents of the report. This is a simple """The actual book report. Start it out, then go through the item list
default implementation suitable for testing. Is should be and call each item's write_book_item method."""
overridden to produce a real report."""
self.doc.start_paragraph("Title") self.doc.start_paragraph("Title")
title = _("Book Report") title = _("Book Report")
self.doc.write_text(title) self.doc.write_text(title)

View File

@ -1177,7 +1177,6 @@ def _make_default_style(self):
class FtmDescendantReportDialog(Report.TextReportDialog): class FtmDescendantReportDialog(Report.TextReportDialog):
def __init__(self,database,person): def __init__(self,database,person):
Report.TextReportDialog.__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.""" """Where to save styles for this report."""
return "ftm_descendant_report.xml" return "ftm_descendant_report.xml"
def make_default_style(self):
_make_default_style(self)
def make_report(self): def make_report(self):
"""Create the object that will produce the FTM Style Descendant Report. """Create the object that will produce the FTM Style Descendant Report.
All user dialog has already been handled and the output file 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.generations_spinbox.set_value(self.max_gen)
self.pagebreak_checkbox.set_active(self.pg_brk) self.pagebreak_checkbox.set_active(self.pg_brk)
self.window.run()
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Customization hooks # Customization hooks
@ -1294,6 +1298,9 @@ class FtmDescendantBareReportDialog(Report.BareReportDialog):
"""Where to save styles for this report.""" """Where to save styles for this report."""
return "ftm_descendant_report.xml" return "ftm_descendant_report.xml"
def make_default_style(self):
_make_default_style(self)
def on_ok_clicked(self, obj): def on_ok_clicked(self, obj):
"""The user is satisfied with the dialog choices. Parse all options """The user is satisfied with the dialog choices. Parse all options
and close the window.""" and close the window."""
@ -1308,9 +1315,13 @@ class FtmDescendantBareReportDialog(Report.BareReportDialog):
self.window.destroy() self.window.destroy()
def get_options(self): 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 ] return [ self.person, self.max_gen, self.pg_brk ]
def get_style(self): def get_style(self):
"""This function returns the style to be used for this book item."""
return self.selected_style return self.selected_style
@ -1451,4 +1462,4 @@ register_book_item(
write_book_item, write_book_item,
get_options, get_options,
get_style get_style
) )