2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2005-01-09 01:49:06 +05:30
|
|
|
# Copyright (C) 2000-2005 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-02-01 06:04:36 +05:30
|
|
|
# $Id$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
"Generate files/Family Group Report"
|
|
|
|
|
2003-01-15 10:55:50 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# python modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2005-01-02 01:28:53 +05:30
|
|
|
from gettext import gettext as _
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-01-02 01:28:53 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Gnome/GTK modules
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2003-07-07 03:25:52 +05:30
|
|
|
import gtk
|
2005-01-02 01:28:53 +05:30
|
|
|
|
2003-01-15 10:55:50 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import RelLib
|
|
|
|
import Report
|
2003-09-02 06:17:09 +05:30
|
|
|
import BaseDoc
|
2005-01-02 01:28:53 +05:30
|
|
|
import ReportOptions
|
|
|
|
import const
|
|
|
|
from DateHandler import displayer as _dd
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2003-01-15 10:55:50 +05:30
|
|
|
# FamilyGroup
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2005-01-02 01:28:53 +05:30
|
|
|
class FamilyGroup(Report.Report):
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-01-02 01:28:53 +05:30
|
|
|
def __init__(self,database,person,options_class):
|
|
|
|
"""
|
|
|
|
Creates the DetAncestorReport object that produces the report.
|
2004-05-04 09:02:37 +05:30
|
|
|
|
2005-01-02 01:28:53 +05:30
|
|
|
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.
|
|
|
|
|
|
|
|
family_handle - Handle of the family to write report on.
|
|
|
|
"""
|
|
|
|
Report.Report.__init__(self,database,person,options_class)
|
|
|
|
|
2005-01-09 01:49:06 +05:30
|
|
|
self.family = None
|
|
|
|
|
2005-01-02 01:28:53 +05:30
|
|
|
spouse_id = options_class.handler.options_dict['spouse_id']
|
|
|
|
if spouse_id:
|
|
|
|
family_list = person.get_family_handle_list()
|
|
|
|
for family_handle in family_list:
|
|
|
|
family = database.get_family_from_handle(family_handle)
|
|
|
|
if person.get_handle() == family.get_father_handle():
|
2005-01-09 01:49:06 +05:30
|
|
|
this_spouse_handle = family.get_mother_handle()
|
2005-01-02 01:28:53 +05:30
|
|
|
else:
|
2005-01-09 01:49:06 +05:30
|
|
|
this_spouse_handle = family.get_father_handle()
|
|
|
|
this_spouse = database.get_person_from_handle(this_spouse_handle)
|
|
|
|
this_spouse_id = this_spouse.get_gramps_id()
|
2005-01-02 01:28:53 +05:30
|
|
|
if spouse_id == this_spouse_id:
|
|
|
|
self.family = family
|
|
|
|
break
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-01-02 01:28:53 +05:30
|
|
|
self.setup()
|
|
|
|
|
|
|
|
def setup(self):
|
|
|
|
"""
|
|
|
|
Define the table styles used by the report.
|
|
|
|
"""
|
2003-09-02 06:17:09 +05:30
|
|
|
cell = BaseDoc.TableCellStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
cell.set_padding(0.2)
|
|
|
|
cell.set_top_border(1)
|
|
|
|
cell.set_bottom_border(1)
|
|
|
|
cell.set_right_border(1)
|
|
|
|
cell.set_left_border(1)
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.add_cell_style('FGR-ParentHead',cell)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
cell = BaseDoc.TableCellStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
cell.set_padding(0.1)
|
|
|
|
cell.set_bottom_border(1)
|
|
|
|
cell.set_left_border(1)
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.add_cell_style('FGR-TextContents',cell)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
cell = BaseDoc.TableCellStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
cell.set_padding(0.1)
|
|
|
|
cell.set_bottom_border(0)
|
|
|
|
cell.set_left_border(1)
|
|
|
|
cell.set_padding(0.1)
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.add_cell_style('FGR-TextChild1',cell)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
cell = BaseDoc.TableCellStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
cell.set_padding(0.1)
|
|
|
|
cell.set_bottom_border(1)
|
|
|
|
cell.set_left_border(1)
|
|
|
|
cell.set_padding(0.1)
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.add_cell_style('FGR-TextChild2',cell)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
cell = BaseDoc.TableCellStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
cell.set_padding(0.1)
|
|
|
|
cell.set_bottom_border(1)
|
|
|
|
cell.set_right_border(1)
|
|
|
|
cell.set_left_border(1)
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.add_cell_style('FGR-TextContentsEnd',cell)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
cell = BaseDoc.TableCellStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
cell.set_padding(0.2)
|
|
|
|
cell.set_bottom_border(1)
|
|
|
|
cell.set_right_border(1)
|
|
|
|
cell.set_left_border(1)
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.add_cell_style('FGR-ChildName',cell)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
table = BaseDoc.TableStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
table.set_width(100)
|
|
|
|
table.set_columns(3)
|
|
|
|
table.set_column_width(0,20)
|
|
|
|
table.set_column_width(1,40)
|
|
|
|
table.set_column_width(2,40)
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.add_table_style('FGR-ParentTable',table)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
table = BaseDoc.TableStyle()
|
2002-10-20 19:55:16 +05:30
|
|
|
table.set_width(100)
|
|
|
|
table.set_columns(4)
|
|
|
|
table.set_column_width(0,7)
|
|
|
|
table.set_column_width(1,18)
|
|
|
|
table.set_column_width(2,35)
|
|
|
|
table.set_column_width(3,40)
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.add_table_style('FGR-ChildTable',table)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
def dump_parent(self,person_handle):
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
if not person_handle:
|
2002-10-20 19:55:16 +05:30
|
|
|
return
|
|
|
|
|
2005-01-02 01:28:53 +05:30
|
|
|
person = self.database.get_person_from_handle(person_handle)
|
2004-05-04 09:02:37 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if person.get_gender() == RelLib.Person.male:
|
2005-01-09 01:49:06 +05:30
|
|
|
the_id = _("Husband")
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2005-01-09 01:49:06 +05:30
|
|
|
the_id = _("Wife")
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_table(id,'FGR-ParentTable')
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.start_row()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell('FGR-ParentHead',3)
|
|
|
|
self.doc.start_paragraph('FGR-ParentName')
|
2005-01-09 01:49:06 +05:30
|
|
|
self.doc.write_text(the_id + ': ')
|
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.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
|
|
|
self.doc.end_row()
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
birth_handle = person.get_birth_handle()
|
2004-05-04 09:02:37 +05:30
|
|
|
bdate = ""
|
|
|
|
bplace = ""
|
2004-07-28 07:59:07 +05:30
|
|
|
if birth_handle:
|
2005-01-02 01:28:53 +05:30
|
|
|
birth = self.database.get_event_from_handle(birth_handle)
|
2004-05-04 09:02:37 +05:30
|
|
|
bdate = birth.get_date()
|
2004-07-28 07:59:07 +05:30
|
|
|
bplace_handle = birth.get_place_handle()
|
|
|
|
if bplace_handle:
|
2005-01-02 01:28:53 +05:30
|
|
|
bplace = self.database.get_place_from_handle(bplace_handle).get_title()
|
2004-05-04 09:02:37 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
death_handle = person.get_death_handle()
|
2004-05-04 09:02:37 +05:30
|
|
|
ddate = ""
|
|
|
|
dplace = ""
|
2004-07-28 07:59:07 +05:30
|
|
|
if death_handle:
|
2005-01-02 01:28:53 +05:30
|
|
|
death = self.database.get_event_from_handle(death_handle)
|
2004-05-04 09:02:37 +05:30
|
|
|
ddate = death.get_date()
|
2004-07-28 07:59:07 +05:30
|
|
|
dplace_handle = death.get_place_handle()
|
|
|
|
if dplace_handle:
|
2005-01-02 01:28:53 +05:30
|
|
|
dplace = self.database.get_place_from_handle(dplace_handle).get_title()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.doc.start_row()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell("FGR-TextContents")
|
|
|
|
self.doc.start_paragraph('FGR-Normal')
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.write_text(_("Birth"))
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell("FGR-TextContents")
|
|
|
|
self.doc.start_paragraph('FGR-Normal')
|
2004-05-04 09:02:37 +05:30
|
|
|
self.doc.write_text(bdate)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell("FGR-TextContentsEnd")
|
|
|
|
self.doc.start_paragraph('FGR-Normal')
|
2004-05-04 09:02:37 +05:30
|
|
|
self.doc.write_text(bplace)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
|
|
|
self.doc.end_row()
|
|
|
|
|
|
|
|
self.doc.start_row()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell("FGR-TextContents")
|
|
|
|
self.doc.start_paragraph('FGR-Normal')
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.write_text(_("Death"))
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell("FGR-TextContents")
|
|
|
|
self.doc.start_paragraph('FGR-Normal')
|
2004-05-04 09:02:37 +05:30
|
|
|
self.doc.write_text(ddate)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell("FGR-TextContentsEnd")
|
|
|
|
self.doc.start_paragraph('FGR-Normal')
|
2004-05-04 09:02:37 +05:30
|
|
|
self.doc.write_text(dplace)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
|
|
|
self.doc.end_row()
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
family_handle = person.get_main_parents_family_handle()
|
2004-05-04 09:02:37 +05:30
|
|
|
father_name = ""
|
|
|
|
mother_name = ""
|
2004-07-28 07:59:07 +05:30
|
|
|
if family_handle:
|
2005-01-02 01:28:53 +05:30
|
|
|
family = self.database.get_family_from_handle(family_handle)
|
2004-07-28 07:59:07 +05:30
|
|
|
father_handle = family.get_father_handle()
|
|
|
|
if father_handle:
|
2005-01-02 01:28:53 +05:30
|
|
|
father_name = self.database.get_person_from_handle(father_handle).get_primary_name().get_regular_name()
|
2004-07-28 07:59:07 +05:30
|
|
|
mother_handle = family.get_mother_handle()
|
|
|
|
if mother_handle:
|
2005-01-02 01:28:53 +05:30
|
|
|
mother_name = self.database.get_person_from_handle(mother_handle).get_primary_name().get_regular_name()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.doc.start_row()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell("FGR-TextContents")
|
|
|
|
self.doc.start_paragraph('FGR-Normal')
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.write_text(_("Father"))
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell("FGR-TextContentsEnd",2)
|
|
|
|
self.doc.start_paragraph('FGR-Normal')
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.write_text(father_name)
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
|
|
|
self.doc.end_row()
|
|
|
|
|
|
|
|
self.doc.start_row()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell("FGR-TextContents")
|
|
|
|
self.doc.start_paragraph('FGR-Normal')
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.write_text(_("Mother"))
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell("FGR-TextContentsEnd",2)
|
|
|
|
self.doc.start_paragraph('FGR-Normal')
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.write_text(mother_name)
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
|
|
|
self.doc.end_row()
|
|
|
|
|
|
|
|
self.doc.end_table()
|
|
|
|
|
|
|
|
def dump_child_event(self,text,name,event):
|
2004-05-04 09:02:37 +05:30
|
|
|
date = ""
|
|
|
|
place = ""
|
2002-10-20 19:55:16 +05:30
|
|
|
if event:
|
2004-02-14 11:10:30 +05:30
|
|
|
date = event.get_date()
|
2004-07-28 07:59:07 +05:30
|
|
|
place_handle = event.get_place_handle()
|
|
|
|
if place_handle:
|
2005-01-02 01:28:53 +05:30
|
|
|
place = self.database.get_place_from_handle(place_handle).get_title()
|
2004-05-04 09:02:37 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.start_row()
|
|
|
|
self.doc.start_cell(text)
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_paragraph('FGR-Normal')
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell('FGR-TextContents')
|
|
|
|
self.doc.start_paragraph('FGR-Normal')
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.write_text(name)
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell('FGR-TextContents')
|
|
|
|
self.doc.start_paragraph('FGR-Normal')
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.write_text(date)
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell('FGR-TextContentsEnd')
|
|
|
|
self.doc.start_paragraph('FGR-Normal')
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.write_text(place)
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
|
|
|
self.doc.end_row()
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
def dump_child(self,index,person_handle):
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-01-02 01:28:53 +05:30
|
|
|
person = self.database.get_person_from_handle(person_handle)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.start_row()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell('FGR-TextChild1')
|
|
|
|
self.doc.start_paragraph('FGR-ChildText')
|
2004-02-14 11:10:30 +05:30
|
|
|
if person.get_gender() == RelLib.Person.male:
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.write_text("%dM" % index)
|
|
|
|
else:
|
|
|
|
self.doc.write_text("%dF" % index)
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell('FGR-ChildName',3)
|
|
|
|
self.doc.start_paragraph('FGR-ChildText')
|
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.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
|
|
|
self.doc.end_row()
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
families = len(person.get_family_handle_list())
|
|
|
|
birth_handle = person.get_birth_handle()
|
|
|
|
if birth_handle:
|
2005-01-02 01:28:53 +05:30
|
|
|
birth = self.database.get_event_from_handle(birth_handle)
|
2004-05-04 09:02:37 +05:30
|
|
|
else:
|
|
|
|
birth = None
|
2004-07-28 07:59:07 +05:30
|
|
|
death_handle = person.get_death_handle()
|
|
|
|
if death_handle:
|
2005-01-02 01:28:53 +05:30
|
|
|
death = self.database.get_event_from_handle(death_handle)
|
2004-05-04 09:02:37 +05:30
|
|
|
else:
|
|
|
|
death = None
|
|
|
|
self.dump_child_event('FGR-TextChild1',_('Birth'),birth)
|
2002-10-20 19:55:16 +05:30
|
|
|
if families == 0:
|
2004-05-04 09:02:37 +05:30
|
|
|
self.dump_child_event('FGR-TextChild2',_('Death'),death)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-05-04 09:02:37 +05:30
|
|
|
self.dump_child_event('FGR-TextChild1',_('Death'),death)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
index = 1
|
2004-07-28 07:59:07 +05:30
|
|
|
for family_handle in person.get_family_handle_list():
|
2005-01-02 01:28:53 +05:30
|
|
|
family = self.database.get_family_from_handle(family_handle)
|
2004-07-28 07:59:07 +05:30
|
|
|
for event_handle in family.get_event_list():
|
|
|
|
if event_handle:
|
2005-01-02 01:28:53 +05:30
|
|
|
event = self.database.get_event_from_handle(event_handle)
|
2004-05-04 09:02:37 +05:30
|
|
|
if event.get_name() == "Marriage":
|
|
|
|
m = event
|
|
|
|
break
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-05-04 09:02:37 +05:30
|
|
|
m = None
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
if person_handle == family.get_father_handle():
|
|
|
|
spouse_id = family.get_mother_handle()
|
2004-05-04 09:02:37 +05:30
|
|
|
else:
|
2004-07-28 07:59:07 +05:30
|
|
|
spouse_id = family.get_father_handle()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.start_row()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell('FGR-TextChild1')
|
|
|
|
self.doc.start_paragraph('FGR-Normal')
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell('FGR-TextContents')
|
|
|
|
self.doc.start_paragraph('FGR-Normal')
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.write_text(_("Spouse"))
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell('FGR-TextContentsEnd',2)
|
|
|
|
self.doc.start_paragraph('FGR-Normal')
|
2004-05-04 09:02:37 +05:30
|
|
|
if spouse_id:
|
2005-01-02 01:28:53 +05:30
|
|
|
spouse = self.database.get_person_from_handle(spouse_id)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.doc.write_text(spouse.get_primary_name().get_regular_name())
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
|
|
|
self.doc.end_row()
|
|
|
|
|
|
|
|
if index == families:
|
2003-07-18 19:13:13 +05:30
|
|
|
self.dump_child_event('FGR-TextChild2',_("Married"),m)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2003-07-18 19:13:13 +05:30
|
|
|
self.dump_child_event('FGR-TextChild1',_("Married"),m)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-07-07 03:25:52 +05:30
|
|
|
|
2005-01-02 01:28:53 +05:30
|
|
|
def write_report(self):
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_paragraph('FGR-Title')
|
2003-07-07 03:25:52 +05:30
|
|
|
self.doc.write_text(_("Family Group Report"))
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_paragraph()
|
|
|
|
|
2003-07-07 03:25:52 +05:30
|
|
|
if self.family:
|
2004-07-28 07:59:07 +05:30
|
|
|
self.dump_parent(self.family.get_father_handle())
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_paragraph("FGR-blank")
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_paragraph()
|
2004-07-28 07:59:07 +05:30
|
|
|
self.dump_parent(self.family.get_mother_handle())
|
2003-07-07 03:25:52 +05:30
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
length = len(self.family.get_child_handle_list())
|
2003-07-07 03:25:52 +05:30
|
|
|
if length > 0:
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_paragraph("FGR-blank")
|
2003-07-07 03:25:52 +05:30
|
|
|
self.doc.end_paragraph()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_table('FGR-Children','FGR-ChildTable')
|
2003-07-07 03:25:52 +05:30
|
|
|
self.doc.start_row()
|
2003-07-18 19:13:13 +05:30
|
|
|
self.doc.start_cell('FGR-ParentHead',4)
|
|
|
|
self.doc.start_paragraph('FGR-ParentName')
|
2003-07-07 03:25:52 +05:30
|
|
|
self.doc.write_text(_("Children"))
|
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
|
|
|
self.doc.end_row()
|
|
|
|
index = 1
|
2004-07-28 07:59:07 +05:30
|
|
|
for child_handle in self.family.get_child_handle_list():
|
|
|
|
self.dump_child(index,child_handle)
|
2003-07-07 03:25:52 +05:30
|
|
|
index = index + 1
|
|
|
|
self.doc.end_table()
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2005-01-02 01:28:53 +05:30
|
|
|
#
|
2003-07-07 03:25:52 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2005-01-02 01:28:53 +05:30
|
|
|
class FamilyGroupOptions(ReportOptions.ReportOptions):
|
|
|
|
|
|
|
|
"""
|
|
|
|
Defines options and provides handling interface.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self,name,person_id=None):
|
|
|
|
ReportOptions.ReportOptions.__init__(self,name,person_id)
|
|
|
|
|
|
|
|
def set_new_options(self):
|
|
|
|
# Options specific for this report
|
|
|
|
self.options_dict = {
|
|
|
|
'spouse_id' : '',
|
|
|
|
}
|
|
|
|
|
|
|
|
self.options_help = {
|
|
|
|
'spouse_id' : ("=ID","Gramps ID of the person's spouse.",
|
|
|
|
"Use show=id to get ID list.",
|
|
|
|
#[item[0] for item in self.get_spouses(None,None)],
|
|
|
|
#False
|
|
|
|
),
|
|
|
|
}
|
|
|
|
|
|
|
|
def get_spouses(self,database,person):
|
|
|
|
"""
|
|
|
|
Create a mapping of all spouse names:families to be put
|
|
|
|
into the 'extra' option menu in the report options box. If
|
|
|
|
the selected person has never been married then this routine
|
|
|
|
will return a placebo label and disable the OK button.
|
|
|
|
"""
|
|
|
|
spouses = []
|
|
|
|
family_list = person.get_family_handle_list()
|
|
|
|
for family_handle in family_list:
|
|
|
|
family = database.get_family_from_handle(family_handle)
|
|
|
|
if person.get_handle() == family.get_father_handle():
|
2005-01-09 01:49:06 +05:30
|
|
|
spouse_handle = family.get_mother_handle()
|
2003-07-07 03:25:52 +05:30
|
|
|
else:
|
2005-01-09 01:49:06 +05:30
|
|
|
spouse_handle = family.get_father_handle()
|
|
|
|
if spouse_handle:
|
|
|
|
spouse = database.get_person_from_handle(spouse_handle)
|
2005-01-02 01:28:53 +05:30
|
|
|
name = spouse.get_primary_name().get_name()
|
2005-01-09 01:49:06 +05:30
|
|
|
spouse_id = spouse.get_gramps_id()
|
2003-07-07 03:25:52 +05:30
|
|
|
else:
|
2005-01-02 01:28:53 +05:30
|
|
|
name = _("unknown")
|
|
|
|
spouses.append((spouse_id,name))
|
|
|
|
return spouses
|
|
|
|
|
|
|
|
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.
|
|
|
|
"""
|
|
|
|
|
|
|
|
spouses = self.get_spouses(dialog.db,dialog.person)
|
|
|
|
spouse_id = self.options_dict['spouse_id']
|
|
|
|
|
|
|
|
self.spouse_menu = gtk.combo_box_new_text()
|
|
|
|
index = 0
|
|
|
|
spouse_index = 0
|
|
|
|
for item in spouses:
|
|
|
|
self.spouse_menu.append_text(item[1])
|
|
|
|
if item[0] == spouse_id:
|
|
|
|
spouse_index = index
|
|
|
|
index = index + 1
|
|
|
|
self.spouse_menu.set_active(spouse_index)
|
|
|
|
|
|
|
|
dialog.add_option(_("Spouse"),self.spouse_menu)
|
|
|
|
|
|
|
|
def parse_user_options(self,dialog):
|
|
|
|
"""
|
|
|
|
Parses the custom options that we have added.
|
|
|
|
"""
|
|
|
|
spouses = self.get_spouses(dialog.db,dialog.person)
|
|
|
|
spouse_index = self.spouse_menu.get_active()
|
|
|
|
self.options_dict['spouse_id'] = spouses[spouse_index][0]
|
|
|
|
|
|
|
|
def make_default_style(self,default_style):
|
|
|
|
"""Make default output style for the Family Group Report."""
|
|
|
|
para = BaseDoc.ParagraphStyle()
|
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set_size(4)
|
|
|
|
para.set_font(font)
|
|
|
|
default_style.add_style('FGR-blank',para)
|
|
|
|
|
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
|
|
|
font.set_size(16)
|
|
|
|
font.set_bold(1)
|
|
|
|
para = BaseDoc.ParagraphStyle()
|
|
|
|
para.set_font(font)
|
|
|
|
para.set_description(_("The style used for the title of the page."))
|
|
|
|
default_style.add_style('FGR-Title',para)
|
|
|
|
|
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set_type_face(BaseDoc.FONT_SERIF)
|
|
|
|
font.set_size(10)
|
|
|
|
font.set_bold(0)
|
|
|
|
para = BaseDoc.ParagraphStyle()
|
|
|
|
para.set_font(font)
|
|
|
|
para.set_description(_('The basic style used for the text display.'))
|
|
|
|
default_style.add_style('FGR-Normal',para)
|
|
|
|
|
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
|
|
|
font.set_size(10)
|
|
|
|
font.set_bold(1)
|
|
|
|
para = BaseDoc.ParagraphStyle()
|
|
|
|
para.set_font(font)
|
|
|
|
para.set_description(_('The style used for the text related to the children.'))
|
|
|
|
default_style.add_style('FGR-ChildText',para)
|
|
|
|
|
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
|
|
|
font.set_size(12)
|
|
|
|
font.set_bold(1)
|
|
|
|
para = BaseDoc.ParagraphStyle()
|
|
|
|
para.set_font(font)
|
|
|
|
para.set_description(_("The style used for the parent's name"))
|
|
|
|
default_style.add_style('FGR-ParentName',para)
|
2003-07-07 03:25:52 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2005-01-05 10:32:19 +05:30
|
|
|
from PluginMgr import register_report
|
2002-10-20 19:55:16 +05:30
|
|
|
register_report(
|
2005-01-02 01:28:53 +05:30
|
|
|
name = 'family_group',
|
|
|
|
category = const.CATEGORY_TEXT,
|
|
|
|
report_class = FamilyGroup,
|
|
|
|
options_class = FamilyGroupOptions,
|
|
|
|
modes = Report.MODE_GUI | Report.MODE_BKI | Report.MODE_CLI,
|
|
|
|
translated_name = _("Family Group Report"),
|
|
|
|
status = _("Beta"),
|
|
|
|
author_name = "Donald N. Allingham",
|
|
|
|
author_email = "dallingham@users.sourceforge.net",
|
2002-10-20 19:55:16 +05:30
|
|
|
description=_("Creates a family group report, showing information on a set of parents and their children."),
|
|
|
|
)
|