* src/plugins/Calendar.py: no negative years on calendar (no events show before they occur)

* src/plugins/Calendar.py: uses StringOption in MenuOption
	* src/ReportBase/_MenuOptions.py: adds StringOption (one line text entry)
	* src/ReportBase/__init__.py: adds StringOption



svn: r9175
This commit is contained in:
Doug Blank
2007-10-14 01:56:00 +00:00
parent c4206b7c66
commit c49af9ad43
3 changed files with 65 additions and 31 deletions

View File

@ -494,6 +494,8 @@ class MenuOptions(ReportOptions):
self.__add_number_option(category,name,option,dialog) self.__add_number_option(category,name,option,dialog)
elif otype == TextOption: elif otype == TextOption:
self.__add_text_option(category,name,option,dialog) self.__add_text_option(category,name,option,dialog)
elif otype == StringOption:
self.__add_string_option(category,name,option,dialog)
elif otype == BooleanOption: elif otype == BooleanOption:
self.__add_boolean_option(category,name,option,dialog) self.__add_boolean_option(category,name,option,dialog)
elif otype == EnumeratedListOption: elif otype == EnumeratedListOption:
@ -514,6 +516,8 @@ class MenuOptions(ReportOptions):
self.__parse_number_option(name,option) self.__parse_number_option(name,option)
elif otype == TextOption: elif otype == TextOption:
self.__parse_text_option(name,option) self.__parse_text_option(name,option)
elif otype == StringOption:
self.__parse_string_option(name,option)
elif otype == BooleanOption: elif otype == BooleanOption:
self.__parse_boolean_option(name,option) self.__parse_boolean_option(name,option)
elif otype == EnumeratedListOption: elif otype == EnumeratedListOption:
@ -555,13 +559,31 @@ class MenuOptions(ReportOptions):
self.gui[name].add_events(gtk.gdk.LEAVE_NOTIFY_MASK) self.gui[name].add_events(gtk.gdk.LEAVE_NOTIFY_MASK)
self.tooltips.set_tip(self.gui[name],option.get_help()) self.tooltips.set_tip(self.gui[name],option.get_help())
def __add_string_option(self,category,name,option,dialog):
"""
Add a StringOption (single line text) to the dialog.
"""
self.gui[name] = gtk.Entry()
self.gui[name].set_text(self.options_dict[name])
dialog.add_frame_option(category,option.get_label(),self.gui[name])
self.tooltips.set_tip(self.gui[name],option.get_help())
def __parse_text_option(self,name,option): def __parse_text_option(self,name,option):
"""
Parse the text option (multi-line text).
"""
b = self.gui[name].get_buffer() b = self.gui[name].get_buffer()
text_val = unicode( b.get_text( b.get_start_iter(), text_val = unicode( b.get_text( b.get_start_iter(),
b.get_end_iter(), b.get_end_iter(),
False) ) False) )
self.options_dict[name] = text_val.split('\n') self.options_dict[name] = text_val.split('\n')
def __parse_string_option(self,name,option):
"""
Parse the string option (single line text).
"""
self.options_dict[name] = self.gui[name].get_text()
def __add_boolean_option(self,category,name,option,dialog): def __add_boolean_option(self,category,name,option,dialog):
""" """
Add a BooleanOption to the dialog. Add a BooleanOption to the dialog.

View File

@ -38,7 +38,7 @@ from _TextReportDialog import TextReportDialog
from _ReportOptions import ReportOptions from _ReportOptions import ReportOptions
from _MenuOptions import MenuOptions, NumberOption, BooleanOption, TextOption, \ from _MenuOptions import MenuOptions, NumberOption, BooleanOption, TextOption, \
EnumeratedListOption, FilterListOption EnumeratedListOption, FilterListOption, StringOption
import _ReportUtils as ReportUtils import _ReportUtils as ReportUtils
from _Bibliography import Bibliography, Citation from _Bibliography import Bibliography, Citation

View File

