More refactoring in the report system. More reports use MenuOptions now. BareReportDialog no longer has "center person".

svn: r9714
This commit is contained in:
Brian Matherly 2008-01-05 20:42:05 +00:00
parent bf3900f043
commit 81e521c53b
28 changed files with 541 additions and 798 deletions

View File

@ -1,3 +1,34 @@
2008-01-05 Brian Matherly <brian@gramps-project.org>
* src/ReportBase/_ReportDialog.py:
* src/ReportBase/_BareReportDialog.py:
* src/ReportBase/_ReportOptions.py:
* src/plugins/KinshipReport.py:
* src/plugins/DetDescendantReport.py:
* src/plugins/DescendReport.py:
* src/plugins/IndivComplete.py:
* src/plugins/CalculateEstimatedDates.py:
* src/plugins/BookReport.py:
* src/plugins/TimeLine.py:
* src/plugins/GVFamilyLines.py:
* src/plugins/Calendar.py:
* src/plugins/AncestorReport.py:
* src/plugins/MarkerReport.py:
* src/plugins/DescendChart.py:
* src/plugins/EndOfLineReport.py:
* src/plugins/DetAncestralReport.py:
* src/plugins/SimpleBookTitle.py:
* src/plugins/CustomBookText.py:
* src/plugins/FamilyGroup.py:
* src/plugins/GVRelGraph.py:
* src/plugins/GVHourGlass.py:
* src/plugins/StatisticsChart.py:
* src/plugins/FanChart.py:
* src/PluginUtils/_PluginWindows.py:
* src/PluginUtils/__init__.py:
* src/PluginUtils/_MenuOptions.py:
More refactoring in the report system. More reports use MenuOptions now.
BareReportDialog no longer has "center person".
2008-01-05 Raphael Ackermann <raphael.ackermann@gmail.com> 2008-01-05 Raphael Ackermann <raphael.ackermann@gmail.com>
2008-01-05 Brian Matherly <brian@gramps-project.org> 2008-01-05 Brian Matherly <brian@gramps-project.org>
* src/DataViews/PedigreeView.py: * src/DataViews/PedigreeView.py:

View File

@ -549,91 +549,65 @@ class EnumeratedListOption(Option):
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# FilterListOption class # PersonFilterOption class
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class FilterListOption(Option): class PersonFilterOption(Option):
""" """
This class describes an option that provides a finite list of filters. This class describes an option that provides a list of person filters.
Each possible value is assigned a type of set of filters to use. Each possible value represents one of the possible filters.
""" """
def __init__(self,label,value=0): def __init__(self,label, dbstate, value=0, include_single=True):
""" """
@param label: A friendly label to be applied to this option. @param label: A friendly label to be applied to this option.
Example: "Filter" Example: "Filter"
@type label: string @type label: string
@param dbstate: A DbState instance
@type dbstate: DbState
@param value: A default value for the option.
Example: 1
@type label: int
@param include_single: Whether a filter should be included for a
single person.
@type include_single: bool
@return: nothing @return: nothing
""" """
from ReportBase import ReportUtils
Option.__init__(self,label,value) Option.__init__(self,label,value)
self.__items = [] self.__dbstate = dbstate
self.__filters = [] self.__include_single = include_single
self.__person = self.__dbstate.get_active_person()
def add_item(self,value): self.__filters = ReportUtils.get_person_filters(self.__person,
self.__include_single)
if self.get_value() > len(self.__filters):
self.set_value(0)
def get_center_person(self):
return self.__person
def get_filter(self):
""" """
Add an item to the list of possible values. Return the filter object.
@param value: A name of a set of filters.
Example: "person"
@type value: string
@return: nothing
""" """
self.__items.append(value) return self.__filters[self.get_value()]
def get_items(self):
"""
Get all the possible values for this option.
@return: an array of tuples containing (value,description) pairs.
"""
return self.__items
def add_filter(self, filter):
"""
Add a filter set to the list.
@param filter: A filter object.
Example: <Filter>
@type value: Filter
@return: nothing
"""
self.__filters.append(filter)
def get_filters(self):
"""
Get all of the filter objects.
@type value: Filter
@return: an array of filter objects
"""
return self.__filters
def clear_filters(self):
"""
Clear all of the filter objects.
"""
self.__filters = []
def make_gui_obj(self, gtk, dialog): def make_gui_obj(self, gtk, dialog):
""" """
Add an FilterListOption to the dialog. Add an PersonFilterOption to the dialog.
""" """
from ReportBase import ReportUtils
self.dialog = dialog self.dialog = dialog
self.combo = gtk.combo_box_new_text() self.combo = gtk.combo_box_new_text()
self.combo.connect('changed',self.__on_value_changed)
self.gobj = gtk.HBox() self.gobj = gtk.HBox()
for filter in self.get_items():
if filter in ["person"]:
filter_list = ReportUtils.get_person_filters(dialog.person,
include_single=True)
for filter in filter_list:
self.combo.append_text(filter.get_name())
self.add_filter(filter)
self.combo.set_active(self.get_value())
self.change_button = gtk.Button("%s..." % _('C_hange') ) self.change_button = gtk.Button("%s..." % _('C_hange') )
self.change_button.connect('clicked',self.on_change_clicked) self.change_button.connect('clicked',self.on_change_clicked)
self.gobj.pack_start(self.combo, False) self.gobj.pack_start(self.combo, False)
self.gobj.pack_start(self.change_button, False) self.gobj.pack_start(self.change_button, False)
self.update_gui_obj()
def __on_value_changed(self, obj):
self.set_value( int(self.combo.get_active()) )
def on_change_clicked(self, *obj): def on_change_clicked(self, *obj):
from Selectors import selector_factory from Selectors import selector_factory
@ -643,39 +617,28 @@ class FilterListOption(Option):
self.dialog.track) self.dialog.track)
new_person = sel_person.run() new_person = sel_person.run()
if new_person: if new_person:
self.dialog.person = new_person self.__person = new_person
self.update_gui_obj() self.update_gui_obj()
def get_center_person(self):
return self.dialog.person
def get_filter(self):
"""
Return the filter object.
"""
return self.get_filters()[int(self.combo.get_active())]
def update_gui_obj(self): def update_gui_obj(self):
# update the gui object with new filter info # update the gui object with new filter info
from ReportBase import ReportUtils from ReportBase import ReportUtils
for i in range(len(self.get_filters())): self.combo.get_model().clear()
self.combo.remove_text(0) self.__filters = ReportUtils.get_person_filters(self.__person,
self.clear_filters() self.__include_single)
for filter in self.get_items(): for filter in self.__filters:
if filter in ["person"]: self.combo.append_text(filter.get_name())
filter_list = ReportUtils.get_person_filters(self.dialog.person,
include_single=True) if self.get_value() >= len(self.__filters):
for filter in filter_list: # Set the value to zero if it is not valid.
self.combo.append_text(filter.get_name()) self.set_value(0)
self.add_filter(filter)
self.combo.set_active(self.get_value()) self.combo.set_active(self.get_value())
def parse(self): def parse(self):
""" """
Parse the object and return. Parse the object and return.
""" """
self.__value = int(self.combo.get_active()) return self.get_value()
return self.__value
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #

View File

@ -217,7 +217,6 @@ class ToolManagedWindowBase(ManagedWindow.ManagedWindow):
# Build the list of widgets that are used to extend the Options # Build the list of widgets that are used to extend the Options
# frame and to create other frames # frame and to create other frames
self.add_user_options() self.add_user_options()
self.setup_center_person()
self.notebook = gtk.Notebook() self.notebook = gtk.Notebook()
self.notebook.set_border_width(6) self.notebook.set_border_width(6)
@ -365,11 +364,6 @@ class ToolManagedWindowBase(ManagedWindow.ManagedWindow):
label = gtk.Label('<span size="larger" weight="bold">%s</span>' % title) label = gtk.Label('<span size="larger" weight="bold">%s</span>' % title)
label.set_use_markup(True) label.set_use_markup(True)
self.window.vbox.pack_start(label, True, True, self.border_pad) self.window.vbox.pack_start(label, True, True, self.border_pad)
def setup_center_person(self):
"""Set up center person labels and change button.
Should be overwritten by standalone report dialogs. """
pass
def add_frame_option(self,frame_name,label_text,widget,tooltip=None): def add_frame_option(self,frame_name,label_text,widget,tooltip=None):
"""Similar to add_option this method takes a frame_name, a """Similar to add_option this method takes a frame_name, a

View File

@ -2,6 +2,7 @@
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2001-2006 Donald N. Allingham # Copyright (C) 2001-2006 Donald N. Allingham
# Copyright (C) 2008 Brian Matherly
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -29,7 +30,7 @@
# of the list. # of the list.
from _MenuOptions import MenuOptions, \ from _MenuOptions import MenuOptions, \
NumberOption, FloatOption, BooleanOption, TextOption, \ NumberOption, FloatOption, BooleanOption, TextOption, \
EnumeratedListOption, FilterListOption, StringOption, ColourButtonOption, \ EnumeratedListOption, PersonFilterOption, StringOption, ColourButtonOption, \
PersonOption, PersonListOption, SurnameColourOption PersonOption, PersonListOption, SurnameColourOption
from _PluginMgr import \ from _PluginMgr import \
register_export, register_import, \ register_export, register_import, \

View File

@ -146,7 +146,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow):
self.add_user_options() self.add_user_options()
self.setup_main_options() self.setup_main_options()
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()
@ -297,27 +296,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow):
self.tbl.attach(label, 0, 4, self.col, self.col+1, gtk.FILL|gtk.EXPAND) self.tbl.attach(label, 0, 4, self.col, self.col+1, gtk.FILL|gtk.EXPAND)
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(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 = name_displayer.display(self.person)
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)
self.col += 1
def setup_style_frame(self): def setup_style_frame(self):
"""Set up the style frame of the dialog. This function relies """Set up the style frame of the dialog. This function relies
on other routines create the default style for this report, on other routines create the default style for this report,
@ -493,18 +471,6 @@ class BareReportDialog(ManagedWindow.ManagedWindow):
StyleListDisplay(self.style_sheet_list,self.build_style_menu, StyleListDisplay(self.style_sheet_list,self.build_style_menu,
self.window) self.window)
def on_center_person_change_clicked(self,*obj):
from Selectors import selector_factory
SelectPerson = selector_factory('Person')
sel_person = SelectPerson(self.dbstate,self.uistate,self.track)
new_person = sel_person.run()
if new_person:
self.new_person = new_person
new_name = name_displayer.display(new_person)
if new_name:
self.person_label.set_text( "<i>%s</i>" % new_name )
self.person_label.set_use_markup(True)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Functions related to creating the actual report document. # Functions related to creating the actual report document.

View File

@ -88,9 +88,6 @@ class ReportDialog(BareReportDialog):
def init_interface(self): def init_interface(self):
BareReportDialog.init_interface(self) BareReportDialog.init_interface(self)
def setup_center_person(self):
pass
def get_title(self): def get_title(self):
"""The window title for this dialog""" """The window title for this dialog"""
name = self.report_name name = self.report_name

View File

