* src/docgen/Makefile.am, src/docgen/Makefile.in: Ship LPRDoc.py.

* src/plugins/GraphViz.py (dump_index): Remove utf8 to latin
conversion. Switch to FreeSans.
* src/docgen/PdfDoc.py (draw_text, rotate_text): Fix encoding.

* src/plugins/WebPage.py: Add option for using only birth date.
* src/Date.py: Switch over to lowercase function names.


svn: r3025
This commit is contained in:
Alex Roitman 2004-03-17 03:04:10 +00:00
parent ac6d3e74e0
commit 5475905a4c
2 changed files with 110 additions and 48 deletions

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000 Donald N. Allingham
# Copyright (C) 2000-2004 Donald N. Allingham
#
# 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
@ -18,6 +18,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
"Support for dates"
__author__ = "Donald N. Allingham"
@ -126,56 +128,56 @@ class Date:
self.stop.calendar = self.calendar
return self.stop
def getLowYear(self):
return self.start.getYear()
def get_low_year(self):
return self.start.get_year()
def getHighYear(self):
def get_high_year(self):
if self.stop == None:
return self.start.getYear()
return self.start.get_year()
else:
return self.stop.getYear()
return self.stop.get_year()
def getYear(self):
def get_year(self):
return self.start.year
def getYearValid(self):
def get_year_valid(self):
return self.start.year != UNDEF
def getMonth(self):
def get_month(self):
if self.start.month == UNDEF:
return UNDEF
return self.start.month
def getMonthValid(self):
def get_month_valid(self):
return self.start.month != UNDEF
def getDay(self):
def get_day(self):
return self.start.day
def getDayValid(self):
def get_day_valid(self):
return self.start.day != UNDEF
def getValid(self):
def get_valid(self):
""" Returns true if any part of the date is valid"""
return self.start.year != UNDEF or self.start.month != UNDEF or self.start.day != UNDEF
def getIncomplete(self):
def get_incomplete(self):
return self.range == 0 and self.start.year == UNDEF or \
self.start.month == UNDEF or self.start.day == UNDEF
def getStopYear(self):
def get_stop_year(self):
if self.stop == None:
self.stop = SingleDate()
self.stop.calendar = self.calendar
return self.stop.year
def getStopMonth(self):
def get_stop_month(self):
if self.stop == None:
self.stop = SingleDate()
self.stop.calendar = self.calendar
return self.stop.month+1
def getStopDay(self):
def get_stop_day(self):
if self.stop == None:
self.stop = SingleDate()
self.stop.calendar = self.calendar
@ -268,14 +270,14 @@ class Date:
s = self.start
return s.year==UNDEF and s.month==UNDEF and s.day==UNDEF and not self.text
def isValid(self):
def is_valid(self):
if self.range == -1:
return 0
elif self.range:
return self.start.getValid() and self.stop.getValid()
return self.start.getValid()
return self.start.get_valid() and self.stop.get_valid()
return self.start.get_valid()
def isRange(self):
def is_range(self):
return self.range == 1
#-------------------------------------------------------------------------
@ -300,64 +302,64 @@ class SingleDate:
self.mode = Calendar.EXACT
self.calendar = Gregorian.Gregorian()
def setMode(self,val):
def set_mode(self,val):
self.mode = self.calendar.set_mode_value(val)
def setMonth(self,val):
def set_month(self,val):
if val > 14 or val < 0:
self.month = UNDEF
else:
self.month = val
def setMonthVal(self,s):
def set_month_val(self,s):
self.month = self.calendar.set_value(s)
def setDayVal(self,s):
def set_day_val(self,s):
self.day = self.calendar.set_value(s)
def setYearVal(self,s):
def set_year_val(self,s):
if s:
self.year = self.calendar.set_value(s)
else:
self.year = UNDEF
def getMonth(self):
def get_month(self):
return self.month
def getMonthValid(self):
def get_month_valid(self):
return self.month != UNDEF
def setDay(self,val):
def set_day(self,val):
self.day = val
def getDay(self):
def get_day(self):
return self.day
def getDayValid(self):
def get_day_valid(self):
return self.day != UNDEF
def setYear(self,val):
def set_year(self,val):
self.year = val
def getYear(self):
def get_year(self):
return self.year
def getYearValid(self):
def get_year_valid(self):
return self.year != UNDEF
def getValid(self):
def get_valid(self):
""" Returns true if any part of the date is valid"""
if self.year == UNDEF and self.month == UNDEF and self.day == UNDEF:
return 1
return self.calendar.check(self.year,self.month,self.day)
def setMonthStr(self,text):
def set_month_str(self,text):
self.calendar.set_month_string(text)
def getMonthStr(self):
def get_month_str(self):
return self.calendar.month(self.month)
def getIsoDate(self):
def get_iso_date(self):
if self.year == UNDEF:
y = "????"
else:
@ -385,30 +387,30 @@ class SingleDate:
else:
return self.calendar.quote_display(self.year, self.month, self.day, self.mode)
def setIsoDate(self,v):
def set_iso_date(self,v):
data = string.split(v)
if len(data) > 1:
self.setMode(data[0])
self.set_mode(data[0])
v = data[1]
vals = string.split(v,'-')
self.setYearVal(vals[0])
self.set_year_val(vals[0])
if len(vals) > 1:
try:
self.setMonthVal(int(vals[1]))
self.set_month_val(int(vals[1]))
except:
self.month = UNDEF
else:
self.month = UNDEF
if len(vals) > 2:
self.setDayVal(vals[2])
self.set_day_val(vals[2])
else:
self.day = UNDEF
def getModeVal(self):
def get_mode_val(self):
return self.mode
def setModeVal(self,val):
def set_mode_val(self,val):
self.mode = val
def set(self,text):

