2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2004-02-01 06:04:36 +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-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
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2002-10-20 19:55:16 +05:30
|
|
|
import os
|
|
|
|
|
2003-07-07 03:25:52 +05:30
|
|
|
import gtk
|
2003-01-15 10:55:50 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
import RelLib
|
|
|
|
import Report
|
2003-09-02 06:17:09 +05:30
|
|
|
import BaseDoc
|
2003-01-29 10:13:12 +05:30
|
|
|
import Errors
|
2003-07-07 03:25:52 +05:30
|
|
|
import Utils
|
2003-08-17 07:44:33 +05:30
|
|
|
from gettext import gettext as _
|
2003-01-29 10:13:12 +05:30
|
|
|
from QuestionDialog import ErrorDialog
|
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
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
class FamilyGroup:
|
|
|
|
|
2003-07-07 03:25:52 +05:30
|
|
|
def __init__(self,database,family,doc,output,newpage=0):
|
2002-10-20 19:55:16 +05:30
|
|
|
self.db = database
|
|
|
|
self.family = family
|
|
|
|
self.output = output
|
|
|
|
self.doc = doc
|
2003-07-07 03:25:52 +05:30
|
|
|
self.newpage = newpage
|
|
|
|
if output:
|
|
|
|
self.standalone = 1
|
|
|
|
self.doc.open(output)
|
2003-09-13 10:26:04 +05:30
|
|
|
self.doc.init()
|
2003-07-07 03:25:52 +05:30
|
|
|
else:
|
|
|
|
self.standalone = 0
|
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_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
|
|
|
|
|
|
|
def end(self):
|
2003-07-07 03:25:52 +05:30
|
|
|
if self.standalone:
|
|
|
|
self.doc.close()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def dump_parent(self,person):
|
|
|
|
|
|
|
|
if not person:
|
|
|
|
return
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if person.get_gender() == RelLib.Person.male:
|
2002-10-20 19:55:16 +05:30
|
|
|
id = _("Husband")
|
|
|
|
else:
|
|
|
|
id = _("Wife")
|
|
|
|
|
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')
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.write_text(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-02-14 11:10:30 +05:30
|
|
|
birth = person.get_birth()
|
|
|
|
death = person.get_death()
|
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-02-14 11:10:30 +05:30
|
|
|
self.doc.write_text(birth.get_date())
|
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-02-14 11:10:30 +05:30
|
|
|
self.doc.write_text(birth.get_place_name())
|
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-02-14 11:10:30 +05:30
|
|
|
self.doc.write_text(death.get_date())
|
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-02-14 11:10:30 +05:30
|
|
|
self.doc.write_text(death.get_place_name())
|
2002-10-20 19:55:16 +05:30
|
|
|
self.doc.end_paragraph()
|
|
|
|
self.doc.end_cell()
|
|
|
|
self.doc.end_row()
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
family = person.get_main_parents_family_id()
|
|
|
|
if family == None or family.get_father_id() == None:
|
2002-10-20 19:55:16 +05:30
|
|
|
father_name = ""
|
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
father_name = family.get_father_id().get_primary_name().get_regular_name()
|
|
|
|
if family == None or family.get_mother_id() == None:
|
2002-10-20 19:55:16 +05:30
|
|
|
mother_name = ""
|
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
mother_name = family.get_mother_id().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):
|
|
|
|
if event:
|
2004-02-14 11:10:30 +05:30
|
|
|
date = event.get_date()
|
|
|
|
place = event.get_place_name()
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
date = ""
|
|
|
|
place = ""
|
|
|
|
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()
|
|
|
|
|
|
|
|
def dump_child(self,index,person):
|
|
|
|
|
|
|
|
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-02-14 11:10:30 +05:30
|
|
|
families = len(person.get_family_id_list())
|
2004-02-23 00:54:31 +05:30
|
|
|
self.dump_child_event('FGR-TextChild1',_('Birth'),person.get_birth())
|
2002-10-20 19:55:16 +05:30
|
|
|
if families == 0:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.dump_child_event('FGR-TextChild2',_('Death'),person.get_death())
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.dump_child_event('FGR-TextChild1',_('Death'),person.get_death())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
index = 1
|
2004-02-14 11:10:30 +05:30
|
|
|
for family in person.get_family_id_list():
|
|
|
|
m = family.get_marriage()
|
|
|
|
if person == family.get_father_id():
|
|
|
|
spouse = family.get_mother_id()
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
spouse = family.get_father_id()
|
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')
|
2003-12-28 03:26:38 +05:30
|
|
|
if spouse:
|
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
|
|
|
|
|
|
|
#--------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#--------------------------------------------------------------------
|
|
|
|
def write_report(self):
|
2003-07-07 03:25:52 +05:30
|
|
|
if self.newpage:
|
|
|
|
self.doc.page_break()
|
|
|
|
|
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-02-14 11:10:30 +05:30
|
|
|
self.dump_parent(self.family.get_father_id())
|
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-02-14 11:10:30 +05:30
|
|
|
self.dump_parent(self.family.get_mother_id())
|
2003-07-07 03:25:52 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
length = len(self.family.get_child_id_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-02-14 11:10:30 +05:30
|
|
|
for child in self.family.get_child_id_list():
|
2003-07-07 03:25:52 +05:30
|
|
|
self.dump_child(index,child)
|
|
|
|
index = index + 1
|
|
|
|
self.doc.end_table()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.end()
|
|
|
|
|
2003-07-07 03:25:52 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2003-01-15 10:55:50 +05:30
|
|
|
# FamilyGroupDialog
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2003-01-15 10:55:50 +05:30
|
|
|
class FamilyGroupDialog(Report.TextReportDialog):
|
2003-10-31 06:53:16 +05:30
|
|
|
|
|
|
|
report_options = {}
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def __init__(self,database,person):
|
2003-10-31 06:53:16 +05:30
|
|
|
Report.TextReportDialog.__init__(self,database,person,self.report_options)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def get_title(self):
|
|
|
|
"""The window title for this dialog"""
|
|
|
|
return "%s - %s - GRAMPS" % (_("Family Group Report"),_("Text Reports"))
|
|
|
|
|
|
|
|
def get_header(self, name):
|
|
|
|
"""The header line at the top of the dialog contents"""
|
|
|
|
return _("Family Group Report for %s") % name
|
|
|
|
|
|
|
|
def get_target_browser_title(self):
|
|
|
|
"""The title of the window created when the 'browse' button is
|
|
|
|
clicked in the 'Save As' frame."""
|
|
|
|
return _("Save Family Group Report")
|
|
|
|
|
|
|
|
def get_stylesheet_savefile(self):
|
|
|
|
"""Where to save styles for this report."""
|
|
|
|
return "family_group.xml"
|
|
|
|
|
|
|
|
def doc_uses_tables(self):
|
|
|
|
"""This report requires table support."""
|
|
|
|
return 1
|
|
|
|
|
|
|
|
def get_report_generations(self):
|
|
|
|
"""No generation options."""
|
|
|
|
return (0, 0)
|
|
|
|
|
|
|
|
def get_report_extra_menu_info(self):
|
2003-07-07 03:25:52 +05:30
|
|
|
spouse_map = _build_spouse_map(self.person)
|
|
|
|
return (_("Spouse"), spouse_map, None, None)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Create output styles appropriate to this report.
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
def make_default_style(self):
|
2003-07-07 03:25:52 +05:30
|
|
|
_make_default_style(self.default_style)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Create the contents of the report.
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
def make_report(self):
|
|
|
|
"""Create the object that will produce the Ancestor Chart.
|
|
|
|
All user dialog has already been handled and the output file
|
|
|
|
opened."""
|
2003-01-29 10:13:12 +05:30
|
|
|
try:
|
2003-07-07 03:25:52 +05:30
|
|
|
MyReport = FamilyGroup(self.db, self.report_menu,
|
|
|
|
self.doc, self.target_path)
|
2003-01-29 10:13:12 +05:30
|
|
|
MyReport.write_report()
|
|
|
|
except Errors.ReportError, msg:
|
2003-05-16 07:19:50 +05:30
|
|
|
(m1,m2) = msg.messages()
|
|
|
|
ErrorDialog(m1,m2)
|
2003-05-23 09:38:03 +05:30
|
|
|
except Errors.FilterError, msg:
|
|
|
|
(m1,m2) = msg.messages()
|
|
|
|
ErrorDialog(m1,m2)
|
2003-01-29 10:13:12 +05:30
|
|
|
except:
|
|
|
|
import DisplayTrace
|
|
|
|
DisplayTrace.DisplayTrace()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
2003-07-07 03:25:52 +05:30
|
|
|
# Standalone report function
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
def report(database,person):
|
|
|
|
FamilyGroupDialog(database,person)
|
|
|
|
|
2003-07-07 03:25:52 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Set up sane defaults for the book_item
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
_style_file = "family_group.xml"
|
|
|
|
_style_name = "default"
|
|
|
|
|
|
|
|
_person_id = ""
|
|
|
|
_spouse_name = ""
|
|
|
|
_options = ( _person_id, _spouse_name )
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Book Item Options dialog
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
class FamilyGroupBareDialog(Report.BareReportDialog):
|
|
|
|
|
|
|
|
def __init__(self,database,person,opt,stl):
|
|
|
|
|
|
|
|
self.options = opt
|
|
|
|
self.db = database
|
|
|
|
if self.options[0]:
|
2004-02-14 11:10:30 +05:30
|
|
|
self.person = self.db.get_person(self.options[0])
|
2003-07-07 03:25:52 +05:30
|
|
|
else:
|
|
|
|
self.person = person
|
2003-07-11 08:59:33 +05:30
|
|
|
self.style_name = stl
|
|
|
|
|
2003-07-07 03:25:52 +05:30
|
|
|
Report.BareReportDialog.__init__(self,database,self.person)
|
|
|
|
|
|
|
|
self.spouse_name = self.options[1]
|
|
|
|
|
|
|
|
self.new_person = None
|
|
|
|
|
|
|
|
self.spouse_map = _build_spouse_map(self.person)
|
|
|
|
if self.extra_menu:
|
|
|
|
myMenu = Utils.build_string_optmenu(self.spouse_map,self.spouse_name)
|
|
|
|
self.extra_menu.set_menu(myMenu)
|
|
|
|
self.extra_menu.set_sensitive(len(self.spouse_map) > 1)
|
|
|
|
|
|
|
|
self.window.run()
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Customization hooks
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2003-07-07 22:27:27 +05:30
|
|
|
def make_default_style(self):
|
|
|
|
_make_default_style(self.default_style)
|
|
|
|
|
2003-07-07 03:25:52 +05:30
|
|
|
def get_title(self):
|
|
|
|
"""The window title for this dialog"""
|
|
|
|
return "%s - GRAMPS Book" % (_("Family Group Report"))
|
|
|
|
|
|
|
|
def get_header(self, name):
|
|
|
|
"""The header line at the top of the dialog contents"""
|
|
|
|
return _("Family Group Report for GRAMPS Book")
|
|
|
|
|
|
|
|
def get_stylesheet_savefile(self):
|
|
|
|
"""Where to save styles for this report."""
|
|
|
|
return _style_file
|
|
|
|
|
|
|
|
def get_report_generations(self):
|
|
|
|
"""No generation options."""
|
|
|
|
return (0, 0)
|
|
|
|
|
|
|
|
def doc_uses_tables(self):
|
|
|
|
"""This report requires table support."""
|
|
|
|
return 1
|
|
|
|
|
|
|
|
def get_report_extra_menu_info(self):
|
|
|
|
self.spouse_map = _build_spouse_map(self.person)
|
|
|
|
return (_("Spouse"), self.spouse_map, None, None)
|
|
|
|
|
|
|
|
def on_center_person_change_clicked(self,obj):
|
|
|
|
import SelectPerson
|
2004-02-01 06:04:36 +05:30
|
|
|
sel_person = SelectPerson.SelectPerson(self.db,_('Select Person'))
|
2003-07-07 03:25:52 +05:30
|
|
|
new_person = sel_person.run()
|
|
|
|
if new_person:
|
|
|
|
self.new_person = new_person
|
|
|
|
self.new_spouse_map = _build_spouse_map(self.new_person)
|
|
|
|
|
|
|
|
if self.new_spouse_map:
|
|
|
|
if not self.extra_menu:
|
|
|
|
old_person = self.person
|
|
|
|
self.person = self.new_person
|
|
|
|
self.setup_report_options_frame()
|
|
|
|
self.window.show_all()
|
|
|
|
self.person = old_person
|
|
|
|
myMenu = Utils.build_string_optmenu(self.new_spouse_map,None)
|
|
|
|
self.extra_menu.set_menu(myMenu)
|
|
|
|
self.extra_menu.set_sensitive(len(self.new_spouse_map) > 1)
|
|
|
|
else:
|
|
|
|
if self.extra_menu:
|
|
|
|
myMenu = Utils.build_string_optmenu(self.new_spouse_map,None)
|
|
|
|
self.extra_menu.set_menu(myMenu)
|
|
|
|
self.extra_menu.set_sensitive(gtk.FALSE)
|
|
|
|
self.window.show_all()
|
|
|
|
self.extra_menu = None
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
new_name = new_person.get_primary_name().get_regular_name()
|
2003-07-07 03:25:52 +05:30
|
|
|
if new_name:
|
|
|
|
self.person_label.set_text( "<i>%s</i>" % new_name )
|
|
|
|
self.person_label.set_use_markup(gtk.TRUE)
|
|
|
|
|
|
|
|
|
|
|
|
def on_cancel(self, obj):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def on_ok_clicked(self, obj):
|
|
|
|
"""The user is satisfied with the dialog choices. Parse all options
|
|
|
|
and close the window."""
|
|
|
|
|
|
|
|
if self.new_person:
|
|
|
|
self.person = self.new_person
|
|
|
|
self.spouse_map = self.new_spouse_map
|
|
|
|
|
|
|
|
self.parse_style_frame()
|
|
|
|
self.parse_report_options_frame()
|
|
|
|
|
|
|
|
if self.spouse_map:
|
|
|
|
spouse_number = self.extra_menu.get_history()
|
|
|
|
spouse_names = self.spouse_map.keys()
|
|
|
|
spouse_names.sort()
|
|
|
|
self.spouse_name = spouse_names[spouse_number]
|
|
|
|
else:
|
|
|
|
self.spouse_name = ""
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
self.options = ( self.person.get_id(), self.spouse_name )
|
2003-07-07 03:25:52 +05:30
|
|
|
self.style_name = self.selected_style.get_name()
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Function to write Book Item
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
def write_book_item(database,person,doc,options,newpage=0):
|
|
|
|
"""Write the Family Group Report using options set.
|
|
|
|
All user dialog has already been handled and the output file opened."""
|
|
|
|
try:
|
|
|
|
if options[0]:
|
2004-02-14 11:10:30 +05:30
|
|
|
person = database.get_person(options[0])
|
2003-07-07 03:25:52 +05:30
|
|
|
spouse_name = options[1]
|
|
|
|
spouse_map = _build_spouse_map(person)
|
|
|
|
if spouse_map:
|
|
|
|
if spouse_map.has_key(spouse_name):
|
|
|
|
family = spouse_map[spouse_name]
|
|
|
|
else:
|
|
|
|
spouse_names = spouse_map.keys()
|
|
|
|
spouse_names.sort()
|
|
|
|
family = spouse_map[spouse_names[0]]
|
|
|
|
else:
|
|
|
|
family = None
|
|
|
|
return FamilyGroup(database, family, doc, None, newpage )
|
|
|
|
except Errors.ReportError, msg:
|
|
|
|
(m1,m2) = msg.messages()
|
|
|
|
ErrorDialog(m1,m2)
|
|
|
|
except Errors.FilterError, msg:
|
|
|
|
(m1,m2) = msg.messages()
|
|
|
|
ErrorDialog(m1,m2)
|
|
|
|
except:
|
|
|
|
import DisplayTrace
|
|
|
|
DisplayTrace.DisplayTrace()
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Functions shared between the dialogs
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
def _make_default_style(default_style):
|
|
|
|
"""Make default output style for the Family Group Report."""
|
2003-09-02 06:17:09 +05:30
|
|
|
para = BaseDoc.ParagraphStyle()
|
|
|
|
font = BaseDoc.FontStyle()
|
2003-07-07 03:25:52 +05:30
|
|
|
font.set_size(4)
|
|
|
|
para.set_font(font)
|
2003-07-18 19:13:13 +05:30
|
|
|
default_style.add_style('FGR-blank',para)
|
2003-07-07 03:25:52 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
2003-07-07 03:25:52 +05:30
|
|
|
font.set_size(16)
|
|
|
|
font.set_bold(1)
|
2003-09-02 06:17:09 +05:30
|
|
|
para = BaseDoc.ParagraphStyle()
|
2003-07-07 03:25:52 +05:30
|
|
|
para.set_font(font)
|
|
|
|
para.set_description(_("The style used for the title of the page."))
|
2003-07-18 19:13:13 +05:30
|
|
|
default_style.add_style('FGR-Title',para)
|
2003-07-07 03:25:52 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set_type_face(BaseDoc.FONT_SERIF)
|
2003-07-07 03:25:52 +05:30
|
|
|
font.set_size(10)
|
|
|
|
font.set_bold(0)
|
2003-09-02 06:17:09 +05:30
|
|
|
para = BaseDoc.ParagraphStyle()
|
2003-07-07 03:25:52 +05:30
|
|
|
para.set_font(font)
|
|
|
|
para.set_description(_('The basic style used for the text display.'))
|
2003-07-18 19:13:13 +05:30
|
|
|
default_style.add_style('FGR-Normal',para)
|
2003-07-07 03:25:52 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
2003-07-07 03:25:52 +05:30
|
|
|
font.set_size(10)
|
|
|
|
font.set_bold(1)
|
2003-09-02 06:17:09 +05:30
|
|
|
para = BaseDoc.ParagraphStyle()
|
2003-07-07 03:25:52 +05:30
|
|
|
para.set_font(font)
|
|
|
|
para.set_description(_('The style used for the text related to the children.'))
|
2003-07-18 19:13:13 +05:30
|
|
|
default_style.add_style('FGR-ChildText',para)
|
2003-07-07 03:25:52 +05:30
|
|
|
|
2003-09-02 06:17:09 +05:30
|
|
|
font = BaseDoc.FontStyle()
|
|
|
|
font.set_type_face(BaseDoc.FONT_SANS_SERIF)
|
2003-07-07 03:25:52 +05:30
|
|
|
font.set_size(12)
|
|
|
|
font.set_bold(1)
|
2003-09-02 06:17:09 +05:30
|
|
|
para = BaseDoc.ParagraphStyle()
|
2003-07-07 03:25:52 +05:30
|
|
|
para.set_font(font)
|
|
|
|
para.set_description(_("The style used for the parent's name"))
|
2003-07-18 19:13:13 +05:30
|
|
|
default_style.add_style('FGR-ParentName',para)
|
2003-07-07 03:25:52 +05:30
|
|
|
|
|
|
|
def _build_spouse_map(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."""
|
|
|
|
spouse_map = {}
|
2004-02-14 11:10:30 +05:30
|
|
|
family_list = person.get_family_id_list()
|
2003-07-07 03:25:52 +05:30
|
|
|
for family in family_list:
|
2004-02-14 11:10:30 +05:30
|
|
|
if person == family.get_father_id():
|
|
|
|
spouse = family.get_mother_id()
|
2003-07-07 03:25:52 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
spouse = family.get_father_id()
|
2003-07-07 03:25:52 +05:30
|
|
|
if spouse:
|
2004-02-14 11:10:30 +05:30
|
|
|
name = spouse.get_primary_name().get_name()
|
2003-07-07 03:25:52 +05:30
|
|
|
else:
|
|
|
|
name= _("unknown")
|
|
|
|
spouse_map[name] = family
|
|
|
|
return spouse_map
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
def get_xpm_image():
|
|
|
|
return [
|
|
|
|
"48 48 33 1",
|
|
|
|
" c None",
|
|
|
|
". c #1A1A1A",
|
|
|
|
"+ c #6A665E",
|
|
|
|
"@ c #A6A6A6",
|
|
|
|
"# c #BABAB6",
|
|
|
|
"$ c #D2D2D2",
|
|
|
|
"% c #EDE2D2",
|
|
|
|
"& c #7A7262",
|
|
|
|
"* c #F1EADF",
|
|
|
|
"= c #867A6E",
|
|
|
|
"- c #56524E",
|
|
|
|
"; c #868686",
|
|
|
|
"> c #E2CAA2",
|
|
|
|
", c #F2EEE2",
|
|
|
|
"' c #4E4E4E",
|
|
|
|
") c #B2966E",
|
|
|
|
"! c #FAFAFA",
|
|
|
|
"~ c #A29E96",
|
|
|
|
"{ c #BEA27A",
|
|
|
|
"] c #CECABE",
|
|
|
|
"^ c #968A76",
|
|
|
|
"/ c #DAD2C6",
|
|
|
|
"( c #423E3E",
|
|
|
|
"_ c #BA9E72",
|
|
|
|
": c #B7AC9A",
|
|
|
|
"< c #E9DAC3",
|
|
|
|
"[ c #E6E2E2",
|
|
|
|
"} c #322E2A",
|
|
|
|
"| c #9E9286",
|
|
|
|
"1 c #E6D2B6",
|
|
|
|
"2 c #F2EEE9",
|
|
|
|
"3 c #5E5A56",
|
|
|
|
"4 c #F6F2EE",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" ^=^=====&&&+&++++333+& ",
|
|
|
|
" =##############:#:~;33& ",
|
|
|
|
" =#!!!!!!!!!!!!!!*[$#;;|- ",
|
|
|
|
" ;#!!!!!!!!!!!!!!!2[$@&]|( ",
|
|
|
|
" =#!!!!!!!!!!!!!!!!2[$-[];} ",
|
|
|
|
" =#!!!!@@@@@@@@!!!!![4'![];} ",
|
|
|
|
" =#!!!!!!4!!4!!!!!!!!4'!![];} ",
|
|
|
|
" =#!!!!!!!!!!!!!!!!!!!'*!![];( ",
|
|
|
|
" =#!!!!!!!!!!!!!!!!!!!'[*!![]|- ",
|
|
|
|
" &#!!!!@@~@@@~@@~@@@@@'][4!![#|+ ",
|
|
|
|
" &#!4!!!!!!!!!!!!!4!!!'..}('3&=+& ",
|
|
|
|
" =#!!!!@@@@@@@@@@@@@@@@##@~;=+3(+ ",
|
|
|
|
" &#!!!!!!!!!!!!!!!!!!!![$##~;;='( ",
|
|
|
|
" &#!!!!@@@@@~@@@~@@@@~@@@@@#~~;+( ",
|
|
|
|
" &#!!!!!!!!!!!!!!!!!!!!444[]#@~&} ",
|
|
|
|
" &#!!!!!!!!!!!!!!!!!!4442[[$]#@=} ",
|
|
|
|
" &#!!!!!!!!!!!!!!!!!!4444[[$]]:;} ",
|
|
|
|
" +#!!!!@~@@@@@@@@~@@@@@~~~|;]]];} ",
|
|
|
|
" +#!!!!!!!!!!!!!!!!!44444,[$/]:^} ",
|
|
|
|
" +#!!!!@@@~@@@@@@@@~@~~~~~~|1>$|} ",
|
|
|
|
" +#!!!!!!!!!!!!!!!44442[*%[[<$]|} ",
|
|
|
|
" +#!!!!@@@@~@@@@~~@~~~~~~~~|1/>~} ",
|
|
|
|
" +#!!!!!!!!!!!!!!44444**[%%</1])} ",
|
|
|
|
" +#!!!!!!!!!!!!!4422******%%<1/|} ",
|
|
|
|
" +#!!!!!!!!!!!!!!4,*,**2***%<1/)} ",
|
|
|
|
" 3#!!!!@@@@@~,442,*,*,2**,,[<1/)} ",
|
|
|
|
" +#!!!!!!4!!444444**[%%%%%%<<1>~} ",
|
|
|
|
" 3#!!!!@@4*@@@~~~~~~~~~~||||<11)} ",
|
|
|
|
" +#4!!4444444,24[[*[<%<%<<<<<11|} ",
|
|
|
|
" 3#!!!44,,,@~~~~~~~~~|||||||111_} ",
|
|
|
|
" 3#!!!!!44444[4[[%%%%%<<<<11111)} ",
|
|
|
|
" 3#!!!!~@,*~~~~~~~~||||||^|^1>1_} ",
|
|
|
|
" 3#!!!444442%**[%<%%%<<<<11111>_} ",
|
|
|
|
" 3#!!!4***[~~~~~~|||||||^|^^1>>{} ",
|
|
|
|
" -#!444444**[%<%%%<<<<11111>1>>_} ",
|
|
|
|
" -#4444~~[[~~~|||||||^)^^^^^>>>_} ",
|
|
|
|
" -#4444[**[%%%%%%<<<<11111>>>>>)} ",
|
|
|
|
" '#4444****%%%%%<<<111<11>>>>>>_} ",
|
|
|
|
" ':44****%%%%%<<<1<1<1>>1>>>>>>)} ",
|
|
|
|
" -@4******%%%<%<1<<1111>>>>>>>>)} ",
|
|
|
|
" '#****%%%%<%<<<<1<11>1>>>>>>>>)} ",
|
|
|
|
" ':##:::::::{{{{{{__{___))^)))))} ",
|
|
|
|
" }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} ",
|
|
|
|
" ",
|
|
|
|
" ",
|
|
|
|
" "]
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2003-07-07 03:25:52 +05:30
|
|
|
from Plugins import register_report, register_book_item
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
register_report(
|
|
|
|
report,
|
|
|
|
_("Family Group Report"),
|
|
|
|
category=_("Text Reports"),
|
|
|
|
status=(_("Beta")),
|
|
|
|
description=_("Creates a family group report, showing information on a set of parents and their children."),
|
|
|
|
xpm=get_xpm_image()
|
|
|
|
)
|
|
|
|
|
2003-07-07 03:25:52 +05:30
|
|
|
# (name,category,options_dialog,write_book_item,options,style_name,style_file,make_default_style)
|
|
|
|
register_book_item(
|
|
|
|
_("Family Group Report"),
|
|
|
|
_("Text"),
|
|
|
|
FamilyGroupBareDialog,
|
|
|
|
write_book_item,
|
|
|
|
_options,
|
|
|
|
_style_name,
|
|
|
|
_style_file,
|
|
|
|
_make_default_style
|
|
|
|
)
|