@ -670,5 +670,11 @@ class MenuReportOptions(MenuOptions,ReportOptions):
active_person = None active_person = None
ReportOptions.__init__(self,name,active_person) ReportOptions.__init__(self,name,active_person)
MenuOptions.__init__(self,dbstate) MenuOptions.__init__(self,dbstate)
def load_previous_values(self):
ReportOptions.load_previous_values(self)
# Pass the loaded values to the menu options so they will be displayed properly.
for optname in self.options_dict:
menu_option = self.menu.get_option_by_name(optname)
menu_option.set_value(self.options_dict[optname])

View File

@ -2,7 +2,7 @@
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2007 Donald N. Allingham # Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2007 Brian G. Matherly # Copyright (C) 2007-2008 Brian G. Matherly
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -37,7 +37,8 @@ from gettext import gettext as _
# gramps modules # gramps modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from PluginUtils import register_report, NumberOption, BooleanOption from PluginUtils import register_report, NumberOption, \
BooleanOption, PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions, \ from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
import BaseDoc import BaseDoc
@ -79,6 +80,8 @@ class AncestorReport(Report):
self.max_generations = options_class.handler.options_dict['maxgen'] self.max_generations = options_class.handler.options_dict['maxgen']
self.pgbrk = options_class.handler.options_dict['pagebbg'] self.pgbrk = options_class.handler.options_dict['pagebbg']
self.opt_namebrk = options_class.handler.options_dict['namebrk'] self.opt_namebrk = options_class.handler.options_dict['namebrk']
pid = options_class.handler.options_dict['pid']
self.center_person = database.get_person_from_gramps_id(pid)
def apply_filter(self,person_handle,index,generation=1): def apply_filter(self,person_handle,index,generation=1):
""" """
@ -142,12 +145,12 @@ class AncestorReport(Report):
# Call apply_filter to build the self.map array of people in the database that # Call apply_filter to build the self.map array of people in the database that
# match the ancestry. # match the ancestry.
self.apply_filter(self.start_person.get_handle(),1) self.apply_filter(self.center_person.get_handle(),1)
# Write the title line. Set in INDEX marker so that this section will be # Write the title line. Set in INDEX marker so that this section will be
# identified as a major category if this is included in a Book report. # identified as a major category if this is included in a Book report.
name = name_displayer.display_formal(self.start_person) name = name_displayer.display_formal(self.center_person)
title = _("Ahnentafel Report for %s") % name title = _("Ahnentafel Report for %s") % name
mark = BaseDoc.IndexMark(title, BaseDoc.INDEX_TYPE_TOC,1 ) mark = BaseDoc.IndexMark(title, BaseDoc.INDEX_TYPE_TOC,1 )
self.doc.start_paragraph("AHN-Title") self.doc.start_paragraph("AHN-Title")
@ -226,6 +229,16 @@ class AncestorOptions(MenuReportOptions):
MenuReportOptions.__init__(self,name,dbstate) MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu,dbstate): def add_menu_options(self,menu,dbstate):
"""
Add options to the menu for the ancestor report.
"""
id = ""
if dbstate:
id = dbstate.get_active_person().get_gramps_id()
pid = PersonOption(_("Center Person"),id,dbstate)
pid.set_help(_("The center person for the report"))
menu.add_option("","pid",pid)
category_name = _("Report Options") category_name = _("Report Options")
maxgen = NumberOption(_("Generations"),10,1,15) maxgen = NumberOption(_("Generations"),10,1,15)

View File

@ -2,7 +2,7 @@
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2003-2007 Donald N. Allingham # Copyright (C) 2003-2007 Donald N. Allingham
# Copyright (C) 2007 Brian G. Matherly # Copyright (C) 2007-2008 Brian G. Matherly
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -71,6 +71,7 @@ import Errors
import BaseDoc import BaseDoc
from QuestionDialog import WarningDialog, ErrorDialog from QuestionDialog import WarningDialog, ErrorDialog
from PluginUtils import bkitems_list, register_report, Plugins from PluginUtils import bkitems_list, register_report, Plugins
from PluginUtils import PersonOption, PersonFilterOption
import ManagedWindow import ManagedWindow
# Import from specific modules in ReportBase # Import from specific modules in ReportBase
@ -82,6 +83,35 @@ from ReportBase._DocReportDialog import DocReportDialog
from ReportBase._CommandLineReport import CommandLineReport from ReportBase._CommandLineReport import CommandLineReport
from ReportBase._ReportOptions import ReportOptions from ReportBase._ReportOptions import ReportOptions
#------------------------------------------------------------------------
#
# Private Functions
#
#------------------------------------------------------------------------
def _get_subject(options,db):
"""
Attempts to determine the subject of a set of options. The subject would
likely be a person (using a PersonOption) or a filter (using a
PersonFilterOption)
options: The ReportOptions class
db: the database for which it corresponds
"""
if not hasattr(options,"menu"):
return _("Not Applicable")
menu = options.menu
option_names = menu.get_all_option_names()
for name in option_names:
option = menu.get_option_by_name(name)
if isinstance(option,PersonOption):
from BasicUtils import name_displayer as _nd
gid = option.get_value()
person = db.get_person_from_gramps_id(gid)
return _nd.display(person)
elif isinstance(option,PersonFilterOption):
return option.get_filter().get_name()
return _("Not Applicable")
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Book Item class # Book Item class
@ -92,14 +122,14 @@ class BookItem:
Interface into the book item -- a smallest element of the book. Interface into the book item -- a smallest element of the book.
""" """
def __init__(self,name=None): def __init__(self,dbstate,name=None):
""" """
Creates a new empty BookItem. Creates a new empty BookItem.
name: if not None then the book item is retreived name: if not None then the book item is retreived
from the book item registry using name for lookup from the book item registry using name for lookup
""" """
self.dbstate = dbstate
if name: if name:
self.get_registered_item(name) self.get_registered_item(name)
else: else:
@ -137,7 +167,7 @@ class BookItem:
self.category = item[1] self.category = item[1]
self.write_item = item[2] self.write_item = item[2]
self.name = item[4] self.name = item[4]
self.option_class = item[3](self.name) self.option_class = item[3](self.name,self.dbstate)
self.option_class.load_previous_values() self.option_class.load_previous_values()
def get_name(self): def get_name(self):
@ -309,14 +339,14 @@ class BookList:
BookList is loaded from a specified XML file if it exists. BookList is loaded from a specified XML file if it exists.
""" """
def __init__(self,filename): def __init__(self,filename,dbstate):
""" """
Creates a new BookList from the books that may be defined in the Creates a new BookList from the books that may be defined in the
specified file. specified file.
file: XML file that contains book items definitions file: XML file that contains book items definitions
""" """
self.dbstate = dbstate
self.bookmap = {} self.bookmap = {}
self.file = os.path.join(const.HOME_DIR,filename) self.file = os.path.join(const.HOME_DIR,filename)
self.parse() self.parse()
@ -402,7 +432,7 @@ class BookList:
""" """
try: try:
p = make_parser() p = make_parser()
p.setContentHandler(BookParser(self)) p.setContentHandler(BookParser(self,self.dbstate))
the_file = open(self.file) the_file = open(self.file)
p.parse(the_file) p.parse(the_file)
the_file.close() the_file.close()
@ -420,13 +450,14 @@ class BookParser(handler.ContentHandler):
SAX parsing class for the Books XML file. SAX parsing class for the Books XML file.
""" """
def __init__(self,booklist): def __init__(self,booklist,dbstate):
""" """
Creates a BookParser class that populates the passed booklist. Creates a BookParser class that populates the passed booklist.
booklist: BookList to be loaded from the file. booklist: BookList to be loaded from the file.
""" """
handler.ContentHandler.__init__(self) handler.ContentHandler.__init__(self)
self.dbstate = dbstate
self.booklist = booklist self.booklist = booklist
self.b = None self.b = None
self.i = None self.i = None
@ -449,7 +480,7 @@ class BookParser(handler.ContentHandler):
self.dbname = attrs['database'] self.dbname = attrs['database']
self.b.set_dbname(self.dbname) self.b.set_dbname(self.dbname)
elif tag == "item": elif tag == "item":
self.i = BookItem(attrs['name']) self.i = BookItem(self.dbstate,attrs['name'])
self.o = {} self.o = {}
elif tag == "option": elif tag == "option":
self.an_o_name = attrs['name'] self.an_o_name = attrs['name']
@ -587,7 +618,7 @@ class BookOptions(ReportOptions):
} }
self.options_help = { self.options_help = {
'bookname' : ("=name","Name of the book. MANDATORY", 'bookname' : ("=name","Name of the book. MANDATORY",
BookList('books.xml').get_book_names(), BookList('books.xml',None).get_book_names(),
False), False),
} }
@ -655,7 +686,7 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
av_titles = [(_('Name'),0,150),(_('Type'),1,50),('',-1,0)] av_titles = [(_('Name'),0,150),(_('Type'),1,50),('',-1,0)]
bk_titles = [(_('Item name'),-1,150),(_('Type'),-1,50),('',-1,0), bk_titles = [(_('Item name'),-1,150),(_('Type'),-1,50),('',-1,0),
(_('Center person'),-1,50)] (_('Subject'),-1,50)]
self.av_ncols = len(av_titles) self.av_ncols = len(av_titles)
self.bk_ncols = len(bk_titles) self.bk_ncols = len(bk_titles)
@ -718,22 +749,15 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
self.bk_model.clear() self.bk_model.clear()
for saved_item in book.get_item_list(): for saved_item in book.get_item_list():
name = saved_item.get_name() name = saved_item.get_name()
item = BookItem(name) item = BookItem(self.dbstate,name)
item.option_class = saved_item.option_class item.option_class = saved_item.option_class
person_id = item.option_class.handler.get_person_id()
if not same_db or not person_id:
person_id = self.person.get_gramps_id()
item.option_class.handler.set_person_id(person_id)
item.set_style_name(saved_item.get_style_name()) item.set_style_name(saved_item.get_style_name())
self.book.append_item(item) self.book.append_item(item)
data = [ item.get_translated_name(), data = [ item.get_translated_name(),
item.get_category(), item.get_name() ] item.get_category(), item.get_name() ]
if data[2] in ('simple_book_title','custom_text'):
data[2]=(_("Not Applicable")) data[2] = _get_subject(item.option_class,self.db)
else:
pname = self.db.get_person_from_gramps_id(person_id)
data[2]=(pname.get_primary_name().get_regular_name())
self.bk_model.add(data) self.bk_model.add(data)
def on_add_clicked(self,obj): def on_add_clicked(self,obj):
@ -746,16 +770,9 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
if not the_iter: if not the_iter:
return return
data = self.av_model.get_data(the_iter,range(self.av_ncols)) data = self.av_model.get_data(the_iter,range(self.av_ncols))
item = BookItem(data[2]) item = BookItem(self.dbstate,data[2])
if data[2] in ('simple_book_title','custom_text'): data[2] = _get_subject(item.option_class,self.db)
data[2]=(_("Not Applicable"))
else:
data[2]=(self.person.get_primary_name().get_regular_name())
self.bk_model.add(data) self.bk_model.add(data)
person_id = item.option_class.handler.get_person_id()
if not person_id:
person_id = self.person.get_gramps_id()
item.option_class.handler.set_person_id(person_id)
self.book.append_item(item) self.book.append_item(item)
def on_remove_clicked(self,obj): def on_remove_clicked(self,obj):
@ -820,10 +837,9 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
item.get_translated_name(), item.get_translated_name(),
self.track) self.track)
response = item_dialog.window.run() response = item_dialog.window.run()
if (response == RESPONSE_OK) and (item_dialog.person) \ if response == RESPONSE_OK:
and (data[1] != _("Title")): subject = _get_subject(option_class,self.db)
self.bk_model.model.set_value(the_iter,2, self.bk_model.model.set_value(the_iter,2,subject)
item_dialog.person.get_primary_name().get_regular_name())
self.book.set_item(row,item) self.book.set_item(row,item)
item_dialog.close() item_dialog.close()
@ -914,7 +930,7 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
""" """
Save the current book in the xml booklist file. Save the current book in the xml booklist file.
""" """
self.book_list = BookList(self.file) self.book_list = BookList(self.file,dbstate)
name = unicode(self.name_entry.get_text()) name = unicode(self.name_entry.get_text())
self.book.set_name(name) self.book.set_name(name)
self.book.set_dbname(self.db.get_save_path()) self.book.set_dbname(self.db.get_save_path())
@ -925,7 +941,7 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
""" """
Run the BookListDisplay dialog to present the choice of books to open. Run the BookListDisplay dialog to present the choice of books to open.
""" """
self.book_list = BookList(self.file) self.book_list = BookList(self.file,self.dbstate)
booklistdisplay = BookListDisplay(self.book_list,1,0) booklistdisplay = BookListDisplay(self.book_list,1,0)
booklistdisplay.top.destroy() booklistdisplay.top.destroy()
book = booklistdisplay.selection book = booklistdisplay.selection
@ -937,7 +953,7 @@ class BookReportSelector(ManagedWindow.ManagedWindow):
""" """
Run the BookListDisplay dialog to present the choice of books to delete. Run the BookListDisplay dialog to present the choice of books to delete.
""" """
self.book_list = BookList(self.file) self.book_list = BookList(self.file,self.dbstate)
booklistdisplay = BookListDisplay(self.book_list,0,1) booklistdisplay = BookListDisplay(self.book_list,0,1)
booklistdisplay.top.destroy() booklistdisplay.top.destroy()
@ -958,10 +974,7 @@ class BookItemDialog(BareReportDialog):
self.database = dbstate.db self.database = dbstate.db
self.option_class = option_class self.option_class = option_class
self.person = self.database.get_person_from_gramps_id( BareReportDialog.__init__(self,dbstate,uistate,None,
self.option_class.handler.get_person_id())
self.new_person = None
BareReportDialog.__init__(self,dbstate,uistate,self.person,
option_class,name,translated_name,track) option_class,name,translated_name,track)
def on_ok_clicked(self, obj): def on_ok_clicked(self, obj):
@ -972,10 +985,6 @@ class BookItemDialog(BareReportDialog):
self.parse_style_frame() self.parse_style_frame()
self.parse_user_options() self.parse_user_options()
if self.new_person:
self.person = self.new_person
self.option_class.handler.set_person_id(self.person.get_gramps_id())
self.options.handler.save_options() self.options.handler.save_options()
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -1108,7 +1117,7 @@ def cl_report(database,name,category,options_str_dict):
if clr.show: if clr.show:
return return
book_list = BookList('books.xml') book_list = BookList('books.xml',None)
book_name = clr.options_dict['bookname'] book_name = clr.options_dict['bookname']
book = book_list.get_book(book_name) book = book_list.get_book(book_name)
selected_style = BaseDoc.StyleSheet() selected_style = BaseDoc.StyleSheet()

