Refactoring the report system. Decouple MenuOptions from the code that displays them. (Book Report is broken and needs to be fixed.)
svn: r9875
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
# Copyright (C) 2007-2008 Brian G. Matherly
|
||||
#
|
||||
# Adapted from GraphViz.py (now deprecated)
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
@@ -29,14 +29,21 @@
|
||||
Create a relationship graph using Graphviz
|
||||
"""
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# python modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from TransUtils import sgettext as _
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from PluginUtils import register_report, PersonFilterOption, \
|
||||
EnumeratedListOption, BooleanOption
|
||||
from ReportBase import Report, MenuReportOptions, \
|
||||
EnumeratedListOption, BooleanOption, PersonOption
|
||||
from ReportBase import Report, ReportUtils, MenuReportOptions, \
|
||||
MODE_GUI, MODE_CLI, CATEGORY_GRAPHVIZ
|
||||
from BasicUtils import name_displayer
|
||||
import DateHandler
|
||||
@@ -408,35 +415,48 @@ class RelGraphOptions(MenuReportOptions):
|
||||
"""
|
||||
Defines options and provides handling interface.
|
||||
"""
|
||||
def __init__(self,name,dbstate=None):
|
||||
MenuReportOptions.__init__(self,name,dbstate)
|
||||
def __init__(self, name, dbstate=None):
|
||||
self.__pid = None
|
||||
self.__filter = None
|
||||
self.__include_images = None
|
||||
self.__image_on_side = None
|
||||
self.__dbstate = dbstate
|
||||
MenuReportOptions.__init__(self, name, dbstate)
|
||||
|
||||
def add_menu_options(self,menu,dbstate):
|
||||
def add_menu_options(self, menu, dbstate):
|
||||
################################
|
||||
category_name = _("Report Options")
|
||||
################################
|
||||
|
||||
self.__pid = PersonOption(_("Filter Person"))
|
||||
self.__pid.set_help(_("The center person for the filter"))
|
||||
menu.add_option(category_name, "pid", self.__pid)
|
||||
self.__pid.connect('value-changed', self.__update_filters)
|
||||
|
||||
filter = PersonFilterOption(_("Filter"),dbstate,0,False)
|
||||
filter.set_help(_("Select the filter to be applied to the report"))
|
||||
menu.add_option(category_name,"filter", filter)
|
||||
self.__filter = PersonFilterOption(_("Filter"), 0)
|
||||
self.__filter.set_help(
|
||||
_("Determines what people are included in the graph"))
|
||||
self.__update_filters()
|
||||
menu.add_option(category_name, "filter", self.__filter)
|
||||
self.__filter.connect('value-changed', self.__filter_changed)
|
||||
|
||||
incdate = BooleanOption(
|
||||
_("Include Birth, Marriage and Death dates"), True)
|
||||
incdate.set_help(_("Include the dates that the individual was born, "
|
||||
"got married and/or died in the graph labels."))
|
||||
menu.add_option(category_name,"incdate", incdate)
|
||||
menu.add_option(category_name, "incdate", incdate)
|
||||
|
||||
justyears = BooleanOption(_("Limit dates to years only"), False)
|
||||
justyears.set_help(_("Prints just dates' year, neither "
|
||||
"month or day nor date approximation "
|
||||
"or interval are shown."))
|
||||
menu.add_option(category_name,"justyears", justyears)
|
||||
menu.add_option(category_name, "justyears", justyears)
|
||||
|
||||
placecause = BooleanOption(_("Place/cause when no date"), True)
|
||||
placecause.set_help(_("When no birth, marriage, or death date is "
|
||||
"available, the correspondent place field (or "
|
||||
"cause field when blank place) will be used."))
|
||||
menu.add_option(category_name,"placecause", placecause)
|
||||
menu.add_option(category_name, "placecause", placecause)
|
||||
|
||||
url = BooleanOption(_("Include URLs"), False)
|
||||
url.set_help(_("Include a URL in each graph node so "
|
||||
@@ -444,23 +464,26 @@ class RelGraphOptions(MenuReportOptions):
|
||||
"generated that contain active links "
|
||||
"to the files generated by the 'Narrated "
|
||||
"Web Site' report."))
|
||||
menu.add_option(category_name,"url", url)
|
||||
menu.add_option(category_name, "url", url)
|
||||
|
||||
incid = BooleanOption(_("Include IDs"), False)
|
||||
incid.set_help(_("Include individual and family IDs."))
|
||||
menu.add_option(category_name,"incid", incid)
|
||||
menu.add_option(category_name, "incid", incid)
|
||||
|
||||
self.includeImages = BooleanOption(
|
||||
self.__include_images = BooleanOption(
|
||||
_('Include thumbnail images of people'), False)
|
||||
self.includeImages.set_help(_("Whether to include thumbnails of people."))
|
||||
menu.add_option(category_name,"includeImages", self.includeImages)
|
||||
self.__include_images.set_help(
|
||||
_("Whether to include thumbnails of people."))
|
||||
menu.add_option(category_name, "includeImages", self.__include_images)
|
||||
self.__include_images.connect('value-changed', self.__image_changed)
|
||||
|
||||
self.imageOnTheSide = EnumeratedListOption(_("Thumbnail Location"), 0)
|
||||
self.imageOnTheSide.add_item(0, _('Above the name'))
|
||||
self.imageOnTheSide.add_item(1, _('Beside the name'))
|
||||
self.imageOnTheSide.set_help(_("Where the thumbnail image should appear "
|
||||
"relative to the name"))
|
||||
menu.add_option(category_name,"imageOnTheSide",self.imageOnTheSide)
|
||||
self.__image_on_side = EnumeratedListOption(_("Thumbnail Location"), 0)
|
||||
self.__image_on_side.add_item(0, _('Above the name'))
|
||||
self.__image_on_side.add_item(1, _('Beside the name'))
|
||||
self.__image_on_side.set_help(
|
||||
_("Where the thumbnail image should appear "
|
||||
"relative to the name"))
|
||||
menu.add_option(category_name, "imageOnTheSide", self.__image_on_side)
|
||||
|
||||
################################
|
||||
category_name = _("Graph Style")
|
||||
@@ -472,35 +495,55 @@ class RelGraphOptions(MenuReportOptions):
|
||||
color.set_help(_("Males will be shown with blue, females "
|
||||
"with red. If the sex of an individual "
|
||||
"is unknown it will be shown with gray."))
|
||||
menu.add_option(category_name,"color",color)
|
||||
menu.add_option(category_name, "color", color)
|
||||
|
||||
arrow = EnumeratedListOption(_("Arrowhead direction"), 'd')
|
||||
for i in range( 0, len(_ARROWS) ):
|
||||
arrow.add_item(_ARROWS[i]["value"], _ARROWS[i]["name"])
|
||||
arrow.set_help(_("Choose the direction that the arrows point."))
|
||||
menu.add_option(category_name,"arrow",arrow)
|
||||
menu.add_option(category_name, "arrow", arrow)
|
||||
|
||||
dashed = BooleanOption(
|
||||
_("Indicate non-birth relationships with dotted lines"), True)
|
||||
dashed.set_help(_("Non-birth relationships will show up "
|
||||
"as dotted lines in the graph."))
|
||||
menu.add_option(category_name,"dashed", dashed)
|
||||
menu.add_option(category_name, "dashed", dashed)
|
||||
|
||||
showfamily = BooleanOption(_("Show family nodes"), True)
|
||||
showfamily.set_help(_("Families will show up as ellipses, linked "
|
||||
"to parents and children."))
|
||||
menu.add_option(category_name,"showfamily", showfamily)
|
||||
|
||||
|
||||
def imageChanged(self, button):
|
||||
self.imageOnTheSide.gobj.set_sensitive(self.includeImages.gobj.get_active())
|
||||
|
||||
|
||||
def post_init(self, dialog):
|
||||
self.includeImages.gobj.connect('toggled', self.imageChanged)
|
||||
self.imageChanged(self.includeImages.gobj)
|
||||
|
||||
menu.add_option(category_name, "showfamily", showfamily)
|
||||
|
||||
def __update_filters(self):
|
||||
"""
|
||||
Update the filter list based on the selected person
|
||||
"""
|
||||
_db = self.__dbstate.get_database()
|
||||
gid = self.__pid.get_value()
|
||||
person = _db.get_person_from_gramps_id(gid)
|
||||
filter_list = ReportUtils.get_person_filters(person, False)
|
||||
self.__filter.set_filters(filter_list)
|
||||
|
||||
def __filter_changed(self):
|
||||
"""
|
||||
Handle filter change. If the filter is not specific to a person,
|
||||
disable the person option
|
||||
"""
|
||||
filter_value = self.__filter.get_value()
|
||||
if filter_value in [1, 2, 3, 4]:
|
||||
# Filters 1, 2, 3 and 4 rely on the center person
|
||||
self.__pid.set_available(True)
|
||||
else:
|
||||
# The rest don't
|
||||
self.__pid.set_available(False)
|
||||
|
||||
def __image_changed(self):
|
||||
"""
|
||||
Handle thumbnail change. If the image is not to be included, make the
|
||||
image location option unavailable.
|
||||
"""
|
||||
self.__image_on_side.set_available(self.__include_images.get_value())
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user