2007-12-17 Douglas S. Blank <dblank@cs.brynmawr.edu>

* src/plugins/CalculateEstimatedDates.py: Give good defaults for Filter 
	and Enumerated Lists
	* src/plugins/Calendar.py: Give good defaults for Filter and Enumerated
	lists
	* src/PluginUtils/_MenuOptions.py: added a get_filter() method to return
	filter object; added a param to constructor to set default filter



svn: r9526
This commit is contained in:
Doug Blank 2007-12-17 05:09:34 +00:00
parent f5393d7d3a
commit ca186628c7
4 changed files with 24 additions and 13 deletions

View File

@ -1,3 +1,11 @@
2007-12-17 Douglas S. Blank <dblank@cs.brynmawr.edu>
* src/plugins/CalculateEstimatedDates.py: Give good defaults for Filter
and Enumerated Lists
* src/plugins/Calendar.py: Give good defaults for Filter and Enumerated
lists
* src/PluginUtils/_MenuOptions.py: added a get_filter() method to return
filter object; added a param to constructor to set default filter
2007-12-16 Brian Matherly <brian@gramps-project.org>
* src/plugins/Calendar.py: Properly initialize Filter option.
* src/PluginUtils/_MenuOptions.py: Properly initialize Filter option.

View File

@ -386,14 +386,14 @@ class FilterListOption(Option):
This class describes an option that provides a finite list of filters.
Each possible value is assigned a type of set of filters to use.
"""
def __init__(self,label):
def __init__(self,label,value=0):
"""
@param label: A friendly label to be applied to this option.
Example: "Filter"
@type label: string
@return: nothing
"""
Option.__init__(self,label,0)
Option.__init__(self,label,value)
self.__items = []
self.__filters = []
@ -453,7 +453,6 @@ class FilterListOption(Option):
self.gobj = gtk.HBox()
for filter in self.get_items():
if filter in ["person"]:
# FIXME: get filter list from filter sidebar?
filter_list = ReportUtils.get_person_filters(dialog.person,
include_single=True)
for filter in filter_list:
@ -479,6 +478,12 @@ class FilterListOption(Option):
def get_center_person(self):
return self.dialog.person
def get_filter(self):
"""
Return the filter object.
"""
return self.get_filters()[int(self.combo.get_active())]
def update_gui_obj(self):
# update the gui object with new filter info
from ReportBase import ReportUtils

View File

@ -55,7 +55,7 @@ class CalcEstDateOptions(MenuToolOptions):
""" Adds the options """
category_name = _("Options")
filter = FilterListOption(_("Filter"))
filter = FilterListOption(_("Filter"), 3)
filter.add_item("person")
filter.set_help(_("Select filter to restrict people"))
menu.add_option(category_name,"filter", filter)
@ -121,7 +121,8 @@ class CalcToolManagedWindow(PluginWindows.ToolManagedWindowBatch):
self.results_write("Processing...\n")
self.trans = self.db.transaction_begin("",batch=True)
self.db.disable_signals()
self.filter = self.options.handler.options_dict['filter']
self.filter_option = self.options.menu.get_option_by_name('filter')
self.filter = self.filter_option.get_filter() # the actual filter
people = self.filter.apply(self.db,
self.db.get_person_handles(sort_handles=False))
source_text = self.options.handler.options_dict['source_text']

View File

@ -143,9 +143,7 @@ class Calendar(Report):
self.text2 = options_class.handler.options_dict['text2']
self.text3 = options_class.handler.options_dict['text3']
self.filter_option = options_class.menu.get_option_by_name('filter')
filter_index = int(self.filter_option.get_value())
filters = self.filter_option.get_filters()
self.filter = filters[filter_index]
self.filter = self.filter_option.get_filter()
self.title = _("Calendar Report") #% name
@ -487,13 +485,13 @@ class CalendarOptions(MenuReportOptions):
filter.set_help(_("Select filter to restrict people that appear on calendar"))
menu.add_option(category_name,"filter", filter)
name_format = EnumeratedListOption(_("Name format"), (1, ""))
name_format = EnumeratedListOption(_("Name format"), -1)
for num, name, fmt_str, act in name_displayer.get_name_format():
name_format.add_item(num, name)
name_format.set_help(_("Select the format to display names"))
menu.add_option(category_name,"name_format", name_format)
country = EnumeratedListOption(_("Country for holidays"), (0,_("Don't include holidays")))
country = EnumeratedListOption(_("Country for holidays"), 0)
count = 0
for c in _countries:
country.add_item(count, c)
@ -501,15 +499,14 @@ class CalendarOptions(MenuReportOptions):
country.set_help(_("Select the country to see associated holidays"))
menu.add_option(category_name,"country", country)
start_dow = EnumeratedListOption(_("First day of week"), GrampsLocale.long_days[1].capitalize())
start_dow = EnumeratedListOption(_("First day of week"), 1)
for count in range(1,8):
# conversion between gramps numbering (sun=1) and iso numbering (mon=1) of weekdays below
start_dow.add_item((count+5) % 7 + 1, GrampsLocale.long_days[count].capitalize())
start_dow.set_help(_("Select the first day of the week for the calendar"))
menu.add_option(category_name, "start_dow", start_dow)
maiden_name = EnumeratedListOption(_("Birthday surname"),
("own", _("Wives use their own surname")))
maiden_name = EnumeratedListOption(_("Birthday surname"), "own")
maiden_name.add_item("spouse_first", _("Wives use husband's surname (from first family listed)"))
maiden_name.add_item("spouse_last", _("Wives use husband's surname (from last family listed)"))
maiden_name.add_item("own", _("Wives use their own surname"))