View File

@ -36,7 +36,7 @@ import time
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from PluginUtils import Tool, register_tool, PluginWindows, \ from PluginUtils import Tool, register_tool, PluginWindows, \
MenuToolOptions, BooleanOption, FilterListOption, StringOption, \ MenuToolOptions, BooleanOption, PersonFilterOption, StringOption, \
NumberOption NumberOption
import gen.lib import gen.lib
import Config import Config
@ -55,8 +55,7 @@ class CalcEstDateOptions(MenuToolOptions):
""" Adds the options """ """ Adds the options """
category_name = _("Options") category_name = _("Options")
filter = FilterListOption(_("Filter"), 3) filter = PersonFilterOption(_("Filter"), dbstate, 3)
filter.add_item("person")
filter.set_help(_("Select filter to restrict people")) filter.set_help(_("Select filter to restrict people"))
menu.add_option(category_name,"filter", filter) menu.add_option(category_name,"filter", filter)

View File

@ -45,7 +45,7 @@ from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_DRAW, CATEGORY_TEXT, \ CATEGORY_DRAW, CATEGORY_TEXT, \
MODE_GUI, MODE_BKI, MODE_CLI MODE_GUI, MODE_BKI, MODE_CLI
from PluginUtils import NumberOption, BooleanOption, StringOption, \ from PluginUtils import NumberOption, BooleanOption, StringOption, \
FilterListOption, EnumeratedListOption PersonFilterOption, EnumeratedListOption
import GrampsLocale import GrampsLocale
import gen.lib import gen.lib
from Utils import probably_alive, ProgressMeter from Utils import probably_alive, ProgressMeter
@ -480,8 +480,7 @@ class CalendarOptions(MenuReportOptions):
year.set_help(_("Year of calendar")) year.set_help(_("Year of calendar"))
menu.add_option(category_name,"year", year) menu.add_option(category_name,"year", year)
filter = FilterListOption(_("Filter")) filter = PersonFilterOption(_("Filter"),dbstate,0,False)
filter.add_item("person")
filter.set_help(_("Select filter to restrict people that appear on calendar")) filter.set_help(_("Select filter to restrict people that appear on calendar"))
menu.add_option(category_name,"filter", filter) menu.add_option(category_name,"filter", filter)

View File

@ -41,8 +41,8 @@ import gtk
# gramps modules # gramps modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from PluginUtils import register_report from PluginUtils import register_report, TextOption
from ReportBase import Report, ReportOptions, CATEGORY_TEXT, MODE_BKI from ReportBase import Report, MenuReportOptions, CATEGORY_TEXT, MODE_BKI
import BaseDoc import BaseDoc
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -77,105 +77,52 @@ class CustomText(Report):
def write_report(self): def write_report(self):
self.doc.start_paragraph('CBT-Initial') self.doc.start_paragraph('CBT-Initial')
self.doc.write_text(self.top_text) for line in self.top_text:
self.doc.write_text(line)
self.doc.write_text("\n")
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.start_paragraph('CBT-Middle') self.doc.start_paragraph('CBT-Middle')
self.doc.write_text(self.middle_text) for line in self.middle_text:
self.doc.write_text(line)
self.doc.write_text("\n")
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.start_paragraph('CBT-Final') self.doc.start_paragraph('CBT-Final')
self.doc.write_text(self.bottom_text) for line in self.bottom_text:
self.doc.write_text(line)
self.doc.write_text("\n")
self.doc.end_paragraph() self.doc.end_paragraph()
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# # CustomTextOptions
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class CustomTextOptions(ReportOptions): class CustomTextOptions(MenuReportOptions):
""" """
Defines options and provides handling interface. Defines options and provides handling interface.
""" """
def __init__(self,name,person_id=None): def __init__(self,name,dbstate=None):
ReportOptions.__init__(self,name,person_id) MenuReportOptions.__init__(self,name,dbstate)
# Options specific for this report
self.options_dict = {
'top' : '',
'mid' : '',
'bot' : '',
}
self.options_help = {
'top' : ("=str","Initial Text",
"Whatever String You Wish"),
'mid' : ("=str","Middle Text",
"Whatever String You Wish"),
'bot' : ("=str","Final Text",
"Whatever String You Wish"),
}
def do_nothing(self): def add_menu_options(self,menu,dbstate):
pass
category_name = _("Text")
def add_user_options(self,dialog):
dialog.setup_center_person = self.do_nothing #Disable center person top = TextOption(_("Initial Text"), [""] )
dialog.notebook = gtk.Notebook() top.set_help(_("Text to display at the top."))
dialog.notebook.set_border_width(6) menu.add_option(category_name,"top",top)
dialog.window.vbox.add(dialog.notebook)
mid = TextOption(_("Middle Text"), [""] )
top_sw = gtk.ScrolledWindow() mid.set_help(_("Text to display in the middle"))
middle_sw = gtk.ScrolledWindow() menu.add_option(category_name,"mid",mid)
bottom_sw = gtk.ScrolledWindow()
bot = TextOption(_("Final Text"), [""] )
top_sw.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) bot.set_help(_("Text to display last."))
middle_sw.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC) menu.add_option(category_name,"bot",bot)
bottom_sw.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
self.top_text_view = gtk.TextView()
self.top_text_view.get_buffer().set_text(self.options_dict['top'])
self.middle_text_view = gtk.TextView()
self.middle_text_view.get_buffer().set_text(self.options_dict['mid'])
self.bottom_text_view = gtk.TextView()
self.bottom_text_view.get_buffer().set_text(self.options_dict['bot'])
top_sw.add_with_viewport(self.top_text_view)
middle_sw.add_with_viewport(self.middle_text_view)
bottom_sw.add_with_viewport(self.bottom_text_view)
dialog.add_frame_option(_('Initial Text'),"",top_sw)
dialog.add_frame_option(_('Middle Text'),"",middle_sw)
dialog.add_frame_option(_('Final Text'),"",bottom_sw)
def parse_user_options(self,dialog):
"""
Parses the custom options that we have added.
"""
self.options_dict['top'] = unicode(
self.top_text_view.get_buffer().get_text(
self.top_text_view.get_buffer().get_start_iter(),
self.top_text_view.get_buffer().get_end_iter(),
False
)
).replace('\n',' ')
self.options_dict['mid'] = unicode(
self.middle_text_view.get_buffer().get_text(
self.middle_text_view.get_buffer().get_start_iter(),
self.middle_text_view.get_buffer().get_end_iter(),
False
)
).replace('\n',' ')
self.options_dict['bot'] = unicode(
self.bottom_text_view.get_buffer().get_text(
self.bottom_text_view.get_buffer().get_start_iter(),
self.bottom_text_view.get_buffer().get_end_iter(),
False
)
).replace('\n',' ')
def make_default_style(self,default_style): def make_default_style(self,default_style):
"""Make the default output style for the Custom Text report.""" """Make the default output style for the Custom Text report."""

View File