View File

@ -69,6 +69,7 @@ _month = [
"JUL", "AUG", "SEP", "OCT", "NOV", "DEC" ]
_hline = " " # Everything is underlined, so use blank
_BORN = _('b.')
#------------------------------------------------------------------------
#
@ -683,7 +684,8 @@ class WebReport(Report.Report):
def __init__(self,db,person,target_path,max_gen,photos,filter,restrict,
private, srccomments, include_link, include_mini_tree,
style, image_dir, template_name,use_id,id_link,gendex,ext,
include_alpha_links,separate_alpha,n_cols,ind_template_name,depth):
include_alpha_links,separate_alpha,n_cols,ind_template_name,
depth,birth_dates,year_only):
self.db = db
self.ext = ext
self.use_id = use_id
@ -707,6 +709,8 @@ class WebReport(Report.Report):
self.n_cols = n_cols
self.ind_template_name = ind_template_name
self.depth = depth
self.birth_dates = birth_dates
self.year_only = year_only
def get_progressbar_data(self):
return (_("Generate HTML reports - GRAMPS"), _("Creating Web Pages"))
@ -864,10 +868,27 @@ class WebReport(Report.Report):
col_len = n_rows
for person_id in p_id_list:
name = self.db.find_person_from_if(person_id).get_primary_name().get_name()
name = self.db.find_person_from_id(person_id).get_primary_name().get_name()
if self.birth_dates:
birth_id = self.db.find_person_from_id(person_id).get_birth_id()
if birth_id:
birth_event = self.db.find_event_from_id(birth_id)
if self.year_only:
birth_dobj = birth_event.get_date_object()
if birth_dobj.get_year_valid():
birth_date = birth_dobj.get_year()
else:
birth_date = ""
else:
birth_date = birth_event.get_date()
else:
birth_date = ""
doc.start_link("%s.%s" % (person_id,self.ext))
doc.write_text(name)
if self.birth_dates and birth_date:
doc.write_text(' (%s %s)' % (_BORN,birth_date))
doc.end_link()
if col_len <= 0:
@ -900,8 +921,25 @@ class WebReport(Report.Report):
for person_id in p_id_list:
name = self.db.find_person_from_id(person_id).get_primary_name().get_name()
if self.birth_dates:
birth_id = self.db.find_person_from_id(person_id).get_birth_id()
if birth_id:
birth_event = self.db.find_event_from_id(birth_id)
if self.year_only:
birth_dobj = birth_event.get_date_object()
if birth_dobj.get_year_valid():
birth_date = birth_dobj.get_year()
else:
birth_date = ""
else:
birth_date = birth_event.get_date()
else:
birth_date = ""
doc.start_link("%s.%s" % (person_id,self.ext))
doc.write_text(name)
if self.birth_dates and birth_date:
doc.write_text(' (%s %s)' % (_BORN,birth_date))
doc.end_link()
if col_len <= 0:
doc.write_raw('</td><td width="%d%%" valign="top">' % td_width)
@ -1034,6 +1072,8 @@ class WebReportDialog(Report.ReportDialog):
ext_msg = _("File extension")
alpha_links_msg = _("Links to alphabetical sections in index page")
sep_alpha_msg = _("Split alphabetical sections to separate pages")
birth_date_msg = _("Append birth dates to the names")
year_only_msg = _("Use only year of birth")
tree_msg = _("Include short ancestor tree")
self.mini_tree = gtk.CheckButton(tree_msg)
@ -1085,6 +1125,12 @@ class WebReportDialog(Report.ReportDialog):
self.ind_template.entry.set_editable(0)
self.ind_user_template = gnome.ui.FileEntry("HTML_Template",_("Choose File"))
self.ind_user_template.set_sensitive(0)
self.add_birth_date = gtk.CheckButton(birth_date_msg)
self.use_year_only = gtk.CheckButton(year_only_msg)
self.use_year_only.set_active(1)
self.use_year_only.set_sensitive(0)
self.add_birth_date.connect('toggled',self.on_birth_date_toggled)
self.add_option(imgdir_msg,self.imgdir)
self.add_option('',self.mini_tree)
@ -1109,6 +1155,8 @@ class WebReportDialog(Report.ReportDialog):
self.add_frame_option(title,None,self.use_alpha_links)
self.add_frame_option(title,None,self.use_sep_alpha)
self.add_frame_option(title,_('Number of columns'),self.use_n_cols)
self.add_frame_option(title,None,self.add_birth_date)
self.add_frame_option(title,None,self.use_year_only)
title = _('Advanced')
self.add_frame_option(title,'',self.include_id)
@ -1376,6 +1424,8 @@ class WebReportDialog(Report.ReportDialog):
else:
self.separate_alpha = 0
self.n_cols = self.use_n_cols.get_value()
self.birth_dates = self.add_birth_date.get_active()
self.year_only = self.use_year_only.get_active()
#------------------------------------------------------------------------
#
@ -1421,6 +1471,15 @@ class WebReportDialog(Report.ReportDialog):
else:
self.ind_user_template.set_sensitive(0)
def on_birth_date_toggled(self,obj):
"""Keep the 'User year only' check button in line with
the 'Add birth date' checkbox. If no mini birth date is added
then it makes no sense to worry about its format."""
if obj.get_active():
self.use_year_only.set_sensitive(1)
else:
self.use_year_only.set_sensitive(0)
#------------------------------------------------------------------------
#
# Functions related to creating the actual report document.
@ -1439,7 +1498,8 @@ class WebReportDialog(Report.ReportDialog):
self.use_id,self.id_link,self.use_gendex,
self.html_ext,self.include_alpha_links,
self.separate_alpha,self.n_cols,
self.ind_template_name,self.depth_value)
self.ind_template_name,self.depth_value,
self.birth_dates,self.year_only)
MyReport.write_report()
except Errors.FilterError, msg:
(m1,m2) = msg.messages()