2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2004-04-26 09:47:01 +05:30
|
|
|
# Copyright (C) 2000-2004 Donald N. Allingham
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# 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
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2004-04-26 09:47:01 +05:30
|
|
|
# $Id$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
"Generate files/Descendant Report"
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# standard python modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import os
|
2004-12-23 07:18:00 +05:30
|
|
|
from gettext import gettext as _
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2003-01-15 10:55:50 +05:30
|
|
|
import Report
|
2003-09-02 06:17:09 +05:30
|
|
|
import BaseDoc
|
2003-01-29 10:13:12 +05:30
|
|
|
import Errors
|
2004-05-05 07:51:47 +05:30
|
|
|
import Sort
|
2003-01-29 10:13:12 +05:30
|
|
|
from QuestionDialog import ErrorDialog
|
2004-12-23 07:18:00 +05:30
|
|
|
import ReportOptions
|
|
|
|
import const
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GTK/GNOME modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
|
2003-07-17 07:26:12 +05:30
|
|
|
_BORN = _('b.')
|
|
|
|
_DIED = _('d.')
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# DescendantReport
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2004-12-30 05:51:49 +05:30
|
|
|
class DescendantReport(Report.Report):
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-12-23 07:18:00 +05:30
|
|
|
def __init__(self,database,person,options_class):
|
|
|
|
"""
|
|
|
|
Creates the DescendantReport object that produces the report.
|
|
|
|
|
|
|
|
The arguments are:
|
|
|
|
|
|
|
|
database - the GRAMPS database instance
|
|
|
|
person - currently selected person
|
|
|
|
options_class - instance of the Options class for this report
|
|
|
|
|
|
|
|
This report needs the following parameters (class variables)
|
|
|
|
that come in the options class.
|
|
|
|
|
|
|
|
max_gen - Maximum number of generations to include.
|
|
|
|
pg_breaks - Whether to include page breaks between generations.
|
|
|
|
document - BaseDoc instance for the output file. Any class derived
|
|
|
|
from BaseDoc may be used
|
|
|
|
output - name of the output file.
|
|
|
|
None if report is not a standalone, in which case
|
|
|
|
somebody must take care of opening and initializing report
|
|
|
|
prior to writing.
|
|
|
|
newpage - if True, newpage is made before writing a report
|
|
|
|
|
|
|
|
"""
|
2004-12-30 05:51:49 +05:30
|
|
|
|
|
|
|
Report.Report.__init__(self,database,person,options_class)
|
2004-12-23 07:18:00 +05:30
|
|
|
|
|
|
|
(self.max_generations,self.pgbrk) \
|
2004-12-23 23:09:47 +05:30
|
|
|
= options_class.get_report_generations()
|
2004-05-05 07:51:47 +05:30
|
|
|
sort = Sort.Sort(self.database)
|
|
|
|
self.by_birthdate = sort.by_birthdate
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def dump_dates(self, person):
|
2004-07-28 07:59:07 +05:30
|
|
|
birth_handle = person.get_birth_handle()
|
|
|
|
if birth_handle:
|
2004-10-27 08:40:53 +05:30
|
|
|
birth = self.database.get_event_from_handle(birth_handle).get_date_object()
|
2004-04-26 09:47:01 +05:30
|
|
|
birth_year_valid = birth.get_year_valid()
|
|
|
|
else:
|
|
|
|
birth_year_valid = 0
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
death_handle = person.get_death_handle()
|
|
|
|
if death_handle:
|
2004-10-27 08:40:53 +05:30
|
|
|
death = self.database.get_event_from_handle(death_handle).get_date_object()
|
2004-04-26 09:47:01 +05:30
|
|
|
death_year_valid = death.get_year_valid()
|
|
|
|
else:
|
|
|
|
death_year_valid = 0
|
|
|
|
|
|
|
|
if birth_year_valid or death_year_valid:
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.write_text(' (')
|
2004-04-26 09:47:01 +05:30
|
|
|
if birth_year_valid:
|
|
|
|
self.doc.write_text("%s %d" % (_BORN,birth.get_year()))
|
|
|
|
if death_year_valid:
|
|
|
|
if birth_year_valid:
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.write_text(', ')
|
2004-04-26 09:47:01 +05:30
|
|
|
self.doc.write_text("%s %d" % (_DIED,death.get_year()))
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.write_text(')')
|
|
|
|
|
2003-07-06 03:17:41 +05:30
|
|
|
def write_report(self):
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_paragraph("DR-Title")
|
2004-12-30 05:51:49 +05:30
|
|
|
name = self.start_person.get_primary_name().get_regular_name()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.write_text(_("Descendants of %s") % name)
|
2004-12-30 05:51:49 +05:30
|
|
|
self.dump_dates(self.start_person)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_paragraph()
|
2004-12-30 05:51:49 +05:30
|
|
|
self.dump(0,self.start_person)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def dump(self,level,person):
|
|
|
|
|
|
|
|
if level != 0:
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_paragraph("DR-Level%d" % level)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.write_text("%d." % level)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.doc.write_text(person.get_primary_name().get_regular_name())
|
2002-10-20 19:55:16 +05:30
|
|
|
self.dump_dates(person)
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
|
|
|
if level >= self.max_generations:
|
|
|
|
return
|
|
|
|
|
|
|
|
childlist = []
|
2004-07-28 07:59:07 +05:30
|
|
|
for family_handle in person.get_family_handle_list():
|
2004-08-20 03:05:16 +05:30
|
|
|
family = self.database.get_family_from_handle(family_handle)
|
2004-07-28 07:59:07 +05:30
|
|
|
for child_handle in family.get_child_handle_list():
|
|
|
|
childlist.append(child_handle)
|
2004-04-26 09:47:01 +05:30
|
|
|
|
|
|
|
childlist.sort(self.by_birthdate)
|
2004-07-28 07:59:07 +05:30
|
|
|
for child_handle in childlist:
|
2004-08-07 10:46:57 +05:30
|
|
|
child = self.database.get_person_from_handle(child_handle)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.dump(level+1,child)
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2004-12-23 07:18:00 +05:30
|
|
|
#
|
2003-07-06 03:17:41 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2004-12-23 07:18:00 +05:30
|
|
|
class DescendantOptions(ReportOptions.ReportOptions):
|
2003-07-11 08:59:33 +05:30
|
|
|
|
2004-12-23 07:18:00 +05:30
|
|
|
"""
|
|
|
|
Defines options and provides handling interface.
|
|
|
|
"""
|
2003-07-06 03:17:41 +05:30
|
|
|
|
2004-12-23 07:18:00 +05:30
|
|
|
def __init__(self,name,person_id=None):
|
|
|
|
ReportOptions.ReportOptions.__init__(self,name,person_id)
|
2003-07-06 03:17:41 +05:30
|
|
|
|
2004-12-23 07:18:00 +05:30
|
|
|
def enable_options(self):
|
|
|
|
# Semi-common options that should be enabled for this report
|
|
|
|
self.enable_dict = {
|
2005-01-01 07:47:17 +05:30
|
|
|
'gen' : 10,
|
|
|
|
'pagebbg' : 0,
|
2004-12-23 07:18:00 +05:30
|
|
|
}
|
2003-07-07 22:27:27 +05:30
|
|
|
|
2004-12-23 07:18:00 +05:30
|
|
|
def make_default_style(self,default_style):
|
|
|
|
"""Make the default output style for the Descendant Report."""
|
|
|
|
f = BaseDoc.FontStyle()
|
|
|
|
f.set_size(14)
|
|
|
|
f.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
|
|
|
f.set_bold(1)
|
2003-09-02 06:17:09 +05:30
|
|
|
p = BaseDoc.ParagraphStyle()
|
2004-12-23 07:18:00 +05:30
|
|
|
p.set_header_level(1)
|
2003-07-06 03:17:41 +05:30
|
|
|
p.set_font(f)
|
2004-12-23 07:18:00 +05:30
|
|
|
p.set_description(_("The style used for the title of the page."))
|
|
|
|
default_style.add_style("DR-Title",p)
|
|
|
|
|
|
|
|
f = BaseDoc.FontStyle()
|
|
|
|
for i in range(1,32):
|
|
|
|
p = BaseDoc.ParagraphStyle()
|
|
|
|
p.set_font(f)
|
|
|
|
p.set_left_margin(min(10.0,float(i-1)))
|
|
|
|
p.set_description(_("The style used for the level %d display.") % i)
|
|
|
|
default_style.add_style("DR-Level%d" % i,p)
|
2003-07-06 03:17:41 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2004-12-23 07:18:00 +05:30
|
|
|
from Plugins import register_report
|
2002-10-20 19:55:16 +05:30
|
|
|
register_report(
|
2004-12-23 07:18:00 +05:30
|
|
|
name = 'descend_report',
|
|
|
|
category = const.CATEGORY_TEXT,
|
|
|
|
report_class = DescendantReport,
|
|
|
|
options_class = DescendantOptions,
|
|
|
|
modes = Report.MODE_GUI | Report.MODE_BKI | Report.MODE_CLI,
|
|
|
|
translated_name = _("Descendant Report"),
|
2002-10-20 19:55:16 +05:30
|
|
|
status=(_("Beta")),
|
|
|
|
description=_("Generates a list of descendants of the active person"),
|
2003-02-08 22:58:41 +05:30
|
|
|
author_name="Donald N. Allingham",
|
|
|
|
author_email="dallingham@users.sourceforge.net"
|
2002-10-20 19:55:16 +05:30
|
|
|
)
|