@ -2,7 +2,7 @@
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2007 Donald N. Allingham # Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2007 Brian G. Matherly # Copyright (C) 2007-2008 Brian G. Matherly
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -29,7 +29,8 @@
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from BasicUtils import name_displayer from BasicUtils import name_displayer
from PluginUtils import register_report, NumberOption, BooleanOption, TextOption from PluginUtils import register_report, NumberOption, BooleanOption, \
TextOption, PersonOption
from ReportBase import Report, MenuReportOptions, \ from ReportBase import Report, MenuReportOptions, \
ReportUtils, CATEGORY_DRAW, MODE_GUI, MODE_BKI, MODE_CLI ReportUtils, CATEGORY_DRAW, MODE_GUI, MODE_BKI, MODE_CLI
from SubstKeywords import SubstKeywords from SubstKeywords import SubstKeywords
@ -124,8 +125,10 @@ class DescendChart(Report):
self.max_generations = options_class.handler.options_dict['maxgen'] self.max_generations = options_class.handler.options_dict['maxgen']
self.force_fit = options_class.handler.options_dict['singlep'] self.force_fit = options_class.handler.options_dict['singlep']
self.incblank = options_class.handler.options_dict['incblank'] self.incblank = options_class.handler.options_dict['incblank']
pid = options_class.handler.options_dict['pid']
center_person = database.get_person_from_gramps_id(pid)
name = name_displayer.display_formal(person) name = name_displayer.display_formal(center_person)
self.title = _("Descendant Chart for %s") % name self.title = _("Descendant Chart for %s") % name
self.map = {} self.map = {}
@ -139,7 +142,7 @@ class DescendChart(Report):
self.genchart = GenChart(32) self.genchart = GenChart(32)
self.apply_filter(self.start_person.get_handle(),0,0) self.apply_filter(center_person.get_handle(),0,0)
self.calc() self.calc()
@ -400,7 +403,17 @@ class DescendChartOptions(MenuReportOptions):
def __init__(self,name,dbstate=None): def __init__(self,name,dbstate=None):
MenuReportOptions.__init__(self,name,dbstate) MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu): def add_menu_options(self,menu,dbstate):
"""
Add options to the menu for the descendant report.
"""
id = ""
if dbstate:
id = dbstate.get_active_person().get_gramps_id()
pid = PersonOption(_("Center Person"),id,dbstate)
pid.set_help(_("The center person for the report"))
menu.add_option("","pid",pid)
category_name = _("Report Options") category_name = _("Report Options")
max_gen = NumberOption(_("Generations"),10,1,50) max_gen = NumberOption(_("Generations"),10,1,50)

View File

@ -2,7 +2,7 @@
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2007 Donald N. Allingham # Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2007 Brian G. Matherly # Copyright (C) 2007-2008 Brian G. Matherly
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -36,7 +36,7 @@ from gettext import gettext as _
# GRAMPS modules # GRAMPS modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from PluginUtils import register_report, NumberOption from PluginUtils import register_report, NumberOption, PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions, \ from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
import BaseDoc import BaseDoc
@ -83,6 +83,8 @@ class DescendantReport(Report):
Report.__init__(self,database,person,options_class) Report.__init__(self,database,person,options_class)
self.max_generations = options_class.handler.options_dict['gen'] self.max_generations = options_class.handler.options_dict['gen']
pid = options_class.handler.options_dict['pid']
self.center_person = database.get_person_from_gramps_id(pid)
sort = Sort.Sort(self.database) sort = Sort.Sort(self.database)
self.by_birthdate = sort.by_birthdate self.by_birthdate = sort.by_birthdate
@ -148,12 +150,12 @@ class DescendantReport(Report):
def write_report(self): def write_report(self):
self.doc.start_paragraph("DR-Title") self.doc.start_paragraph("DR-Title")
name = name_displayer.display(self.start_person) name = name_displayer.display(self.center_person)
title = _("Descendants of %s") % name title = _("Descendants of %s") % name
mark = BaseDoc.IndexMark(title,BaseDoc.INDEX_TYPE_TOC,1) mark = BaseDoc.IndexMark(title,BaseDoc.INDEX_TYPE_TOC,1)
self.doc.write_text(title,mark) self.doc.write_text(title,mark)
self.doc.end_paragraph() self.doc.end_paragraph()
self.dump(1,self.start_person) self.dump(1,self.center_person)
def dump(self,level,person): def dump(self,level,person):
@ -199,6 +201,13 @@ class DescendantOptions(MenuReportOptions):
MenuReportOptions.__init__(self,name,dbstate) MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu,dbstate): def add_menu_options(self,menu,dbstate):
id = ""
if dbstate:
id = dbstate.get_active_person().get_gramps_id()
pid = PersonOption(_("Center Person"),id,dbstate)
pid.set_help(_("The center person for the report"))
menu.add_option("","pid",pid)
category_name = _("Report Options") category_name = _("Report Options")
gen = NumberOption(_("Generations"),10,1,15) gen = NumberOption(_("Generations"),10,1,15)

View File

@ -3,7 +3,7 @@
# #
# Copyright (C) 2000-2002 Bruce J. DeGrasse # Copyright (C) 2000-2002 Bruce J. DeGrasse
# Copyright (C) 2000-2007 Donald N. Allingham # Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2007 Brian G. Matherly # Copyright (C) 2007-2008 Brian G. Matherly
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -31,20 +31,14 @@
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gettext import gettext as _ from gettext import gettext as _
#------------------------------------------------------------------------
#
# Gnome/GTK modules
#
#------------------------------------------------------------------------
import gtk
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import gen.lib import gen.lib
from PluginUtils import register_report, NumberOption, BooleanOption from PluginUtils import register_report, NumberOption, \
BooleanOption, PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions, \ from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
from ReportBase import Bibliography, Endnotes from ReportBase import Bibliography, Endnotes
@ -92,6 +86,7 @@ class DetAncestorReport(Report):
dupPerson - Whether to omit duplicate ancestors (e.g. when distant cousins mary). dupPerson - Whether to omit duplicate ancestors (e.g. when distant cousins mary).
childRef - Whether to add descendant references in child list. childRef - Whether to add descendant references in child list.
addImages - Whether to include images. addImages - Whether to include images.
pid - The Gramps ID of the center person for the report.
""" """
Report.__init__(self,database,person,options_class) Report.__init__(self,database,person,options_class)
@ -114,6 +109,8 @@ class DetAncestorReport(Report):
self.includeAddr = options_class.handler.options_dict['incaddresses'] self.includeAddr = options_class.handler.options_dict['incaddresses']
self.includeSources= options_class.handler.options_dict['incsources'] self.includeSources= options_class.handler.options_dict['incsources']
self.includeAttrs = options_class.handler.options_dict['incattrs'] self.includeAttrs = options_class.handler.options_dict['incattrs']
pid = options_class.handler.options_dict['pid']
self.center_person = database.get_person_from_gramps_id(pid)
self.gen_handles = {} self.gen_handles = {}
self.prev_gen_handles= {} self.prev_gen_handles= {}
@ -143,9 +140,9 @@ class DetAncestorReport(Report):
self.apply_filter(family.get_mother_handle(),(index*2)+1) self.apply_filter(family.get_mother_handle(),(index*2)+1)
def write_report(self): def write_report(self):
self.apply_filter(self.start_person.get_handle(),1) self.apply_filter(self.center_person.get_handle(),1)
name = _nd.display_name(self.start_person.get_primary_name()) name = _nd.display_name(self.center_person.get_primary_name())
self.doc.start_paragraph("DAR-Title") self.doc.start_paragraph("DAR-Title")
title = _("Ancestral Report for %s") % name title = _("Ancestral Report for %s") % name
mark = BaseDoc.IndexMark(title,BaseDoc.INDEX_TYPE_TOC,1) mark = BaseDoc.IndexMark(title,BaseDoc.INDEX_TYPE_TOC,1)
@ -663,6 +660,13 @@ class DetAncestorOptions(MenuReportOptions):
MenuReportOptions.__init__(self,name,dbstate) MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu,dbstate): def add_menu_options(self,menu,dbstate):
id = ""
if dbstate:
id = dbstate.get_active_person().get_gramps_id()
pid = PersonOption(_("Center Person"),id,dbstate)
pid.set_help(_("The center person for the report"))
menu.add_option("","pid",pid)
category_name = _("Report Options") category_name = _("Report Options")
gen = NumberOption(_("Generations"),10,1,100) gen = NumberOption(_("Generations"),10,1,100)

View File

@ -3,7 +3,7 @@
# #
# Copyright (C) 2000-2002 Bruce J. DeGrasse # Copyright (C) 2000-2002 Bruce J. DeGrasse
# Copyright (C) 2000-2007 Donald N. Allingham # Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2007 Brian G. Matherly # Copyright (C) 2007-2008 Brian G. Matherly
# Copyright (C) 2007 Robert Cawley <rjc@cawley.id.au> # Copyright (C) 2007 Robert Cawley <rjc@cawley.id.au>
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
@ -32,20 +32,14 @@
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gettext import gettext as _ from gettext import gettext as _
#------------------------------------------------------------------------
#
# Gnome/GTK modules
#
#------------------------------------------------------------------------
import gtk
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import gen.lib import gen.lib
from PluginUtils import register_report, NumberOption, BooleanOption from PluginUtils import register_report, NumberOption, \
BooleanOption, PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions, \ from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
from ReportBase import Bibliography, Endnotes from ReportBase import Bibliography, Endnotes
@ -95,6 +89,7 @@ class DetDescendantReport(Report):
dupPerson - Whether to omit duplicate ancestors (e.g. when distant cousins mary). dupPerson - Whether to omit duplicate ancestors (e.g. when distant cousins mary).
childRef - Whether to add descendant references in child list. childRef - Whether to add descendant references in child list.
addImages - Whether to include images. addImages - Whether to include images.
pid - The Gramps ID of the center person for the report.
""" """
Report.__init__(self,database,person,options_class) Report.__init__(self,database,person,options_class)
@ -118,6 +113,8 @@ class DetDescendantReport(Report):
self.includeSources= options_class.handler.options_dict['incsources'] self.includeSources= options_class.handler.options_dict['incsources']
self.includeMates = options_class.handler.options_dict['incmates'] self.includeMates = options_class.handler.options_dict['incmates']
self.includeAttrs = options_class.handler.options_dict['incattrs'] self.includeAttrs = options_class.handler.options_dict['incattrs']
pid = options_class.handler.options_dict['pid']
self.center_person = database.get_person_from_gramps_id(pid)
self.gen_handles = {} self.gen_handles = {}
self.prev_gen_handles= {} self.prev_gen_handles= {}
@ -158,15 +155,15 @@ class DetDescendantReport(Report):
index += 1 index += 1
def write_report(self): def write_report(self):
self.apply_filter(self.start_person.get_handle(),1,"1") self.apply_filter(self.center_person.get_handle(),1,"1")
name = _nd.display_name(self.start_person.get_primary_name()) name = _nd.display_name(self.center_person.get_primary_name())
spouseName = "" spouseName = ""
nspouses = 0 nspouses = 0
for family_handle in self.start_person.get_family_handle_list(): for family_handle in self.center_person.get_family_handle_list():
family = self.database.get_family_from_handle(family_handle) family = self.database.get_family_from_handle(family_handle)
if self.start_person.get_gender() == gen.lib.Person.MALE: if self.center_person.get_gender() == gen.lib.Person.MALE:
spouse_handle = family.get_mother_handle() spouse_handle = family.get_mother_handle()
else: else:
spouse_handle = family.get_father_handle() spouse_handle = family.get_father_handle()
@ -626,6 +623,16 @@ class DetDescendantOptions(MenuReportOptions):
MenuReportOptions.__init__(self,name,dbstate) MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu,dbstate): def add_menu_options(self,menu,dbstate):
"""
Add options to the menu for the detailed descendant report.
"""
id = ""
if dbstate:
id = dbstate.get_active_person().get_gramps_id()
pid = PersonOption(_("Center Person"),id,dbstate)
pid.set_help(_("The center person for the report"))
menu.add_option("","pid",pid)
category_name = _("Report Options") category_name = _("Report Options")
gen = NumberOption(_("Generations"),10,1,100) gen = NumberOption(_("Generations"),10,1,100)

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2007 Brian G. Matherly # Copyright (C) 2007-2008 Brian G. Matherly
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -34,7 +34,7 @@ from gettext import gettext as _
# gramps modules # gramps modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from PluginUtils import register_report from PluginUtils import register_report, PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions, \ from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
import BaseDoc import BaseDoc
@ -64,7 +64,8 @@ class EndOfLineReport(Report):
""" """
Report.__init__(self,database,person,options_class) Report.__init__(self,database,person,options_class)
self.person = person pid = options_class.handler.options_dict['pid']
self.center_person = database.get_person_from_gramps_id(pid)
# eol_map is a map whose: # eol_map is a map whose:
# keys are the generations of the people # keys are the generations of the people
@ -81,7 +82,7 @@ class EndOfLineReport(Report):
# #
# eol_map is populated by get_eol() which calls itself recursively. # eol_map is populated by get_eol() which calls itself recursively.
self.eol_map = {} self.eol_map = {}
self.get_eol(self.person,1,[]) self.get_eol(self.center_person,1,[])
def get_eol(self,person,gen,pedigree): def get_eol(self,person,gen,pedigree):
name = name_displayer.display(person) name = name_displayer.display(person)
@ -123,7 +124,7 @@ class EndOfLineReport(Report):
The routine the actually creates the report. At this point, the document The routine the actually creates the report. At this point, the document
is opened and ready for writing. is opened and ready for writing.
""" """
pname = name_displayer.display(self.person) pname = name_displayer.display(self.center_person)
self.doc.start_paragraph("EOL-Title") self.doc.start_paragraph("EOL-Title")
title = _("End of Line Report for %s") % pname title = _("End of Line Report for %s") % pname
@ -221,7 +222,15 @@ class EndOfLineOptions(MenuReportOptions):
MenuReportOptions.__init__(self,name,dbstate) MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu,dbstate): def add_menu_options(self,menu,dbstate):
pass """
Add options to the menu for the End of Line report.
"""
id = ""
if dbstate:
id = dbstate.get_active_person().get_gramps_id()
pid = PersonOption(_("Center Person"),id,dbstate)
pid.set_help(_("The center person for the report"))
menu.add_option("","pid",pid)
def make_default_style(self,default_style): def make_default_style(self,default_style):
"""Make the default output style for the End of Line Report.""" """Make the default output style for the End of Line Report."""

