More updates to better support MenuOptions. FamilyLines seems to work now.

svn: r9634
This commit is contained in:
Brian Matherly 2007-12-30 05:41:16 +00:00
parent 07bdb19028
commit e0543b0644
23 changed files with 240 additions and 308 deletions

View File

@ -1,3 +1,28 @@
2007-12-29 Brian Matherly <brian@gramps-project.org>
* src/ReportBase/_GraphvizReportDialog.py:
* src/ReportBase/_BareReportDialog.py:
* src/ReportBase/_ReportOptions.py:
* src/plugins/DescendReport.py:
* src/plugins/DetDescendantReport.py:
* src/plugins/CalculateEstimatedDates.py:
* src/plugins/Calendar.py:
* src/plugins/GVFamilyLines.py:
* src/plugins/AncestorReport.py:
* src/plugins/DescendChart.py:
* src/plugins/EndOfLineReport.py:
* src/plugins/AncestorChart.py:
* src/plugins/DetAncestralReport.py:
* src/plugins/FamilyGroup.py:
* src/plugins/GVRelGraph.py:
* src/plugins/GVHourGlass.py:
* src/plugins/FamilyLines.py:
* src/plugins/FanChart.py:
* src/DbState.py:
* src/PluginUtils/__init__.py:
* src/PluginUtils/_MenuOptions.py:
* src/BaseDoc.py:
More updates to better support MenuOptions. FamilyLines seems to work now.
2007-12-29 Douglas S. Blank <dblank@cs.brynmawr.edu>
* src/DataViews/MyGrampsView.py: show matching surnames
* src/plugins/OnThisDay.py: refinement

View File

@ -1599,3 +1599,22 @@ class GVDoc:
@return: nothing
"""
raise NotImplementedError
def start_subgraph(self,id):
"""
Start a subgraph in this graph.
@param id: The unique identifier of the subgraph.
Example: "p55"
@type id1: string
@return: nothing
"""
raise NotImplementedError
def end_subgraph(self):
"""
End a subgraph that was previously started in this graph.
@return: nothing
"""
raise NotImplementedError

View File

@ -119,3 +119,9 @@ class DbState(GrampsDBCallback):
self.active = None
self.open = False
self.emit('database-changed', (self.db, ))
def get_database(self):
"""
Gets a reference to the current database.
"""
return self.db

View File

@ -31,6 +31,7 @@ import gobject
import _Tool as Tool
import GrampsWidgets
from Selectors import selector_factory
from BasicUtils import name_displayer as _nd
#-------------------------------------------------------------------------
#
@ -595,7 +596,7 @@ class PeoplePickerOption(Option):
This class describes a widget that allows
people from the database to be selected.
"""
def __init__(self, label, value, db):
def __init__(self, label, value, dbstate):
"""
@param label: A friendly label to be applied to this option.
Example: "People of interest"
@ -605,13 +606,16 @@ class PeoplePickerOption(Option):
@type value: set()
@return: nothing
"""
self.db = db
self.db = dbstate.get_database()
self.dbstate = dbstate
Option.__init__(self,label,value)
def make_gui_obj(self, gtk, dialog):
"""
Add a "people picker" widget to the dialog.
"""
self.dialog = dialog
value = self.get_value()
self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
self.treeView = gtk.TreeView(self.model)
@ -633,14 +637,11 @@ class PeoplePickerOption(Option):
self.hbox = gtk.HBox()
self.hbox.pack_start(self.scrolledWindow, expand=True, fill=True)
if not self.db:
print "PROBLEM: from where can I obtain or pass in a db parm?"
else:
for gid in value.split():
person = self.db.get_person_from_gramps_id(gid)
if person:
name = _nd.display(person)
self.model.append([name, gid])
for gid in value.split():
person = self.db.get_person_from_gramps_id(gid)
if person:
name = _nd.display(person)
self.model.append([name, gid])
# now setup the '+' and '-' pushbutton for adding/removing people from the container
self.addPerson = GrampsWidgets.SimpleButton(gtk.STOCK_ADD, self.addPersonClicked)
@ -669,9 +670,6 @@ class PeoplePickerOption(Option):
def addPersonClicked(self, obj):
# people we already have must be excluded
# so we don't list them multiple times
if not self.db:
print "PROBLEM: this method needs a db parm, and various other things like db, uistate, and track!"
skipList = set()
iter = self.model.get_iter_first()
while (iter):
@ -681,7 +679,7 @@ class PeoplePickerOption(Option):
iter = self.model.iter_next(iter)
SelectPerson = selector_factory('Person')
sel = SelectPerson(self.dbstate, self.uistate, self.track, skip=skipList)
sel = SelectPerson(self.dbstate, self.dialog.uistate, self.dialog.track, skip=skipList)
person = sel.run()
if person:
name = _nd.display(person)
@ -694,12 +692,18 @@ class PeoplePickerOption(Option):
if familyList:
for familyHandle in familyList:
family = self.db.get_family_from_handle(familyHandle)
spouseHandle = ReportUtils.find_spouse(person, family)
if person.get_handle() == family.get_father_handle():
spouseHandle = family.get_mother_handle()
else:
spouseHandle = family.get_father_handle()
if spouseHandle:
if spouseHandle not in skipList:
import gtk
spouse = self.db.get_person_from_handle(spouseHandle)
text = _('Also include %s?') % spouse.get_primary_name().get_regular_name()
prompt = gtk.MessageDialog(parent=self.window, flags=gtk.DIALOG_MODAL, type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_YES_NO, message_format=text)
prompt = gtk.MessageDialog(parent=self.dialog.window, flags=gtk.DIALOG_MODAL, type=gtk.MESSAGE_QUESTION, buttons=gtk.BUTTONS_YES_NO, message_format=text)
prompt.set_default_response(gtk.RESPONSE_YES)
prompt.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
prompt.set_title(_('Select Person'))
@ -826,13 +830,13 @@ class Menu:
#
#------------------------------------------------------------------------
class MenuOptions:
def __init__(self):
def __init__(self,dbstate):
self.menu = Menu()
# Fill options_dict with report/tool defaults:
self.options_dict = {}
self.options_help = {}
self.add_menu_options(self.menu)
self.add_menu_options(self.menu,dbstate)
for name in self.menu.get_all_option_names():
option = self.menu.get_option_by_name(name)
self.options_dict[name] = option.get_value()
@ -841,7 +845,7 @@ class MenuOptions:
def make_default_style(self,default_style):
pass
def add_menu_options(self,menu):
def add_menu_options(self,menu,dbstate):
"""
Add the user defined options to the menu.

View File

@ -58,6 +58,6 @@ class MenuToolOptions(MenuOptions,Tool.ToolOptions):
"""
def __init__(self,name,person_id=None):
Tool.ToolOptions.__init__(self,name, person_id)
MenuOptions.__init__(self)
MenuOptions.__init__(self,None)

