Hide the merge menu entry when not needed

svn: r517
This commit is contained in:
Don Allingham 2001-10-30 00:40:26 +00:00
parent 0a5a76305e
commit 2a287f8c23
3 changed files with 287 additions and 163 deletions

View File

@ -36,6 +36,8 @@ Version 0.6.0pre
GRAMPS' ids. You can now set a prefix for each type (such as "I-" GRAMPS' ids. You can now set a prefix for each type (such as "I-"
for individuals) or specify more powerful formatting using C-like for individuals) or specify more powerful formatting using C-like
format statements (such as "I-%04d"). format statements (such as "I-%04d").
* Adoption relationships are visible on the pedigree view (seen as
a dotted line).
Version 0.5.1 Version 0.5.1
* Bug fixes * Bug fixes

View File

@ -1291,32 +1291,32 @@ def display_comment_box(filename):
def on_person_list1_activate(obj): def on_person_list1_activate(obj):
"""Switches to the person list view""" """Switches to the person list view"""
notebook.set_page(0) notebook.set_page(0)
merge_button.set_sensitive(1) merge_button.show()
def on_family1_activate(obj): def on_family1_activate(obj):
"""Switches to the family view""" """Switches to the family view"""
notebook.set_page(1) notebook.set_page(1)
merge_button.set_sensitive(0) merge_button.hide()
def on_pedegree1_activate(obj): def on_pedegree1_activate(obj):
"""Switches to the pedigree view""" """Switches to the pedigree view"""
notebook.set_page(2) notebook.set_page(2)
merge_button.set_sensitive(0) merge_button.hide()
def on_sources_activate(obj): def on_sources_activate(obj):
"""Switches to the sources view""" """Switches to the sources view"""
notebook.set_page(3) notebook.set_page(3)
merge_button.set_sensitive(0) merge_button.hide()
def on_places_activate(obj): def on_places_activate(obj):
"""Switches to the places view""" """Switches to the places view"""
notebook.set_page(4) notebook.set_page(4)
merge_button.set_sensitive(1) merge_button.show()
def on_media_activate(obj): def on_media_activate(obj):
"""Switches to the media view""" """Switches to the media view"""
notebook.set_page(5) notebook.set_page(5)
merge_button.set_sensitive(0) merge_button.hide()
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #

View File