View File

@ -596,8 +596,13 @@ class FamilyGroupOptions(MenuReportOptions):
category_name = _("Report Options") category_name = _("Report Options")
########################## ##########################
families = self.get_families(dbstate.get_database(), if dbstate:
dbstate.get_active_person()) db = dbstate.get_database()
person = dbstate.get_active_person()
else:
db = None
person = None
families = self.get_families(db, person)
family_id = EnumeratedListOption(_("Spouse"), "") family_id = EnumeratedListOption(_("Spouse"), "")
for item in families: for item in families:

View File

@ -1,8 +1,8 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2003-2006 Donald N. Allingham # Copyright (C) 2003-2006 Donald N. Allingham
# Copyright (C) 2007 Brian G. Matherly # Copyright (C) 2007-2008 Brian G. Matherly
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -35,8 +35,8 @@ from gettext import gettext as _
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import BaseDoc import BaseDoc
from PluginUtils import register_report from PluginUtils import register_report
from PluginUtils import NumberOption, EnumeratedListOption from PluginUtils import NumberOption, EnumeratedListOption, PersonOption
from ReportBase import Report, ReportUtils,MenuReportOptions,CATEGORY_DRAW, \ from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_DRAW, \
MODE_GUI, MODE_BKI, MODE_CLI MODE_GUI, MODE_BKI, MODE_CLI
from SubstKeywords import SubstKeywords from SubstKeywords import SubstKeywords
@ -87,6 +87,8 @@ class FanChart(Report):
self.circle = options_class.handler.options_dict['circle'] self.circle = options_class.handler.options_dict['circle']
self.background = options_class.handler.options_dict['background'] self.background = options_class.handler.options_dict['background']
self.radial = options_class.handler.options_dict['radial'] self.radial = options_class.handler.options_dict['radial']
pid = options_class.handler.options_dict['pid']
self.center_person = database.get_person_from_gramps_id(pid)
self.background_style = [] self.background_style = []
self.text_style = [] self.text_style = []
@ -143,8 +145,8 @@ class FanChart(Report):
self.doc.start_page() self.doc.start_page()
self.apply_filter(self.start_person.get_handle(),1) self.apply_filter(self.center_person.get_handle(),1)
n = self.start_person.get_primary_name().get_regular_name() n = self.center_person.get_primary_name().get_regular_name()
if self.circle == FULL_CIRCLE: if self.circle == FULL_CIRCLE:
max_angle = 360.0 max_angle = 360.0
@ -321,6 +323,16 @@ class FanChartOptions(MenuReportOptions):
MenuReportOptions.__init__(self,name,dbstate) MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu,dbstate): def add_menu_options(self,menu,dbstate):
"""
Add options to the menu for the fan chart.
"""
id = ""
if dbstate:
id = dbstate.get_active_person().get_gramps_id()
pid = PersonOption(_("Center Person"),id,dbstate)
pid.set_help(_("The center person for the report"))
menu.add_option("","pid",pid)
category_name = _("Report Options") category_name = _("Report Options")
max_gen = NumberOption(_("Generations"),5,1,self.MAX_GENERATIONS) max_gen = NumberOption(_("Generations"),5,1,self.MAX_GENERATIONS)

View File

@ -64,10 +64,10 @@ import DateHandler
import GrampsWidgets import GrampsWidgets
import ManagedWindow import ManagedWindow
from PluginUtils import register_report from PluginUtils import register_report
from ReportBase import Report, ReportUtils, ReportOptions, CATEGORY_CODE, MODE_GUI, MODE_CLI from ReportBase import Report, ReportUtils, CATEGORY_CODE, MODE_GUI, MODE_CLI
from ReportBase import Report, MenuReportOptions, MODE_GUI, MODE_CLI, CATEGORY_GRAPHVIZ from ReportBase import Report, MenuReportOptions, MODE_GUI, MODE_CLI, CATEGORY_GRAPHVIZ
from ReportBase._ReportDialog import ReportDialog from ReportBase._ReportDialog import ReportDialog
from PluginUtils import register_report, FilterListOption, EnumeratedListOption, BooleanOption, NumberOption, ColourButtonOption, PersonListOption, SurnameColourOption from PluginUtils import register_report, EnumeratedListOption, BooleanOption, NumberOption, ColourButtonOption, PersonListOption, SurnameColourOption
from QuestionDialog import ErrorDialog, WarningDialog from QuestionDialog import ErrorDialog, WarningDialog
from BasicUtils import name_displayer as _nd from BasicUtils import name_displayer as _nd
from DateHandler import displayer as _dd from DateHandler import displayer as _dd

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2007 Brian G. Matherly # Copyright (C) 2007-2008 Brian G. Matherly
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -28,7 +28,7 @@ Generate an hourglass graph using the GraphViz generator.
# GRAMPS modules # GRAMPS modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from PluginUtils import register_report, NumberOption from PluginUtils import register_report, NumberOption, PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions, \ from ReportBase import Report, ReportUtils, MenuReportOptions, \
MODE_GUI, MODE_CLI, CATEGORY_GRAPHVIZ MODE_GUI, MODE_CLI, CATEGORY_GRAPHVIZ
from BasicUtils import name_displayer from BasicUtils import name_displayer
@ -46,15 +46,16 @@ class HourGlassReport(Report):
Creates HourGlass object that produces the report. Creates HourGlass object that produces the report.
""" """
Report.__init__(self,database,person,options_class) Report.__init__(self,database,person,options_class)
self.person = person
self.db = database self.db = database
self.max_descend = options_class.handler.options_dict['maxdescend'] self.max_descend = options_class.handler.options_dict['maxdescend']
self.max_ascend = options_class.handler.options_dict['maxascend'] self.max_ascend = options_class.handler.options_dict['maxascend']
pid = options_class.handler.options_dict['pid']
self.center_person = database.get_person_from_gramps_id(pid)
def write_report(self): def write_report(self):
self.add_person(self.person) self.add_person(self.center_person)
self.traverse_up(self.person,1) self.traverse_up(self.center_person,1)
self.traverse_down(self.person,1) self.traverse_down(self.center_person,1)
def traverse_down(self,person,gen): def traverse_down(self,person,gen):
""" """
@ -153,6 +154,13 @@ class HourGlassOptions(MenuReportOptions):
MenuReportOptions.__init__(self,name,dbstate) MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu,dbstate): def add_menu_options(self,menu,dbstate):
id = ""
if dbstate:
id = dbstate.get_active_person().get_gramps_id()
pid = PersonOption(_("Center Person"),id,dbstate)
pid.set_help(_("The center person for the report"))
menu.add_option("","pid",pid)
category_name = _("Report Options") category_name = _("Report Options")
max_gen = NumberOption(_('Max Descendant Generations'),10,1,15) max_gen = NumberOption(_('Max Descendant Generations'),10,1,15)

View File