View File

@ -87,7 +87,7 @@ class BareReportDialog(ManagedWindow.ManagedWindow):
def init_options(self,option_class):
if type(option_class) == ClassType:
self.options = option_class(self.raw_name)
self.options = option_class(self.raw_name,self.dbstate)
elif type(option_class) == InstanceType:
self.options = option_class

View File

@ -127,7 +127,6 @@ class GVDocBase(BaseDoc.BaseDoc,BaseDoc.GVDoc):
self.rankdir = _RANKDIR[ self.options['rank_dir' ]]['value']
self.ranksep = self.options['ranksep' ]
self.ratio = _RATIO[ self.options['ratio' ]]['value']
self.usesubgraphs = self.options['usesubgraphs' ]
self.vpages = self.options['v_pages' ]
paper_size = paper_style.get_size()
@ -265,6 +264,13 @@ class GVDocBase(BaseDoc.BaseDoc,BaseDoc.GVDoc):
self.dot.write(']')
self.dot.write(';\n')
def start_subgraph(self,id):
self.dot.write(' subgraph cluster_%s\n' % id)
self.dot.write(' {\n')
def end_subgraph(self):
self.dot.write(' }\n')
#-------------------------------------------------------------------------------
#
@ -680,7 +686,7 @@ class GraphvizReportDialog(ReportDialog):
def init_options(self,option_class):
if type(option_class) == ClassType:
self.options = option_class(self.raw_name)
self.options = option_class(self.raw_name,self.dbstate)
elif type(option_class) == InstanceType:
self.options = option_class
@ -778,17 +784,6 @@ class GraphvizReportDialog(ReportDialog):
"between columns."))
self.options.add_menu_option(category, "ranksep", ranksep)
usesubgraphs = BooleanOption(_('Use subgraphs'), False)
usesubgraphs.set_help(_("Subgraphs can help GraphViz position "
"certain linked nodes closer together, "
"but with non-trivial graphs will result "
"in longer lines and larger graphs."))
self.options.add_menu_option(category, "usesubgraphs", usesubgraphs)
# this control only affects a subset of graphviz-based reports, so we
# need to remember it since we'll be toggling the visibility
self.usesubgraphs = usesubgraphs
################################
category = _("Note")
################################
@ -821,14 +816,6 @@ class GraphvizReportDialog(ReportDialog):
self.page_dir.combo.set_sensitive(True)
else:
self.page_dir.combo.set_sensitive(False)
def report_allows_subgraphs(self, state):
# if your report can take advantage of subgraphs, call this
# method to allow the users to toggle the state of subgraphs
if state:
self.usesubgraphs.gobj.show()
else:
self.usesubgraphs.gobj.hide()
def init_interface(self):
ReportDialog.init_interface(self)
@ -843,10 +830,6 @@ class GraphvizReportDialog(ReportDialog):
self.v_pages.gobj.connect('value-changed', self.pages_changed)
self.pages_changed(self.h_pages.gobj)
# note that the "use subgraph" option isn't used by many reports,
# so we'll hide it unless a reports specifically asks for it
self.report_allows_subgraphs(False)
def setup_format_frame(self):
"""Set up the format frame of the dialog."""