@ -56,7 +56,7 @@ style_sheet_list = None
# #
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
class AncestorReport: class DetAncestorReport:
gen = { gen = {
1 : _("First"), 1 : _("First"),
@ -127,11 +127,16 @@ class AncestorReport:
def write_children(self, family): def write_children(self, family):
""" List children """ """ List children """
print "family: ", family.__dict__
num_children= len(family.getChildList()) num_children= len(family.getChildList())
#print "Children= ", len(family.getChildList()) print "Children= ", len(family.getChildList())
if num_children > 0: if num_children > 0:
self.doc.start_paragraph("ChildTitle") self.doc.start_paragraph("ChildTitle")
self.doc.write_text("Children:") mother= family.getMother().getPrimaryName().getRegularName()
father= family.getFather().getPrimaryName().getRegularName()
if num_children == 1:
self.doc.write_text(_("Child of %s and %s is:") % (mother, father))
else: self.doc.write_text(_("Children of %s and %s are:") % (mother, father))
self.doc.end_paragraph() self.doc.end_paragraph()
for child in family.getChildList(): for child in family.getChildList():
@ -145,7 +150,7 @@ class AncestorReport:
" "+child.getBirth().getPlaceName() " "+child.getBirth().getPlaceName()
#print "getDeath()", child.getDeath().__dict__ #print "getDeath()", child.getDeath().__dict__
if child.getDeath().getPlace() != None: if child.getDeath().getPlace() != None:
#print child.getDeath().getPlace().__dict__ # print child.getDeath().getPlace().__dict__
if child.getDeath().getDate() != "" or \ if child.getDeath().getDate() != "" or \
child.getDeath().getPlaceName() != "": child.getDeath().getPlaceName() != "":
t= t+ " Died: "+child.getDeath().getDate() + \ t= t+ " Died: "+child.getDeath().getDate() + \
@ -173,85 +178,142 @@ class AncestorReport:
self.doc.end_bold() self.doc.end_bold()
# Check birth record # Check birth record
#print person.getPrimaryName().getRegularName() birth = person.getBirth()
if birth:
self.write_birth(person, rptOptions)
self.write_death(person, firstName, rptOptions)
self.write_parents(person, firstName)
self.write_marriage(person, rptOptions)
self.doc.end_paragraph()
if key == 1: self.write_mate(person, rptOptions)
if person.getNote() != "" and rptOptions.includeNotes == reportOptions.Yes:
self.doc.start_paragraph("Entry")
self.doc.write_text(_("Notes for %s" % name))
self.doc.end_paragraph()
self.doc.start_paragraph("Entry")
self.doc.write_text(person.getNote())
self.doc.end_paragraph()
def write_birth(self, person, rptOptions):
# Check birth record
# Statement formats name precedes this
# was born on DATE.
# was born on ________.
# was born on Date in Place.
# was born on ________ in PLACE.
# was born in ____________.
# was born in the year YEAR.
# was born in PLACE.
# was born in ____________.
# .
birth = person.getBirth() birth = person.getBirth()
if birth: if birth:
date = birth.getDateObj().get_start_date() date = birth.getDateObj().get_start_date()
if birth.getPlaceName() != "": if birth.getPlaceName() != "":
place = birth.getPlaceName() place = birth.getPlaceName()
else: place= ""
if place[-1:] == '.': if place[-1:] == '.':
place = place[:-1] place = place[:-1]
t= "" elif rptOptions.blankDate == reportOptions.Yes:
place= "______________"
else: place= ""
if date.getDate() != "": if date.getDate() != "":
if date.getDay() != -1 and date.getMonth() != -1 and \ if date.getDay() != -1 and date.getMonth() != -1 and \
rptOptions.fullDate == reportOptions.Yes: rptOptions.fullDate == reportOptions.Yes:
t= "on %s" % date.getDate()
else:
t= "in the year %s" % date.getYear()
elif rptOptions.blankDate == reportOptions.Yes:
t= "on _______________"
if place != "": if place != "":
t= t + " in %s" % place self.doc.write_text(" was born on %s in %s." % (date.getDate(), place))
elif rptOptions.blankPlace == reportOptions.Yes: else:
t= t + " in _____________________" self.doc.write_text(_(" was born on %s.") % date.getDate())
elif place != "":
self.doc.write_text(_(" was born in the year %s in %s.") % \
(date.getYear(), place))
else:
self.doc.write_text(_(" was born in the year %s.") % date.getYear())
elif place != "":
self.doc.write_text(_(" in %s.") % place)
else:
self.doc.write_text(_("."))
if t != "": return
self.doc.write_text(_(" was born " + t + ".")) self.doc.write_text(_("."))
else: self.doc.write_text(_(".")) return
def write_death(self, person, firstName, rptOptions):
t= "" t= ""
death = person.getDeath() death = person.getDeath()
buried = None #print "death=", death, death.__dict__
for event in person.getEventList(): if death != None:
if string.lower(event.getName()) == "burial":
buried = event
if death:
date = death.getDateObj().get_start_date() date = death.getDateObj().get_start_date()
place = death.getPlaceName() place = death.getPlaceName()
#print "date=", date.getDate(), "place=", place, "day= ", date.getDay(), \
# "month= ", date.getMonth(), "year= ", date.getYear()
if place[-1:] == '.': if place[-1:] == '.':
place = place[:-1] place = place[:-1]
t= " %s died " % firstName elif place == "" and rptOptions.blankPlace == reportOptions.Yes:
place= "_____________"
if date.getDate() != "": if date.getDate() != "":
if date.getDay() != -1 and date.getMonth() != -1 and \ if date.getDay() > 0 and date.getMonth() > 0 and \
rptOptions.fullDate == reportOptions.Yes: rptOptions.fullDate == reportOptions.Yes:
t= t + ("on %s" % date.getDate()) fulldate= date.getDate()
else: elif date.getMonth() > 0 and rptOptions.fullDate == reportOptions.Yes:
t= t + ("in the year %s" % date.getDate()) fulldate= "%s %s" % (date.getMonth(), date.getYear())
else: fulldate= ""
elif rptOptions.blankDate == reportOptions.Yes: elif rptOptions.blankDate == reportOptions.Yes:
t= "on ______________" fulldate= "_____________"
else: fulldate= ""
if fulldate != "":
if place != "": if place != "":
t= t + (" in %s") % place t= _(" %s died on %s in %s") % (firstName, fulldate, place)
elif rptOptions.blankPlace == reportOptions.Yes: else: t= _(" %s died on %s") % (firstName, fulldate)
t= t + (" in _____________") elif date.getYear() > 0:
if place != "":
t= _(" %s died in %s in %s") % (firstName, date.getYear(), place)
else: t= _(" %s died in %s") % (firstName, date.getYear())
elif place != "":
t= _(" %s died in %s") % (firstName, place)
if rptOptions.calcAgeFlag == reportOptions.Yes:
t= t + rptOptions.calcAge(person)
if t != "":
self.doc.write_text(t+".")
t= ""
famList= person.getFamilyList()
if len(famList) > 0:
for fam in famList:
#print "fam event=", fam.__dict__
buried= None
if buried: if buried:
date = buried.getDateObj().get_start_date() date = buried.getDateObj().get_start_date()
place = buried.getPlaceName() place = buried.getPlaceName()
if place[-1:] == '.': if place[-1:] == '.':
place = place[:-1] place = place[:-1]
if date.getDate() != "" or place != "": fulldate= ""
t= t + ", and was buried "
if date.getDate() != "": if date.getDate() != "":
if date.getDay() != -1 and date.getMonth() != -1 and \ if date.getDay() != -1 and date.getMonth() != -1 and \
rptOptions.fullDate == reportOptions.Yes: rptOptions.fullDate == reportOptions.Yes:
t= t + "on %s" % date.getDate() fulldate= date.getDate()
if place != "":
t = t + " in %s" % place
else:
t = t + "in the year %s" % date.getDate()
elif rptOptions.blankDate == reportOptions.Yes: elif rptOptions.blankDate == reportOptions.Yes:
t= t + " on ___________" fulldate= "___________"
if place != "":
t = t + " in %s" % place if fulldate != "" and place != "":
t= _(" And %s was buried on %s in %s.") % (firstName, fulldate, place)
elif fulldate != "" and place == "":
t= _(" And %s was buried on %s.") % (firstName, fulldate)
elif fulldate == "" and place != "":
t= _(" And %s was buried in %s.") % (firstName, place)
if rptOptions.calcAgeFlag == reportOptions.Yes:
t= t + rptOptions.calcAge(birth.date.start, death.date.start)
if t != "": if t != "":
self.doc.write_text(_(t+".")) self.doc.write_text(t)
t= ""
def write_parents(self, person, firstName):
ext_family= person.getMainFamily() ext_family= person.getMainFamily()
if ext_family != None: if ext_family != None:
if ext_family.getFather() != None: if ext_family.getFather() != None:
@ -262,26 +324,36 @@ class AncestorReport:
else: mother= "" else: mother= ""
if father != "" or mother != "": if father != "" or mother != "":
t = " %s was the " % firstName
if person.getGender() == RelLib.Person.male: if person.getGender() == RelLib.Person.male:
t= t + "son of"
else:
t= t + "daughter of"
if father != "": if father != "":
t= t + " %s" % father
if mother != "": if mother != "":
t= t + " and %s" % mother self.doc.write_text(_(" %s was the son of %s and %s." % \
else: t= t + " %s" % mother (firstName, father, mother)))
else:
self.doc.write_text(_(" %s was the son of %s." % \
(firstName, father)))
else:
self.doc.write_text(_(" %s was the son of %s." % \
(firstName, mother)))
else:
if father != "":
if mother != "":
self.doc.write_text(_(" %s was the daughter of %s and %s." % \
(firstName, father, mother)))
else:
self.doc.write_text(_(" %s was the daughter of %s." % \
(firstName, father)))
else:
self.doc.write_text(_(" %s was the daughter of %s." % \
(firstName, mother)))
self.doc.write_text(_(t + "."))
t= ""
def write_marriage(self, person, rptOptions):
famList= person.getFamilyList() famList= person.getFamilyList()
#print "len of famList=", len(famList) #print "Marriage: len of famList=", len(famList)
if len(famList) > 0: if len(famList) > 0:
for fam in famList: for fam in famList:
#print "fam", fam.__dict__ #print "Marriage:fam", fam.__dict__
spouse= ""
if person.getGender() == RelLib.Person.male: if person.getGender() == RelLib.Person.male:
if fam.getMother() != None: if fam.getMother() != None:
spouse= fam.getMother().getPrimaryName().getRegularName() spouse= fam.getMother().getPrimaryName().getRegularName()
@ -293,43 +365,83 @@ class AncestorReport:
marriage= fam.getMarriage() marriage= fam.getMarriage()
if marriage != None: if marriage != None:
#print "marriage", marriage.__dict__
if spouse != "":
t= " %s married %s" % (heshe, spouse)
else:
t= " %s was married" % heshe
date= marriage.getDateObj()
if date != None:
#print "date", date.__dict__
#print "date.start=", date.start.__dict__
if date.getYear() != -1:
if date.getDay() != -1 and \
date.getMonth() != -1 and \
rptOptions.fullDate == reportOptions.Yes:
t= t + " on "+date.getDate()
else: t= t + " in the year %s" % date.getYear()
elif rptOptions.blankDate == reportOptions.Yes:
t= t + " on __________"
else: t= t + " on __________"
if marriage.getPlace() != None and \ if marriage.getPlace() != None and \
marriage.getPlaceName() != "": marriage.getPlaceName() != "":
t= t + " in " + marriage.getPlaceName() place= marriage.getPlaceName()
elif rptOptions.blankPlace == reportOptions.Yes: elif rptOptions.blankPlace == reportOptions.Yes:
t= t + " in ____________" place= "____________"
self.doc.write_text(_(t+".")) else: place= ""
date= marriage.getDateObj()
fulldate= ""
if date != None:
if date.getYear() != -1:
if date.getDay() != -1 and date.getMonth() != -1 and \
rptOptions.fullDate == reportOptions.Yes:
fulldate= date.getDate()
elif rptOptions.blankDate == reportOptions.Yes:
fulldate= "__________"
if person.getNote() != "" and rptOptions.includeNotes == reportOptions.Yes: if spouse != "":
self.doc.end_paragraph() if fulldate == "" and place == "":
t= _(" %s married %s." % (heshe, spouse))
elif fulldate == "" and place != "":
t= _(" %s married %s in %s." % (heshe, spouse, place))
elif fulldate != "" and place == "":
t= _(" %s married %s on %s" % (heshe, spouse, fulldate))
else: t= _(" %s married %s on %s in %s." % \
(heshe, spouse, fulldate, place))
else:
if fulldate == "" and place == "":
t= _(" %s married.")
elif fulldate == "" and place != "":
t= _(" %s married in %s." % (heshe, place))
elif fulldate != "" and place == "":
t= _(" %s married on %s" % (heshe, fulldate))
else: t= _(" %s married on %s in %s." % \
(heshe, fulldate, place))
self.doc.write_text(t)
def write_mate(self, mate, rptOptions):
"""Output birth, death, parentage, marriage and notes information """
famList= mate.getFamilyList()
#print "len of famList=", len(famList)
if len(famList) > 0:
for fam in famList:
person= ""
if mate.getGender() == RelLib.Person.male:
if fam.getMother() != None:
ind= fam.getMother()
person= fam.getMother().getPrimaryName().getRegularName()
firstName= fam.getMother().getPrimaryName().getFirstName()
heshe= "He"
else:
heshe= "She"
if fam.getFather() != None:
ind= fam.getFather()
person= fam.getFather().getPrimaryName().getRegularName()
firstName= fam.getFather().getPrimaryName().getFirstName()
if person != "":
self.doc.start_paragraph("Entry") self.doc.start_paragraph("Entry")
self.doc.write_text(_("Notes for %s" % name)) if rptOptions.firstName == reportOptions.No:
self.doc.end_paragraph() firstName= heshe
self.doc.start_paragraph("Entry")
self.doc.write_text(person.getNote()) self.doc.write_text(person)
#print person.getNote()
self.write_birth(ind, rptOptions)
self.write_death(ind, firstName, rptOptions)
self.write_parents(ind, firstName)
self.doc.end_paragraph() self.doc.end_paragraph()
if rptOptions.listChildren == reportOptions.Yes:
self.write_children(fam)
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# #
# #
@ -351,15 +463,12 @@ class AncestorReport:
generation = 0 generation = 0
need_header = 1 need_header = 1
rptOpt.blankDate = reportOptions.No
rptOpt.blankPlace = reportOptions.No
for key in keys : for key in keys :
if generation == 0 or key >= 2**generation: if generation == 0 or key >= 2**generation:
if self.pgbrk and generation > 0: if self.pgbrk and generation > 0:
self.doc.page_break() self.doc.page_break()
self.doc.start_paragraph("Generation") self.doc.start_paragraph("Generation")
t = _("%s Generation") % AncestorReport.gen[generation+1] t = _("%s Generation") % DetAncestorReport.gen[generation+1]
self.doc.write_text(t) self.doc.write_text(t)
self.doc.end_paragraph() self.doc.end_paragraph()
generation = generation + 1 generation = generation + 1
@ -436,6 +545,12 @@ def report(database,person):
para.set(first_indent=-1.0,lmargin=1.0,pad=0.25) para.set(first_indent=-1.0,lmargin=1.0,pad=0.25)
styles.add_style("Entry",para) styles.add_style("Entry",para)
table = TableStyle()
table.set_width(1000)
table.set_columns(3)
table.set_column_width(1,"30%")
#add_table_style("Images",table)
style_sheet_list = StyleSheetList("det_ancestor_report.xml",styles) style_sheet_list = StyleSheetList("det_ancestor_report.xml",styles)
build_menu(None) build_menu(None)
@ -513,7 +628,7 @@ def on_save_clicked(obj):
doc = FindDoc.make_text_doc(styles,format,paper,orien,template) doc = FindDoc.make_text_doc(styles,format,paper,orien,template)
MyReport = AncestorReport(db,active_person,outputName,max_gen,pgbrk,doc) MyReport = DetAncestorReport(db,active_person,outputName,max_gen,pgbrk,doc)
MyReport.write_report() MyReport.write_report()
utils.destroy_passed_object(obj) utils.destroy_passed_object(obj)
@ -636,10 +751,10 @@ class reportOptions:
#self.noSourceNotes= reportOptions.Yes #self.noSourceNotes= reportOptions.Yes
#Replace missing Place with ___________ #Replace missing Place with ___________
self.blankPlace= reportOptions.Yes self.blankPlace= reportOptions.No
#Replace missing dates with __________ #Replace missing dates with __________
self.blankDate= reportOptions.Yes self.blankDate= reportOptions.No
#Omit country code #Omit country code
#self.noCountryInfo= reportOptions.No #self.noCountryInfo= reportOptions.No
@ -650,6 +765,9 @@ class reportOptions:
#Add "Died at the age of NN" in text #Add "Died at the age of NN" in text
self.calcAgeFlag= reportOptions.Yes self.calcAgeFlag= reportOptions.Yes
#Add Photos and Images to report
self.addImages= reportOptions.Yes
#Omit sensitive information such as birth, christening, marriage #Omit sensitive information such as birth, christening, marriage
# for living after XXXXX date. # for living after XXXXX date.
@ -664,27 +782,31 @@ class reportOptions:
#else: #else:
#self.images.append(key, fname, align, width, height) #self.images.append(key, fname, align, width, height)
def calcAge(self, birth, death): def calcAge(self, ind):
### Calulate age ### ### Calulate age ###
birth= ind.getBirth().getDateObj().get_start_date()
death= ind.getDeath().getDateObj().get_start_date()
#print "birth=", birth.__dict__
#print "death=", death.__dict__
self.t= "" self.t= ""
if birth.year != -1 and death.year != -1: if birth.getYear() != -1 and death.getYear() != -1:
self.age= death.year - birth.year self.age= death.getYear() - birth.getYear()
self.units= "year" self.units= "year"
if birth.month != -1 and death.month != -1: if birth.getMonth() != -1 and death.getMonth() != -1:
if birth.month > death.month: if birth.getMonth() > death.getMonth():
self.age= self.age -1 self.age= self.age -1
if birth.day != -1 and death.day != -1: if birth.getDay() != -1 and death.getDay() != -1:
if birth.month == death.month and birth.day > death.day: if birth.getMonth() == death.getMonth() and birth.getDay() > death.getDay():
self.age= self.age -1 self.age= self.age -1
self.units= "month" self.units= "month"
if self.age == 0: if self.age == 0:
self.age= death.month - birth.month # calc age in months self.age= death.getMonth() - birth.getMonth() # calc age in months
if birth.day > death.day: if birth.getDay() > death.getDay():
self.age= self.age - 1 self.age= self.age - 1
if self.age == 0: if self.age == 0:
self.age= death.day + 31 - birth.day # calc age in days self.age= death.getDay() + 31 - birth.getDay() # calc age in days
self.units= "day" self.units= "day"
self.t= " at the age of %d %s" % (self.age, self.units) self.t= _(" at the age of %d %s") % (self.age, self.units)
if self.age > 1: self.t= self.t + "s" if self.age > 1: self.t= self.t + "s"
return self.t return self.t