@ -34,7 +34,7 @@ Create a relationship graph using Graphviz
# GRAMPS modules # GRAMPS modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from PluginUtils import register_report, FilterListOption, \ from PluginUtils import register_report, PersonFilterOption, \
EnumeratedListOption, BooleanOption EnumeratedListOption, BooleanOption
from ReportBase import Report, MenuReportOptions, \ from ReportBase import Report, MenuReportOptions, \
MODE_GUI, MODE_CLI, CATEGORY_GRAPHVIZ MODE_GUI, MODE_CLI, CATEGORY_GRAPHVIZ
@ -135,9 +135,7 @@ class RelGraphReport(Report):
self.arrowtailstyle = 'none' self.arrowtailstyle = 'none'
filter_option = options_class.menu.get_option_by_name('filter') filter_option = options_class.menu.get_option_by_name('filter')
filter_index = int(filter_option.get_value()) self.filter = filter_option.get_filter()
filters = filter_option.get_filters()
self.filter = filters[filter_index]
def write_report(self): def write_report(self):
self.person_handles = self.filter.apply(self.database, self.person_handles = self.filter.apply(self.database,
@ -418,8 +416,7 @@ class RelGraphOptions(MenuReportOptions):
category_name = _("Report Options") category_name = _("Report Options")
################################ ################################
filter = FilterListOption(_("Filter")) filter = PersonFilterOption(_("Filter"),dbstate,0,False)
filter.add_item("person")
filter.set_help(_("Select the filter to be applied to the report")) filter.set_help(_("Select the filter to be applied to the report"))
menu.add_option(category_name,"filter", filter) menu.add_option(category_name,"filter", filter)

View File

@ -1,8 +1,8 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2007 Donald N. Allingham # Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2007 Brian G. Matherly # Copyright (C) 2007-2008 Brian G. Matherly
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -29,13 +29,6 @@
import os import os
from gettext import gettext as _ from gettext import gettext as _
#------------------------------------------------------------------------
#
# Gnome/GTK modules
#
#------------------------------------------------------------------------
import gtk
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
@ -47,8 +40,8 @@ import Utils
import BaseDoc import BaseDoc
from Filters import GenericFilter, Rules from Filters import GenericFilter, Rules
import DateHandler import DateHandler
from PluginUtils import register_report from PluginUtils import register_report, PersonFilterOption, BooleanOption
from ReportBase import Report, ReportUtils, ReportOptions, \ from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
from ReportBase import Bibliography, Endnotes from ReportBase import Bibliography, Endnotes
from BasicUtils import name_displayer as _nd from BasicUtils import name_displayer as _nd
@ -84,9 +77,8 @@ class IndivCompleteReport(Report):
self.use_srcs = options_class.handler.options_dict['cites'] self.use_srcs = options_class.handler.options_dict['cites']
filter_num = options_class.handler.options_dict['filter'] filter_option = options_class.menu.get_option_by_name('filter')
filters = ReportUtils.get_person_filters(person) self.filter = filter_option.get_filter()
self.filter = filters[filter_num]
self.bibli = None self.bibli = None
def write_fact(self,event_ref): def write_fact(self,event_ref):
@ -529,61 +521,31 @@ class IndivCompleteReport(Report):
self.write_note() self.write_note()
if self.use_srcs: if self.use_srcs:
Endnotes.write_endnotes(self.bibli,self.database,self.doc) Endnotes.write_endnotes(self.bibli,self.database,self.doc)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# # IndivCompleteOptions
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class IndivCompleteOptions(ReportOptions): class IndivCompleteOptions(MenuReportOptions):
""" """
Defines options and provides handling interface. Defines options and provides handling interface.
""" """
def __init__(self,name,dbstate=None):
def __init__(self,name,person_id=None): MenuReportOptions.__init__(self,name,dbstate)
ReportOptions.__init__(self,name,person_id)
def add_menu_options(self,menu,dbstate):
# Options specific for this report ################################
self.options_dict = { category_name = _("Report Options")
'filter' : 0, ################################
'cites' : 1,
} filter = PersonFilterOption(_("Filter"),dbstate,0,True)
filters = ReportUtils.get_person_filters(None) filter.set_help(_("Select the filter to be applied to the report"))
self.options_help = { menu.add_option(category_name,"filter", filter)
'filter' : ("=num","Filter number.",
[ filt.get_name() for filt in filters ], cites = BooleanOption(_("Include Source Information"), True)
True ), cites.set_help(_("Whether to cite sources."))
'cites' : ("=0/1","Whether to cite sources.", menu.add_option(category_name,"cites", cites)
["Do not cite sources","Cite sources"],
True),
}
def add_user_options(self,dialog):
"""
Override the base class add_user_options task to add a menu that allows
the user to select the sort method.
"""
filter_index = self.options_dict['filter']
filter_list = ReportUtils.get_person_filters(dialog.person)
self.filter_menu = gtk.combo_box_new_text()
for filter in filter_list:
self.filter_menu.append_text(filter.get_name())
if filter_index > len(filter_list):
filter_index = 0
self.filter_menu.set_active(filter_index)
dialog.add_option('Filter',self.filter_menu)
self.use_srcs = gtk.CheckButton(_('Include Source Information'))
self.use_srcs.set_active(self.options_dict['cites'])
dialog.add_option('',self.use_srcs)
def parse_user_options(self,dialog):
"""
Parses the custom options that we have added.
"""
self.options_dict['filter'] = int(self.filter_menu.get_active())
self.options_dict['cites'] = int(self.use_srcs.get_active())
def make_default_style(self,default_style): def make_default_style(self,default_style):
"""Make the default output style for the Individual Complete Report.""" """Make the default output style for the Individual Complete Report."""

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2007 Brian G. Matherly # Copyright (C) 2007-2008 Brian G. Matherly
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -30,20 +30,14 @@
from gettext import gettext as _ from gettext import gettext as _
from string import capitalize from string import capitalize
#------------------------------------------------------------------------
#
# GTK modules
#
#------------------------------------------------------------------------
import gtk
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# gramps modules # gramps modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from PluginUtils import register_report, relationship_class from PluginUtils import register_report, relationship_class, NumberOption, \
from ReportBase import Report, ReportUtils, ReportOptions, \ BooleanOption, PersonOption
from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
import BaseDoc import BaseDoc
from BasicUtils import name_displayer from BasicUtils import name_displayer
@ -74,6 +68,7 @@ class KinshipReport(Report):
incspouses - Whether to include spouses. incspouses - Whether to include spouses.
inccousins - Whether to include cousins. inccousins - Whether to include cousins.
incaunts - Whether to include aunts/uncles/nephews/nieces. incaunts - Whether to include aunts/uncles/nephews/nieces.
pid - The Gramps ID of the center person for the report.
""" """
Report.__init__(self,database,person,options_class) Report.__init__(self,database,person,options_class)
@ -82,8 +77,9 @@ class KinshipReport(Report):
self.incSpouses = options_class.handler.options_dict['incspouses'] self.incSpouses = options_class.handler.options_dict['incspouses']
self.incCousins = options_class.handler.options_dict['inccousins'] self.incCousins = options_class.handler.options_dict['inccousins']
self.incAunts = options_class.handler.options_dict['incaunts'] self.incAunts = options_class.handler.options_dict['incaunts']
pid = options_class.handler.options_dict['pid']
self.person = person self.person = database.get_person_from_gramps_id(pid)
self.db = database self.db = database
self.relCalc = relationship_class() self.relCalc = relationship_class()
self.kinship_map = {} self.kinship_map = {}
@ -113,7 +109,7 @@ class KinshipReport(Report):
# Collect all ancestors/aunts/uncles/nephews/cousins of the person # Collect all ancestors/aunts/uncles/nephews/cousins of the person
self.traverse_up(self.person.get_handle(),1,0) self.traverse_up(self.person.get_handle(),1,0)
# Write Ancestors # Write Kin
for Ga in self.kinship_map.keys(): for Ga in self.kinship_map.keys():
for Gb in self.kinship_map[Ga]: for Gb in self.kinship_map[Ga]:
# To understand these calculations, see: # To understand these calculations, see:
@ -321,72 +317,47 @@ class KinshipReport(Report):
# KinshipOptions # KinshipOptions
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class KinshipOptions(ReportOptions): class KinshipOptions(MenuReportOptions):
""" """
Defines options and provides handling interface. Defines options and provides handling interface.
""" """
def __init__(self,name,person_id=None): def __init__(self,name,dbstate=None):
ReportOptions.__init__(self,name,person_id) MenuReportOptions.__init__(self,name,dbstate)
self.options_dict = {
'maxdescend' : 2,
'maxascend' : 2,
'incspouses' : 1,
'inccousins' : 1,
'incsiblings' : 1,
'incaunts' : 1,
}
self.options_help = {
'maxdescend' : ("=int","Max Descendants",
"The number of generations of descendants to " \
"include in the report",
True),
'maxascend' : ("=int","Max Ancestors",
"The number of generations of ancestors to " \
"include in the report",
True),
'incspouses' : ("=0/1","Whether to include spouses",
["Do not include spouses","Include spouses"],
True),
'inccousins' : ("=0/1","Whether to include cousins",
["Do not include cousins","Include cousins"],
True),
'incaunts' : ("=0/1",
"Whether to include aunts/uncles/nephews/nieces",
["Do not include aunts","Include aunts"],
True),
}
def add_user_options(self,dialog): def add_menu_options(self,menu,dbstate):
self.maxdescend = gtk.SpinButton(gtk.Adjustment(1,1,20,1)) """
self.maxdescend.set_value(self.options_dict['maxdescend']) Add options to the menu for the kinship report.
"""
id = ""
if dbstate:
id = dbstate.get_active_person().get_gramps_id()
pid = PersonOption(_("Center Person"),id,dbstate)
pid.set_help(_("The center person for the report"))
menu.add_option("","pid",pid)
self.maxascend = gtk.SpinButton(gtk.Adjustment(1,1,20,1)) category_name = _("Report Options")
self.maxascend.set_value(self.options_dict['maxascend'])
self.incspouses = gtk.CheckButton(_("Include spouses")) maxdescend = NumberOption(_("Max Descendant Generations"),2,1,20)
self.incspouses.set_active(self.options_dict['incspouses']) maxdescend.set_help(_("The maximum number of descendant generations"))
menu.add_option(category_name,"maxdescend",maxdescend)
self.inccousins = gtk.CheckButton(_("Include cousins")) maxascend = NumberOption(_("Max Ancestor Generations"),2,1,20)
self.inccousins.set_active(self.options_dict['inccousins']) maxascend.set_help(_("The maximum number of ancestor generations"))
menu.add_option(category_name,"maxascend",maxascend)
self.incaunts = gtk.CheckButton( incspouses = BooleanOption(_("Include spouses"),True)
_("Include aunts/uncles/nephews/nieces")) incspouses.set_help(_("Whether to include spouses"))
self.incaunts.set_active(self.options_dict['incaunts']) menu.add_option(category_name,"incspouses",incspouses)
dialog.add_option (_('Max Descendant Generations'), self.maxdescend) inccousins = BooleanOption(_("Include cousins"),True)
dialog.add_option (_('Max Ancestor Generations'), self.maxascend) inccousins.set_help(_("Whether to include cousins"))
dialog.add_option ('', self.incspouses) menu.add_option(category_name,"inccousins",inccousins)
dialog.add_option ('', self.inccousins)
dialog.add_option ('', self.incaunts) incaunts = BooleanOption(_("Include aunts/uncles/nephews/nieces"),True)
incaunts.set_help(_("Whether to include aunts/uncles/nephews/nieces"))
def parse_user_options(self,dialog): menu.add_option(category_name,"incaunts",incaunts)
self.options_dict['maxdescend'] = self.maxdescend.get_value_as_int()
self.options_dict['maxascend'] = self.maxascend.get_value_as_int()
self.options_dict['incspouses'] = int(self.incspouses.get_active ())
self.options_dict['inccousins'] = int(self.inccousins.get_active())
self.options_dict['incaunts'] = int(self.incaunts.get_active())
def make_default_style(self,default_style): def make_default_style(self,default_style):
"""Make the default output style for the Kinship Report.""" """Make the default output style for the Kinship Report."""

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2007 Brian G. Matherly # Copyright (C) 2007-2008 Brian G. Matherly
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -28,31 +28,21 @@
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gettext import gettext as _ from gettext import gettext as _
import copy
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from PluginUtils import register_report from PluginUtils import register_report, EnumeratedListOption
from ReportBase import Report, ReportUtils, ReportOptions, \ from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
import BaseDoc import BaseDoc
import Sort
import AutoComp
from gen.lib import MarkerType, FamilyRelType from gen.lib import MarkerType, FamilyRelType
from Filters import GenericFilter, GenericFilterFactory, Rules from Filters import GenericFilter, GenericFilterFactory, Rules
from BasicUtils import name_displayer from BasicUtils import name_displayer
import DateHandler import DateHandler
#------------------------------------------------------------------------
#
# GTK/GNOME modules
#
#------------------------------------------------------------------------
import gtk
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# MarkerReport # MarkerReport
@ -73,18 +63,20 @@ class MarkerReport(Report):
This report needs the following parameters (class variables) This report needs the following parameters (class variables)
that come in the options class. that come in the options class.
marker - The marker each object must match to be included, marker - The marker each object must match to be included.
an English string for normal data, otherwise custom
language string.
marker_str - Same as marker but now always localized.
""" """
Report.__init__(self,database,person,options_class) Report.__init__(self,database,person,options_class)
self.marker = options_class.markerval self.marker = options_class.handler.options_dict['marker']
self.marker_str = options_class.marker_str
def write_report(self): def write_report(self):
markerstr = self.marker
# Use localized name if this is not a custom marker
if MarkerType._E2IMAP.has_key(self.marker):
mtype = MarkerType._E2IMAP[self.marker]
markerstr = MarkerType._I2SMAP[mtype]
self.doc.start_paragraph("MR-Title") self.doc.start_paragraph("MR-Title")
title = _("Marker Report for %s Items") % self.marker_str title = _("Marker Report for %s Items") % markerstr
mark = BaseDoc.IndexMark(title,BaseDoc.INDEX_TYPE_TOC,1) mark = BaseDoc.IndexMark(title,BaseDoc.INDEX_TYPE_TOC,1)
self.doc.write_text(title,mark) self.doc.write_text(title,mark)
self.doc.end_paragraph() self.doc.end_paragraph()
@ -427,70 +419,32 @@ class MarkerReport(Report):
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# # MarkerOptions
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class MarkerOptions(ReportOptions): class MarkerOptions(MenuReportOptions):
""" def __init__(self,name,dbstate=None):
Defines options and provides handling interface. MenuReportOptions.__init__(self,name,dbstate)
"""
def __init__(self,name,person_id=None):
ReportOptions.__init__(self,name,person_id)
# Options specific for this report
self.options_dict = {
'marker' : "",
}
self.options_help = {
'marker' : ("=str","Marker",
"The marker each item must match to be included",
True),
}
def add_user_options(self,dialog): def add_menu_options(self,menu,dbstate):
""" """
Override the base class add_user_options task to add generations option Add options to the menu for the marker report.
""" """
self.marker_menu = gtk.ComboBoxEntry() category_name = _("Report Options")
int_to_string_map = copy.deepcopy(MarkerType._I2SMAP)
#remove the None
del int_to_string_map[MarkerType.NONE]
#add custom markers
self.max_non_custom = max(int_to_string_map.keys())
nextint = self.max_non_custom+1
custommarkers = dialog.db.get_marker_types()
for item in custommarkers:
int_to_string_map[nextint] = item
nextint += 1
marker_index = 0
for int, str in int_to_string_map.items() :
if self.options_dict['marker'] == str :
marker_index = int
break
self.sel = AutoComp.StandardCustomSelector(int_to_string_map,
self.marker_menu,
MarkerType._CUSTOM,
marker_index)
dialog.add_option(_('Marker'),self.marker_menu) marker = EnumeratedListOption(_('Marker'),0)
# Add built-in marker types
def parse_user_options(self,dialog): for mtype in MarkerType._I2SMAP:
""" if mtype != MarkerType.NONE and mtype != MarkerType.CUSTOM:
Parses the custom options that we have added. Set the value in the # Use translated name for built-in marker types
options dictionary. marker.add_item(MarkerType._I2EMAP[mtype],
""" MarkerType._I2SMAP[mtype] )
self.options_dict['marker'] = self.sel.get_values()[1] # Add custom marker types
for m in dbstate.get_database().get_marker_types():
int, str = self.sel.get_values() marker.add_item( m, m )
self.marker_str = str marker.set_help( _("The marker to use for the report"))
#marker filter needs untranslated english string, skip custom entry menu.add_option(category_name,"marker",marker)
if int is not MarkerType.CUSTOM and int <= self.max_non_custom:
self.markerval = MarkerType._I2EMAP[int]
else:
self.markerval = str
def make_default_style(self,default_style): def make_default_style(self,default_style):
"""Make the default output style for the Marker Report.""" """Make the default output style for the Marker Report."""

View File

@ -144,12 +144,8 @@ class SimpleBookTitleOptions(ReportOptions):
"0 (to fit the page)."], "0 (to fit the page)."],
False), False),
} }
def do_nothing(self):
pass
def add_user_options(self,dialog): def add_user_options(self,dialog):
dialog.setup_center_person = self.do_nothing #Disable center person
dialog.notebook = gtk.Notebook() dialog.notebook = gtk.Notebook()
dialog.notebook.set_border_width(6) dialog.notebook.set_border_width(6)
dialog.window.vbox.add(dialog.notebook) dialog.window.vbox.add(dialog.notebook)

