* src/plugins/DetAncestralReport.py: Minor cleanup.
* src/plugins/DetDescendantReport.py: Convert to new scheme. * src/plugins/FamilyGroup.py: Convert to new scheme. svn: r3854
This commit is contained in:
parent
e09d31a694
commit
1c7d6d60c5
@ -1,3 +1,8 @@
|
|||||||
|
2005-01-01 Alex Roitman <shura@alex.neuro.umn.edu>
|
||||||
|
* src/plugins/DetAncestralReport.py: Minor cleanup.
|
||||||
|
* src/plugins/DetDescendantReport.py: Convert to new scheme.
|
||||||
|
* src/plugins/FamilyGroup.py: Convert to new scheme.
|
||||||
|
|
||||||
2004-12-31 Don Allingham <dallingham@users.sourceforge.net>
|
2004-12-31 Don Allingham <dallingham@users.sourceforge.net>
|
||||||
* src/gramps.glade: remove name display options
|
* src/gramps.glade: remove name display options
|
||||||
* src/GrampsCfg.py: remove name displaying functions
|
* src/GrampsCfg.py: remove name displaying functions
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
# standard python modules
|
# standard python modules
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
import os
|
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
@ -105,11 +104,6 @@ class DetAncestorReport(Report.Report):
|
|||||||
self.genIDs = {}
|
self.genIDs = {}
|
||||||
self.prevGenIDs= {}
|
self.prevGenIDs= {}
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
def apply_filter(self,person_handle,index):
|
def apply_filter(self,person_handle,index):
|
||||||
if (not person_handle) or (index >= 2**self.max_generations):
|
if (not person_handle) or (index >= 2**self.max_generations):
|
||||||
return
|
return
|
||||||
@ -596,16 +590,16 @@ class DetAncestorReport(Report.Report):
|
|||||||
mother = self.database.get_person_from_handle(fam.get_mother_handle())
|
mother = self.database.get_person_from_handle(fam.get_mother_handle())
|
||||||
spouse = mother.get_primary_name().get_regular_name()
|
spouse = mother.get_primary_name().get_regular_name()
|
||||||
if fam_num == 1:
|
if fam_num == 1:
|
||||||
heshe= _("He")
|
heshe = _("He")
|
||||||
elif fam_num < len(famList):
|
elif fam_num < len(famList):
|
||||||
heshe= _(",")
|
heshe = _(",")
|
||||||
else: heshe= _("and he")
|
else: heshe = _("and he")
|
||||||
else:
|
else:
|
||||||
if fam_num == 1:
|
if fam_num == 1:
|
||||||
heshe= _("She")
|
heshe = _("She")
|
||||||
elif fam_num < len(famList):
|
elif fam_num < len(famList):
|
||||||
heshe= _(",")
|
heshe = _(",")
|
||||||
else: heshe= _("and she")
|
else: heshe = _("and she")
|
||||||
|
|
||||||
if fam.get_father_handle():
|
if fam.get_father_handle():
|
||||||
father = self.database.get_person_from_handle(fam.get_father_handle())
|
father = self.database.get_person_from_handle(fam.get_father_handle())
|
||||||
@ -692,7 +686,7 @@ class DetAncestorReport(Report.Report):
|
|||||||
|
|
||||||
self.doc.start_paragraph("DAR-Entry")
|
self.doc.start_paragraph("DAR-Entry")
|
||||||
|
|
||||||
if self.firstName:
|
if not self.firstName:
|
||||||
firstName = heshe
|
firstName = heshe
|
||||||
|
|
||||||
self.doc.write_text(person)
|
self.doc.write_text(person)
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -27,9 +27,15 @@
|
|||||||
# python modules
|
# python modules
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
import os
|
from gettext import gettext as _
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Gnome/GTK modules
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------
|
||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# GRAMPS
|
# GRAMPS
|
||||||
@ -40,33 +46,57 @@ import Report
|
|||||||
import BaseDoc
|
import BaseDoc
|
||||||
import Errors
|
import Errors
|
||||||
import Utils
|
import Utils
|
||||||
from gettext import gettext as _
|
|
||||||
from QuestionDialog import ErrorDialog
|
from QuestionDialog import ErrorDialog
|
||||||
|
import ReportOptions
|
||||||
|
import const
|
||||||
|
from DateHandler import displayer as _dd
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# FamilyGroup
|
# FamilyGroup
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
class FamilyGroup:
|
class FamilyGroup(Report.Report):
|
||||||
|
|
||||||
def __init__(self,database,family_handle,doc,output,newpage=0):
|
def __init__(self,database,person,options_class):
|
||||||
self.db = database
|
#,family_handle,doc,output,newpage=0):
|
||||||
|
"""
|
||||||
|
Creates the DetAncestorReport object that produces the report.
|
||||||
|
|
||||||
if family_handle:
|
The arguments are:
|
||||||
self.family = self.db.get_family_from_handle(family_handle)
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
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():
|
||||||
|
this_spouse_id = family.get_mother_handle()
|
||||||
|
else:
|
||||||
|
this_spouse_id = family.get_father_handle()
|
||||||
|
if spouse_id == this_spouse_id:
|
||||||
|
self.family = family
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
self.family = None
|
self.family = None
|
||||||
self.output = output
|
|
||||||
self.doc = doc
|
|
||||||
self.newpage = newpage
|
|
||||||
if output:
|
|
||||||
self.standalone = 1
|
|
||||||
self.doc.open(output)
|
|
||||||
self.doc.init()
|
|
||||||
else:
|
|
||||||
self.standalone = 0
|
|
||||||
|
|
||||||
|
self.setup()
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
"""
|
||||||
|
Define the table styles used by the report.
|
||||||
|
"""
|
||||||
cell = BaseDoc.TableCellStyle()
|
cell = BaseDoc.TableCellStyle()
|
||||||
cell.set_padding(0.2)
|
cell.set_padding(0.2)
|
||||||
cell.set_top_border(1)
|
cell.set_top_border(1)
|
||||||
@ -126,16 +156,12 @@ class FamilyGroup:
|
|||||||
table.set_column_width(3,40)
|
table.set_column_width(3,40)
|
||||||
self.doc.add_table_style('FGR-ChildTable',table)
|
self.doc.add_table_style('FGR-ChildTable',table)
|
||||||
|
|
||||||
def end(self):
|
|
||||||
if self.standalone:
|
|
||||||
self.doc.close()
|
|
||||||
|
|
||||||
def dump_parent(self,person_handle):
|
def dump_parent(self,person_handle):
|
||||||
|
|
||||||
if not person_handle:
|
if not person_handle:
|
||||||
return
|
return
|
||||||
|
|
||||||
person = self.db.get_person_from_handle(person_handle)
|
person = self.database.get_person_from_handle(person_handle)
|
||||||
|
|
||||||
if person.get_gender() == RelLib.Person.male:
|
if person.get_gender() == RelLib.Person.male:
|
||||||
id = _("Husband")
|
id = _("Husband")
|
||||||
@ -156,21 +182,21 @@ class FamilyGroup:
|
|||||||
bdate = ""
|
bdate = ""
|
||||||
bplace = ""
|
bplace = ""
|
||||||
if birth_handle:
|
if birth_handle:
|
||||||
birth = self.db.get_event_from_handle(birth_handle)
|
birth = self.database.get_event_from_handle(birth_handle)
|
||||||
bdate = birth.get_date()
|
bdate = birth.get_date()
|
||||||
bplace_handle = birth.get_place_handle()
|
bplace_handle = birth.get_place_handle()
|
||||||
if bplace_handle:
|
if bplace_handle:
|
||||||
bplace = self.db.get_place_from_handle(bplace_handle).get_title()
|
bplace = self.database.get_place_from_handle(bplace_handle).get_title()
|
||||||
|
|
||||||
death_handle = person.get_death_handle()
|
death_handle = person.get_death_handle()
|
||||||
ddate = ""
|
ddate = ""
|
||||||
dplace = ""
|
dplace = ""
|
||||||
if death_handle:
|
if death_handle:
|
||||||
death = self.db.get_event_from_handle(death_handle)
|
death = self.database.get_event_from_handle(death_handle)
|
||||||
ddate = death.get_date()
|
ddate = death.get_date()
|
||||||
dplace_handle = death.get_place_handle()
|
dplace_handle = death.get_place_handle()
|
||||||
if dplace_handle:
|
if dplace_handle:
|
||||||
dplace = self.db.get_place_from_handle(dplace_handle).get_title()
|
dplace = self.database.get_place_from_handle(dplace_handle).get_title()
|
||||||
|
|
||||||
self.doc.start_row()
|
self.doc.start_row()
|
||||||
self.doc.start_cell("FGR-TextContents")
|
self.doc.start_cell("FGR-TextContents")
|
||||||
@ -212,13 +238,13 @@ class FamilyGroup:
|
|||||||
father_name = ""
|
father_name = ""
|
||||||
mother_name = ""
|
mother_name = ""
|
||||||
if family_handle:
|
if family_handle:
|
||||||
family = self.db.get_family_from_handle(family_handle)
|
family = self.database.get_family_from_handle(family_handle)
|
||||||
father_handle = family.get_father_handle()
|
father_handle = family.get_father_handle()
|
||||||
if father_handle:
|
if father_handle:
|
||||||
father_name = self.db.get_person_from_handle(father_handle).get_primary_name().get_regular_name()
|
father_name = self.database.get_person_from_handle(father_handle).get_primary_name().get_regular_name()
|
||||||
mother_handle = family.get_mother_handle()
|
mother_handle = family.get_mother_handle()
|
||||||
if mother_handle:
|
if mother_handle:
|
||||||
mother_name = self.db.get_person_from_handle(mother_handle).get_primary_name().get_regular_name()
|
mother_name = self.database.get_person_from_handle(mother_handle).get_primary_name().get_regular_name()
|
||||||
|
|
||||||
self.doc.start_row()
|
self.doc.start_row()
|
||||||
self.doc.start_cell("FGR-TextContents")
|
self.doc.start_cell("FGR-TextContents")
|
||||||
@ -255,7 +281,7 @@ class FamilyGroup:
|
|||||||
date = event.get_date()
|
date = event.get_date()
|
||||||
place_handle = event.get_place_handle()
|
place_handle = event.get_place_handle()
|
||||||
if place_handle:
|
if place_handle:
|
||||||
place = self.db.get_place_from_handle(place_handle).get_title()
|
place = self.database.get_place_from_handle(place_handle).get_title()
|
||||||
|
|
||||||
self.doc.start_row()
|
self.doc.start_row()
|
||||||
self.doc.start_cell(text)
|
self.doc.start_cell(text)
|
||||||
@ -281,7 +307,7 @@ class FamilyGroup:
|
|||||||
|
|
||||||
def dump_child(self,index,person_handle):
|
def dump_child(self,index,person_handle):
|
||||||
|
|
||||||
person = self.db.get_person_from_handle(person_handle)
|
person = self.database.get_person_from_handle(person_handle)
|
||||||
self.doc.start_row()
|
self.doc.start_row()
|
||||||
self.doc.start_cell('FGR-TextChild1')
|
self.doc.start_cell('FGR-TextChild1')
|
||||||
self.doc.start_paragraph('FGR-ChildText')
|
self.doc.start_paragraph('FGR-ChildText')
|
||||||
@ -301,12 +327,12 @@ class FamilyGroup:
|
|||||||
families = len(person.get_family_handle_list())
|
families = len(person.get_family_handle_list())
|
||||||
birth_handle = person.get_birth_handle()
|
birth_handle = person.get_birth_handle()
|
||||||
if birth_handle:
|
if birth_handle:
|
||||||
birth = self.db.get_event_from_handle(birth_handle)
|
birth = self.database.get_event_from_handle(birth_handle)
|
||||||
else:
|
else:
|
||||||
birth = None
|
birth = None
|
||||||
death_handle = person.get_death_handle()
|
death_handle = person.get_death_handle()
|
||||||
if death_handle:
|
if death_handle:
|
||||||
death = self.db.get_event_from_handle(death_handle)
|
death = self.database.get_event_from_handle(death_handle)
|
||||||
else:
|
else:
|
||||||
death = None
|
death = None
|
||||||
self.dump_child_event('FGR-TextChild1',_('Birth'),birth)
|
self.dump_child_event('FGR-TextChild1',_('Birth'),birth)
|
||||||
@ -317,10 +343,10 @@ class FamilyGroup:
|
|||||||
|
|
||||||
index = 1
|
index = 1
|
||||||
for family_handle in person.get_family_handle_list():
|
for family_handle in person.get_family_handle_list():
|
||||||
family = self.db.get_family_from_handle(family_handle)
|
family = self.database.get_family_from_handle(family_handle)
|
||||||
for event_handle in family.get_event_list():
|
for event_handle in family.get_event_list():
|
||||||
if event_handle:
|
if event_handle:
|
||||||
event = self.db.get_event_from_handle(event_handle)
|
event = self.database.get_event_from_handle(event_handle)
|
||||||
if event.get_name() == "Marriage":
|
if event.get_name() == "Marriage":
|
||||||
m = event
|
m = event
|
||||||
break
|
break
|
||||||
@ -344,7 +370,7 @@ class FamilyGroup:
|
|||||||
self.doc.start_cell('FGR-TextContentsEnd',2)
|
self.doc.start_cell('FGR-TextContentsEnd',2)
|
||||||
self.doc.start_paragraph('FGR-Normal')
|
self.doc.start_paragraph('FGR-Normal')
|
||||||
if spouse_id:
|
if spouse_id:
|
||||||
spouse = self.db.get_person_from_handle(spouse_id)
|
spouse = self.database.get_person_from_handle(spouse_id)
|
||||||
self.doc.write_text(spouse.get_primary_name().get_regular_name())
|
self.doc.write_text(spouse.get_primary_name().get_regular_name())
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
self.doc.end_cell()
|
self.doc.end_cell()
|
||||||
@ -355,15 +381,8 @@ class FamilyGroup:
|
|||||||
else:
|
else:
|
||||||
self.dump_child_event('FGR-TextChild1',_("Married"),m)
|
self.dump_child_event('FGR-TextChild1',_("Married"),m)
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#--------------------------------------------------------------------
|
|
||||||
def write_report(self):
|
|
||||||
if self.newpage:
|
|
||||||
self.doc.page_break()
|
|
||||||
|
|
||||||
|
def write_report(self):
|
||||||
self.doc.start_paragraph('FGR-Title')
|
self.doc.start_paragraph('FGR-Title')
|
||||||
self.doc.write_text(_("Family Group Report"))
|
self.doc.write_text(_("Family Group Report"))
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
@ -391,262 +410,88 @@ class FamilyGroup:
|
|||||||
self.dump_child(index,child_handle)
|
self.dump_child(index,child_handle)
|
||||||
index = index + 1
|
index = index + 1
|
||||||
self.doc.end_table()
|
self.doc.end_table()
|
||||||
self.end()
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# FamilyGroupDialog
|
#
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
class FamilyGroupDialog(Report.TextReportDialog):
|
class FamilyGroupOptions(ReportOptions.ReportOptions):
|
||||||
|
|
||||||
report_options = {}
|
"""
|
||||||
|
Defines options and provides handling interface.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self,database,person):
|
def __init__(self,name,person_id=None):
|
||||||
self.db = database
|
ReportOptions.ReportOptions.__init__(self,name,person_id)
|
||||||
Report.TextReportDialog.__init__(self,database,person,self.report_options)
|
|
||||||
|
|
||||||
def get_title(self):
|
def set_new_options(self):
|
||||||
"""The window title for this dialog"""
|
# Options specific for this report
|
||||||
return "%s - %s - GRAMPS" % (_("Family Group Report"),_("Text Reports"))
|
self.options_dict = {
|
||||||
|
'spouse_id' : '',
|
||||||
|
}
|
||||||
|
|
||||||
def get_header(self, name):
|
self.options_help = {
|
||||||
"""The header line at the top of the dialog contents"""
|
'spouse_id' : ("=ID","Gramps ID of the person's spouse.",
|
||||||
return _("Family Group Report for %s") % name
|
"Use show=id to get ID list.",
|
||||||
|
#[item[0] for item in self.get_spouses(None,None)],
|
||||||
|
#False
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
def get_target_browser_title(self):
|
def get_spouses(self,database,person):
|
||||||
"""The title of the window created when the 'browse' button is
|
"""
|
||||||
clicked in the 'Save As' frame."""
|
Create a mapping of all spouse names:families to be put
|
||||||
return _("Save Family Group Report")
|
into the 'extra' option menu in the report options box. If
|
||||||
|
the selected person has never been married then this routine
|
||||||
def get_stylesheet_savefile(self):
|
will return a placebo label and disable the OK button.
|
||||||
"""Where to save styles for this report."""
|
"""
|
||||||
return "family_group.xml"
|
spouses = []
|
||||||
|
family_list = person.get_family_handle_list()
|
||||||
def doc_uses_tables(self):
|
for family_handle in family_list:
|
||||||
"""This report requires table support."""
|
family = database.get_family_from_handle(family_handle)
|
||||||
return 1
|
if person.get_handle() == family.get_father_handle():
|
||||||
|
spouse_id = family.get_mother_handle()
|
||||||
def get_report_generations(self):
|
|
||||||
"""No generation options."""
|
|
||||||
return (0, 0)
|
|
||||||
|
|
||||||
def get_report_extra_menu_info(self):
|
|
||||||
spouse_map = _build_spouse_map(self.db,self.person)
|
|
||||||
return (_("Spouse"), spouse_map, None, None)
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# Create output styles appropriate to this report.
|
|
||||||
#
|
|
||||||
#------------------------------------------------------------------------
|
|
||||||
def make_default_style(self):
|
|
||||||
_make_default_style(self.default_style)
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# 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."""
|
|
||||||
try:
|
|
||||||
MyReport = FamilyGroup(self.db, self.report_menu,
|
|
||||||
self.doc, self.target_path)
|
|
||||||
MyReport.write_report()
|
|
||||||
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()
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# Standalone report function
|
|
||||||
#
|
|
||||||
#------------------------------------------------------------------------
|
|
||||||
def report(database,person):
|
|
||||||
FamilyGroupDialog(database,person)
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
# Set up sane defaults for the book_item
|
|
||||||
#
|
|
||||||
#------------------------------------------------------------------------
|
|
||||||
_style_file = "family_group.xml"
|
|
||||||
_style_name = "default"
|
|
||||||
|
|
||||||
_person_handle = ""
|
|
||||||
_spouse_name = ""
|
|
||||||
_options = ( _person_handle, _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]:
|
|
||||||
self.person = self.db.get_person_from_handle(self.options[0])
|
|
||||||
else:
|
else:
|
||||||
self.person = person
|
spouse_id = family.get_father_handle()
|
||||||
self.style_name = stl
|
if spouse_id:
|
||||||
|
spouse = database.get_person_from_handle(spouse_id)
|
||||||
Report.BareReportDialog.__init__(self,database,self.person)
|
name = spouse.get_primary_name().get_name()
|
||||||
|
|
||||||
self.spouse_name = self.options[1]
|
|
||||||
|
|
||||||
self.new_person = None
|
|
||||||
|
|
||||||
self.spouse_map = _build_spouse_map(self.db,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
|
|
||||||
#
|
|
||||||
#------------------------------------------------------------------------
|
|
||||||
def make_default_style(self):
|
|
||||||
_make_default_style(self.default_style)
|
|
||||||
|
|
||||||
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.db,self.person)
|
|
||||||
return (_("Spouse"), self.spouse_map, None, None)
|
|
||||||
|
|
||||||
def on_center_person_change_clicked(self,obj):
|
|
||||||
import SelectPerson
|
|
||||||
sel_person = SelectPerson.SelectPerson(self.db,_('Select Person'))
|
|
||||||
new_person = sel_person.run()
|
|
||||||
if new_person:
|
|
||||||
self.new_person = new_person
|
|
||||||
self.new_spouse_map = _build_spouse_map(self.db,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:
|
else:
|
||||||
if self.extra_menu:
|
name = _("unknown")
|
||||||
myMenu = Utils.build_string_optmenu(self.new_spouse_map,None)
|
spouses.append((spouse_id,name))
|
||||||
self.extra_menu.set_menu(myMenu)
|
return spouses
|
||||||
self.extra_menu.set_sensitive(gtk.FALSE)
|
|
||||||
self.window.show_all()
|
|
||||||
self.extra_menu = None
|
|
||||||
|
|
||||||
new_name = new_person.get_primary_name().get_regular_name()
|
def add_user_options(self,dialog):
|
||||||
if new_name:
|
"""
|
||||||
self.person_label.set_text( "<i>%s</i>" % new_name )
|
Override the base class add_user_options task to add a menu that allows
|
||||||
self.person_label.set_use_markup(gtk.TRUE)
|
the user to select the sort method.
|
||||||
|
"""
|
||||||
|
|
||||||
|
spouses = self.get_spouses(dialog.db,dialog.person)
|
||||||
|
spouse_id = self.options_dict['spouse_id']
|
||||||
|
|
||||||
def on_cancel(self, obj):
|
self.spouse_menu = gtk.combo_box_new_text()
|
||||||
pass
|
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)
|
||||||
|
|
||||||
def on_ok_clicked(self, obj):
|
dialog.add_option(_("Spouse"),self.spouse_menu)
|
||||||
"""The user is satisfied with the dialog choices. Parse all options
|
|
||||||
and close the window."""
|
|
||||||
|
|
||||||
if self.new_person:
|
def parse_user_options(self,dialog):
|
||||||
self.person = self.new_person
|
"""
|
||||||
self.spouse_map = self.new_spouse_map
|
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]
|
||||||
|
|
||||||
self.parse_style_frame()
|
def make_default_style(self,default_style):
|
||||||
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 = ""
|
|
||||||
|
|
||||||
self.options = ( self.person.get_handle(), self.spouse_name )
|
|
||||||
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]:
|
|
||||||
person = database.get_person_from_handle(options[0])
|
|
||||||
spouse_name = options[1]
|
|
||||||
spouse_map = _build_spouse_map(database,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."""
|
"""Make default output style for the Family Group Report."""
|
||||||
para = BaseDoc.ParagraphStyle()
|
para = BaseDoc.ParagraphStyle()
|
||||||
font = BaseDoc.FontStyle()
|
font = BaseDoc.FontStyle()
|
||||||
@ -690,50 +535,21 @@ def _make_default_style(default_style):
|
|||||||
para.set_description(_("The style used for the parent's name"))
|
para.set_description(_("The style used for the parent's name"))
|
||||||
default_style.add_style('FGR-ParentName',para)
|
default_style.add_style('FGR-ParentName',para)
|
||||||
|
|
||||||
def _build_spouse_map(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."""
|
|
||||||
spouse_map = {}
|
|
||||||
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():
|
|
||||||
spouse_id = family.get_mother_handle()
|
|
||||||
else:
|
|
||||||
spouse_id = family.get_father_handle()
|
|
||||||
if spouse_id:
|
|
||||||
spouse = database.get_person_from_handle(spouse_id)
|
|
||||||
name = spouse.get_primary_name().get_name()
|
|
||||||
else:
|
|
||||||
name= _("unknown")
|
|
||||||
spouse_map[name] = family_handle
|
|
||||||
return spouse_map
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
from Plugins import register_report, register_book_item
|
from Plugins import register_report
|
||||||
|
|
||||||
register_report(
|
register_report(
|
||||||
report,
|
name = 'family_group',
|
||||||
_("Family Group Report"),
|
category = const.CATEGORY_TEXT,
|
||||||
category=_("Text Reports"),
|
report_class = FamilyGroup,
|
||||||
status=(_("Beta")),
|
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",
|
||||||
description=_("Creates a family group report, showing information on a set of parents and their children."),
|
description=_("Creates a family group report, showing information on a set of parents and their children."),
|
||||||
)
|
)
|
||||||
|
|
||||||
# (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
|
|
||||||
)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user