View File

@ -663,8 +663,12 @@ class MenuReportOptions(MenuOptions,ReportOptions):
MenuReportOptions class will worry about setting up the GUI.
"""
def __init__(self,name,person_id=None):
ReportOptions.__init__(self,name, person_id)
MenuOptions.__init__(self)
def __init__(self,name,dbstate=None):
if dbstate:
active_person = dbstate.get_active_person().get_gramps_id()
else:
active_person = None
ReportOptions.__init__(self,name,active_person)
MenuOptions.__init__(self,dbstate)

View File

@ -444,10 +444,10 @@ class AncestorChartOptions(MenuReportOptions):
Defines options and provides handling interface.
"""
def __init__(self,name,person_id=None):
MenuReportOptions.__init__(self,name,person_id)
def __init__(self,name,dbstate=None):
MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu):
def add_menu_options(self,menu,dbstate):
category_name = _("Report Options")
max_gen = NumberOption(_("Generations"),10,1,15)

View File

@ -38,7 +38,7 @@ from gettext import gettext as _
#
#------------------------------------------------------------------------
from PluginUtils import register_report, NumberOption, BooleanOption
from ReportBase import Report, ReportUtils, ReportOptions, MenuReportOptions, \
from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
import BaseDoc
from BasicUtils import name_displayer
@ -222,10 +222,10 @@ class AncestorOptions(MenuReportOptions):
Defines options and provides handling interface.
"""
def __init__(self,name,person_id=None):
MenuReportOptions.__init__(self,name,person_id)
def __init__(self,name,dbstate=None):
MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu):
def add_menu_options(self,menu,dbstate):
category_name = _("Report Options")
maxgen = NumberOption(_("Generations"),10,1,15)

View File

@ -51,7 +51,7 @@ import Errors
class CalcEstDateOptions(MenuToolOptions):
""" Calculate Estimated Date options """
def add_menu_options(self, menu):
def add_menu_options(self, menu, dbstate):
""" Adds the options """
category_name = _("Options")

View File

@ -472,7 +472,7 @@ class CalendarReport(Calendar):
class CalendarOptions(MenuReportOptions):
""" Calendar options for graphic calendar """
def add_menu_options(self, menu):
def add_menu_options(self, menu,dbstate):
""" Adds the options for the graphical calendar """
category_name = _("Report Options")
@ -605,14 +605,14 @@ class CalendarOptions(MenuReportOptions):
class CalendarReportOptions(CalendarOptions):
""" Options for the calendar (birthday and anniversary) report """
def add_menu_options(self, menu):
def add_menu_options(self, menu,dbstate):
""" Adds the options for the graphical calendar """
category_name = _("Text Options")
titletext = StringOption(_("Title text"),
_("Birthday and Anniversary Report"))
titletext.set_help(_("Title of calendar"))
menu.add_option(category_name,"titletext", titletext)
CalendarOptions.add_menu_options(self, menu)
CalendarOptions.add_menu_options(self, menu, dbstate)
category_name = _("Report Options")
option = BooleanOption(_("Include relationships to center person (slower)"),
False)

View File

@ -30,7 +30,7 @@
#------------------------------------------------------------------------
from BasicUtils import name_displayer
from PluginUtils import register_report, NumberOption, BooleanOption, TextOption
from ReportBase import Report, ReportOptions, MenuReportOptions, \
from ReportBase import Report, MenuReportOptions, \
ReportUtils, CATEGORY_DRAW, MODE_GUI, MODE_BKI, MODE_CLI
from SubstKeywords import SubstKeywords
from gettext import gettext as _
@ -397,8 +397,8 @@ class DescendChartOptions(MenuReportOptions):
Defines options and provides handling interface.
"""
def __init__(self,name,person_id=None):
MenuReportOptions.__init__(self,name,person_id)
def __init__(self,name,dbstate=None):
MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu):
category_name = _("Report Options")