View File

@ -1,8 +1,8 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2003-2006 Donald N. Allingham # Copyright (C) 2003-2006 Donald N. Allingham
# Copyright (C) 2007 Brian G. Matherly # Copyright (C) 2007-2008 Brian G. Matherly
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -37,13 +37,6 @@ Statistics Chart report
import time import time
from TransUtils import sgettext as _ from TransUtils import sgettext as _
#------------------------------------------------------------------------
#
# GNOME/gtk
#
#------------------------------------------------------------------------
import gtk
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
@ -55,7 +48,9 @@ from gen.lib import Person, FamilyRelType, EventType
# gender and report type names # gender and report type names
import BaseDoc import BaseDoc
from PluginUtils import register_report from PluginUtils import register_report
from ReportBase import Report, ReportUtils, ReportOptions, \ from PluginUtils import BooleanOption, PersonFilterOption, EnumeratedListOption, \
NumberOption
from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_DRAW, MODE_GUI, MODE_BKI, MODE_CLI CATEGORY_DRAW, MODE_GUI, MODE_BKI, MODE_CLI
from Filters import GenericFilter, Rules from Filters import GenericFilter, Rules
import DateHandler import DateHandler
@ -479,9 +474,8 @@ class StatisticsChart(Report):
""" """
Report.__init__(self,database,person,options_class) Report.__init__(self,database,person,options_class)
filter_num = options_class.handler.options_dict['filter'] self.filter_option = options_class.menu.get_option_by_name('filter')
filters = ReportUtils.get_person_filters(person,False) self.filter = self.filter_option.get_filter()
filterfun = filters[filter_num]
options = options_class.handler.options_dict options = options_class.handler.options_dict
self.bar_items = options['bar_items'] self.bar_items = options['bar_items']
@ -507,7 +501,7 @@ class StatisticsChart(Report):
# extract requested items from the database and count them # extract requested items from the database and count them
self.progress.set_pass(_('Collecting data...'), 1) self.progress.set_pass(_('Collecting data...'), 1)
tables = _Extract.collect_data(database, filterfun, options, tables = _Extract.collect_data(database, self.filter, options,
gender, year_from, year_to, options['no_years']) gender, year_from, year_to, options['no_years'])
self.progress.step() self.progress.step()
@ -660,55 +654,87 @@ class StatisticsChart(Report):
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Statistics report options # StatisticsChartOptions
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class StatisticsChartOptions(ReportOptions): class StatisticsChartOptions(MenuReportOptions):
"""
Defines options and provides their handling interface.
"""
def __init__(self,name, person_id=None):
ReportOptions.__init__(self, name, person_id)
# Options specific for this report def __init__(self,name,dbstate=None):
self.options_dict = { MenuReportOptions.__init__(self,name,dbstate)
'filter' : 0,
'gender' : Person.UNKNOWN, def add_menu_options(self,menu,dbstate):
'sortby' : _options.SORT_VALUE, """
'reverse' : 0, Add options to the menu for the statistics report.
'year_from' : 1700, """
'year_to' : time.localtime()[0], category_name = _("Report Options")
'no_years' : 0,
'bar_items' : 8 filter = PersonFilterOption(_("Filter"),dbstate,0,False)
} filter.set_help(_("Determines what people are included in the report"))
for key in _Extract.extractors: menu.add_option(category_name,"filter", filter)
self.options_dict[key] = 0
self.options_dict['data_gender'] = 1 sortby = EnumeratedListOption(_('Sort chart items by'),
_options.SORT_VALUE )
for item_idx in range(len(_options.sorts)):
item = _options.sorts[item_idx]
sortby.add_item(item_idx,item[2])
sortby.set_help( _("Select how the statistical data is sorted."))
menu.add_option(category_name,"sortby",sortby)
filters = ReportUtils.get_person_filters(None,False) reverse = BooleanOption(_("Sort in reverse order"), False)
self.options_help = { reverse.set_help(_("Check to reverse the sorting order."))
'gender' : ("=num", "Genders included", menu.add_option(category_name,"reverse", reverse)
["%d\t%s" % (item[0], item[1]) for item in _options.genders],
False), this_year = time.localtime()[0]
'sortby' : ("=num", "Sort chart items by", year_from = NumberOption(_("People Born Before"),
["%d\t%s" % (item[0], item[1]) for item in _options.sorts], 1700, 1, this_year)
False), year_from.set_help(_("Birth year from which to include people"))
'reverse' : ("=0/1", "Whether to sort in reverse order", menu.add_option(category_name,"year_from", year_from)
["Do not sort in reverse", "Sort in reverse"],
True), year_to = NumberOption(_("People Born After"),
'year_from' : ("=num", "Birth year from which to include people", this_year, 1, this_year)
"Earlier than 'year_to' value"), year_to.set_help(_("Birth year until which to include people"))
'year_to' : ("=num", "Birth year until which to include people", menu.add_option(category_name,"year_to", year_to)
"Smaller than %d" % self.options_dict['year_to']),
'no_years' : ("=0/1", "Whether to include people without known birth years", no_years = BooleanOption(_("Include people without known birth years"),
["Do not include", "Include"], True), False)
'bar_items' : ("=num", "Use barchart instead of piechart with this many or more items", no_years.set_help(_("Whether to include people without "
"Number of items with which piecharts still look good...") "known birth years"))
} menu.add_option(category_name,"no_years", no_years)
gender = EnumeratedListOption(_('Genders included'),
Person.UNKNOWN )
for item_idx in range(len(_options.genders)):
item = _options.genders[item_idx]
gender.add_item(item[0],item[2])
gender.set_help( _("Select which genders are included into "
"statistics."))
menu.add_option(category_name,"gender",gender)
bar_items = NumberOption(_("Max. items for a pie"), 8, 0, 20)
bar_items.set_help(_("With fewer items pie chart and legend will be "
"used instead of a bar chart."))
menu.add_option(category_name,"bar_items", bar_items)
# -------------------------------------------------
# List of available charts on separate option tabs
idx = 0
half = (len(_Extract.extractors))/2
self.charts = {}
for key in _Extract.extractors: for key in _Extract.extractors:
self.options_help[key] = ("=0/1", _Extract.extractors[key][0], if idx < half:
["Leave chart with this data out", "Include chart with this data"], category_name = _("Charts 1")
True) else:
category_name = _("Charts 2")
opt = BooleanOption(_Extract.extractors[key][1], False)
opt.set_help(_("Include charts with indicated dat"))
menu.add_option(category_name,key, opt)
idx += 1
# Enable a couple of charts by default
menu.get_option_by_name("data_gender").set_value(True)
menu.get_option_by_name("data_ccount").set_value(True)
menu.get_option_by_name("data_bmonth").set_value(True)
def make_default_style(self, default_style): def make_default_style(self, default_style):
"""Make the default output style for the Statistics report.""" """Make the default output style for the Statistics report."""
@ -819,121 +845,6 @@ class StatisticsChartOptions(ReportOptions):
g.set_line_width(0) g.set_line_width(0)
default_style.add_draw_style("SC-legend",g) default_style.add_draw_style("SC-legend",g)
def add_user_options(self, dialog):
"""
Override the base class add_user_options task to add
report specific options
"""
filter_index = self.options_dict['filter']
filter_list = ReportUtils.get_person_filters(dialog.person,False)
self.filter_menu = gtk.combo_box_new_text()
for filter in filter_list:
self.filter_menu.append_text(filter.get_name())
if filter_index > len(filter_list):
filter_index = 0
self.filter_menu.set_active(filter_index)
dialog.add_option(_('Filter'),self.filter_menu)
# how to sort the data
self.sort_menu = gtk.combo_box_new_text()
for item_idx in range(len(_options.sorts)):
item = _options.sorts[item_idx]
self.sort_menu.append_text(item[2])
if item[0] == self.options_dict['sortby']:
self.sort_menu.set_active(item_idx)
tip = _("Select how the statistical data is sorted.")
dialog.add_option(_("Sort chart items by"), self.sort_menu, tip)
# sorting order
tip = _("Check to reverse the sorting order.")
self.reverse = gtk.CheckButton(_("Sort in reverse order"))
self.reverse.set_active(self.options_dict['reverse'])
dialog.add_option(None, self.reverse, tip)
self.reverse.show()
# year range
from_adj = gtk.Adjustment(value=self.options_dict['year_from'],
lower=1, upper=time.localtime()[0],
step_incr=1, page_incr=100)
self.from_box = gtk.SpinButton(adjustment=from_adj, digits=0)
to_adj = gtk.Adjustment(value=self.options_dict['year_to'],
lower=1, upper=time.localtime()[0],
step_incr=1, page_incr=100)
self.to_box = gtk.SpinButton(adjustment=to_adj, digits=0)
box = gtk.HBox()
box.add(self.from_box)
box.add(gtk.Label("-"))
box.add(self.to_box)
tip = _("Select year range within which people need to be born to be selected for statistics.")
dialog.add_option(_('People born between'), box, tip)
box.show_all()
# include people without known birth year?
tip = _("Check this if you want people who have no known birth date or year to be accounted also in the statistics.")
self.no_years = gtk.CheckButton(_("Include people without known birth years"))
self.no_years.set_active(self.options_dict['no_years'])
dialog.add_option(None, self.no_years, tip)
self.no_years.show()
# gender selection
self.gender_menu = gtk.combo_box_new_text()
for item_idx in range(len(_options.genders)):
item = _options.genders[item_idx]
self.gender_menu.append_text(item[2])
if item[0] == self.options_dict['gender']:
self.gender_menu.set_active(item_idx)
tip = _("Select which genders are included into statistics.")
dialog.add_option(_("Genders included"), self.gender_menu, tip)
# max. pie item selection
tip = _("With fewer items pie chart and legend will be used instead of a bar chart.")
pie_adj = gtk.Adjustment(value=self.options_dict['bar_items'],
lower=0, upper=20, step_incr=1)
self.bar_items = gtk.SpinButton(adjustment=pie_adj, digits=0)
dialog.add_option(_("Max. items for a pie"), self.bar_items, tip)
# -------------------------------------------------
# List of available charts on a separate option tab
idx = 0
half = (len(_Extract.extractors)+1)/2
hbox = gtk.HBox()
vbox = gtk.VBox()
self.charts = {}
for key in _Extract.extractors:
check = gtk.CheckButton(_Extract.extractors[key][1])
check.set_active(self.options_dict[key])
self.charts[key] = check
vbox.add(check)
idx += 1
if idx == half:
hbox.add(vbox)
vbox = gtk.VBox()
hbox.add(vbox)
tip = _("Mark checkboxes to add charts with indicated data")
dialog.add_frame_option(_("Charts"), "", hbox, tip)
hbox.show_all()
# Note about children
label = gtk.Label(_("Note that both biological and adopted children are taken into account."))
dialog.add_frame_option(_("Charts"), "", label)
def parse_user_options(self, dialog):
"""
Parses the custom options that we have added.
"""
self.options_dict['filter'] = int(self.filter_menu.get_active())
self.options_dict['sortby'] = _options.sorts[self.sort_menu.get_active()][0]
self.options_dict['reverse'] = int(self.reverse.get_active())
self.options_dict['year_to'] = int(self.to_box.get_value_as_int())
self.options_dict['year_from'] = int(self.from_box.get_value_as_int())
self.options_dict['no_years'] = int(self.no_years.get_active())
self.options_dict['gender'] = _options.genders[self.gender_menu.get_active()][0]
self.options_dict['bar_items'] = int(self.bar_items.get_value_as_int())
for key in _Extract.extractors:
self.options_dict[key] = int(self.charts[key].get_active())
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# Register report/options # Register report/options
@ -949,6 +860,7 @@ register_report(
status = (_("Stable")), status = (_("Stable")),
author_name="Eero Tamminen", author_name="Eero Tamminen",
author_email="", author_email="",
description= _("Generates statistical bar and pie charts of the people in the database."), description= _("Generates statistical bar and pie charts of the people "
"in the database."),
require_active=False, require_active=False,
) )