@ -40,7 +40,7 @@ import BaseDoc
from BasicUtils import name_displayer from BasicUtils import name_displayer
from PluginUtils import register_report from PluginUtils import register_report
from ReportBase import Report, ReportUtils, ReportOptions, \ from ReportBase import Report, ReportUtils, ReportOptions, \
MenuOptions, NumberOption, BooleanOption, TextOption, EnumeratedListOption, \ MenuOptions, NumberOption, BooleanOption, StringOption, EnumeratedListOption, \
FilterListOption, \ FilterListOption, \
CATEGORY_DRAW, CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI CATEGORY_DRAW, CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI
import GrampsLocale import GrampsLocale
@ -61,7 +61,10 @@ class Calendar(Report):
""" """
def __init__(self,database,person,options_class): def __init__(self,database,person,options_class):
Report.__init__(self,database,person,options_class) Report.__init__(self,database,person,options_class)
self.titletext = "\n".join(options_class.handler.options_dict['titletext']) if 'titletext' in options_class.handler.options_dict.keys():
# report and graphic share most of the same code
# but calendar doesn't have a title
self.titletext = options_class.handler.options_dict['titletext']
self.year = options_class.handler.options_dict['year'] self.year = options_class.handler.options_dict['year']
self.country = options_class.handler.options_dict['country'] self.country = options_class.handler.options_dict['country']
self.anniversaries = options_class.handler.options_dict['anniversaries'] self.anniversaries = options_class.handler.options_dict['anniversaries']
@ -69,9 +72,9 @@ class Calendar(Report):
self.maiden_name = options_class.handler.options_dict['maiden_name'] self.maiden_name = options_class.handler.options_dict['maiden_name']
self.alive = options_class.handler.options_dict['alive'] self.alive = options_class.handler.options_dict['alive']
self.birthdays = options_class.handler.options_dict['birthdays'] self.birthdays = options_class.handler.options_dict['birthdays']
self.text1 = "\n".join(options_class.handler.options_dict['text1']) self.text1 = options_class.handler.options_dict['text1']
self.text2 = "\n".join(options_class.handler.options_dict['text2']) self.text2 = options_class.handler.options_dict['text2']
self.text3 = "\n".join(options_class.handler.options_dict['text3']) self.text3 = options_class.handler.options_dict['text3']
self.filter = options_class.handler.options_dict['filter'] self.filter = options_class.handler.options_dict['filter']
self.filter.person = person self.filter.person = person
name = name_displayer.display_formal(person) name = name_displayer.display_formal(person)
@ -278,7 +281,8 @@ class Calendar(Report):
if father != None: if father != None:
father_lastname = father.get_primary_name().get_surname() father_lastname = father.get_primary_name().get_surname()
short_name = self.get_short_name(person, father_lastname) short_name = self.get_short_name(person, father_lastname)
self.add_day_item("%s, %d" % (short_name, age), year, month, day) if age >= 0:
self.add_day_item("%s, %d" % (short_name, age), year, month, day)
if self.anniversaries and ((self.alive and alive) or not self.alive): if self.anniversaries and ((self.alive and alive) or not self.alive):
family_list = person.get_family_handle_list() family_list = person.get_family_handle_list()
for fhandle in family_list: for fhandle in family_list:
@ -304,12 +308,13 @@ class Calendar(Report):
month = event_obj.get_month() month = event_obj.get_month()
day = event_obj.get_day() day = event_obj.get_day()
years = self.year - year years = self.year - year
text = _("%(spouse)s and\n %(person)s, %(nyears)d") % { if years >= 0:
'spouse' : spouse_name, text = _("%(spouse)s and\n %(person)s, %(nyears)d") % {
'person' : short_name, 'spouse' : spouse_name,
'nyears' : years, 'person' : short_name,
} 'nyears' : years,
self.add_day_item(text, year, month, day) }
self.add_day_item(text, year, month, day)
class CalendarReport(Calendar): class CalendarReport(Calendar):
""" The Calendar text report """ """ The Calendar text report """
@ -376,24 +381,7 @@ class CalendarOptions(MenuOptions):
def add_menu_options(self, menu): def add_menu_options(self, menu):
""" Adds the options for the graphical calendar """ """ Adds the options for the graphical calendar """
category_name = _("Text Options") category_name = _("Report Options")
titletext = TextOption(_("Title text"),
[_("Birthday and Anniversary Report")])
titletext.set_help(_("Title of calendar"))
menu.add_option(category_name,"titletext", titletext)
text1 = TextOption(_("Text Area 1"), [_("My Calendar")])
text1.set_help(_("First line of text at bottom of calendar"))
menu.add_option(category_name,"text1", text1)
text2 = TextOption(_("Text Area 2"), [_("Produced with GRAMPS")])
text2.set_help(_("Second line of text at bottom of calendar"))
menu.add_option(category_name,"text2", text2)
text3 = TextOption(_("Text Area 3"), ["http://gramps-project.org/"],)
text3.set_help(_("Third line of text at bottom of calendar"))
menu.add_option(category_name,"text3", text3)
year = NumberOption(_("Year of calendar"), time.localtime()[0], 1000, 3000) year = NumberOption(_("Year of calendar"), time.localtime()[0], 1000, 3000)
year.set_help(_("Year of calendar")) year.set_help(_("Year of calendar"))
@ -438,6 +426,20 @@ class CalendarOptions(MenuOptions):
anniversaries.set_help(_("Include anniversaries in the calendar")) anniversaries.set_help(_("Include anniversaries in the calendar"))
menu.add_option(category_name,"anniversaries", anniversaries) menu.add_option(category_name,"anniversaries", anniversaries)
category_name = _("Text Options")
text1 = StringOption(_("Text Area 1"), _("My Calendar"))
text1.set_help(_("First line of text at bottom of calendar"))
menu.add_option(category_name,"text1", text1)
text2 = StringOption(_("Text Area 2"), _("Produced with GRAMPS"))
text2.set_help(_("Second line of text at bottom of calendar"))
menu.add_option(category_name,"text2", text2)
text3 = StringOption(_("Text Area 3"), "http://gramps-project.org/",)
text3.set_help(_("Third line of text at bottom of calendar"))
menu.add_option(category_name,"text3", text3)
def make_my_style(self, default_style, name, description, def make_my_style(self, default_style, name, description,
size=9, font=BaseDoc.FONT_SERIF, justified ="left", size=9, font=BaseDoc.FONT_SERIF, justified ="left",
color=None, align=BaseDoc.PARA_ALIGN_CENTER, color=None, align=BaseDoc.PARA_ALIGN_CENTER,
@ -503,6 +505,16 @@ class CalendarOptions(MenuOptions):
class CalendarReportOptions(CalendarOptions): class CalendarReportOptions(CalendarOptions):
""" Options for the calendar (birthday and anniversary) report """ """ Options for the calendar (birthday and anniversary) report """
def add_menu_options(self, menu):
""" Adds the options for the graphical calendar """
category_name = _("Text Options")
titletext = StringOption(_("Title text"),
_("Birthday and Anniversary Report"))
titletext.set_help(_("Title of calendar"))
menu.add_option(category_name,"titletext", titletext)
CalendarOptions.add_menu_options(self, menu)
def make_default_style(self, default_style): def make_default_style(self, default_style):
""" Adds the options for the textual report """ """ Adds the options for the textual report """
self.make_my_style(default_style, "BIR-Title", self.make_my_style(default_style, "BIR-Title",