View File

@ -37,7 +37,7 @@ from gettext import gettext as _
#
#------------------------------------------------------------------------
from PluginUtils import register_report, NumberOption
from ReportBase import Report, ReportUtils, ReportOptions, MenuReportOptions, \
from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
import BaseDoc
import Errors
@ -195,10 +195,10 @@ class DescendantOptions(MenuReportOptions):
Defines options and provides handling interface.
"""
def __init__(self,name,person_id=None):
MenuReportOptions.__init__(self,name,person_id)
def __init__(self,name,dbstate=None):
MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu):
def add_menu_options(self,menu,dbstate):
category_name = _("Report Options")
gen = NumberOption(_("Generations"),10,1,15)

View File

@ -659,10 +659,10 @@ class DetAncestorOptions(MenuReportOptions):
Defines options and provides handling interface.
"""
def __init__(self,name,person_id=None):
MenuReportOptions.__init__(self,name,person_id)
def __init__(self,name,dbstate=None):
MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu):
def add_menu_options(self,menu,dbstate):
category_name = _("Report Options")
gen = NumberOption(_("Generations"),10,1,100)

View File

@ -622,10 +622,10 @@ class DetDescendantOptions(MenuReportOptions):
Defines options and provides handling interface.
"""
def __init__(self,name,person_id=None):
MenuReportOptions.__init__(self,name,person_id)
def __init__(self,name,dbstate=None):
MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu):
def add_menu_options(self,menu,dbstate):
category_name = _("Report Options")
gen = NumberOption(_("Generations"),10,1,100)

View File

@ -35,7 +35,7 @@ from gettext import gettext as _
#
#------------------------------------------------------------------------
from PluginUtils import register_report
from ReportBase import Report, ReportUtils, ReportOptions, \
from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
import BaseDoc
from BasicUtils import name_displayer
@ -207,13 +207,21 @@ class EndOfLineReport(Report):
self.doc.end_cell()
self.doc.end_row()
class EndOfLineOptions(ReportOptions):
#------------------------------------------------------------------------
#
# EndOfLineOptions
#
#------------------------------------------------------------------------
class EndOfLineOptions(MenuReportOptions):
"""
Defines options and provides handling interface.
"""
def __init__(self,name,person_id=None):
ReportOptions.__init__(self,name,person_id)
def __init__(self,name,dbstate=None):
MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu,dbstate):
pass
def make_default_style(self,default_style):
"""Make the default output style for the End of Line Report."""

View File

@ -36,8 +36,8 @@ import gtk
#
#------------------------------------------------------------------------
import gen.lib
from PluginUtils import register_report
from ReportBase import Report, ReportUtils, ReportOptions, \
from PluginUtils import register_report, BooleanOption, EnumeratedListOption
from ReportBase import Report, ReportUtils, MenuReportOptions, \
CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
import BaseDoc
import DateHandler
@ -324,41 +324,6 @@ class FamilyGroup(Report):
self.doc.end_table()
def dump_marriage(self,family):
if not family:
return
m = None
family_ref_list = family.get_event_ref_list()
for event_ref in family_ref_list:
if event_ref:
event = self.database.get_event_from_handle(event_ref.ref)
if int(event.get_type()) == gen.lib.EventType.MARRIAGE:
m = event
break
if m or self.missingInfo:
self.doc.start_table("MarriageInfo",'FGR-ParentTable')
self.doc.start_row()
self.doc.start_cell('FGR-ParentHead',3)
self.doc.start_paragraph('FGR-ParentName')
self.doc.write_text(_("Marriage:"))
self.doc.end_paragraph()
self.doc.end_cell()
self.doc.end_row()
evtName = str(gen.lib.EventType(gen.lib.EventType.MARRIAGE))
self.dump_parent_event(evtName,m)
for event_ref in family_ref_list:
if event_ref:
event = self.database.get_event_from_handle(event_ref.ref)
evtType = event.get_type()
if int(evtType) != gen.lib.EventType.MARRIAGE:
name = Utils.format_event( evtType )
self.dump_parent_event(name,event)
self.doc.end_table()
def dump_marriage(self,family):
if not family:
@ -613,82 +578,93 @@ class FamilyGroup(Report):
#------------------------------------------------------------------------
#
#
# MenuReportOptions
#
#------------------------------------------------------------------------
class FamilyGroupOptions(ReportOptions):
class FamilyGroupOptions(MenuReportOptions):
"""
Defines options and provides handling interface.
"""
def __init__(self,name,person_id=None):
ReportOptions.__init__(self,name,person_id)
def __init__(self,name,dbstate=None):
MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu,dbstate):
##########################
category_name = _("Report Options")
##########################
families = self.get_families(dbstate.get_database(),
dbstate.get_active_person())
# Options specific for this report
self.options_dict = {
'family_id' : '',
'recursive' : 0,
'missinginfo' : 1,
'generations' : 1,
'incParEvents' : 0,
'incParAddr' : 0,
'incParNotes' : 0,
'incattrs' : 0,
'incParNames' : 0,
'incParMar' : 0,
'incChiMar' : 1,
'incRelDates' : 0,
}
self.options_help = {
'family_id' : ("=ID","Gramps ID of the person's family.",
"Use show=id to get ID list.",
),
'recursive' : ("=0/1","Create reports for all decendants of this family.",
["Do not create reports for decendants","Create reports for decendants"],
False),
'missinginfo' : ("=0/1","Whether to include fields for missing information.",
["Do not include missing info","Include missing info"],
True),
'generations' : ("=0/1","Whether to include the generation on each report (recursive only).",
["Do not include the generation","Include the generation"],
True),
'incParEvents' : ("=0/1","Whether to include events for parents.",
["Do not include parental events","Include parental events"],
True),
'incParAddr' : ("=0/1","Whether to include addresses for parents.",
["Do not include parental addresses","Include parental addresses"],
True),
'incParNotes' : ("=0/1","Whether to include notes for parents.",
["Do not include parental notes","Include parental notes"],
True),
'incattrs' : ("=0/1","Whether to include attributes.",
["Do not include attributes","Include attributes"],
True),
'incParNames' : ("=0/1","Whether to include alternate names for parents.",
["Do not include parental names","Include parental names"],
True),
'incParMar' : ("=0/1","Whether to include marriage information for parents.",
["Do not include parental marriage info","Include parental marriage info"],
False),
'incChiMar' : ("=0/1","Whether to include marriage information for children.",
["Do not include children marriage info","Include children marriage info"],
True),
'incRelDates' : ("=0/1","Whether to include dates for relatives.",
["Do not include dates of relatives","Include dates of relatives"],
True),
}
family_id = EnumeratedListOption(_("Spouse"), "")
for item in families:
family_id.add_item(item[0], item[1])
family_id.set_help(_("Gramps ID of the person's family."))
menu.add_option(category_name,"family_id",family_id)
recursive = BooleanOption(_('Recursive'),False)
recursive.set_help(_("Create reports for all decendants "
"of this family."))
menu.add_option(category_name,"recursive",recursive)
##########################
category_name = _("Include")
##########################
generations = BooleanOption(_("Generation numbers "
"(recursive only)"),True)
generations.set_help(_("Whether to include the generation on each "
"report (recursive only)."))
menu.add_option(category_name,"generations",generations)
incParEvents = BooleanOption(_("Parent Events"),False)
incParEvents.set_help(_("Whether to include events for parents."))
menu.add_option(category_name,"incParEvents",incParEvents)
incParAddr = BooleanOption(_("Parent Addresses"),False)
incParAddr.set_help(_("Whether to include addresses for parents."))
menu.add_option(category_name,"incParAddr",incParAddr)
incParNotes = BooleanOption(_("Parent Notes"),False)
incParNotes.set_help(_("Whether to include notes for parents."))
menu.add_option(category_name,"incParNotes",incParNotes)
incattrs = BooleanOption(_("Parent Attributes"),False)
incattrs.set_help(_("Whether to include attributes."))
menu.add_option(category_name,"incattrs",incattrs)
incParNames = BooleanOption(_("Alternate Parent Names"),False)
incParNames.set_help(_("Whether to include alternate "
"names for parents."))
menu.add_option(category_name,"incParNames",incParNames)
incParMar = BooleanOption(_("Parent Marriage"),False)
incParMar.set_help(_("Whether to include marriage information "
"for parents."))
menu.add_option(category_name,"incParMar",incParMar)
incRelDates = BooleanOption(_("Dates of Relatives"),False)
incRelDates.set_help(_("Whether to include dates for relatives "
"(father, mother, spouse)."))
menu.add_option(category_name,"incRelDates",incRelDates)
incChiMar = BooleanOption(_("Children Marriages"),True)
incChiMar.set_help(_("Whether to include marriage information "
"for children."))
menu.add_option(category_name,"incChiMar",incChiMar)
##########################
category_name = _("Missing Information")
##########################
missinginfo = BooleanOption(_("Print fields for missing "
"information"),True)
missinginfo.set_help(_("Whether to include fields for missing "
"information."))
menu.add_option(category_name,"missinginfo",missinginfo)
def get_families(self,database,person):
"""
@ -716,103 +692,6 @@ class FamilyGroupOptions(ReportOptions):
families.append((family_id,name))
return families
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.
"""
families = self.get_families(dialog.db,dialog.person)
family_id = self.options_dict['family_id']
self.spouse_menu = gtk.combo_box_new_text()
index = 0
family_index = 0
for item in families:
self.spouse_menu.append_text(item[1])
if item[0] == family_id:
family_index = index
index = index + 1
self.spouse_menu.set_active(family_index)
# Recursive
self.recursive_option = gtk.CheckButton()
self.recursive_option.set_active(self.options_dict['recursive'])
# Missing Info
self.missing_info_option = gtk.CheckButton(_("Print fields for missing information"))
self.missing_info_option.set_active(self.options_dict['missinginfo'])
# Generations
self.include_generations_option = gtk.CheckButton(_("Generation numbers (recursive only)"))
self.include_generations_option.set_active(self.options_dict['generations'])
# Parental Events
self.include_par_events_option = gtk.CheckButton(_("Parent Events"))
self.include_par_events_option.set_active(self.options_dict['incParEvents'])
# Parental Addresses
self.include_par_addr_option = gtk.CheckButton(_("Parent Addresses"))
self.include_par_addr_option.set_active(self.options_dict['incParAddr'])
# Parental Notes
self.include_par_notes_option = gtk.CheckButton(_("Parent Notes"))
self.include_par_notes_option.set_active(self.options_dict['incParNotes'])
# Parental Attributes
self.include_attributes_option = gtk.CheckButton(_("Parent Attributes"))
self.include_attributes_option.set_active(self.options_dict['incattrs'])
# Parental Names
self.include_par_names_option = gtk.CheckButton(_("Alternate Parent Names"))
self.include_par_names_option.set_active(self.options_dict['incParNames'])
# Parental Marriage
self.include_par_marriage_option = gtk.CheckButton(_("Parent Marriage"))
self.include_par_marriage_option.set_active(self.options_dict['incParMar'])
# Relatives Dates
self.include_rel_dates_option = gtk.CheckButton(_("Dates of Relatives (father, mother, spouse)"))
self.include_rel_dates_option.set_active(self.options_dict['incRelDates'])
# Children Marriages
self.include_chi_marriage_option = gtk.CheckButton(_("Children Marriages"))
self.include_chi_marriage_option.set_active(self.options_dict['incChiMar'])
dialog.add_option(_("Spouse"),self.spouse_menu)
dialog.add_option(_("Recursive"),self.recursive_option)
dialog.add_frame_option(_('Include'),'',self.include_generations_option)
dialog.add_frame_option(_('Include'),'',self.include_par_events_option)
dialog.add_frame_option(_('Include'),'',self.include_par_addr_option)
dialog.add_frame_option(_('Include'),'',self.include_par_notes_option)
dialog.add_frame_option(_('Include'),'',self.include_attributes_option)
dialog.add_frame_option(_('Include'),'',self.include_par_names_option)
dialog.add_frame_option(_('Include'),'',self.include_par_marriage_option)
dialog.add_frame_option(_('Include'),'',self.include_chi_marriage_option)
dialog.add_frame_option(_('Include'),'',self.include_rel_dates_option)
dialog.add_frame_option(_('Missing Information'),'',self.missing_info_option)
def parse_user_options(self,dialog):
"""
Parses the custom options that we have added.
"""
families = self.get_families(dialog.db,dialog.person)
family_index = self.spouse_menu.get_active()
if families:
self.options_dict['family_id'] = families[family_index][0]
self.options_dict['recursive'] = int(self.recursive_option.get_active())
self.options_dict['missinginfo'] = int(self.missing_info_option.get_active())
self.options_dict['generations'] = int(self.include_generations_option.get_active())
self.options_dict['incParEvents'] = int(self.include_par_events_option.get_active())
self.options_dict['incParAddr'] = int(self.include_par_addr_option.get_active())
self.options_dict['incParNotes'] = int(self.include_par_notes_option.get_active())
self.options_dict['incattrs'] = int(self.include_attributes_option.get_active())
self.options_dict['incParNames'] = int(self.include_par_names_option.get_active())
self.options_dict['incParMar'] = int(self.include_par_marriage_option.get_active())
self.options_dict['incChiMar'] = int(self.include_chi_marriage_option.get_active())
self.options_dict['incRelDates'] = int(self.include_rel_dates_option.get_active())
def make_default_style(self,default_style):
"""Make default output style for the Family Group Report."""
para = BaseDoc.ParagraphStyle()

View File

@ -1435,5 +1435,6 @@ register_report(
report_class = FamilyLinesDialog, # class which will create everything needed for the report
options_class = None,
translated_name = _("Family Lines Graph"),
unsupported = True
)

View File

@ -315,12 +315,12 @@ class FanChart(Report):
#------------------------------------------------------------------------
class FanChartOptions(MenuReportOptions):
def __init__(self,name,person_id=None):
def __init__(self,name,dbstate=None):
self.MAX_GENERATIONS = 8
MenuReportOptions.__init__(self,name,person_id)
MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu):
def add_menu_options(self,menu,dbstate):
category_name = _("Report Options")
max_gen = NumberOption(_("Generations"),5,1,self.MAX_GENERATIONS)

View File

@ -2,6 +2,7 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2007 Stephane Charette
# Copyright (C) 2007 Brian G. Matherly
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Pubilc License as published by
@ -101,16 +102,18 @@ class FamilyLinesOptions(MenuReportOptions):
Defines all of the controls necessary
to configure the FamilyLines reports.
"""
def __init__(self, name, person_id=None):
MenuReportOptions.__init__(self, name, person_id)
def __init__(self, name, dbstate=None):
MenuReportOptions.__init__(self, name, dbstate)
def add_menu_options(self, menu):
def add_menu_options(self, menu,dbstate):
# --------------------------------
category = _('People of Interest')
# --------------------------------
peoplePicker = PeoplePickerOption( _('People of interest'), '', None) # todo, fixme: need access to the database (3rd parm)
peoplePicker = PeoplePickerOption( _('People of interest'),
'',
dbstate )
peoplePicker.set_help( _('People of interest are used as a starting point when determining \"family lines\".'))
menu.add_option(category, 'FLgidlist', peoplePicker)
@ -205,6 +208,13 @@ class FamilyLinesOptions(MenuReportOptions):
includePrivate = BooleanOption( _('Include private records'), False)
includePrivate.set_help( _('Whether to include names, dates, and families that are marked as private.'))
menu.add_option(category, 'FLincludePrivate', includePrivate)
usesubgraphs = BooleanOption(_('Use subgraphs'), False)
usesubgraphs.set_help(_("Subgraphs can help GraphViz position "
"certain linked nodes closer together, "
"but with non-trivial graphs will result "
"in longer lines and larger graphs."))
menu.add_option(category, "usesubgraphs", usesubgraphs)
#------------------------------------------------------------------------
@ -223,6 +233,7 @@ class FamilyLinesReport(Report):
person - currently selected person
options - instance of the FamilyLinesOptions class for this report
"""
Report.__init__(self,database,person,options)
# initialize several convenient variables
self.options = options
@ -232,10 +243,7 @@ class FamilyLinesReport(Report):
self.deletedPeople = 0
self.deletedFamilies = 0
# inherited from parent; see "usesubgraphs" in _GraphvizReportDialog.py
self.useSubgraphs = options.handler.options_dict['usesubgraphs' ]
# the remainder of the options are specific to this report
self.followParents = options.handler.options_dict['FLfollowParents' ]
self.followChildren = options.handler.options_dict['FLfollowChildren' ]
self.removeExtraPeople = options.handler.options_dict['FLremoveExtraPeople' ]
@ -714,11 +722,7 @@ class FamilyLinesReport(Report):
if imagePath:
label += '</TD></TR></TABLE>'
if bUseHtmlOutput:
label = '<%s>' % label
else:
label = '"%s"' % label
self.write(' %s [shape="box", fillcolor="%s", label=%s];\n' % (person.get_gramps_id(), colour, label))
self.doc.add_node(person.get_gramps_id(),label,"box","","filled",colour)
def writeFamilies(self):
@ -778,12 +782,12 @@ class FamilyLinesReport(Report):
if label != '':
label += '\\n'
label += '%s' % childrenStr
self.write(' %s [shape="ellipse", fillcolor="%s", label="%s"];\n' % (fgid, self.colourFamilies, label))
self.doc.add_node(fgid,label,"ellipse","","filled",self.colourFamilies)
# now that we have the families written, go ahead and link the parents and children to the families
for familyHandle in self.familiesToOutput:
self.progress.step()
self.write('\n')
# get the parents for this family
family = self.db.get_family_from_handle(familyHandle)
@ -792,29 +796,28 @@ class FamilyLinesReport(Report):
motherHandle = family.get_mother_handle()
if self.useSubgraphs and fatherHandle and motherHandle:
self.write(' subgraph cluster_%s\n' % fgid)
self.write(' {\n')
self.doc.start_subgraph(fgid)
# see if we have a father to link to this family
if fatherHandle:
if fatherHandle in self.peopleToOutput:
father = self.db.get_person_from_handle(fatherHandle)
self.write(' %s -> %s // father: %s\n' % (fgid, father.get_gramps_id(), father.get_primary_name().get_regular_name()))
self.doc.add_link(fgid, father.get_gramps_id())
# see if we have a mother to link to this family
if motherHandle:
if motherHandle in self.peopleToOutput:
mother = self.db.get_person_from_handle(motherHandle)
self.write(' %s -> %s // mother: %s\n' % (fgid, mother.get_gramps_id(), mother.get_primary_name().get_regular_name()))
self.doc.add_link(fgid, mother.get_gramps_id())
if self.useSubgraphs and fatherHandle and motherHandle:
self.write(' }\n')
self.doc.end_subgraph()
# link the children to the family
for childRef in family.get_child_ref_list():
if childRef.ref in self.peopleToOutput:
child = self.db.get_person_from_handle(childRef.ref)
self.write(' %s -> %s // child: %s\n' % (child.get_gramps_id(), fgid, child.get_primary_name().get_regular_name()))
self.doc.add_link(child.get_gramps_id(), fgid)
#------------------------------------------------------------------------

View File

@ -149,10 +149,10 @@ class HourGlassOptions(MenuReportOptions):
"""
Defines options for the HourGlass report.
"""
def __init__(self,name,person_id=None):
MenuReportOptions.__init__(self,name,person_id)
def __init__(self,name,dbstate=None):
MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu):
def add_menu_options(self,menu,dbstate):
category_name = _("Report Options")
max_gen = NumberOption(_('Max Descendant Generations'),10,1,15)

View File

@ -410,10 +410,10 @@ class RelGraphOptions(MenuReportOptions):
"""
Defines options and provides handling interface.
"""
def __init__(self,name,person_id=None):
MenuReportOptions.__init__(self,name,person_id)
def __init__(self,name,dbstate=None):
MenuReportOptions.__init__(self,name,dbstate)
def add_menu_options(self,menu):
def add_menu_options(self,menu,dbstate):
################################
category_name = _("Report Options")
################################