View File

@ -1,8 +1,8 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2003-2007 Donald N. Allingham # Copyright (C) 2003-2007 Donald N. Allingham
# Copyright (C) 2007 Brian G. Matherly # Copyright (C) 2007-2008 Brian G. Matherly
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -32,20 +32,14 @@ Timeline report
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from TransUtils import sgettext as _ from TransUtils import sgettext as _
#------------------------------------------------------------------------
#
# GNOME/gtk
#
#------------------------------------------------------------------------
import gtk
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# GRAMPS modules # GRAMPS modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from PluginUtils import register_report from PluginUtils import register_report
from ReportBase import Report, ReportUtils, ReportOptions, \ from PluginUtils import PersonFilterOption, EnumeratedListOption
from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_DRAW, MODE_GUI, MODE_BKI, MODE_CLI CATEGORY_DRAW, MODE_GUI, MODE_BKI, MODE_CLI
pt2cm = ReportUtils.pt2cm pt2cm = ReportUtils.pt2cm
import BaseDoc import BaseDoc
@ -54,6 +48,17 @@ import Sort
from QuestionDialog import ErrorDialog from QuestionDialog import ErrorDialog
from BasicUtils import name_displayer from BasicUtils import name_displayer
#------------------------------------------------------------------------
#
# Private Functions
#
#------------------------------------------------------------------------
def _get_sort_functions(sort):
return [
(_("Birth Date"),sort.by_birthdate),
(_("Name"),sort.by_last_name),
]
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# TimeLine # TimeLine
@ -77,23 +82,19 @@ class TimeLine(Report):
filter - Filter to be applied to the people of the database. filter - Filter to be applied to the people of the database.
The option class carries its number, and the function The option class carries its number, and the function
returning the list of filters. returning the list of filters.
sort_func - function used to sort entries, that returns -1/0/1 sortby - Sorting method to be used.
when given two personal handles (like cmp).
The option class carries its number, and the function
returning the list of sort functions.
""" """
Report.__init__(self,database,person,options_class) Report.__init__(self,database,person,options_class)
filter_num = options_class.handler.options_dict['filter'] filter_num = options_class.handler.options_dict['filter']
filters = ReportUtils.get_person_filters(person,False) self.filter_option = options_class.menu.get_option_by_name('filter')
self.filter = filters[filter_num] self.filter = self.filter_option.get_filter()
name = name_displayer.display_formal(person) self.title = _("Timeline Graph for %s") % self.filter.get_name()
self.title = _("Timeline Graph for %s") % name
sort_func_num = options_class.handler.options_dict['sortby'] sort_func_num = options_class.handler.options_dict['sortby']
sort_functions = options_class.get_sort_functions(Sort.Sort(database)) sort_functions = _get_sort_functions(Sort.Sort(database))
self.sort_func = sort_functions[sort_func_num][1] self.sort_func = sort_functions[sort_func_num][1]
def write_report(self): def write_report(self):
@ -289,34 +290,30 @@ class TimeLine(Report):
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# # TimeLineOptions
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class TimeLineOptions(ReportOptions): class TimeLineOptions(MenuReportOptions):
"""
Defines options and provides handling interface.
"""
def __init__(self,name,person_id=None):
ReportOptions.__init__(self,name,person_id)
# Options specific for this report
self.options_dict = {
'filter' : 0,
'sortby' : 0,
}
filters = ReportUtils.get_person_filters(None,False)
self.options_help = {
'filter' : ("=num","Filter number.",
[ filt.get_name() for filt in filters ],
True ),
'sortby' : ("=num","Number of a sorting function",
[item[0] for item in
self.get_sort_functions(Sort.Sort(None))],
True),
}
def __init__(self,name,dbstate=None):
MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu,dbstate):
category_name = _("Report Options")
filter = PersonFilterOption(_("Filter"),dbstate,0,False)
filter.set_help(_("Determine what people will be included in "
"the report"))
menu.add_option(category_name,"filter", filter)
sortby = EnumeratedListOption(_('Sort by'), 0 )
idx = 0
for item in _get_sort_functions(Sort.Sort(dbstate.get_database())):
sortby.add_item(idx,item[0])
idx += 1
sortby.set_help( _("Sorting method to use"))
menu.add_option(category_name,"sortby",sortby)
def make_default_style(self,default_style): def make_default_style(self,default_style):
"""Make the default output style for the Timeline report.""" """Make the default output style for the Timeline report."""
# Paragraph Styles # Paragraph Styles
@ -405,44 +402,6 @@ class TimeLineOptions(ReportOptions):
g.set_line_width(0) g.set_line_width(0)
default_style.add_draw_style("TLG-label",g) default_style.add_draw_style("TLG-label",g)
def get_sort_functions(self,sort):
return [
(_("Birth Date"),sort.by_birthdate),
(_("Name"),sort.by_last_name),
]
def add_user_options(self,dialog):
"""
Override the base class add_user_options task to add a menu that allows
the user to select the sort method.
"""
filter_index = self.options_dict['filter']
filter_list = ReportUtils.get_person_filters(dialog.person,False)
self.filter_menu = gtk.combo_box_new_text()
for filter in filter_list:
self.filter_menu.append_text(filter.get_name())
if filter_index > len(filter_list):
filter_index = 0
self.filter_menu.set_active(filter_index)
dialog.add_option(_('Filter'),self.filter_menu)
self.sort_menu = gtk.combo_box_new_text()
sort_functions = self.get_sort_functions(Sort.Sort(dialog.db))
for item in sort_functions:
self.sort_menu.append_text(item[0])
self.sort_menu.set_active(self.options_dict['sortby'])
dialog.add_option(_('Sort by'),self.sort_menu)
def parse_user_options(self,dialog):
"""
Parses the custom options that we have added.
"""
self.options_dict['filter'] = int(self.filter_menu.get_active())
self.options_dict['sortby'] = self.sort_menu.get_active()
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# #