def add_menu_options(self, menu): """ Add options to the menu for the place report. """ category_name = _("Report Options") # Reload filters to pick any new ones CustomFilters = None from gramps.gen.filters import CustomFilters, GenericFilter opt = FilterOption(_("Select using filter"), 0) opt.set_help(_("Select places using a filter")) filter_list = [] filter_list.append(GenericFilter()) filter_list.extend(CustomFilters.get_filters('Place')) opt.set_filters(filter_list) menu.add_option(category_name, "filter", opt) places = PlaceListOption(_("Select places individually")) places.set_help(_("List of places to report on")) menu.add_option(category_name, "places", places) stdoptions.add_private_data_option(menu, category_name) stdoptions.add_name_format_option(menu, category_name) center = EnumeratedListOption(_("Center on"), "Event") center.set_items([ ("Event", _("Event")), ("Person", _("Person"))]) center.set_help(_("If report is event or person centered")) menu.add_option(category_name, "center", center) stdoptions.add_localization_option(menu, category_name)
def add_menu_options(self, menu): """ Add options to the menu for the place report. """ category_name = _("Report Options") # Reload filters to pick any new ones CustomFilters = None from gramps.gen.filters import CustomFilters, GenericFilter opt = FilterOption(_("Select using filter"), 0) opt.set_help(_("Select places using a filter")) filter_list = [] filter_list.append(GenericFilter()) filter_list.extend(CustomFilters.get_filters('Place')) opt.set_filters(filter_list) menu.add_option(category_name, "filter", opt) places = PlaceListOption(_("Select places individually")) places.set_help(_("List of places to report on")) menu.add_option(category_name, "places", places) reporttype = EnumeratedListOption(_("Type de Liste"), "ListeType") reporttype.set_items([ ("ListeEclair", _("Tiny Tafel")), ("cousingenweb", _("cousingenweb"))]) reporttype.set_help(_("Type de liste")) menu.add_option(category_name, "reporttype", reporttype) incpriv = BooleanOption(_("Include private data"), True) incpriv.set_help(_("Whether to include private data")) menu.add_option(category_name, "incpriv", incpriv)
def add_menu_options(self, menu): """ Add options to the menu for the place report. """ category_name = _("Report Options") # Reload filters to pick any new ones CustomFilters = None #p from Filters import CustomFilters, GenericFilter from gramps.gen.filters import CustomFilters, GenericFilter opt = FilterOption(_("Select using filter"), 0) opt.set_help(_("Select places using a filter")) filter_list = [] filter_list.append(GenericFilter()) filter_list.extend(CustomFilters.get_filters('Place')) opt.set_filters(filter_list) menu.add_option(category_name, "filter", opt) places = PlaceListOption(_("Select places individually")) places.set_help(_("List of places to report on")) menu.add_option(category_name, "places", places) center = EnumeratedListOption(_("Center on"), "Event") center.set_items([ ("Event", _("Event")), ("Person", _("Person"))]) center.set_help(_("If report is event or person centered")) menu.add_option(category_name, "center", center) incpriv = BooleanOption(_("Include private data"), True) incpriv.set_help(_("Whether to include private data")) menu.add_option(category_name, "incpriv", incpriv)
def add_menu_options(self, menu): """ Add the options for this report """ category_name = _("Report Options") title = StringOption(_('book|Title'), _('Title of the Book') ) title.set_help(_("Title string for the book.")) menu.add_option(category_name, "title", title) subtitle = StringOption(_('Subtitle'), _('Subtitle of the Book') ) subtitle.set_help(_("Subtitle string for the book.")) menu.add_option(category_name, "subtitle", subtitle) dateinfo = time.localtime(time.time()) #rname = self.__db.get_researcher().get_name() rname = "researcher name" footer_string = _('Copyright %(year)d %(name)s') % { 'year' : dateinfo[0], 'name' : rname } footer = StringOption(_('Footer'), footer_string ) footer.set_help(_("Footer string for the page.")) menu.add_option(category_name, "footer", footer) # Reload filters to pick any new ones CustomFilters = None from gramps.gen.filters import CustomFilters, GenericFilter opt = FilterOption(_("Select using filter"), 0) opt.set_help(_("Select places using a filter")) filter_list = [] filter_list.append(GenericFilter()) filter_list.extend(CustomFilters.get_filters('Source')) opt.set_filters(filter_list) menu.add_option(category_name, "filter", opt) showperson = BooleanOption(_("Show persons"), True) showperson.set_help(_("Whether to show events and persons mentioned in the note")) menu.add_option(category_name, "showperson", showperson) sort_by_citation = BooleanOption(_("Sort by Citation"), True) sort_by_citation.set_help(_("Whether to sort lines by Citation or Date")) menu.add_option(category_name, "sort_by_citation", sort_by_citation) sort_by_date = BooleanOption(_("Sort by Date"), True) sort_by_date.set_help(_("Whether to sort lines by Date or citation")) menu.add_option(category_name, "sort_by_date", sort_by_date) placeformat = EnumeratedListOption(_("Place Format"), "Default") placeformat.set_items([ ("default", _("Default")), ("first", _("First")), ("firstplace", _("Firstplace")), ("firstplace-country", _("Firstplace-Country")), ("country", _("Country")), ("long", _("Long"))]) placeformat.set_help(_("If Placename is given long or short")) menu.add_option(category_name, "placeformat", placeformat)
def add_menu_options(self, menu): """ Define the options for the menu. """ category_name = _("Tool Options") self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help(_("Select the people to sort")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self.__update_filters() sort_by = EnumeratedListOption(_('Sort by'), 0 ) idx = 0 for item in _get_sort_functions(Sort(self.__db)): sort_by.add_item(idx, item[0]) idx += 1 sort_by.set_help( _("Sorting method to use")) menu.add_option(category_name, "sort_by", sort_by) sort_desc = BooleanOption(_("Sort descending"), False) sort_desc.set_help(_("Set the sort order")) menu.add_option(category_name, "sort_desc", sort_desc) family_events = BooleanOption(_("Include family events"), True) family_events.set_help(_("Sort family events of the person")) menu.add_option(category_name, "family_events", family_events)
def add_menu_options(self, menu): category_name = _("Report Options") self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Determines what people are included in the report")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_private_data_option(menu, category_name) sortby = EnumeratedListOption(_('Sort by'), 0 ) idx = 0 for item in _get_sort_functions(Sort(self.__db)): sortby.add_item(idx, _(item[0])) idx += 1 sortby.set_help( _("Sorting method to use")) menu.add_option(category_name,"sortby",sortby) stdoptions.add_localization_option(menu, category_name)
def add_menu_options(self, menu): """ Add the options """ category_name = _("Options") self.__filter = FilterOption(_("Person Filter"), 0) self.__filter.set_help(_("Select filter to restrict people")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) attribute_text = StringOption(_("Attribute"), "") attribute_value = StringOption(_("Value"), "") attribute_text.set_help(_("Attribute type to add or edit")) attribute_value.set_help(_("Attribute value to add or edit")) menu.add_option(category_name, "attribute_text", attribute_text) menu.add_option(category_name, "attribute_value", attribute_value) self.__attribute_text = attribute_text self.__attribute_value = attribute_value remove = BooleanOption(_("Remove"), False) remove.set_help(_("Remove attribute type and value set")) menu.add_option(category_name, "remove", remove) self.__update_filters()
def add_menu_options(self, menu): category_name = _("Report Options") self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Determines what people are included in the report.")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) top_size = NumberOption(_("Number of ranks to display"), 3, 1, 100) menu.add_option(category_name, "top_size", top_size) callname = EnumeratedListOption(_("Use call name"), CALLNAME_DONTUSE) callname.set_items([ (CALLNAME_DONTUSE, _("Don't use call name")), (CALLNAME_REPLACE, _("Replace first names with call name")), (CALLNAME_UNDERLINE_ADD, _("Underline call name in first names / " "add call name to first name"))]) menu.add_option(category_name, "callname", callname) footer = StringOption(_("Footer text"), "") menu.add_option(category_name, "footer", footer) category_name = _("Report Options (2)") self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_private_data_option(menu, category_name) stdoptions.add_living_people_option(menu, category_name) stdoptions.add_localization_option(menu, category_name) p_count = 0 for (text, varname, default) in RECORDS: if varname.startswith('person'): p_count += 1 p_half = p_count // 2 p_idx = 0 for (text, varname, default) in RECORDS: option = BooleanOption(_(text), default) if varname.startswith('person'): if p_idx >= p_half: category_name = _("Person 2") else: category_name = _("Person 1") p_idx += 1 elif varname.startswith('family'): category_name = _("Family") menu.add_option(category_name, varname, option)
def add_menu_options(self, menu): """ Add the options for this report """ category_name = _("Report Options") title = StringOption(_('book|Title'), _('Title of the Book') ) title.set_help(_("Title string for the book.")) menu.add_option(category_name, "title", title) subtitle = StringOption(_('Subtitle'), _('Subtitle of the Book') ) subtitle.set_help(_("Subtitle string for the book.")) menu.add_option(category_name, "subtitle", subtitle) dateinfo = time.localtime(time.time()) #rname = self.__db.get_researcher().get_name() rname = "researcher name" footer_string = _('Copyright %(year)d %(name)s') % { 'year' : dateinfo[0], 'name' : rname } footer = StringOption(_('Footer'), footer_string ) footer.set_help(_("Footer string for the page.")) menu.add_option(category_name, "footer", footer) # Reload filters to pick any new ones CustomFilters = None #p from Filters import CustomFilters, GenericFilter from gramps.gen.filters import CustomFilters, GenericFilter opt = FilterOption(_("Select using filter"), 0) opt.set_help(_("Select places using a filter")) filter_list = [] filter_list.append(GenericFilter()) filter_list.extend(CustomFilters.get_filters('Source')) opt.set_filters(filter_list) menu.add_option(category_name, "filter", opt) showinlaw = BooleanOption(_("Show inlaw"), True) showinlaw.set_help(_("Whether to show inlaw persons")) menu.add_option(category_name, "showinlaw", showinlaw) showperson = BooleanOption(_("Show persons"), True) showperson.set_help(_("Whether to show events and persons mentioned in the note")) menu.add_option(category_name, "showperson", showperson) incphotos = BooleanOption(_("Include Photos"), True) incphotos.set_help(_("Whether to show photos mentioned in the citation")) menu.add_option(category_name, "incphotos", incphotos)
def add_menu_options(self, menu): """ Add options to the menu for the place report. """ category_name = _("Report Options") # Reload filters to pick any new ones CustomFilters = None from gramps.gen.filters import CustomFilters, GenericFilter opt = FilterOption(_("Select using filter"), 0) opt.set_help(_("Select places using a filter")) filter_list = [] filter_list.append(GenericFilter()) filter_list.extend(CustomFilters.get_filters('Place')) opt.set_filters(filter_list) menu.add_option(category_name, "filter", opt) stdoptions.add_name_format_option(menu, category_name) places = PlaceListOption(_("Select places individually")) places.set_help(_("List of places to report on")) menu.add_option(category_name, "places", places) placeformat = EnumeratedListOption(_("Place Format"), "Default") placeformat.set_items([ ("default", _("Default")), ("first", _("First")), ("firstplace", _("Firstplace")), ("firstplace-country", _("Firstplace-Country")), ("country", _("Country")), ("long", _("Long"))]) placeformat.set_help(_("If Placename is given long or short")) menu.add_option(category_name, "placeformat", placeformat) incpriv = BooleanOption(_("Include private data"), True) incpriv.set_help(_("Whether to include private data")) menu.add_option(category_name, "incpriv", incpriv) showgodparents = BooleanOption(_("show godparents"), True) showgodparents.set_help(_("Whether to include and show godparents")) menu.add_option(category_name, "showgodparents", showgodparents) stdoptions.add_localization_option(menu, category_name)
class SetAttributeOptions(MenuToolOptions): """ Set Attribute options """ def __init__(self, name, person_id=None, dbstate=None): self.__db = dbstate.get_database() MenuToolOptions.__init__(self, name, person_id, dbstate) def add_menu_options(self, menu): """ Add the options """ category_name = _("Options") self.__filter = FilterOption(_("Person Filter"), 0) self.__filter.set_help(_("Select filter to restrict people")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) attribute_text = StringOption(_("Attribute"), "") attribute_value = StringOption(_("Value"), "") attribute_text.set_help(_("Attribute type to add or edit")) attribute_value.set_help(_("Attribute value to add or edit")) menu.add_option(category_name, "attribute_text", attribute_text) menu.add_option(category_name, "attribute_value", attribute_value) self.__attribute_text = attribute_text self.__attribute_value = attribute_value remove = BooleanOption(_("Remove"), False) remove.set_help(_("Remove attribute type and value set")) menu.add_option(category_name, "remove", remove) self.__update_filters() def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) filter_list = ReportUtils.get_person_filters(person, False) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value in [1, 2, 3, 4]: # Filters 0, 2, 3, 4 and 5 rely on the center person self.__pid.set_available(True) else: # The rest don't self.__pid.set_available(False)
def add_menu_options(self, menu): """ Add options to the menu for the place report. """ category_name = _("Report Options") # Reload filters to pick any new ones CustomFilters = None from gramps.gen.filters import CustomFilters, GenericFilter opt = FilterOption(_("Select using filter"), 0) opt.set_help(_("Select places using a filter")) filter_list = [] filter_list.append(GenericFilter()) filter_list.extend(CustomFilters.get_filters('Place')) opt.set_filters(filter_list) menu.add_option(category_name, "filter", opt) stdoptions.add_name_format_option(menu, category_name) places = PlaceListOption(_("Select places individually")) places.set_help(_("List of places to report on")) menu.add_option(category_name, "places", places) # classwidth = EnumeratedListOption(_("Class wdith"), "classwidth") classwidth = EnumeratedListOption(_("Class wdith"), 10) classwidth.set_items([ (10, _("10 Years")), (20, _("20 Years")), (40, _("40 Years")), (50, _("50 Years"))]) classwidth.set_help(_("classwidth fpr Analysis")) menu.add_option(category_name, "classwidth", classwidth) incpriv = BooleanOption(_("Include private data"), True) incpriv.set_help(_("Whether to include private data")) menu.add_option(category_name, "incpriv", incpriv) stdoptions.add_localization_option(menu, category_name)
def add_menu_options(self, menu): category_name = _("Report Options") self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Select filter to restrict people that appear in the report")) menu.add_option(category_name, "filter", self.__filter) self.__pid = PersonOption(_("Center Person")) self.__pid.set_help(_("The center person for the report")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self.__update_filters() # We must figure out the value of the first option before we can # create the EnumeratedListOption fmt_list = global_name_display.get_name_format() name_format = EnumeratedListOption(_("Name format"), 0) name_format.add_item(0, _("Default")) for num, name, fmt_str, act in fmt_list: 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) numbering = EnumeratedListOption(_("Numbering system"), "Simple") numbering.set_items([ ("Simple", _("Simple numbering")), ("de Villiers/Pama", _("de Villiers/Pama numbering")), ("Meurgey de Tupigny", _("Meurgey de Tupigny numbering"))]) numbering.set_help(_("The numbering system to be used")) menu.add_option(category_name, "numbering", numbering) gen = NumberOption(_("Generations"), 10, 1, 15) gen.set_help(_("The number of generations to include in the report")) menu.add_option(category_name, "gen", gen) marrs = BooleanOption(_('Show marriage info'), False) marrs.set_help(_("Whether to show marriage information in the report.")) menu.add_option(category_name, "marrs", marrs) divs = BooleanOption(_('Show divorce info'), False) divs.set_help(_("Whether to show divorce information in the report.")) menu.add_option(category_name, "divs", divs) dups = BooleanOption(_('Show duplicate trees'), True) dups.set_help(_("Whether to show duplicate family trees in the report.")) menu.add_option(category_name, "dups", dups)
def add_menu_options(self, menu): """ Add the options """ category_name = _("Options") self.__filter = FilterOption(_("Person Filter"), 0) self.__filter.set_help(_("Select filter to restrict people")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self.__update_filters()
class DownloadOptions(MenuToolOptions): """ Attach Source options """ def __init__(self, name, person_id=None, dbstate=None): self.__db = dbstate.get_database() MenuToolOptions.__init__(self, name, person_id, dbstate) def add_menu_options(self, menu): """ Add the options """ category_name = _("Options") self.__filter = FilterOption(_("Person Filter"), 0) self.__filter.set_help(_("Select filter to restrict people")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self.__update_filters() def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) filter_list = ReportUtils.get_person_filters(person, False) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value in [1, 2, 3, 4]: # Filters 0, 2, 3, 4 and 5 rely on the center person self.__pid.set_available(True) else: # The rest don't self.__pid.set_available(False)
def add_menu_options(self, menu): """ Add the options for this report """ category_name = _("Report Options") title = StringOption(_('Report Title'), _('Title of the Report') ) title.set_help(_("Title string for the report.")) menu.add_option(category_name, "title", title) subtitle = StringOption(_('Subtitle'), _('Subtitle of the Report') ) subtitle.set_help(_("Subtitle string for the report.")) menu.add_option(category_name, "subtitle", subtitle) dateinfo = time.localtime(time.time()) #rname = self.__db.get_researcher().get_name() rname = "researcher name" footer_string = _('Copyright %(year)d %(name)s') % { 'year' : dateinfo[0], 'name' : rname } footer = StringOption(_('Footer'), footer_string ) footer.set_help(_("Footer string for the page.")) menu.add_option(category_name, "footer", footer) # Reload filters to pick any new ones CustomFilters = None from gramps.gen.filters import CustomFilters, GenericFilter self.__filter = FilterOption(_("Select using filter"), 0) self.__filter.set_help(_("Select sources using a filter")) filter_list = [] filter_list.append(GenericFilter()) filter_list.extend(CustomFilters.get_filters('Source')) self.__filter.set_filters(filter_list) menu.add_option(category_name, "filter", self.__filter) showperson = BooleanOption(_("Show persons"), True) showperson.set_help(_("Whether to show events and persons mentioned in the note")) menu.add_option(category_name, "showperson", showperson) locale_opt = stdoptions.add_localization_option(menu, category_name) stdoptions.add_date_format_option(menu, category_name, locale_opt)
def add_menu_options(self, menu): """ Add the options """ category_name = _("Options") self.__filter = FilterOption(_("Person Filter"), 0) self.__filter.set_help(_("Select filter to restrict people")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self.__update_filters() source_type = EnumeratedListOption(_("Source type"), 0) source_type.add_item(0, _("New source")) source_type.add_item(1, _("Existing source")) source_type.set_help(_("Select the type of source to attach")) menu.add_option(category_name, "source_type", source_type) source_type.connect('value-changed', self.__update_source_type) self.__source_type = source_type source_text = StringOption(_("New Source Title"), "") source_text.set_help(_("Text of source to attach")) menu.add_option(category_name, "source_text", source_text) self.__source_text = source_text source_id = StringOption(_("Existing Source ID"), "") source_id.set_help(_("ID of source to attach")) menu.add_option(category_name, "source_id", source_id) self.__source_id = source_id self.__update_source_type()
class DescendantBookOptions(MenuReportOptions): """ Defines options and provides handling interface. """ def __init__(self, name, dbase): self.__db = dbase self.__pid = None self.__filter = None MenuReportOptions.__init__(self, name, dbase) def add_menu_options(self, menu): category_name = _("Report Options") self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Select filter to restrict people that appear in the report")) menu.add_option(category_name, "filter", self.__filter) self.__pid = PersonOption(_("Center Person")) self.__pid.set_help(_("The center person for the report")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self.__update_filters() # We must figure out the value of the first option before we can # create the EnumeratedListOption fmt_list = global_name_display.get_name_format() name_format = EnumeratedListOption(_("Name format"), 0) name_format.add_item(0, _("Default")) for num, name, fmt_str, act in fmt_list: 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) numbering = EnumeratedListOption(_("Numbering system"), "Simple") numbering.set_items([ ("Simple", _("Simple numbering")), ("de Villiers/Pama", _("de Villiers/Pama numbering")), ("Meurgey de Tupigny", _("Meurgey de Tupigny numbering")) ]) numbering.set_help(_("The numbering system to be used")) menu.add_option(category_name, "numbering", numbering) gen = NumberOption(_("Generations"), 10, 1, 15) gen.set_help(_("The number of generations to include in the report")) menu.add_option(category_name, "gen", gen) marrs = BooleanOption(_('Show marriage info'), False) marrs.set_help( _("Whether to show marriage information in the report.")) menu.add_option(category_name, "marrs", marrs) divs = BooleanOption(_('Show divorce info'), False) divs.set_help(_("Whether to show divorce information in the report.")) menu.add_option(category_name, "divs", divs) dups = BooleanOption(_('Show duplicate trees'), True) dups.set_help( _("Whether to show duplicate family trees in the report.")) menu.add_option(category_name, "dups", dups) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) filter_list = ReportUtils.get_person_filters(person, False) self.__filter.set_filters(filter_list) def make_default_style(self, default_style): """Make the default output style for the Descendant Report.""" f = FontStyle() f.set(face=FONT_SANS_SERIF, size=12, bold=1) p = ParagraphStyle() p.set_header_level(1) p.set_bottom_border(1) p.set_top_margin(ReportUtils.pt2cm(3)) p.set_bottom_margin(ReportUtils.pt2cm(3)) p.set_font(f) p.set_description(_("The style used for the title of the page.")) default_style.add_paragraph_style("DR-Title", p) f = FontStyle() f.set(face=FONT_SANS_SERIF, size=12, italic=1) p = ParagraphStyle() p.set_font(f) p.set_header_level(2) p.set_top_margin(ReportUtils.pt2cm(3)) p.set_bottom_margin(ReportUtils.pt2cm(3)) p.set_description( _('The style used for the table of contents header.')) default_style.add_paragraph_style("DR-TOC-Title", p) f = FontStyle() f.set_size(10) p = ParagraphStyle() p.set_font(f) p.set_top_margin(0.25) p.set_bottom_margin(0.25) p.set_first_indent(1.0) p.set_description( _("The style used for the table of contents detail.")) default_style.add_paragraph_style("DR-TOC-Detail", p) f = FontStyle() f.set_size(10) for i in range(1, 33): p = ParagraphStyle() p.set_font(f) p.set_top_margin(ReportUtils.pt2cm(f.get_size() * 0.125)) p.set_bottom_margin(ReportUtils.pt2cm(f.get_size() * 0.125)) p.set_first_indent(-0.8) p.set_left_margin(min(10.0, float(i - 0.5))) p.set_description( _("The style used for the " "level %d display.") % i) default_style.add_paragraph_style("DR-Level%d" % min(i, 32), p) p = ParagraphStyle() p.set_font(f) p.set_top_margin(ReportUtils.pt2cm(f.get_size() * 0.125)) p.set_bottom_margin(ReportUtils.pt2cm(f.get_size() * 0.125)) p.set_left_margin(min(10.0, float(i - 0.5))) p.set_description( _("The style used for the " "spouse level %d display.") % i) default_style.add_paragraph_style("DR-Spouse%d" % min(i, 32), p)
def add_menu_options(self, menu): ################################ category_name = _("Report Options") add_option = partial(menu.add_option, category_name) ################################ self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Determines what people are included in the graph")) add_option("filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Center Person")) self.__pid.set_help(_("The center person for the report")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) arrow = EnumeratedListOption(_("Arrowhead direction"), 'd') for i in range(0, len(_ARROWS)): arrow.add_item(_ARROWS[i]["value"], _ARROWS[i]["name"]) arrow.set_help(_("Choose the direction that the arrows point.")) add_option("arrow", arrow) color = EnumeratedListOption(_("Graph coloring"), 'filled') for i in range(0, len(_COLORS)): color.add_item(_COLORS[i]["value"], _COLORS[i]["name"]) color.set_help( _("Males will be shown with blue, females " "with red. If the sex of an individual " "is unknown it will be shown with gray.")) add_option("color", color) # see bug report #2180 roundedcorners = BooleanOption(_("Use rounded corners"), False) roundedcorners.set_help( _("Use rounded corners to differentiate " "between women and men.")) add_option("useroundedcorners", roundedcorners) stdoptions.add_gramps_id_option(menu, category_name, ownline=True) ################################ category_name = _("Report Options (2)") add_option = partial(menu.add_option, category_name) ################################ self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_private_data_option(menu, category_name) stdoptions.add_living_people_option(menu, category_name) locale_opt = stdoptions.add_localization_option(menu, category_name) stdoptions.add_date_format_option(menu, category_name, locale_opt) ################################ add_option = partial(menu.add_option, _("Include")) ################################ self.event_choice = EnumeratedListOption(_('Dates and/or Places'), 0) self.event_choice.add_item(0, _('Do not include any dates or places')) self.event_choice.add_item( 1, _('Include (birth, marriage, death) ' 'dates, but no places')) self.event_choice.add_item( 2, _('Include (birth, marriage, death) ' 'dates, and places')) self.event_choice.add_item( 3, _('Include (birth, marriage, death) ' 'dates, and places if no dates')) self.event_choice.add_item( 4, _('Include (birth, marriage, death) ' 'years, but no places')) self.event_choice.add_item( 5, _('Include (birth, marriage, death) ' 'years, and places')) self.event_choice.add_item( 6, _('Include (birth, marriage, death) ' 'places, but no dates')) self.event_choice.add_item( 7, _('Include (birth, marriage, death) ' 'dates and places on same line')) self.event_choice.set_help(_("Whether to include dates and/or places")) add_option("event_choice", self.event_choice) url = BooleanOption(_("Include URLs"), False) url.set_help( _("Include a URL in each graph node so " "that PDF and imagemap files can be " "generated that contain active links " "to the files generated by the 'Narrated " "Web Site' report.")) add_option("url", url) self.__show_relships = BooleanOption( _("Include relationship to center person"), False) self.__show_relships.set_help( _("Whether to show every person's " "relationship to the center person")) add_option("increlname", self.__show_relships) self.__show_relships.connect('value-changed', self.__show_relships_changed) self.__include_images = BooleanOption( _('Include thumbnail images of people'), False) self.__include_images.set_help( _("Whether to include thumbnails of people.")) add_option("includeImages", self.__include_images) self.__include_images.connect('value-changed', self.__image_changed) self.__image_on_side = EnumeratedListOption(_("Thumbnail Location"), 0) self.__image_on_side.add_item(0, _('Above the name')) self.__image_on_side.add_item(1, _('Beside the name')) self.__image_on_side.set_help( _("Where the thumbnail image should appear relative to the name")) add_option("imageOnTheSide", self.__image_on_side) #occupation = BooleanOption(_("Include occupation"), False) occupation = EnumeratedListOption(_('Include occupation'), 0) occupation.add_item(0, _('Do not include any occupation')) occupation.add_item( 1, _('Include description ' 'of most recent occupation')) occupation.add_item( 2, _('Include date, description and place ' 'of all occupations')) occupation.set_help(_("Whether to include the last occupation")) add_option("occupation", occupation) if __debug__: self.__show_ga_gb = BooleanOption( _("Include relationship " "debugging numbers also"), False) self.__show_ga_gb.set_help( _("Whether to include 'Ga' and 'Gb' " "also, to debug the relationship " "calculator")) add_option("advrelinfo", self.__show_ga_gb) ################################ add_option = partial(menu.add_option, _("Graph Style")) ################################ color_males = ColorOption(_('Males'), '#e0e0ff') color_males.set_help(_('The color to use to display men.')) add_option('colormales', color_males) color_females = ColorOption(_('Females'), '#ffe0e0') color_females.set_help(_('The color to use to display women.')) add_option('colorfemales', color_females) color_unknown = ColorOption(_('Unknown'), '#e0e0e0') color_unknown.set_help( _('The color to use when the gender is unknown.')) add_option('colorunknown', color_unknown) color_family = ColorOption(_('Families'), '#ffffe0') color_family.set_help(_('The color to use to display families.')) add_option('colorfamilies', color_family) dashed = BooleanOption( _("Indicate non-birth relationships with dotted lines"), True) dashed.set_help( _("Non-birth relationships will show up " "as dotted lines in the graph.")) add_option("dashed", dashed) showfamily = BooleanOption(_("Show family nodes"), True) showfamily.set_help( _("Families will show up as ellipses, linked " "to parents and children.")) add_option("showfamily", showfamily)
class BirthdayOptions(MenuReportOptions): """ Options for the Birthday/Anniversary Report """ def __init__(self, name, dbase): self.__db = dbase self.__pid = None self.__filter = None MenuReportOptions.__init__(self, name, dbase) def add_menu_options(self, menu): """ Add the options for the text birthday report """ category_name = _("Report Options") year = NumberOption(_("Year of report"), time.localtime()[0], 1000, 3000) year.set_help(_("Year of report")) menu.add_option(category_name, "year", year) self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Select filter to restrict people that appear on report")) menu.add_option(category_name, "filter", self.__filter) self.__pid = PersonOption(_("Center Person")) self.__pid.set_help(_("The center person for the report")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_private_data_option(menu, category_name) alive = BooleanOption(_("Include only living people"), True) alive.set_help(_("Include only living people in the report")) menu.add_option(category_name, "alive", alive) country = EnumeratedListOption(_("Country for holidays"), 0) holiday_table = libholiday.HolidayTable() countries = holiday_table.get_countries() countries.sort() if (len(countries) == 0 or (len(countries) > 0 and countries[0] != '')): countries.insert(0, '') count = 0 for c in holiday_table.get_countries(): country.add_item(count, c) count += 1 country.set_help(_("Select the country to see associated holidays")) menu.add_option(category_name, "country", country) start_dow = EnumeratedListOption(_("First day of week"), 1) long_days = date_displayer.long_days 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, long_days[count].capitalize()) start_dow.set_help( _("Select the first day of the week for the report")) menu.add_option(category_name, "start_dow", start_dow) 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")) maiden_name.set_help(_("Select married women's displayed surname")) menu.add_option(category_name, "maiden_name", maiden_name) birthdays = BooleanOption(_("Include birthdays"), True) birthdays.set_help(_("Include birthdays in the report")) menu.add_option(category_name, "birthdays", birthdays) anniversaries = BooleanOption(_("Include anniversaries"), True) anniversaries.set_help(_("Include anniversaries in the report")) menu.add_option(category_name, "anniversaries", anniversaries) option = BooleanOption(_("Include relationships to center person"), False) option.set_help(_("Include relationships to center person (slower)")) menu.add_option(category_name, "relationships", option) stdoptions.add_localization_option(menu, category_name) category_name = _("Text Options") titletext = StringOption(_("Title text"), _(_TITLE0)) titletext.set_help(_("Title of report")) menu.add_option(category_name, "titletext", titletext) text1 = StringOption(_("Text Area 1"), _(_TITLE1)) text1.set_help(_("First line of text at bottom of report")) menu.add_option(category_name, "text1", text1) text2 = StringOption(_("Text Area 2"), _(_TITLE2)) text2.set_help(_("Second line of text at bottom of report")) menu.add_option(category_name, "text2", text2) text3 = StringOption( _("Text Area 3"), URL_HOMEPAGE, ) text3.set_help(_("Third line of text at bottom of report")) menu.add_option(category_name, "text3", text3) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) nfv = self._nf.get_value() filter_list = ReportUtils.get_person_filters(person, include_single=False, name_format=nfv) self.__filter.set_filters(filter_list) def make_my_style(self, default_style, name, description, size=9, font=FONT_SERIF, justified="left", color=None, align=PARA_ALIGN_CENTER, shadow=None, italic=0, bold=0, borders=0, indent=None): """ Create paragraph and graphic styles of the same name """ # Paragraph: f = FontStyle() f.set_size(size) f.set_type_face(font) f.set_italic(italic) f.set_bold(bold) p = ParagraphStyle() p.set_font(f) p.set_alignment(align) p.set_description(description) p.set_top_border(borders) p.set_left_border(borders) p.set_bottom_border(borders) p.set_right_border(borders) if indent: p.set(first_indent=indent) if justified == "left": p.set_alignment(PARA_ALIGN_LEFT) elif justified == "right": p.set_alignment(PARA_ALIGN_RIGHT) elif justified == "center": p.set_alignment(PARA_ALIGN_CENTER) default_style.add_paragraph_style(name, p) # Graphics: g = GraphicsStyle() g.set_paragraph_style(name) if shadow: g.set_shadow(*shadow) if color is not None: g.set_fill_color(color) if not borders: g.set_line_width(0) default_style.add_draw_style(name, g) def make_default_style(self, default_style): """ Add the styles used in this report """ self.make_my_style(default_style, "BIR-Title", _('Title text style'), 14, bold=1, justified="center") self.make_my_style(default_style, "BIR-Datastyle", _('Data text display'), 12, indent=1.0) self.make_my_style(default_style, "BIR-Daystyle", _('Day text style'), 12, indent=.5, italic=1, bold=1) self.make_my_style(default_style, "BIR-Monthstyle", _('Month text style'), 14, bold=1) self.make_my_style(default_style, "BIR-Text1style", _('Text at bottom, line 1'), 12, justified="center") self.make_my_style(default_style, "BIR-Text2style", _('Text at bottom, line 2'), 12, justified="center") self.make_my_style(default_style, "BIR-Text3style", _('Text at bottom, line 3'), 12, justified="center")
def add_menu_options(self, menu): """ Add the options """ category_name = _("Options") self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help(_("Select filter to restrict people")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self.__update_filters() source_text = StringOption(_("Source text"), _("Calculated Date Estimates")) source_text.set_help(_("Source to remove and/or add")) menu.add_option(category_name, "source_text", source_text) remove = BooleanOption( _("Remove previously added events, notes, and source"), True) remove.set_help( _("Remove calculated events, notes, and source; occurs immediately on Execute" )) menu.add_option(category_name, "remove", remove) birth = EnumeratedListOption(_("Birth"), 0) birth.add_item(0, _("Do not add birth events")) birth.add_item(1, _("Add birth events without dates")) birth.add_item(2, _("Add birth events with dates")) birth.set_help(_("Add a birth events with or without estimated dates")) menu.add_option(category_name, "add_birth", birth) death = EnumeratedListOption(_("Death"), 0) death.add_item(0, _("Do not add death events")) death.add_item(1, _("Add death events without dates")) death.add_item(2, _("Add death events with dates")) death.set_help(_("Add death events with or without estimated dates")) menu.add_option(category_name, "add_death", death) # ----------------------------------------------------- num = NumberOption(_("Maximum age"), config.get('behavior.max-age-prob-alive'), 0, 200) num.set_help(_("Maximum age that one can live to")) menu.add_option(category_name, "MAX_AGE_PROB_ALIVE", num) num = NumberOption(_("Maximum sibling age difference"), config.get('behavior.max-sib-age-diff'), 0, 200) num.set_help(_("Maximum age difference between siblings")) menu.add_option(category_name, "MAX_SIB_AGE_DIFF", num) num = NumberOption(_("Average years between generations"), config.get('behavior.avg-generation-gap'), 0, 200) num.set_help(_("Average years between two generations")) menu.add_option(category_name, "AVG_GENERATION_GAP", num) dates = EnumeratedListOption(_("Estimated Dates"), 0) dates.add_item(0, _("Approximate (about)")) dates.add_item(1, _("Extremes (after and before)")) dates.set_help(_("Dates on events are either about or after/before")) menu.add_option(category_name, "dates", dates)
def add_menu_options(self, menu): ########################## category_name = _("Report Options") add_option = partial(menu.add_option, category_name) ########################## self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Select the filter to be applied to the report.")) add_option("filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__fid = FamilyOption(_("Center Family")) self.__fid.set_help(_("The center family for the filter")) add_option("family_id", self.__fid) self.__fid.connect('value-changed', self.__update_filters) self.__recursive = BooleanOption(_('Recursive (down)'), False) self.__recursive.set_help( _("Create reports for all descendants " "of this family.")) add_option("recursive", self.__recursive) self.__recursive.connect('value-changed', self.__recursive_changed) ########################## category_name = _("Report Options (2)") add_option = partial(menu.add_option, category_name) ########################## self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_place_format_option(menu, category_name) stdoptions.add_private_data_option(menu, category_name) stdoptions.add_living_people_option(menu, category_name) locale_opt = stdoptions.add_localization_option(menu, category_name) stdoptions.add_date_format_option(menu, category_name, locale_opt) ########################## add_option = partial(menu.add_option, _("Include")) ########################## inc_par_mar = BooleanOption(_("Parent Marriage"), True) inc_par_mar.set_help( _("Whether to include marriage information for parents.")) add_option("incParMar", inc_par_mar) inc_par_events = BooleanOption(_("Parent Events"), False) inc_par_events.set_help(_("Whether to include events for parents.")) add_option("incParEvents", inc_par_events) inc_par_addr = BooleanOption(_("Parent Addresses"), False) inc_par_addr.set_help(_("Whether to include addresses for parents.")) add_option("incParAddr", inc_par_addr) inc_par_notes = BooleanOption(_("Parent Notes"), False) inc_par_notes.set_help(_("Whether to include notes for parents.")) add_option("incParNotes", inc_par_notes) incattrs = BooleanOption(_("Parent Attributes"), False) incattrs.set_help(_("Whether to include attributes.")) add_option("incattrs", incattrs) inc_par_names = BooleanOption(_("Alternate Parent Names"), False) inc_par_names.set_help( _("Whether to include alternate names for parents.")) add_option("incParNames", inc_par_names) ########################## category_name = _("Include (2)") add_option = partial(menu.add_option, category_name) ########################## stdoptions.add_gramps_id_option(menu, category_name) inc_fam_notes = BooleanOption(_("Family Notes"), False) inc_fam_notes.set_help(_("Whether to include notes for families.")) add_option("incFamNotes", inc_fam_notes) inc_rel_dates = BooleanOption(_("Dates of Relatives"), False) inc_rel_dates.set_help( _("Whether to include dates for relatives " "(father, mother, spouse).")) add_option("incRelDates", inc_rel_dates) inc_chi_mar = BooleanOption(_("Children Marriages"), True) inc_chi_mar.set_help( _("Whether to include marriage information for children.")) add_option("incChiMar", inc_chi_mar) self.__generations = BooleanOption( _("Generation numbers " "(recursive only)"), False) self.__generations.set_help( _("Whether to include the generation " "on each report (recursive only).")) add_option("generations", self.__generations) missinginfo = BooleanOption( _("Print fields for missing " "information"), True) missinginfo.set_help( _("Whether to include fields for missing " "information.")) add_option("missinginfo", missinginfo)
def add_menu_options(self, menu): """ Add options to the menu for the statistics report. """ ################################ category_name = _("Report Options") add_option = partial(menu.add_option, category_name) ################################ self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Determines what people are included " "in the report.")) add_option("filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter.")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) sortby = EnumeratedListOption(_('Sort chart items by'), _options.SORT_VALUE) for item_idx in range(len(_options.opt_sorts)): item = _options.opt_sorts[item_idx] sortby.add_item(item_idx, item[2]) sortby.set_help(_("Select how the statistical data is sorted.")) add_option("sortby", sortby) reverse = BooleanOption(_("Sort in reverse order"), False) reverse.set_help(_("Check to reverse the sorting order.")) add_option("reverse", reverse) this_year = time.localtime()[0] year_from = NumberOption(_("People Born After"), 1700, 1, this_year) year_from.set_help(_("Birth year from which to include people.")) add_option("year_from", year_from) year_to = NumberOption(_("People Born Before"), this_year, 1, this_year) year_to.set_help(_("Birth year until which to include people")) add_option("year_to", year_to) no_years = BooleanOption(_("Include people without known birth years"), False) no_years.set_help( _("Whether to include people without " "known birth years.")) add_option("no_years", no_years) gender = EnumeratedListOption(_('Genders included'), Person.UNKNOWN) for item_idx in range(len(_options.opt_genders)): item = _options.opt_genders[item_idx] gender.add_item(item[0], item[2]) gender.set_help( _("Select which genders are included into " "statistics.")) add_option("gender", gender) bar_items = NumberOption(_("Max. items for a pie"), 8, 0, 20) bar_items.set_help( _("With fewer items pie chart and legend will be " "used instead of a bar chart.")) add_option("bar_items", bar_items) show_empty_information = BooleanOption( _("Include counts of missing information"), False) show_empty_information.set_help( _("Whether to include counts of the " "number of people who lack the given " "information.")) add_option("show_empty_information", show_empty_information) ################################ category_name = _("Report Options (2)") add_option = partial(menu.add_option, category_name) ################################ self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_private_data_option(menu, category_name) stdoptions.add_living_people_option(menu, category_name) stdoptions.add_localization_option(menu, category_name) ################################ # List of available charts on separate option tabs ################################ idx = 0 third = (len(_Extract.extractors) + 1) // 3 chart_types = [] for (chart_opt, ctuple) in _Extract.extractors.items(): chart_types.append((_(ctuple[1]), chart_opt, ctuple)) sorted_chart_types = sorted(chart_types, key=lambda x: glocale.sort_key(x[0])) for (translated_option_name, opt_name, ctuple) in sorted_chart_types: if idx >= (third * 2): category_name = _("Charts 3") elif idx >= third: category_name = _("Charts 2") else: category_name = _("Charts 1") opt = BooleanOption(translated_option_name, False) opt.set_help(_("Include charts with indicated data.")) menu.add_option(category_name, opt_name, opt) idx += 1 # Enable a couple of charts by default menu.get_option_by_name("data_gender").set_value(True) menu.get_option_by_name("data_ccount").set_value(True) menu.get_option_by_name("data_bmonth").set_value(True)
class RecordsReportOptions(MenuReportOptions): """ Defines options and provides handling interface. """ def __init__(self, name, dbase): self.__pid = None self.__filter = None self.__db = dbase self._nf = None MenuReportOptions.__init__(self, name, dbase) def get_subject(self): """ Return a string that describes the subject of the report. """ return self.__filter.get_filter().get_name() def add_menu_options(self, menu): category_name = _("Report Options") self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Determines what people are included in the report.")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) top_size = NumberOption(_("Number of ranks to display"), 3, 1, 100) menu.add_option(category_name, "top_size", top_size) callname = EnumeratedListOption(_("Use call name"), CALLNAME_DONTUSE) callname.set_items([ (CALLNAME_DONTUSE, _("Don't use call name")), (CALLNAME_REPLACE, _("Replace first names with call name")), (CALLNAME_UNDERLINE_ADD, _("Underline call name in first names / " "add call name to first name"))]) menu.add_option(category_name, "callname", callname) footer = StringOption(_("Footer text"), "") menu.add_option(category_name, "footer", footer) category_name = _("Report Options (2)") self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_private_data_option(menu, category_name) stdoptions.add_living_people_option(menu, category_name) stdoptions.add_localization_option(menu, category_name) p_count = 0 for (text, varname, default) in RECORDS: if varname.startswith('person'): p_count += 1 p_half = p_count // 2 p_idx = 0 for (text, varname, default) in RECORDS: option = BooleanOption(_(text), default) if varname.startswith('person'): if p_idx >= p_half: category_name = _("Person 2") else: category_name = _("Person 1") p_idx += 1 elif varname.startswith('family'): category_name = _("Family") menu.add_option(category_name, varname, option) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) nfv = self._nf.get_value() filter_list = utils.get_person_filters(person, include_single=False, name_format=nfv) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value == 0: # "Entire Database" (as "include_single=False") self.__pid.set_available(False) else: # The other filters need a center person (assume custom ones too) self.__pid.set_available(True) def make_default_style(self, default_style): #Paragraph Styles font = FontStyle() font.set_type_face(FONT_SANS_SERIF) font.set_size(16) font.set_bold(True) para = ParagraphStyle() para.set_font(font) para.set_alignment(PARA_ALIGN_CENTER) para.set_description(_("The style used for the title.")) default_style.add_paragraph_style('REC-Title', para) font = FontStyle() font.set_type_face(FONT_SANS_SERIF) font.set_size(12) font.set_bold(True) para = ParagraphStyle() para.set_font(font) para.set_alignment(PARA_ALIGN_CENTER) para.set_description(_("The style used for the subtitle.")) default_style.add_paragraph_style('REC-Subtitle', para) font = FontStyle() font.set_size(12) font.set_bold(True) para = ParagraphStyle() para.set_font(font) para.set_top_margin(utils.pt2cm(6)) para.set_description(_('The style used for the section headers.')) default_style.add_paragraph_style('REC-Heading', para) font = FontStyle() font.set_size(10) para = ParagraphStyle() para.set_font(font) para.set_left_margin(0.5) para.set_description(_('The basic style used for the text display.')) default_style.add_paragraph_style('REC-Normal', para) font = FontStyle() font.set_size(8) para = ParagraphStyle() para.set_font(font) para.set_alignment(PARA_ALIGN_CENTER) para.set_top_border(True) para.set_top_margin(utils.pt2cm(8)) para.set_description(_('The style used for the footer.')) default_style.add_paragraph_style('REC-Footer', para)
def add_menu_options(self, menu): """ Add the options for the text birthday report """ category_name = _("Report Options") self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Select the filter to be applied to the report.")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter.")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) titletext = StringOption(_("Title text"), _(_TITLE0)) titletext.set_help(_("Title of report")) menu.add_option(category_name, "titletext", titletext) text1 = StringOption(_("Text Area 1"), _(_TITLE1)) text1.set_help(_("First line of text at bottom of report")) menu.add_option(category_name, "text1", text1) text2 = StringOption(_("Text Area 2"), _(_TITLE2)) text2.set_help(_("Second line of text at bottom of report")) menu.add_option(category_name, "text2", text2) text3 = StringOption( _("Text Area 3"), URL_HOMEPAGE, ) text3.set_help(_("Third line of text at bottom of report")) menu.add_option(category_name, "text3", text3) category_name = _("Report Options (2)") self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) stdoptions.add_private_data_option(menu, category_name) alive = BooleanOption(_("Include only living people"), True) alive.set_help(_("Include only living people in the report")) menu.add_option(category_name, "alive", alive) deadtxt = StringOption(_("Dead Symbol"), _(_DEADTXT)) deadtxt.set_help( _("This will show after name to indicate that person is dead")) menu.add_option(category_name, "deadtxt", deadtxt) self.__update_filters() stdoptions.add_localization_option(menu, category_name) showyear = BooleanOption(_("Show event year"), True) showyear.set_help( _("Prints the year the event took place in the report")) menu.add_option(category_name, "showyear", showyear) category_name = _("Content") year = NumberOption(_("Year of report"), time.localtime()[0], 1000, 3000) year.set_help(_("Year of report")) menu.add_option(category_name, "year", year) country = EnumeratedListOption(_("Country for holidays"), 0) holiday_table = libholiday.HolidayTable() countries = holiday_table.get_countries() countries.sort() if (len(countries) == 0 or (len(countries) > 0 and countries[0] != '')): countries.insert(0, '') count = 0 for c in countries: country.add_item(count, c) count += 1 country.set_help(_("Select the country to see associated holidays")) menu.add_option(category_name, "country", country) 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")) maiden_name.set_help(_("Select married women's displayed surname")) menu.add_option(category_name, "maiden_name", maiden_name) birthdays = BooleanOption(_("Include birthdays"), True) birthdays.set_help(_("Whether to include birthdays")) menu.add_option(category_name, "birthdays", birthdays) anniversaries = BooleanOption(_("Include anniversaries"), True) anniversaries.set_help(_("Whether to include anniversaries")) menu.add_option(category_name, "anniversaries", anniversaries) death_anniversaries = BooleanOption(_("Include death anniversaries"), True) death_anniversaries.set_help( _("Whether to include anniversaries of death")) menu.add_option(category_name, "death_anniversaries", death_anniversaries) show_relships = BooleanOption( _("Include relationship to center person"), False) show_relships.set_help( _("Whether to include relationships to the center person")) menu.add_option(category_name, "relationships", show_relships)
class BirthdayOptions(MenuReportOptions): """ Options for the Birthday/Anniversary Report """ def __init__(self, name, dbase): self.__db = dbase self.__pid = None self.__filter = None MenuReportOptions.__init__(self, name, dbase) def get_subject(self): """ Return a string that describes the subject of the report. """ return self.__filter.get_filter().get_name() def add_menu_options(self, menu): """ Add the options for the text birthday report """ category_name = _("Report Options") self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Select the filter to be applied to the report.")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter.")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) titletext = StringOption(_("Title text"), _(_TITLE0)) titletext.set_help(_("Title of report")) menu.add_option(category_name, "titletext", titletext) text1 = StringOption(_("Text Area 1"), _(_TITLE1)) text1.set_help(_("First line of text at bottom of report")) menu.add_option(category_name, "text1", text1) text2 = StringOption(_("Text Area 2"), _(_TITLE2)) text2.set_help(_("Second line of text at bottom of report")) menu.add_option(category_name, "text2", text2) text3 = StringOption( _("Text Area 3"), URL_HOMEPAGE, ) text3.set_help(_("Third line of text at bottom of report")) menu.add_option(category_name, "text3", text3) category_name = _("Report Options (2)") self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) stdoptions.add_private_data_option(menu, category_name) alive = BooleanOption(_("Include only living people"), True) alive.set_help(_("Include only living people in the report")) menu.add_option(category_name, "alive", alive) deadtxt = StringOption(_("Dead Symbol"), _(_DEADTXT)) deadtxt.set_help( _("This will show after name to indicate that person is dead")) menu.add_option(category_name, "deadtxt", deadtxt) self.__update_filters() stdoptions.add_localization_option(menu, category_name) showyear = BooleanOption(_("Show event year"), True) showyear.set_help( _("Prints the year the event took place in the report")) menu.add_option(category_name, "showyear", showyear) category_name = _("Content") year = NumberOption(_("Year of report"), time.localtime()[0], 1000, 3000) year.set_help(_("Year of report")) menu.add_option(category_name, "year", year) country = EnumeratedListOption(_("Country for holidays"), 0) holiday_table = libholiday.HolidayTable() countries = holiday_table.get_countries() countries.sort() if (len(countries) == 0 or (len(countries) > 0 and countries[0] != '')): countries.insert(0, '') count = 0 for c in countries: country.add_item(count, c) count += 1 country.set_help(_("Select the country to see associated holidays")) menu.add_option(category_name, "country", country) 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")) maiden_name.set_help(_("Select married women's displayed surname")) menu.add_option(category_name, "maiden_name", maiden_name) birthdays = BooleanOption(_("Include birthdays"), True) birthdays.set_help(_("Whether to include birthdays")) menu.add_option(category_name, "birthdays", birthdays) anniversaries = BooleanOption(_("Include anniversaries"), True) anniversaries.set_help(_("Whether to include anniversaries")) menu.add_option(category_name, "anniversaries", anniversaries) death_anniversaries = BooleanOption(_("Include death anniversaries"), True) death_anniversaries.set_help( _("Whether to include anniversaries of death")) menu.add_option(category_name, "death_anniversaries", death_anniversaries) show_relships = BooleanOption( _("Include relationship to center person"), False) show_relships.set_help( _("Whether to include relationships to the center person")) menu.add_option(category_name, "relationships", show_relships) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) nfv = self._nf.get_value() filter_list = utils.get_person_filters(person, include_single=False, name_format=nfv) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value == 0: # "Entire Database" (as "include_single=False") self.__pid.set_available(False) else: # The other filters need a center person (assume custom ones too) self.__pid.set_available(True) def make_my_style(self, default_style, name, description, size=9, font=FONT_SERIF, justified="left", color=None, align=PARA_ALIGN_CENTER, shadow=None, italic=0, bold=0, borders=0, indent=None): """ Create paragraph and graphic styles of the same name """ # Paragraph: f = FontStyle() f.set_size(size) f.set_type_face(font) f.set_italic(italic) f.set_bold(bold) p = ParagraphStyle() p.set_font(f) p.set_alignment(align) p.set_description(description) p.set_top_border(borders) p.set_left_border(borders) p.set_bottom_border(borders) p.set_right_border(borders) if indent: p.set(first_indent=indent) if justified == "left": p.set_alignment(PARA_ALIGN_LEFT) elif justified == "right": p.set_alignment(PARA_ALIGN_RIGHT) elif justified == "center": p.set_alignment(PARA_ALIGN_CENTER) default_style.add_paragraph_style(name, p) # Graphics: g = GraphicsStyle() g.set_paragraph_style(name) if shadow: g.set_shadow(*shadow) if color is not None: g.set_fill_color(color) if not borders: g.set_line_width(0) default_style.add_draw_style(name, g) def make_default_style(self, default_style): """ Add the styles used in this report """ self.make_my_style(default_style, "BIR-Title", _('Title text style'), 14, bold=1, justified="center") self.make_my_style(default_style, "BIR-Datastyle", _('Data text display'), 12, indent=1.0) self.make_my_style(default_style, "BIR-Daystyle", _('Day text style'), 12, indent=.5, italic=1, bold=1) self.make_my_style(default_style, "BIR-Monthstyle", _('Month text style'), 14, bold=1) self.make_my_style(default_style, "BIR-Text1style", _('Text at bottom, line 1'), 12, justified="center") self.make_my_style(default_style, "BIR-Text2style", _('Text at bottom, line 2'), 12, justified="center") self.make_my_style(default_style, "BIR-Text3style", _('Text at bottom, line 3'), 12, justified="center")
class TimeLineOptions(MenuReportOptions): """ Options for the TimeLine Report """ def __init__(self, name, dbase): self.__pid = None self.__filter = None self.__db = dbase self._nf = None MenuReportOptions.__init__(self, name, dbase) def get_subject(self): """ Return a string that describes the subject of the report. """ return self.__filter.get_filter().get_name() def add_menu_options(self, menu): category_name = _("Report Options") self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Determines what people are included in the report")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) sortby = EnumeratedListOption(_('Sort by'), 0) idx = 0 for item in _get_sort_functions(Sort(self.__db)): sortby.add_item(idx, _(item[0])) idx += 1 sortby.set_help(_("Sorting method to use")) menu.add_option(category_name, "sortby", sortby) category_name = _("Report Options (2)") self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_private_data_option(menu, category_name) stdoptions.add_living_people_option(menu, category_name) stdoptions.add_localization_option(menu, category_name) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) nfv = self._nf.get_value() filter_list = utils.get_person_filters(person, include_single=False, name_format=nfv) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value == 0: # "Entire Database" (as "include_single=False") self.__pid.set_available(False) else: # The other filters need a center person (assume custom ones too) self.__pid.set_available(True) def make_default_style(self, default_style): """Make the default output style for the Timeline report.""" # Paragraph Styles fstyle = FontStyle() fstyle.set_size(10) fstyle.set_type_face(FONT_SANS_SERIF) pstyle = ParagraphStyle() pstyle.set_font(fstyle) pstyle.set_description(_("The basic style used for the text display.")) default_style.add_paragraph_style("TLG-Name", pstyle) fstyle = FontStyle() fstyle.set_size(8) fstyle.set_type_face(FONT_SANS_SERIF) pstyle = ParagraphStyle() pstyle.set_font(fstyle) pstyle.set_alignment(PARA_ALIGN_CENTER) pstyle.set_description(_("The style used for the section headers.")) default_style.add_paragraph_style("TLG-Label", pstyle) fstyle = FontStyle() fstyle.set_size(14) fstyle.set_type_face(FONT_SANS_SERIF) pstyle = ParagraphStyle() pstyle.set_font(fstyle) pstyle.set_alignment(PARA_ALIGN_CENTER) pstyle.set_description(_("The style used for the title.")) default_style.add_paragraph_style("TLG-Title", pstyle) """ Graphic Styles TLG-grid - 0.5pt wide line dashed line. Used for the lines that make up the grid. TLG-line - 0.5pt wide line. Used for the line connecting two endpoints and for the birth marker. TLG-solid - 0.5pt line with a black fill color. Used for the date of death marker. TLG-text - Contains the TLG-Name paragraph style used for the individual's name. TLG-title - Contains the TLG-Title paragraph style used for the title of the document. TLG-label - Contains the TLG-Label paragraph style used for the year label's in the document. """ gstyle = GraphicsStyle() gstyle.set_line_width(0.5) gstyle.set_color((0, 0, 0)) default_style.add_draw_style("TLG-line", gstyle) gstyle = GraphicsStyle() gstyle.set_line_width(0.5) gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((0, 0, 0)) default_style.add_draw_style("TLG-solid", gstyle) gstyle = GraphicsStyle() gstyle.set_line_width(0.5) gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((255, 255, 255)) default_style.add_draw_style("open", gstyle) gstyle = GraphicsStyle() gstyle.set_line_width(0.5) gstyle.set_line_style(DASHED) gstyle.set_color((0, 0, 0)) default_style.add_draw_style("TLG-grid", gstyle) gstyle = GraphicsStyle() gstyle.set_paragraph_style("TLG-Name") gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((255, 255, 255)) gstyle.set_line_width(0) default_style.add_draw_style("TLG-text", gstyle) gstyle = GraphicsStyle() gstyle.set_paragraph_style("TLG-Title") gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((255, 255, 255)) gstyle.set_line_width(0) default_style.add_draw_style("TLG-title", gstyle) gstyle = GraphicsStyle() gstyle.set_paragraph_style("TLG-Label") gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((255, 255, 255)) gstyle.set_line_width(0) default_style.add_draw_style("TLG-label", gstyle)
class AvatarGeneratorOptions(MenuToolOptions): def __init__(self, name, person_id=None, dbstate=None): self.__db = dbstate.get_database() MenuToolOptions.__init__(self, name, person_id, dbstate) def add_menu_options(self, menu): """ Add all menu options to the tool window. """ # generate list for category menu option words = [ _("male"), _("female"), _("unknown"), _("Option"), _("single image mode") ] itm1 = "{} 1: {}".format(words[3], words[4]) itm2 = "{} 2: {}/{}/{}".format(words[3], words[0], words[1], words[2]) category_names = [(0, itm1), (1, itm2)] # add all menu options self.__category = FilterOption(_("Category"), 0) text = _("Choose how many images you'd like to use.") self.__category.set_help(text) menu.add_option(_("Options"), "category", self.__category) self.__category.set_items(category_names) self.__category.connect('value-changed', self.__update_options) self.__media1 = MediaOption(_("Unknown")) self.__media1.set_help(_("Image for people with unknown gender.")) menu.add_option(_("Options"), "media1", self.__media1) self.__media2 = MediaOption(_("Male")) self.__media2.set_help(_("Image for males.")) menu.add_option(_("Options"), "media2", self.__media2) self.__media3 = MediaOption(_("Female")) self.__media3.set_help(_("Image for females")) menu.add_option(_("Options"), "media3", self.__media3) self.__person_filter = FilterOption(_("Person Filter"), 0) self.__person_filter.set_help(_("Select filter to restrict people")) menu.add_option(_("Options"), "person_filter", self.__person_filter) self.__person_filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Center Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(_("Options"), "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self.__remove = BooleanOption(_("Remove images from people"), False) txt = _("Remove selected image(s).") self.__remove.set_help(txt) menu.add_option(_("Options"), "remove", self.__remove) def __update_filters(self): """ Update filter list based on the selected person. """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) filter_list = ReportUtils.get_person_filters(person, False) self.__person_filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option. """ filter_value = self.__person_filter.get_value() if filter_value in [1, 2, 3, 4]: self.__pid.set_available(True) else: self.__pid.set_available(False) def __update_options(self): """ Update the availability of media options in the menu depending on what the user selects in menu option"category". """ self.__media2.set_available(False) self.__media3.set_available(False) if self.__category.get_value() == 1: self.__media2.set_available(True) self.__media3.set_available(True)
class SourCitaOptions(MenuReportOptions): """ SourcesCitationsOptions provides the options for the SourcesCitationsReport. """ def __init__(self, name, dbase): self.__filter = None MenuReportOptions.__init__(self, name, dbase) def get_subject(self): """ Return a string that describes the subject of the report. """ return self.__filter.get_filter().get_name() def add_menu_options(self, menu): """ Add the options for this report """ category_name = _("Report Options") title = StringOption(_('Report Title'), _('Title of the Report')) title.set_help(_("Title string for the report.")) menu.add_option(category_name, "title", title) subtitle = StringOption(_('Subtitle'), _('Subtitle of the Report')) subtitle.set_help(_("Subtitle string for the report.")) menu.add_option(category_name, "subtitle", subtitle) dateinfo = time.localtime(time.time()) #rname = self.__db.get_researcher().get_name() rname = "researcher name" footer_string = _('Copyright %(year)d %(name)s') % { 'year': dateinfo[0], 'name': rname } footer = StringOption(_('Footer'), footer_string) footer.set_help(_("Footer string for the page.")) menu.add_option(category_name, "footer", footer) # Reload filters to pick any new ones CustomFilters = None from gramps.gen.filters import CustomFilters, GenericFilter self.__filter = FilterOption(_("Select using filter"), 0) self.__filter.set_help(_("Select sources using a filter")) filter_list = [] filter_list.append(GenericFilter()) filter_list.extend(CustomFilters.get_filters('Source')) self.__filter.set_filters(filter_list) menu.add_option(category_name, "filter", self.__filter) showperson = BooleanOption(_("Show persons"), True) showperson.set_help( _("Whether to show events and persons mentioned in the note")) menu.add_option(category_name, "showperson", showperson) locale_opt = stdoptions.add_localization_option(menu, category_name) stdoptions.add_date_format_option(menu, category_name, locale_opt) def make_default_style(self, default_style): """ Make the default output style for the Place report. """ self.default_style = default_style self.__report_title_style() self.__source_title_style() self.__source_details_style() self.__citation_title_style() self.__column_title_style() self.__section_style() self.__event_table_style() self.__details_style() self.__cell_style() self.__table_column_style() def __report_title_style(self): """ Define the style used for the report title """ font = FontStyle() font.set(face=FONT_SANS_SERIF, size=16, bold=1) para = ParagraphStyle() para.set_font(font) para.set_header_level(1) para.set_top_margin(0.25) para.set_bottom_margin(0.25) para.set_alignment(PARA_ALIGN_CENTER) para.set_description(_('The style used for the title of the report.')) self.default_style.add_paragraph_style("SRC-ReportTitle", para) def __source_title_style(self): """ Define the style used for the source title """ font = FontStyle() font.set(face=FONT_SERIF, size=12, italic=0, bold=1) para = ParagraphStyle() para.set_font(font) para.set_header_level(2) para.set(first_indent=0.0, lmargin=0.0) para.set_top_margin(0.75) para.set_bottom_margin(0.25) para.set_description(_('The style used for source title.')) self.default_style.add_paragraph_style("SRC-SourceTitle", para) def __citation_title_style(self): """ Define the style used for the citation title """ font = FontStyle() font.set(face=FONT_SERIF, size=12, italic=0, bold=1) para = ParagraphStyle() para.set_font(font) para.set_header_level(3) para.set(first_indent=0.0, lmargin=0.0) para.set_top_margin(0.75) para.set_bottom_margin(0.0) para.set_description(_('The style used for citation title.')) self.default_style.add_paragraph_style("SRC-CitationTitle", para) def __source_details_style(self): """ Define the style used for the place details """ font = FontStyle() font.set(face=FONT_SERIF, size=10) para = ParagraphStyle() para.set_font(font) para.set(first_indent=0.0, lmargin=0.0) para.set_description(_('The style used for Source details.')) self.default_style.add_paragraph_style("SRC-SourceDetails", para) def __column_title_style(self): """ Define the style used for the event table column title """ font = FontStyle() font.set(face=FONT_SERIF, size=10, bold=1) para = ParagraphStyle() para.set_font(font) para.set(first_indent=0.0, lmargin=0.0) para.set_description(_('The style used for a column title.')) self.default_style.add_paragraph_style("SRC-ColumnTitle", para) def __section_style(self): """ Define the style used for each section """ font = FontStyle() font.set(face=FONT_SERIF, size=10, italic=0, bold=0) para = ParagraphStyle() para.set_font(font) # para.set(first_indent=-1.5, lmargin=1.5) para.set(first_indent=0.0, lmargin=0.0) para.set_top_margin(0.5) para.set_bottom_margin(0.25) para.set_description(_('The style used for each section.')) self.default_style.add_paragraph_style("SRC-Section", para) def __event_table_style(self): """ Define the style used for event table """ table = TableStyle() table.set_width(100) table.set_columns(3) table.set_column_width(0, 35) table.set_column_width(1, 15) table.set_column_width(2, 35) self.default_style.add_table_style("SRC-EventTable", table) table.set_width(100) table.set_columns(3) table.set_column_width(0, 35) table.set_column_width(1, 15) table.set_column_width(2, 35) self.default_style.add_table_style("SRC-PersonTable", table) def __details_style(self): """ Define the style used for person and event details """ font = FontStyle() font.set(face=FONT_SERIF, size=10) para = ParagraphStyle() para.set_font(font) para.set_description(_('The style used for event and person details.')) self.default_style.add_paragraph_style("SRC-Details", para) def __cell_style(self): """ Define the style used for cells in the event table """ cell = TableCellStyle() self.default_style.add_cell_style("SRC-Cell", cell) def __table_column_style(self): """ Define the style used for event table columns """ cell = TableCellStyle() cell.set_bottom_border(1) self.default_style.add_cell_style('SRC-TableColumn', cell)
def add_menu_options(self, menu): ################################ category_name = _("Report Options") ################################ self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Select the filter to be applied to the report.")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter.")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) stdoptions.add_name_format_option(menu, category_name) self.__update_filters() sort = BooleanOption(_("List events chronologically"), True) sort.set_help(_("Whether to sort events into chronological order.")) menu.add_option(category_name, "sort", sort) pageben = BooleanOption(_("Page break before end notes"),False) pageben.set_help( _("Whether to start a new page before the end notes.")) menu.add_option(category_name, "pageben", pageben) stdoptions.add_localization_option(menu, category_name) ################################ category_name = _("Include") ################################ stdoptions.add_private_data_option(menu, category_name) cites = BooleanOption(_("Include Source Information"), True) cites.set_help(_("Whether to cite sources.")) menu.add_option(category_name, "cites", cites) incsrcnotes = BooleanOption(_("Include sources notes"), False) incsrcnotes.set_help(_("Whether to include source notes in the " "Endnotes section. Only works if Include sources is selected.")) menu.add_option(category_name, "incsrcnotes", incsrcnotes) images = BooleanOption(_("Include Photo/Images from Gallery"), True) images.set_help(_("Whether to include images.")) menu.add_option(category_name, "images", images) grampsid = BooleanOption(_("Include Gramps ID"), False) grampsid.set_help(_("Whether to include Gramps ID next to names.")) menu.add_option(category_name, "grampsid", grampsid) ################################ category_name = SECTION_CATEGORY ################################ opt = BooleanListOption(_("Event groups")) opt.set_help(_("Check if a separate section is required.")) for section in SECTION_LIST: if section != SECTION_LIST[0]: opt.add_button(_(section), True) menu.add_option(category_name, "sections", opt)
class FamilyGroupOptions(MenuReportOptions): """ Defines options and provides handling interface. """ def __init__(self, name, dbase): self.__db = dbase self.__fid = None self.__filter = None self.__recursive = None self.__generations = None self._nf = None MenuReportOptions.__init__(self, name, dbase) def get_subject(self): """ Return a string that describes the subject of the report. """ return self.__filter.get_filter().get_name() def add_menu_options(self, menu): ########################## category_name = _("Report Options") add_option = partial(menu.add_option, category_name) ########################## self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Select the filter to be applied to the report.")) add_option("filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__fid = FamilyOption(_("Center Family")) self.__fid.set_help(_("The center family for the filter")) add_option("family_id", self.__fid) self.__fid.connect('value-changed', self.__update_filters) self.__recursive = BooleanOption(_('Recursive (down)'), False) self.__recursive.set_help( _("Create reports for all descendants " "of this family.")) add_option("recursive", self.__recursive) self.__recursive.connect('value-changed', self.__recursive_changed) ########################## category_name = _("Report Options (2)") add_option = partial(menu.add_option, category_name) ########################## self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_place_format_option(menu, category_name) stdoptions.add_private_data_option(menu, category_name) stdoptions.add_living_people_option(menu, category_name) locale_opt = stdoptions.add_localization_option(menu, category_name) stdoptions.add_date_format_option(menu, category_name, locale_opt) ########################## add_option = partial(menu.add_option, _("Include")) ########################## inc_par_mar = BooleanOption(_("Parent Marriage"), True) inc_par_mar.set_help( _("Whether to include marriage information for parents.")) add_option("incParMar", inc_par_mar) inc_par_events = BooleanOption(_("Parent Events"), False) inc_par_events.set_help(_("Whether to include events for parents.")) add_option("incParEvents", inc_par_events) inc_par_addr = BooleanOption(_("Parent Addresses"), False) inc_par_addr.set_help(_("Whether to include addresses for parents.")) add_option("incParAddr", inc_par_addr) inc_par_notes = BooleanOption(_("Parent Notes"), False) inc_par_notes.set_help(_("Whether to include notes for parents.")) add_option("incParNotes", inc_par_notes) incattrs = BooleanOption(_("Parent Attributes"), False) incattrs.set_help(_("Whether to include attributes.")) add_option("incattrs", incattrs) inc_par_names = BooleanOption(_("Alternate Parent Names"), False) inc_par_names.set_help( _("Whether to include alternate names for parents.")) add_option("incParNames", inc_par_names) ########################## category_name = _("Include (2)") add_option = partial(menu.add_option, category_name) ########################## stdoptions.add_gramps_id_option(menu, category_name) inc_fam_notes = BooleanOption(_("Family Notes"), False) inc_fam_notes.set_help(_("Whether to include notes for families.")) add_option("incFamNotes", inc_fam_notes) inc_rel_dates = BooleanOption(_("Dates of Relatives"), False) inc_rel_dates.set_help( _("Whether to include dates for relatives " "(father, mother, spouse).")) add_option("incRelDates", inc_rel_dates) inc_chi_mar = BooleanOption(_("Children Marriages"), True) inc_chi_mar.set_help( _("Whether to include marriage information for children.")) add_option("incChiMar", inc_chi_mar) self.__generations = BooleanOption( _("Generation numbers " "(recursive only)"), False) self.__generations.set_help( _("Whether to include the generation " "on each report (recursive only).")) add_option("generations", self.__generations) missinginfo = BooleanOption( _("Print fields for missing " "information"), True) missinginfo.set_help( _("Whether to include fields for missing " "information.")) add_option("missinginfo", missinginfo) def __update_filters(self): """ Update the filter list based on the selected family """ fid = self.__fid.get_value() family = self.__db.get_family_from_gramps_id(fid) nfv = self._nf.get_value() filter_list = utils.get_family_filters(self.__db, family, include_single=True, name_format=nfv) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not family-specific, disable the family option """ filter_value = self.__filter.get_value() if filter_value == 1: # "Entire Database" (as "include_single=True") self.__fid.set_available(False) else: # The other filters need a center family (assume custom ones too) self.__fid.set_available(True) # only allow recursion if the center family is the only family if self.__recursive and filter_value == 0: self.__recursive.set_available(True) elif self.__recursive: self.__recursive.set_value(False) self.__recursive.set_available(False) def __recursive_changed(self): """ Handle recursive change. """ recursive_value = self.__recursive.get_value() self.__generations.set_available(recursive_value) def make_default_style(self, default_style): """Make default output style for the Family Group Report.""" para = ParagraphStyle() #Paragraph Styles font = FontStyle() font.set_size(4) para.set_font(font) default_style.add_paragraph_style('FGR-blank', para) font = FontStyle() font.set_type_face(FONT_SANS_SERIF) font.set_size(16) font.set_bold(1) para = ParagraphStyle() para.set_font(font) para.set_alignment(PARA_ALIGN_CENTER) para.set_header_level(1) para.set_description(_("The style used for the title.")) default_style.add_paragraph_style('FGR-Title', para) font = FontStyle() font.set_type_face(FONT_SERIF) font.set_size(10) font.set_bold(0) para = ParagraphStyle() para.set_font(font) para.set_description(_('The basic style used for the text display.')) default_style.add_paragraph_style('FGR-Normal', para) para = ParagraphStyle() font = FontStyle() font.set_type_face(FONT_SERIF) font.set_size(10) font.set_bold(0) para.set_font(font) para.set(lmargin=0.0) para.set_top_margin(0.0) para.set_bottom_margin(0.0) para.set_description(_('The basic style used for the note display.')) default_style.add_paragraph_style("FGR-Note", para) font = FontStyle() font.set_type_face(FONT_SANS_SERIF) font.set_size(10) font.set_bold(1) para = ParagraphStyle() para.set_font(font) para.set_description( _('The style used for the text related to the children.')) default_style.add_paragraph_style('FGR-ChildText', para) font = FontStyle() font.set_type_face(FONT_SANS_SERIF) font.set_size(12) font.set_bold(1) para = ParagraphStyle() para.set_font(font) para.set_header_level(3) para.set_description(_("The style used for the parent's name")) default_style.add_paragraph_style('FGR-ParentName', para) #Table Styles cell = TableCellStyle() cell.set_padding(0.2) cell.set_top_border(1) cell.set_bottom_border(1) cell.set_right_border(1) cell.set_left_border(1) default_style.add_cell_style('FGR-ParentHead', cell) cell = TableCellStyle() cell.set_padding(0.1) cell.set_bottom_border(1) cell.set_left_border(1) cell.set_right_border(1) # for RTL default_style.add_cell_style('FGR-TextContents', cell) cell = TableCellStyle() cell.set_padding(0.1) cell.set_bottom_border(0) cell.set_left_border(1) cell.set_right_border(1) # for RTL cell.set_padding(0.1) default_style.add_cell_style('FGR-TextChild1', cell) cell = TableCellStyle() cell.set_padding(0.1) cell.set_bottom_border(1) cell.set_left_border(1) cell.set_right_border(1) # for RTL cell.set_padding(0.1) default_style.add_cell_style('FGR-TextChild2', cell) cell = TableCellStyle() cell.set_padding(0.1) cell.set_bottom_border(1) cell.set_right_border(1) cell.set_left_border(1) default_style.add_cell_style('FGR-TextContentsEnd', cell) cell = TableCellStyle() cell.set_padding(0.2) cell.set_bottom_border(1) cell.set_right_border(1) cell.set_left_border(1) default_style.add_cell_style('FGR-ChildName', cell) table = TableStyle() table.set_width(100) table.set_columns(3) table.set_column_width(0, 20) table.set_column_width(1, 40) table.set_column_width(2, 40) default_style.add_table_style('FGR-ParentTable', table) table = TableStyle() table.set_width(100) table.set_columns(4) table.set_column_width(0, 7) table.set_column_width(1, 18) table.set_column_width(2, 35) table.set_column_width(3, 40) default_style.add_table_style('FGR-ChildTable', table)
class RelGraphOptions(MenuReportOptions): """ Defines options and provides handling interface. """ def __init__(self, name, dbase): self.__pid = None self.__filter = None self.__show_relships = None self.__show_GaGb = None self.__include_images = None self.__image_on_side = None self.__db = dbase MenuReportOptions.__init__(self, name, dbase) def add_menu_options(self, menu): ################################ category_name = _("Report Options") add_option = partial(menu.add_option, category_name) ################################ self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Determines what people are included in the graph")) add_option("filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Center Person")) self.__pid.set_help(_("The center person for the report")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_private_data_option(menu, category_name) stdoptions.add_localization_option(menu, category_name) ################################ add_option = partial(menu.add_option, _("Include")) ################################ self.event_choice = EnumeratedListOption(_('Dates and/or Places'), 0) self.event_choice.add_item(0, _('Do not include any dates or places')) self.event_choice.add_item(1, _('Include (birth, marriage, death) ' 'dates, but no places')) self.event_choice.add_item(2, _('Include (birth, marriage, death) ' 'dates, and places')) self.event_choice.add_item(3, _('Include (birth, marriage, death) ' 'dates, and places if no dates')) self.event_choice.add_item(4, _('Include (birth, marriage, death) ' 'years, but no places')) self.event_choice.add_item(5, _('Include (birth, marriage, death) ' 'years, and places')) self.event_choice.add_item(6, _('Include (birth, marriage, death) ' 'places, but no dates')) self.event_choice.set_help(_("Whether to include dates and/or places")) add_option("event_choice", self.event_choice) url = BooleanOption(_("Include URLs"), False) url.set_help(_("Include a URL in each graph node so " "that PDF and imagemap files can be " "generated that contain active links " "to the files generated by the 'Narrated " "Web Site' report.")) add_option("url", url) include_id = EnumeratedListOption(_('Include Gramps ID'), 0) include_id.add_item(0, _('Do not include')) include_id.add_item(1, _('Share an existing line')) include_id.add_item(2, _('On a line of its own')) include_id.set_help(_("Whether (and where) to include Gramps IDs")) add_option("incid", include_id) self.__show_relships = BooleanOption( _("Include relationship to center person"), False) self.__show_relships.set_help(_("Whether to show every " "person's relationship to the center person")) add_option("increlname", self.__show_relships) self.__show_relships.connect('value-changed', self.__show_relships_changed) self.__include_images = BooleanOption( _('Include thumbnail images of people'), False) self.__include_images.set_help( _("Whether to include thumbnails of people.")) add_option("includeImages", self.__include_images) self.__include_images.connect('value-changed', self.__image_changed) self.__image_on_side = EnumeratedListOption(_("Thumbnail Location"), 0) self.__image_on_side.add_item(0, _('Above the name')) self.__image_on_side.add_item(1, _('Beside the name')) self.__image_on_side.set_help( _("Where the thumbnail image should appear " "relative to the name")) add_option("imageOnTheSide", self.__image_on_side) if __debug__: self.__show_GaGb = BooleanOption(_("Include relationship " "debugging numbers also"), False) self.__show_GaGb.set_help(_("Whether to include 'Ga' and 'Gb' " "also, to debug the relationship calculator")) add_option("advrelinfo", self.__show_GaGb) ################################ add_option = partial(menu.add_option, _("Graph Style")) ################################ color = EnumeratedListOption(_("Graph coloring"), 'filled') for i in range( 0, len(_COLORS) ): color.add_item(_COLORS[i]["value"], _COLORS[i]["name"]) color.set_help(_("Males will be shown with blue, females " "with red. If the sex of an individual " "is unknown it will be shown with gray.")) add_option("color", color) color_males = ColorOption(_('Males'), '#e0e0ff') color_males.set_help(_('The color to use to display men.')) add_option('colormales', color_males) color_females = ColorOption(_('Females'), '#ffe0e0') color_females.set_help(_('The color to use to display women.')) add_option('colorfemales', color_females) color_unknown = ColorOption(_('Unknown'), '#e0e0e0') color_unknown.set_help( _('The color to use when the gender is unknown.') ) add_option('colorunknown', color_unknown) color_family = ColorOption(_('Families'), '#ffffe0') color_family.set_help(_('The color to use to display families.')) add_option('colorfamilies', color_family) arrow = EnumeratedListOption(_("Arrowhead direction"), 'd') for i in range( 0, len(_ARROWS) ): arrow.add_item(_ARROWS[i]["value"], _ARROWS[i]["name"]) arrow.set_help(_("Choose the direction that the arrows point.")) add_option("arrow", arrow) roundedcorners = BooleanOption( # see bug report #2180 _("Use rounded corners"), False) roundedcorners.set_help( _("Use rounded corners to differentiate " "between women and men.")) add_option("useroundedcorners", roundedcorners) dashed = BooleanOption( _("Indicate non-birth relationships with dotted lines"), True) dashed.set_help(_("Non-birth relationships will show up " "as dotted lines in the graph.")) add_option("dashed", dashed) showfamily = BooleanOption(_("Show family nodes"), True) showfamily.set_help(_("Families will show up as ellipses, linked " "to parents and children.")) add_option("showfamily", showfamily) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) nfv = self._nf.get_value() filter_list = ReportUtils.get_person_filters(person, include_single=False, name_format=nfv) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value in [1, 2, 3, 4]: # Filters 1, 2, 3 and 4 rely on the center person self.__pid.set_available(True) elif self.__show_relships and self.__show_relships.get_value(): self.__pid.set_available(True) else: # The rest don't self.__pid.set_available(False) def __image_changed(self): """ Handle thumbnail change. If the image is not to be included, make the image location option unavailable. """ self.__image_on_side.set_available(self.__include_images.get_value()) def __show_relships_changed(self): """ Enable/disable menu items if relationships are required """ if self.__show_GaGb: self.__show_GaGb.set_available(self.__show_relships.get_value()) self.__filter_changed()
class CalendarOptions(MenuReportOptions): """ Calendar options for graphic calendar """ def __init__(self, name, dbase): self.__db = dbase self.__pid = None self.__filter = None MenuReportOptions.__init__(self, name, dbase) def get_subject(self): """ Return a string that describes the subject of the report. """ return self.__filter.get_filter().get_name() def add_menu_options(self, menu): """ Add the options for the graphical calendar """ ########################## category_name = _("Report Options") add_option = partial(menu.add_option, category_name) ########################## self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Select filter to restrict people that appear on calendar")) add_option("filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Center Person")) self.__pid.set_help(_("The center person for the report")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) text1 = StringOption(_("Text Area 1"), _(_TITLE1)) text1.set_help(_("First line of text at bottom of calendar")) add_option("text1", text1) text2 = StringOption(_("Text Area 2"), _(_TITLE2)) text2.set_help(_("Second line of text at bottom of calendar")) add_option("text2", text2) text3 = StringOption(_("Text Area 3"), URL_HOMEPAGE) text3.set_help(_("Third line of text at bottom of calendar")) add_option("text3", text3) ########################## category_name = _("Report Options (2)") add_option = partial(menu.add_option, category_name) ########################## self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_private_data_option(menu, category_name) alive = BooleanOption(_("Include only living people"), True) alive.set_help(_("Include only living people in the calendar")) add_option("alive", alive) stdoptions.add_localization_option(menu, category_name) ########################## category_name = _("Content") add_option = partial(menu.add_option, category_name) ########################## year = NumberOption(_("Year of calendar"), time.localtime()[0], 1000, 3000) year.set_help(_("Year of calendar")) add_option("year", year) country = EnumeratedListOption(_("Country for holidays"), 0) holiday_table = libholiday.HolidayTable() countries = holiday_table.get_countries() countries.sort() if (len(countries) == 0 or (len(countries) > 0 and countries[0] != '')): countries.insert(0, '') count = 0 for c in countries: country.add_item(count, c) count += 1 country.set_help(_("Select the country to see associated holidays")) add_option("country", country) start_dow = EnumeratedListOption(_("First day of week"), 1) long_days = date_displayer.long_days 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, long_days[count].capitalize()) start_dow.set_help( _("Select the first day of the week for the calendar")) add_option("start_dow", start_dow) 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")) maiden_name.set_help(_("Select married women's displayed surname")) add_option("maiden_name", maiden_name) birthdays = BooleanOption(_("Include birthdays"), True) birthdays.set_help(_("Whether to include birthdays")) add_option("birthdays", birthdays) anniversaries = BooleanOption(_("Include anniversaries"), True) anniversaries.set_help(_("Whether to include anniversaries")) add_option("anniversaries", anniversaries) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) nfv = self._nf.get_value() filter_list = utils.get_person_filters(person, include_single=False, name_format=nfv) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value == 0: # "Entire Database" (as "include_single=False") self.__pid.set_available(False) else: # The other filters need a center person (assume custom ones too) self.__pid.set_available(True) def make_my_style(self, default_style, name, description, size=9, font=FONT_SERIF, justified="left", color=None, align=PARA_ALIGN_CENTER, shadow=None, italic=0, bold=0, borders=0, indent=None): """ Create paragraph and graphic styles of the same name """ # Paragraph: f = FontStyle() f.set_size(size) f.set_type_face(font) f.set_italic(italic) f.set_bold(bold) p = ParagraphStyle() p.set_font(f) p.set_alignment(align) p.set_description(description) p.set_top_border(borders) p.set_left_border(borders) p.set_bottom_border(borders) p.set_right_border(borders) if indent: p.set(first_indent=indent) if justified == "left": p.set_alignment(PARA_ALIGN_LEFT) elif justified == "right": p.set_alignment(PARA_ALIGN_RIGHT) elif justified == "center": p.set_alignment(PARA_ALIGN_CENTER) default_style.add_paragraph_style(name, p) # Graphics: g = GraphicsStyle() g.set_paragraph_style(name) if shadow: g.set_shadow(*shadow) if color is not None: g.set_fill_color(color) if not borders: g.set_line_width(0) default_style.add_draw_style(name, g) def make_default_style(self, default_style): """ Add the styles used in this report """ self.make_my_style(default_style, "CAL-Title", _('Title text and background color'), 20, bold=1, italic=1, color=(0xEA, 0xEA, 0xEA)) self.make_my_style(default_style, "CAL-Numbers", _('Calendar day numbers'), 13, bold=1) self.make_my_style(default_style, "CAL-Text", _('Daily text display'), 9) self.make_my_style(default_style, "CAL-Holiday", _('Holiday text display'), 9, bold=1, italic=1) self.make_my_style(default_style, "CAL-Daynames", _('Days of the week text'), 12, italic=1, bold=1, color=(0xEA, 0xEA, 0xEA)) self.make_my_style(default_style, "CAL-Text1style", _('Text at bottom, line 1'), 12) self.make_my_style(default_style, "CAL-Text2style", _('Text at bottom, line 2'), 12) self.make_my_style(default_style, "CAL-Text3style", _('Text at bottom, line 3'), 9) self.make_my_style(default_style, "CAL-Border", _('Borders'), borders=True)
def add_menu_options(self, menu): """ Add the options """ category_name = _("Options") self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help(_("Select filter to restrict people")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self.__update_filters() source_text = StringOption(_("Source text"), _("Calculated Date Estimates")) source_text.set_help(_("Source to remove and/or add")) menu.add_option(category_name, "source_text", source_text) remove = BooleanOption(_("Remove previously added events, notes, and source"), True) remove.set_help(_("Remove calculated events, notes, and source; occurs immediately on Execute")) menu.add_option(category_name, "remove", remove) birth = EnumeratedListOption(_("Birth"), 0) birth.add_item(0, _("Do not add birth events")) birth.add_item(1, _("Add birth events without dates")) birth.add_item(2, _("Add birth events with dates")) birth.set_help( _("Add a birth events with or without estimated dates")) menu.add_option(category_name, "add_birth", birth) death = EnumeratedListOption(_("Death"), 0) death.add_item(0, _("Do not add death events")) death.add_item(1, _("Add death events without dates")) death.add_item(2, _("Add death events with dates")) death.set_help( _("Add death events with or without estimated dates")) menu.add_option(category_name, "add_death", death) # ----------------------------------------------------- num = NumberOption(_("Maximum age"), config.get('behavior.max-age-prob-alive'), 0, 200) num.set_help(_("Maximum age that one can live to")) menu.add_option(category_name, "MAX_AGE_PROB_ALIVE", num) num = NumberOption(_("Maximum sibling age difference"), config.get('behavior.max-sib-age-diff'), 0, 200) num.set_help(_("Maximum age difference between siblings")) menu.add_option(category_name, "MAX_SIB_AGE_DIFF", num) num = NumberOption(_("Average years between generations"), config.get('behavior.avg-generation-gap'), 0, 200) num.set_help(_("Average years between two generations")) menu.add_option(category_name, "AVG_GENERATION_GAP", num) dates = EnumeratedListOption(_("Estimated Dates"), 0) dates.add_item(0, _("Approximate (about)")) dates.add_item(1, _("Extremes (after and before)")) dates.set_help( _("Dates on events are either about or after/before")) menu.add_option(category_name, "dates", dates)
class CalcEstDateOptions(MenuToolOptions): """ Calculate Estimated Date options """ def __init__(self, name, person_id=None, dbstate=None): self.__db = dbstate.get_database() self.__dbstate = dbstate MenuToolOptions.__init__(self, name, person_id, dbstate) def get_dbstate(self): return self.__dbstate def add_menu_options(self, menu): """ Add the options """ category_name = _("Options") self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help(_("Select filter to restrict people")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self.__update_filters() source_text = StringOption(_("Source text"), _("Calculated Date Estimates")) source_text.set_help(_("Source to remove and/or add")) menu.add_option(category_name, "source_text", source_text) remove = BooleanOption( _("Remove previously added events, notes, and source"), True) remove.set_help( _("Remove calculated events, notes, and source; occurs immediately on Execute" )) menu.add_option(category_name, "remove", remove) birth = EnumeratedListOption(_("Birth"), 0) birth.add_item(0, _("Do not add birth events")) birth.add_item(1, _("Add birth events without dates")) birth.add_item(2, _("Add birth events with dates")) birth.set_help(_("Add a birth events with or without estimated dates")) menu.add_option(category_name, "add_birth", birth) death = EnumeratedListOption(_("Death"), 0) death.add_item(0, _("Do not add death events")) death.add_item(1, _("Add death events without dates")) death.add_item(2, _("Add death events with dates")) death.set_help(_("Add death events with or without estimated dates")) menu.add_option(category_name, "add_death", death) # ----------------------------------------------------- num = NumberOption(_("Maximum age"), config.get('behavior.max-age-prob-alive'), 0, 200) num.set_help(_("Maximum age that one can live to")) menu.add_option(category_name, "MAX_AGE_PROB_ALIVE", num) num = NumberOption(_("Maximum sibling age difference"), config.get('behavior.max-sib-age-diff'), 0, 200) num.set_help(_("Maximum age difference between siblings")) menu.add_option(category_name, "MAX_SIB_AGE_DIFF", num) num = NumberOption(_("Average years between generations"), config.get('behavior.avg-generation-gap'), 0, 200) num.set_help(_("Average years between two generations")) menu.add_option(category_name, "AVG_GENERATION_GAP", num) dates = EnumeratedListOption(_("Estimated Dates"), 0) dates.add_item(0, _("Approximate (about)")) dates.add_item(1, _("Extremes (after and before)")) dates.set_help(_("Dates on events are either about or after/before")) menu.add_option(category_name, "dates", dates) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) filter_list = get_person_filters(person, False) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value in [1, 2, 3, 4]: # Filters 0, 2, 3, 4 and 5 rely on the center person self.__pid.set_available(True) else: # The rest don't self.__pid.set_available(False)
class PlaceOptions(MenuReportOptions): """ Defines options and provides handling interface. """ def __init__(self, name, dbase): self.__db = dbase self.__filter = None self.__places = None self.__pf = None MenuReportOptions.__init__(self, name, dbase) def get_subject(self): """ Return a string that describes the subject of the report. """ subject = "" if self.__filter.get_filter().get_name(): # Use the selected filter's name, if any subject += self.__filter.get_filter().get_name() if self.__places.get_value(): # Add places selected individually, if any for place_id in self.__places.get_value().split(): if subject: subject += " + " place = self.__db.get_place_from_gramps_id(place_id) subject += _pd.display(self.__db, place, None, self.__pf.get_value()) return subject def add_menu_options(self, menu): """ Add options to the menu for the place report. """ category_name = _("Report Options") # Reload filters to pick any new ones CustomFilters = None from gramps.gen.filters import CustomFilters, GenericFilter self.__filter = FilterOption(_("Select using filter"), 0) self.__filter.set_help(_("Select places using a filter")) filter_list = [] filter_list.append(GenericFilter()) filter_list.extend(CustomFilters.get_filters('Place')) self.__filter.set_filters(filter_list) menu.add_option(category_name, "filter", self.__filter) self.__places = PlaceListOption(_("Select places individually")) self.__places.set_help(_("List of places to report on")) menu.add_option(category_name, "places", self.__places) center = EnumeratedListOption(_("Center on"), "Event") center.set_items([("Event", _("Event")), ("Person", _("Person"))]) center.set_help(_("If report is event or person centered")) menu.add_option(category_name, "center", center) category_name = _("Report Options (2)") stdoptions.add_name_format_option(menu, category_name) self.__pf = stdoptions.add_place_format_option(menu, category_name) stdoptions.add_private_data_option(menu, category_name) stdoptions.add_living_people_option(menu, category_name) locale_opt = stdoptions.add_localization_option(menu, category_name) stdoptions.add_date_format_option(menu, category_name, locale_opt) def make_default_style(self, default_style): """ Make the default output style for the Place report. """ self.default_style = default_style self.__report_title_style() self.__report_subtitle_style() self.__place_title_style() self.__place_details_style() self.__column_title_style() self.__section_style() self.__event_table_style() self.__details_style() self.__cell_style() self.__table_column_style() def __report_title_style(self): """ Define the style used for the report title """ font = FontStyle() font.set(face=FONT_SANS_SERIF, size=16, bold=1) para = ParagraphStyle() para.set_font(font) para.set_header_level(1) para.set_top_margin(0.25) para.set_bottom_margin(0.25) para.set_alignment(PARA_ALIGN_CENTER) para.set_description(_('The style used for the title.')) self.default_style.add_paragraph_style("PLC-ReportTitle", para) def __report_subtitle_style(self): """ Define the style used for the report subtitle """ font = FontStyle() font.set(face=FONT_SANS_SERIF, size=12, bold=1) para = ParagraphStyle() para.set_font(font) para.set_header_level(1) para.set_top_margin(0.25) para.set_bottom_margin(0.25) para.set_alignment(PARA_ALIGN_CENTER) para.set_description(_('The style used for the subtitle.')) self.default_style.add_paragraph_style("PLC-ReportSubtitle", para) def __place_title_style(self): """ Define the style used for the place title """ font = FontStyle() font.set(face=FONT_SERIF, size=12, italic=0, bold=1) para = ParagraphStyle() para.set_font(font) para.set(first_indent=-1.5, lmargin=1.5) para.set_top_margin(0.75) para.set_bottom_margin(0.25) para.set_description(_('The style used for the section headers.')) self.default_style.add_paragraph_style("PLC-PlaceTitle", para) def __place_details_style(self): """ Define the style used for the place details """ font = FontStyle() font.set(face=FONT_SERIF, size=10) para = ParagraphStyle() para.set_font(font) para.set(first_indent=0.0, lmargin=1.5) para.set_description(_('The style used for details.')) self.default_style.add_paragraph_style("PLC-PlaceDetails", para) def __column_title_style(self): """ Define the style used for the event table column title """ font = FontStyle() font.set(face=FONT_SERIF, size=10, bold=1) para = ParagraphStyle() para.set_font(font) para.set(first_indent=0.0, lmargin=0.0) para.set_description(_('The basic style used for table headings.')) self.default_style.add_paragraph_style("PLC-ColumnTitle", para) def __section_style(self): """ Define the style used for each section """ font = FontStyle() font.set(face=FONT_SERIF, size=10, italic=0, bold=0) para = ParagraphStyle() para.set_font(font) para.set(first_indent=-1.5, lmargin=1.5) para.set_top_margin(0.5) para.set_bottom_margin(0.25) para.set_description(_('The basic style used for the text display.')) self.default_style.add_paragraph_style("PLC-Section", para) def __event_table_style(self): """ Define the style used for event table """ table = TableStyle() table.set_width(100) table.set_columns(4) table.set_column_width(0, 25) table.set_column_width(1, 15) table.set_column_width(2, 35) table.set_column_width(3, 25) self.default_style.add_table_style("PLC-EventTable", table) table.set_width(100) table.set_columns(4) table.set_column_width(0, 35) table.set_column_width(1, 15) table.set_column_width(2, 25) table.set_column_width(3, 25) self.default_style.add_table_style("PLC-PersonTable", table) def __details_style(self): """ Define the style used for person and event details """ font = FontStyle() font.set(face=FONT_SERIF, size=10) para = ParagraphStyle() para.set_font(font) para.set_description(_('The style used for the items and values.')) self.default_style.add_paragraph_style("PLC-Details", para) def __cell_style(self): """ Define the style used for cells in the event table """ cell = TableCellStyle() self.default_style.add_cell_style("PLC-Cell", cell) def __table_column_style(self): """ Define the style used for event table columns """ cell = TableCellStyle() cell.set_bottom_border(1) self.default_style.add_cell_style('PLC-TableColumn', cell)
def add_menu_options(self, menu): """ Add the options for this report """ category_name = _("Report Options") title = StringOption(_('book|Title'), _('Title of the Book')) title.set_help(_("Title string for the book.")) menu.add_option(category_name, "title", title) subtitle = StringOption(_('Subtitle'), _('Subtitle of the Book')) subtitle.set_help(_("Subtitle string for the book.")) menu.add_option(category_name, "subtitle", subtitle) dateinfo = time.localtime(time.time()) #rname = self.__db.get_researcher().get_name() rname = "researcher name" footer_string = _('Copyright %(year)d %(name)s') % { 'year': dateinfo[0], 'name': rname } footer = StringOption(_('Footer'), footer_string) footer.set_help(_("Footer string for the page.")) menu.add_option(category_name, "footer", footer) # Reload filters to pick any new ones CustomFilters = None #p- from Filters import CustomFilters, GenericFilter from gramps.gen.filters import CustomFilters, GenericFilter # opt = FilterOption(_("Select using filter"), 0) # opt.set_help(_("Select places using a filter")) # filter_list = [] # filter_list.append(GenericFilter()) # filter_list.extend(CustomFilters.get_filters('Source')) # opt.set_filters(filter_list) # menu.add_option(category_name, "filter", opt) # # showpersons = BooleanOption(_("Show persons"), True) # showpersons.set_help(_("Whether to show events and persons mentioned in the note")) # menu.add_option(category_name, "showpersons", showpersons) # # incphotos = BooleanOption(_("Include Photos"), True) # incphotos.set_help(_("Whether to show photos mentioned in the citation")) # menu.add_option(category_name, "incphotos", incphotos) category_name = _("Calc Options") # Reload filters to pick any new ones CustomFilters = None #p- from Filters import CustomFilters, GenericFilter from gramps.gen.filters import CustomFilters, GenericFilter opt = FilterOption(_("Select using filter"), 0) opt.set_help(_("Select places using a filter")) filter_list = [] filter_list.append(GenericFilter()) filter_list.extend(CustomFilters.get_filters('Source')) opt.set_filters(filter_list) menu.add_option(category_name, "filter", opt) showallfamilies = BooleanOption( _("Show surnames of all famiies in clans"), True) showallfamilies.set_help( _("Whether to show the names of all families as surname")) menu.add_option(category_name, "showallfamilies", showallfamilies) # self.pl_format = menu.get_option_by_name('placeformat').get_value() #places = PlaceListOption(_("Select places individually")) #places.set_help(_("List of places to report on")) #menu.add_option(category_name, "places", places) stdoptions.add_place_format_option(menu, category_name)
def add_menu_options(self, menu): ################################ category_name = _("Report Options") ################################ self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Select the filter to be applied to the report.")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter.")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_private_data_option(menu, category_name) sort = BooleanOption(_("List events chronologically"), True) sort.set_help(_("Whether to sort events into chronological order.")) menu.add_option(category_name, "sort", sort) pageben = BooleanOption(_("Page break before end notes"),False) pageben.set_help( _("Whether to start a new page before the end notes.")) menu.add_option(category_name, "pageben", pageben) stdoptions.add_localization_option(menu, category_name) ################################ category_name = _("Include") ################################ cites = BooleanOption(_("Include Source Information"), True) cites.set_help(_("Whether to cite sources.")) menu.add_option(category_name, "cites", cites) incsrcnotes = BooleanOption(_("Include sources notes"), False) incsrcnotes.set_help(_("Whether to include source notes in the " "Endnotes section. Only works if Include sources is selected.")) menu.add_option(category_name, "incsrcnotes", incsrcnotes) images = BooleanOption(_("Include Photo/Images from Gallery"), True) images.set_help(_("Whether to include images.")) menu.add_option(category_name, "images", images) grampsid = BooleanOption(_("Include Gramps ID"), False) grampsid.set_help(_("Whether to include Gramps ID next to names.")) menu.add_option(category_name, "grampsid", grampsid) ################################ category_name = _("Sections") ################################ opt = BooleanListOption(_("Event groups")) opt.set_help(_("Check if a separate section is required.")) for section in SECTION_LIST: if section != SECTION_LIST[0]: opt.add_button(_(section), True) menu.add_option(category_name, "sections", opt)
class RelGraphOptions(MenuReportOptions): """ Defines options and provides handling interface. """ def __init__(self, name, dbase): self.__pid = None self.__filter = None self.__show_relships = None self.__show_ga_gb = None self.__include_images = None self.__image_on_side = None self.__db = dbase self._nf = None self.event_choice = None MenuReportOptions.__init__(self, name, dbase) def add_menu_options(self, menu): ################################ category_name = _("Report Options") add_option = partial(menu.add_option, category_name) ################################ self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Determines what people are included in the graph")) add_option("filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Center Person")) self.__pid.set_help(_("The center person for the report")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_private_data_option(menu, category_name) stdoptions.add_living_people_option(menu, category_name) stdoptions.add_localization_option(menu, category_name) ################################ add_option = partial(menu.add_option, _("Include")) ################################ self.event_choice = EnumeratedListOption(_('Dates and/or Places'), 0) self.event_choice.add_item(0, _('Do not include any dates or places')) self.event_choice.add_item(1, _('Include (birth, marriage, death) ' 'dates, but no places')) self.event_choice.add_item(2, _('Include (birth, marriage, death) ' 'dates, and places')) self.event_choice.add_item(3, _('Include (birth, marriage, death) ' 'dates, and places if no dates')) self.event_choice.add_item(4, _('Include (birth, marriage, death) ' 'years, but no places')) self.event_choice.add_item(5, _('Include (birth, marriage, death) ' 'years, and places')) self.event_choice.add_item(6, _('Include (birth, marriage, death) ' 'places, but no dates')) self.event_choice.add_item(7, _('Include (birth, marriage, death) ' 'dates and places on same line')) self.event_choice.set_help( _("Whether to include dates and/or places")) add_option("event_choice", self.event_choice) url = BooleanOption(_("Include URLs"), False) url.set_help(_("Include a URL in each graph node so " "that PDF and imagemap files can be " "generated that contain active links " "to the files generated by the 'Narrated " "Web Site' report.")) add_option("url", url) include_id = EnumeratedListOption(_('Include Gramps ID'), 0) include_id.add_item(0, _('Do not include')) include_id.add_item(1, _('Share an existing line')) include_id.add_item(2, _('On a line of its own')) include_id.set_help(_("Whether (and where) to include Gramps IDs")) add_option("incid", include_id) self.__show_relships = BooleanOption( _("Include relationship to center person"), False) self.__show_relships.set_help(_("Whether to show every person's " "relationship to the center person")) add_option("increlname", self.__show_relships) self.__show_relships.connect('value-changed', self.__show_relships_changed) self.__include_images = BooleanOption( _('Include thumbnail images of people'), False) self.__include_images.set_help( _("Whether to include thumbnails of people.")) add_option("includeImages", self.__include_images) self.__include_images.connect('value-changed', self.__image_changed) self.__image_on_side = EnumeratedListOption(_("Thumbnail Location"), 0) self.__image_on_side.add_item(0, _('Above the name')) self.__image_on_side.add_item(1, _('Beside the name')) self.__image_on_side.set_help( _("Where the thumbnail image should appear relative to the name")) add_option("imageOnTheSide", self.__image_on_side) #occupation = BooleanOption(_("Include occupation"), False) occupation = EnumeratedListOption(_('Include occupation'), 0) occupation.add_item(0, _('Do not include any occupation')) occupation.add_item(1, _('Include description ' 'of most recent occupation')) occupation.add_item(2, _('Include date, description and place ' 'of all occupations')) occupation.set_help(_("Whether to include the last occupation")) add_option("occupation", occupation) if __debug__: self.__show_ga_gb = BooleanOption(_("Include relationship " "debugging numbers also"), False) self.__show_ga_gb.set_help(_("Whether to include 'Ga' and 'Gb' " "also, to debug the relationship " "calculator")) add_option("advrelinfo", self.__show_ga_gb) ################################ add_option = partial(menu.add_option, _("Graph Style")) ################################ color = EnumeratedListOption(_("Graph coloring"), 'filled') for i in range(0, len(_COLORS)): color.add_item(_COLORS[i]["value"], _COLORS[i]["name"]) color.set_help(_("Males will be shown with blue, females " "with red. If the sex of an individual " "is unknown it will be shown with gray.")) add_option("color", color) color_males = ColorOption(_('Males'), '#e0e0ff') color_males.set_help(_('The color to use to display men.')) add_option('colormales', color_males) color_females = ColorOption(_('Females'), '#ffe0e0') color_females.set_help(_('The color to use to display women.')) add_option('colorfemales', color_females) color_unknown = ColorOption(_('Unknown'), '#e0e0e0') color_unknown.set_help( _('The color to use when the gender is unknown.') ) add_option('colorunknown', color_unknown) color_family = ColorOption(_('Families'), '#ffffe0') color_family.set_help(_('The color to use to display families.')) add_option('colorfamilies', color_family) arrow = EnumeratedListOption(_("Arrowhead direction"), 'd') for i in range(0, len(_ARROWS)): arrow.add_item(_ARROWS[i]["value"], _ARROWS[i]["name"]) arrow.set_help(_("Choose the direction that the arrows point.")) add_option("arrow", arrow) # see bug report #2180 roundedcorners = BooleanOption(_("Use rounded corners"), False) roundedcorners.set_help(_("Use rounded corners to differentiate " "between women and men.")) add_option("useroundedcorners", roundedcorners) dashed = BooleanOption( _("Indicate non-birth relationships with dotted lines"), True) dashed.set_help(_("Non-birth relationships will show up " "as dotted lines in the graph.")) add_option("dashed", dashed) showfamily = BooleanOption(_("Show family nodes"), True) showfamily.set_help(_("Families will show up as ellipses, linked " "to parents and children.")) add_option("showfamily", showfamily) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) nfv = self._nf.get_value() filter_list = utils.get_person_filters(person, include_single=False, name_format=nfv) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value in [1, 2, 3, 4]: # Filters 1, 2, 3 and 4 rely on the center person self.__pid.set_available(True) elif self.__show_relships and self.__show_relships.get_value(): self.__pid.set_available(True) else: # The rest don't self.__pid.set_available(False) def __image_changed(self): """ Handle thumbnail change. If the image is not to be included, make the image location option unavailable. """ self.__image_on_side.set_available(self.__include_images.get_value()) def __show_relships_changed(self): """ Enable/disable menu items if relationships are required """ if self.__show_ga_gb: self.__show_ga_gb.set_available(self.__show_relships.get_value()) self.__filter_changed()
class BirthdayOptions(MenuReportOptions): """ Options for the Birthday/Anniversary Report """ def __init__(self, name, dbase): self.__db = dbase self.__pid = None self.__filter = None MenuReportOptions.__init__(self, name, dbase) def get_subject(self): """ Return a string that describes the subject of the report. """ return self.__filter.get_filter().get_name() def add_menu_options(self, menu): """ Add the options for the text birthday report """ category_name = _("Report Options") self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Select the filter to be applied to the report.")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter.")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) stdoptions.add_private_data_option(menu, category_name) alive = BooleanOption(_("Include only living people"), True) alive.set_help(_("Include only living people in the report")) menu.add_option(category_name, "alive", alive) self.__update_filters() stdoptions.add_localization_option(menu, category_name) category_name = _("Content") year = NumberOption(_("Year of report"), time.localtime()[0], 1000, 3000) year.set_help(_("Year of report")) menu.add_option(category_name, "year", year) country = EnumeratedListOption(_("Country for holidays"), 0) holiday_table = libholiday.HolidayTable() countries = holiday_table.get_countries() countries.sort() if (len(countries) == 0 or (len(countries) > 0 and countries[0] != '')): countries.insert(0, '') count = 0 for c in holiday_table.get_countries(): country.add_item(count, c) count += 1 country.set_help(_("Select the country to see associated holidays")) menu.add_option(category_name, "country", country) start_dow = EnumeratedListOption(_("First day of week"), 1) long_days = date_displayer.long_days 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, long_days[count].capitalize()) start_dow.set_help(_("Select the first day of the week for the report")) menu.add_option(category_name, "start_dow", start_dow) 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")) maiden_name.set_help(_("Select married women's displayed surname")) menu.add_option(category_name, "maiden_name", maiden_name) birthdays = BooleanOption(_("Include birthdays"), True) birthdays.set_help(_("Include birthdays in the report")) menu.add_option(category_name, "birthdays", birthdays) anniversaries = BooleanOption(_("Include anniversaries"), True) anniversaries.set_help(_("Include anniversaries in the report")) menu.add_option(category_name, "anniversaries", anniversaries) option = BooleanOption(_("Include relationships to center person"), False) option.set_help(_("Include relationships to center person (slower)")) menu.add_option(category_name, "relationships", option) category_name = _("Text Options") titletext = StringOption(_("Title text"), _(_TITLE0)) titletext.set_help(_("Title of report")) menu.add_option(category_name, "titletext", titletext) text1 = StringOption(_("Text Area 1"), _(_TITLE1)) text1.set_help(_("First line of text at bottom of report")) menu.add_option(category_name, "text1", text1) text2 = StringOption(_("Text Area 2"), _(_TITLE2)) text2.set_help(_("Second line of text at bottom of report")) menu.add_option(category_name, "text2", text2) text3 = StringOption(_("Text Area 3"), URL_HOMEPAGE,) text3.set_help(_("Third line of text at bottom of report")) menu.add_option(category_name, "text3", text3) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) nfv = self._nf.get_value() filter_list = utils.get_person_filters(person, include_single=False, name_format=nfv) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value == 0: # "Entire Database" (as "include_single=False") self.__pid.set_available(False) else: # The other filters need a center person (assume custom ones too) self.__pid.set_available(True) def make_my_style(self, default_style, name, description, size=9, font=FONT_SERIF, justified ="left", color=None, align=PARA_ALIGN_CENTER, shadow = None, italic=0, bold=0, borders=0, indent=None): """ Create paragraph and graphic styles of the same name """ # Paragraph: f = FontStyle() f.set_size(size) f.set_type_face(font) f.set_italic(italic) f.set_bold(bold) p = ParagraphStyle() p.set_font(f) p.set_alignment(align) p.set_description(description) p.set_top_border(borders) p.set_left_border(borders) p.set_bottom_border(borders) p.set_right_border(borders) if indent: p.set(first_indent=indent) if justified == "left": p.set_alignment(PARA_ALIGN_LEFT) elif justified == "right": p.set_alignment(PARA_ALIGN_RIGHT) elif justified == "center": p.set_alignment(PARA_ALIGN_CENTER) default_style.add_paragraph_style(name, p) # Graphics: g = GraphicsStyle() g.set_paragraph_style(name) if shadow: g.set_shadow(*shadow) if color is not None: g.set_fill_color(color) if not borders: g.set_line_width(0) default_style.add_draw_style(name, g) def make_default_style(self, default_style): """ Add the styles used in this report """ self.make_my_style(default_style, "BIR-Title", _('Title text style'), 14, bold=1, justified="center") self.make_my_style(default_style, "BIR-Datastyle", _('Data text display'), 12, indent=1.0) self.make_my_style(default_style, "BIR-Daystyle", _('Day text style'), 12, indent=.5, italic=1, bold=1) self.make_my_style(default_style, "BIR-Monthstyle", _('Month text style'), 14, bold=1) self.make_my_style(default_style, "BIR-Text1style", _('Text at bottom, line 1'), 12, justified="center") self.make_my_style(default_style, "BIR-Text2style", _('Text at bottom, line 2'), 12, justified="center") self.make_my_style(default_style, "BIR-Text3style", _('Text at bottom, line 3'), 12, justified="center")
class QRCodeOptions(MenuReportOptions): """ Defines options and provides handling interface. """ def __init__(self, name, dbase): self.__pid = None self.__filter = None self.__db = dbase MenuReportOptions.__init__(self, name, dbase) def add_menu_options(self, menu): ########################## category_name = _("Report Options") ########################## self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("A filter used to determine which people are included in the QRCode Generation Report")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed',self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("This field unlocks when a filter is selected that depends upon this value.")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self.__update_filters() def __filter_changed(self): filter_value = self.__filter.get_value() if filter_value in [1, 2, 3, 4]: self.__pid.set_available(True) else: self.__pid.set_available(False) def __update_filters(self): gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) filter_list = utils.get_person_filters(person, False) self.__filter.set_filters(filter_list) def make_default_style(self, default_style): """Make default output style for the QR Code Generator Report.""" #Paragraph Styles font = docgen.FontStyle() font.set_type_face(docgen.FONT_SANS_SERIF) font.set_size(12) font.set_bold(0) para = docgen.ParagraphStyle() para.set_font(font) para.set_alignment(docgen.PARA_ALIGN_CENTER) para.set_description(_('The basic style used for the text display')) para.set_padding(3) default_style.add_paragraph_style('QRCG-Normal', para) table = docgen.TableStyle() table.set_width(100) table.set_columns(3) table.set_column_width(0, 33) table.set_column_width(1, 33) table.set_column_width(2, 33) default_style.add_table_style('QRCG-Table', table) cell = docgen.TableCellStyle() cell.set_padding(0.1) cell.set_top_border(1) cell.set_right_border(1) cell.set_left_border(1) cell.set_bottom_border(1) default_style.add_cell_style('QRCG-Cell', cell)
class StatisticsChartOptions(MenuReportOptions): """ Options for StatisticsChart report """ def __init__(self, name, dbase): self.__pid = None self.__filter = None self.__db = dbase self._nf = None MenuReportOptions.__init__(self, name, dbase) def get_subject(self): """ Return a string that describes the subject of the report. """ return self.__filter.get_filter().get_name() def add_menu_options(self, menu): """ Add options to the menu for the statistics report. """ ################################ category_name = _("Report Options") add_option = partial(menu.add_option, category_name) ################################ self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help(_("Determines what people are included " "in the report.")) add_option("filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter.")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) sortby = EnumeratedListOption(_('Sort chart items by'), _options.SORT_VALUE) for item_idx in range(len(_options.opt_sorts)): item = _options.opt_sorts[item_idx] sortby.add_item(item_idx, item[2]) sortby.set_help(_("Select how the statistical data is sorted.")) add_option("sortby", sortby) reverse = BooleanOption(_("Sort in reverse order"), False) reverse.set_help(_("Check to reverse the sorting order.")) add_option("reverse", reverse) this_year = time.localtime()[0] year_from = NumberOption(_("People Born After"), 1700, 1, this_year) year_from.set_help(_("Birth year from which to include people.")) add_option("year_from", year_from) year_to = NumberOption(_("People Born Before"), this_year, 1, this_year) year_to.set_help(_("Birth year until which to include people")) add_option("year_to", year_to) no_years = BooleanOption(_("Include people without known birth years"), False) no_years.set_help(_("Whether to include people without " "known birth years.")) add_option("no_years", no_years) gender = EnumeratedListOption(_('Genders included'), Person.UNKNOWN) for item_idx in range(len(_options.opt_genders)): item = _options.opt_genders[item_idx] gender.add_item(item[0], item[2]) gender.set_help(_("Select which genders are included into " "statistics.")) add_option("gender", gender) bar_items = NumberOption(_("Max. items for a pie"), 8, 0, 20) bar_items.set_help(_("With fewer items pie chart and legend will be " "used instead of a bar chart.")) add_option("bar_items", bar_items) ################################ category_name = _("Report Options (2)") add_option = partial(menu.add_option, category_name) ################################ self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_private_data_option(menu, category_name) stdoptions.add_living_people_option(menu, category_name) stdoptions.add_localization_option(menu, category_name) ################################ # List of available charts on separate option tabs ################################ idx = 0 third = (len(_Extract.extractors) + 1) // 3 chart_types = [] for (chart_opt, ctuple) in _Extract.extractors.items(): chart_types.append((_(ctuple[1]), chart_opt, ctuple)) sorted_chart_types = sorted(chart_types, key=lambda x: glocale.sort_key(x[0])) for (translated_option_name, opt_name, ctuple) in sorted_chart_types: if idx >= (third * 2): category_name = _("Charts 3") elif idx >= third: category_name = _("Charts 2") else: category_name = _("Charts 1") opt = BooleanOption(translated_option_name, False) opt.set_help(_("Include charts with indicated data.")) menu.add_option(category_name, opt_name, opt) idx += 1 # Enable a couple of charts by default menu.get_option_by_name("data_gender").set_value(True) menu.get_option_by_name("data_ccount").set_value(True) menu.get_option_by_name("data_bmonth").set_value(True) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) nfv = self._nf.get_value() filter_list = utils.get_person_filters(person, include_single=False, name_format=nfv) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value == 0: # "Entire Database" (as "include_single=False") self.__pid.set_available(False) else: # The other filters need a center person (assume custom ones too) self.__pid.set_available(True) def make_default_style(self, default_style): """Make the default output style for the Statistics report.""" # Paragraph Styles fstyle = FontStyle() fstyle.set_size(10) fstyle.set_type_face(FONT_SERIF) pstyle = ParagraphStyle() pstyle.set_font(fstyle) pstyle.set_alignment(PARA_ALIGN_LEFT) pstyle.set_description(_("The style used for the items and values.")) default_style.add_paragraph_style("SC-Text", pstyle) fstyle = FontStyle() fstyle.set_size(14) fstyle.set_type_face(FONT_SANS_SERIF) pstyle = ParagraphStyle() pstyle.set_font(fstyle) pstyle.set_alignment(PARA_ALIGN_CENTER) pstyle.set_description(_("The style used for the title.")) default_style.add_paragraph_style("SC-Title", pstyle) """ Graphic Styles: SC-title - Contains the SC-Title paragraph style used for the title of the document SC-text - Contains the SC-Name paragraph style used for the individual's name SC-color-N - The colors for drawing pies. SC-bar - A red bar with 0.5pt black line. """ gstyle = GraphicsStyle() gstyle.set_paragraph_style("SC-Title") gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((255, 255, 255)) gstyle.set_line_width(0) default_style.add_draw_style("SC-title", gstyle) gstyle = GraphicsStyle() gstyle.set_paragraph_style("SC-Text") gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((255, 255, 255)) gstyle.set_line_width(0) default_style.add_draw_style("SC-text", gstyle) width = 0.8 # red gstyle = GraphicsStyle() gstyle.set_paragraph_style('SC-Text') gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((255, 0, 0)) gstyle.set_line_width(width) default_style.add_draw_style("SC-color-0", gstyle) # orange gstyle = GraphicsStyle() gstyle.set_paragraph_style('SC-Text') gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((255, 158, 33)) gstyle.set_line_width(width) default_style.add_draw_style("SC-color-1", gstyle) # green gstyle = GraphicsStyle() gstyle.set_paragraph_style('SC-Text') gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((0, 178, 0)) gstyle.set_line_width(width) default_style.add_draw_style("SC-color-2", gstyle) # violet gstyle = GraphicsStyle() gstyle.set_paragraph_style('SC-Text') gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((123, 0, 123)) gstyle.set_line_width(width) default_style.add_draw_style("SC-color-3", gstyle) # yellow gstyle = GraphicsStyle() gstyle.set_paragraph_style('SC-Text') gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((255, 255, 0)) gstyle.set_line_width(width) default_style.add_draw_style("SC-color-4", gstyle) # blue gstyle = GraphicsStyle() gstyle.set_paragraph_style('SC-Text') gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((0, 105, 214)) gstyle.set_line_width(width) default_style.add_draw_style("SC-color-5", gstyle) # gray gstyle = GraphicsStyle() gstyle.set_paragraph_style('SC-Text') gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((210, 204, 210)) gstyle.set_line_width(width) default_style.add_draw_style("SC-color-6", gstyle) gstyle = GraphicsStyle() gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((255, 0, 0)) gstyle.set_line_width(width) default_style.add_draw_style("SC-bar", gstyle) # legend gstyle = GraphicsStyle() gstyle.set_paragraph_style('SC-Text') gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((255, 255, 255)) gstyle.set_line_width(0) default_style.add_draw_style("SC-legend", gstyle)
class AttachSourceOptions(MenuToolOptions): """ Attach Source options """ def __init__(self, name, person_id=None, dbstate=None): self.__db = dbstate.get_database() MenuToolOptions.__init__(self, name, person_id, dbstate) def add_menu_options(self, menu): """ Add the options """ category_name = _("Options") self.__filter = FilterOption(_("Person Filter"), 0) self.__filter.set_help(_("Select filter to restrict people")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self.__update_filters() source_type = EnumeratedListOption(_("Source type"), 0) source_type.add_item(0, _("New source")) source_type.add_item(1, _("Existing source")) source_type.set_help(_("Select the type of source to attach")) menu.add_option(category_name, "source_type", source_type) source_type.connect('value-changed', self.__update_source_type) self.__source_type = source_type source_text = StringOption(_("New Source Title"), "") source_text.set_help(_("Text of source to attach")) menu.add_option(category_name, "source_text", source_text) self.__source_text = source_text source_id = StringOption(_("Existing Source ID"), "") source_id.set_help(_("ID of source to attach")) menu.add_option(category_name, "source_id", source_id) self.__source_id = source_id self.__update_source_type() def __update_source_type(self): """ Update the options based on the selected source type """ sid = self.__source_type.get_value() if sid == 0: self.__source_text.set_available(True) self.__source_id.set_available(False) else: self.__source_text.set_available(False) self.__source_id.set_available(True) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) filter_list = ReportUtils.get_person_filters(person, False) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value in [1, 2, 3, 4]: # Filters 0, 2, 3, 4 and 5 rely on the center person self.__pid.set_available(True) else: # The rest don't self.__pid.set_available(False)
class RemoveTagOptions(MenuToolOptions): """ Class for creating the remove tag menu options wich are needed for processing tag removal in class RemoveTagWindow. """ def __init__(self, name, person_id=None, dbstate=None): self.__db = dbstate.get_database() self.__tag_dict = self.__get_tag_dict() self.__item_list = self.__get_item_list() MenuToolOptions.__init__(self, name, person_id, dbstate) def __get_tag_dict(self): """ Return a dict in format: {tag_name <type:string> : tag_handle <type:string>} """ db = self.__db tag_list = db.iter_tags() tag_dict = {} for Tag in tag_list: serialized = Tag.serialize() tag_handle = serialized[0] tag_name = serialized[1] tag_dict[tag_name] = tag_handle return tag_dict def __get_item_list(self): """ Return an enumerated list containing the tag touples. Needed so users can select a tag name from the list. format: (number <int>, tag_name <str>) """ item_list = [] number = 0 for tag_name in self.__tag_dict: item = (number, tag_name) item_list.append(item) number += 1 return item_list def add_menu_options(self, menu): """ Add the menu options for the Remove Tag Tool. """ self.__add_tag_category_options(menu) self.__add_person_options(menu) self.__add_family_options(menu) self.__add_event_options(menu) self.__add_place_options(menu) self.__add_source_options(menu) self.__add_citation_options(menu) self.__add_repository_options(menu) self.__add_media_options(menu) self.__add_note_options(menu) self.__update_options() def __add_tag_category_options(self, menu): """ Menu Options for general category. Users selects from which category they'd like to remove a tag. The chosen category also restricts the tag removal to this category e.g. remove tag 'ToDo' from filtered persons, but not from places, events, etc. """ item_list = [] self.category_names = ["People", "Families", "Events", "Places", "Sources", "Citations", "Repositories", "Media", "Notes"] for i in range(1, 10): txt = i, _(self.category_names[i-1]) item_list.append(txt) self.__tag_category = FilterOption(_("Category"), 1) text = _("Choose a category from where would you like to remove a tag") tag_category_text = text self.__tag_category.set_help(tag_category_text) menu.add_option(_("Configuration"), "tag_category", self.__tag_category) self.__tag_category.set_items(item_list) self.__tag_category.connect('value-changed', self.__update_options) item_list = self.__item_list self.__tag_name = FilterOption("Remove Tag", 0) self.__tag_name.set_help(_("Choose a tag to remove")) menu.add_option(_("Configuration"), "tag_name", self.__tag_name) self.__tag_name.set_items(item_list) def __update_options(self): self.__filter.set_available(False) self.__pid.set_available(False) self.__family_filter.set_available(False) self.__fid.set_available(False) self.__event_filter.set_available(False) self.__place_filter.set_available(False) self.__source_filter.set_available(False) self.__cit_filter.set_available(False) self.__repo_filter.set_available(False) self.__media_filter.set_available(False) self.__note_filter.set_available(False) value = self.__tag_category.get_value() if value == 1: self.__filter.set_available(True) self.__filter_changed() elif value == 2: self.__family_filter.set_available(True) self.__family_filter_changed() elif value == 3: self.__event_filter.set_available(True) elif value == 4: self.__place_filter.set_available(True) elif value == 5: self.__source_filter.set_available(True) elif value == 6: self.__cit_filter.set_available(True) elif value == 7: self.__repo_filter.set_available(True) elif value == 8: self.__media_filter.set_available(True) elif value == 9: self.__note_filter.set_available(True) def __add_person_options(self, menu): """ Menu Options for person category. Menu Option 'filter' is used to choose a generic or custom person filter. Menu Option 'pid' selects the center person, which is needed for some person filters. """ self.__filter = FilterOption(_("Person Filter"), 0) self.__filter.set_help(_("Select filter to restrict people")) menu.add_option(_("Configuration"), "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Center Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(_("Configuration"), "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) def __update_filters(self): """ Update the filter list based on the selected person. """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) filter_list = ReportUtils.get_person_filters(person, False) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option. """ filter_value = self.__filter.get_value() if filter_value in [1, 2, 3, 4]: self.__pid.set_available(True) else: self.__pid.set_available(False) def __add_family_options(self, menu): """ Menu Options for family category. Menu Option 'family_filter' is used to choose a generic or custom family filter. Menu Option 'fid' selects the center family, which is needed for some filters. """ self.__family_filter = FilterOption(_("Family Filter"), 0) self.__family_filter.set_help(_("Select filter to restrict families")) menu.add_option(_("Configuration"), "family_filter", self.__family_filter) self.__family_filter.connect('value-changed', self.__family_filter_changed) self.__fid = FamilyOption(_("Center Family")) self.__fid.set_help(_("The center person for the filter")) menu.add_option(_("Configuration"), "fid", self.__fid) self.__fid.connect('value-changed', self.__update_family_filters) def __update_family_filters(self): """ Update the filter list based on the selected family. """ gid = self.__fid.get_value() family = self.__db.get_family_from_gramps_id(gid) filter_list = ReportUtils.get_family_filters(self.__db, family, False) self.__family_filter.set_filters(filter_list) def __family_filter_changed(self): """ Handle filter change. If the filter is not specific to a family, disable the family option. """ filter_value = self.__family_filter.get_value() if filter_value in [1, 2]: self.__fid.set_available(True) else: self.__fid.set_available(False) def __add_event_options(self, menu): """ Menu Options for event category. Menu Option 'event_filter' is used to choose a custom event filter. """ self.__event_filter = FilterOption(_("Event Filter"), 0) self.__event_filter.set_help(_("Select filter to restrict events")) menu.add_option(_("Configuration"), "event_filter", self.__event_filter) filter_list = CustomFilters.get_filters('Event') self.__event_filter.set_filters(filter_list) def __add_place_options(self, menu): """ Menu Options for place category. Menu Option 'place_filter' is used to choose a custom place filter. """ self.__place_filter = FilterOption(_("Place Filter"), 0) self.__place_filter.set_help(_("Select filter to restrict places")) menu.add_option(_("Configuration"), "place_filter", self.__place_filter) filter_list = CustomFilters.get_filters('Place') self.__place_filter.set_filters(filter_list) def __add_source_options(self, menu): """ Menu Options for scoure category. Menu Option 'source_filter' is used to choose a custom source filter. """ self.__source_filter = FilterOption(_("Source Filter"), 0) self.__source_filter.set_help(_("Select filter to restrict sources")) menu.add_option(_("Configuration"), "source_filter", self.__source_filter) filter_list = CustomFilters.get_filters('Source') self.__source_filter.set_filters(filter_list) def __add_citation_options(self, menu): """ Menu Options for citation category. Menu Option 'cit_filter' is used to choose a custom citation filter. """ self.__cit_filter = FilterOption(_("Citation Filter"), 0) self.__cit_filter.set_help(_("Select filter to restrict citations")) menu.add_option(_("Configuration"), "cit_filter", self.__cit_filter) filter_list = CustomFilters.get_filters('Citation') self.__cit_filter.set_filters(filter_list) def __add_repository_options(self, menu): """ Menu Options for repository category. Menu Option 'repo_filter' is usedto choose a custom repository filter. """ self.__repo_filter = FilterOption(_("Repository Filter"), 0) text = _("Select filter to restrict repositories") self.__repo_filter.set_help(text) menu.add_option(_("Configuration"), "repo_filter", self.__repo_filter) filter_list = CustomFilters.get_filters('Repository') self.__repo_filter.set_filters(filter_list) def __add_media_options(self, menu): """ Menu Options for media category. Menu Option 'media_filter' is used to choose a custom media filter. """ self.__media_filter = FilterOption(_("Media Filter"), 0) self.__media_filter.set_help(_("Select filter to restrict media")) menu.add_option(_("Configuration"), "media_filter", self.__media_filter) filter_list = CustomFilters.get_filters('Media') self.__media_filter.set_filters(filter_list) def __add_note_options(self, menu): """ Menu Options for notes category. Menu Option 'note_filter' is used to choose a custom note filter. """ self.__note_filter = FilterOption(_("Note Filter"), 0) self.__note_filter.set_help(_("Select filter to restrict notes")) menu.add_option(_("Configuration"), "note_filter", self.__note_filter) filter_list = CustomFilters.get_filters('Note') self.__note_filter.set_filters(filter_list)
class StatisticsChartOptions(MenuReportOptions): """ Options for StatisticsChart report """ def __init__(self, name, dbase): self.__pid = None self.__filter = None self.__db = dbase self._nf = None MenuReportOptions.__init__(self, name, dbase) def get_subject(self): """ Return a string that describes the subject of the report. """ return self.__filter.get_filter().get_name() def add_menu_options(self, menu): """ Add options to the menu for the statistics report. """ ################################ category_name = _("Report Options") add_option = partial(menu.add_option, category_name) ################################ self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Determines what people are included " "in the report.")) add_option("filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter.")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) sortby = EnumeratedListOption(_('Sort chart items by'), _options.SORT_VALUE) for item_idx in range(len(_options.opt_sorts)): item = _options.opt_sorts[item_idx] sortby.add_item(item_idx, item[2]) sortby.set_help(_("Select how the statistical data is sorted.")) add_option("sortby", sortby) reverse = BooleanOption(_("Sort in reverse order"), False) reverse.set_help(_("Check to reverse the sorting order.")) add_option("reverse", reverse) this_year = time.localtime()[0] year_from = NumberOption(_("People Born After"), 1700, 1, this_year) year_from.set_help(_("Birth year from which to include people.")) add_option("year_from", year_from) year_to = NumberOption(_("People Born Before"), this_year, 1, this_year) year_to.set_help(_("Birth year until which to include people")) add_option("year_to", year_to) no_years = BooleanOption(_("Include people without known birth years"), False) no_years.set_help( _("Whether to include people without " "known birth years.")) add_option("no_years", no_years) gender = EnumeratedListOption(_('Genders included'), Person.UNKNOWN) for item_idx in range(len(_options.opt_genders)): item = _options.opt_genders[item_idx] gender.add_item(item[0], item[2]) gender.set_help( _("Select which genders are included into " "statistics.")) add_option("gender", gender) bar_items = NumberOption(_("Max. items for a pie"), 8, 0, 20) bar_items.set_help( _("With fewer items pie chart and legend will be " "used instead of a bar chart.")) add_option("bar_items", bar_items) show_empty_information = BooleanOption( _("Include counts of missing information"), False) show_empty_information.set_help( _("Whether to include counts of the " "number of people who lack the given " "information.")) add_option("show_empty_information", show_empty_information) ################################ category_name = _("Report Options (2)") add_option = partial(menu.add_option, category_name) ################################ self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_private_data_option(menu, category_name) stdoptions.add_living_people_option(menu, category_name) stdoptions.add_localization_option(menu, category_name) ################################ # List of available charts on separate option tabs ################################ idx = 0 third = (len(_Extract.extractors) + 1) // 3 chart_types = [] for (chart_opt, ctuple) in _Extract.extractors.items(): chart_types.append((_(ctuple[1]), chart_opt, ctuple)) sorted_chart_types = sorted(chart_types, key=lambda x: glocale.sort_key(x[0])) for (translated_option_name, opt_name, ctuple) in sorted_chart_types: if idx >= (third * 2): category_name = _("Charts 3") elif idx >= third: category_name = _("Charts 2") else: category_name = _("Charts 1") opt = BooleanOption(translated_option_name, False) opt.set_help(_("Include charts with indicated data.")) menu.add_option(category_name, opt_name, opt) idx += 1 # Enable a couple of charts by default menu.get_option_by_name("data_gender").set_value(True) menu.get_option_by_name("data_ccount").set_value(True) menu.get_option_by_name("data_bmonth").set_value(True) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) nfv = self._nf.get_value() filter_list = utils.get_person_filters(person, include_single=False, name_format=nfv) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value == 0: # "Entire Database" (as "include_single=False") self.__pid.set_available(False) else: # The other filters need a center person (assume custom ones too) self.__pid.set_available(True) def make_default_style(self, default_style): """Make the default output style for the Statistics report.""" # Paragraph Styles fstyle = FontStyle() fstyle.set_size(10) fstyle.set_type_face(FONT_SERIF) pstyle = ParagraphStyle() pstyle.set_font(fstyle) pstyle.set_alignment(PARA_ALIGN_LEFT) pstyle.set_description(_("The style used for the items and values.")) default_style.add_paragraph_style("SC-Text", pstyle) fstyle = FontStyle() fstyle.set_size(14) fstyle.set_type_face(FONT_SANS_SERIF) pstyle = ParagraphStyle() pstyle.set_font(fstyle) pstyle.set_alignment(PARA_ALIGN_CENTER) pstyle.set_description(_("The style used for the title.")) default_style.add_paragraph_style("SC-Title", pstyle) """ Graphic Styles: SC-title - Contains the SC-Title paragraph style used for the title of the document SC-text - Contains the SC-Name paragraph style used for the individual's name SC-color-N - The colors for drawing pies. SC-bar - A red bar with 0.5pt black line. """ gstyle = GraphicsStyle() gstyle.set_paragraph_style("SC-Title") gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((255, 255, 255)) gstyle.set_line_width(0) default_style.add_draw_style("SC-title", gstyle) gstyle = GraphicsStyle() gstyle.set_paragraph_style("SC-Text") gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((255, 255, 255)) gstyle.set_line_width(0) default_style.add_draw_style("SC-text", gstyle) width = 0.8 # red gstyle = GraphicsStyle() gstyle.set_paragraph_style('SC-Text') gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((255, 0, 0)) gstyle.set_line_width(width) default_style.add_draw_style("SC-color-0", gstyle) # orange gstyle = GraphicsStyle() gstyle.set_paragraph_style('SC-Text') gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((255, 158, 33)) gstyle.set_line_width(width) default_style.add_draw_style("SC-color-1", gstyle) # green gstyle = GraphicsStyle() gstyle.set_paragraph_style('SC-Text') gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((0, 178, 0)) gstyle.set_line_width(width) default_style.add_draw_style("SC-color-2", gstyle) # violet gstyle = GraphicsStyle() gstyle.set_paragraph_style('SC-Text') gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((123, 0, 123)) gstyle.set_line_width(width) default_style.add_draw_style("SC-color-3", gstyle) # yellow gstyle = GraphicsStyle() gstyle.set_paragraph_style('SC-Text') gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((255, 255, 0)) gstyle.set_line_width(width) default_style.add_draw_style("SC-color-4", gstyle) # blue gstyle = GraphicsStyle() gstyle.set_paragraph_style('SC-Text') gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((0, 105, 214)) gstyle.set_line_width(width) default_style.add_draw_style("SC-color-5", gstyle) # gray gstyle = GraphicsStyle() gstyle.set_paragraph_style('SC-Text') gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((210, 204, 210)) gstyle.set_line_width(width) default_style.add_draw_style("SC-color-6", gstyle) gstyle = GraphicsStyle() gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((255, 0, 0)) gstyle.set_line_width(width) default_style.add_draw_style("SC-bar", gstyle) # legend gstyle = GraphicsStyle() gstyle.set_paragraph_style('SC-Text') gstyle.set_color((0, 0, 0)) gstyle.set_fill_color((255, 255, 255)) gstyle.set_line_width(0) default_style.add_draw_style("SC-legend", gstyle)
class IndivCompleteOptions(MenuReportOptions): """ Defines options and provides handling interface. """ def __init__(self, name, dbase): self.__db = dbase self.__pid = None self.__filter = None MenuReportOptions.__init__(self, name, dbase) def add_menu_options(self, menu): ################################ category_name = _("Report Options") ################################ self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Select the filter to be applied to the report.")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter.")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) stdoptions.add_name_format_option(menu, category_name) self.__update_filters() sort = BooleanOption(_("List events chronologically"), True) sort.set_help(_("Whether to sort events into chronological order.")) menu.add_option(category_name, "sort", sort) pageben = BooleanOption(_("Page break before end notes"),False) pageben.set_help( _("Whether to start a new page before the end notes.")) menu.add_option(category_name, "pageben", pageben) stdoptions.add_localization_option(menu, category_name) ################################ category_name = _("Include") ################################ stdoptions.add_private_data_option(menu, category_name) cites = BooleanOption(_("Include Source Information"), True) cites.set_help(_("Whether to cite sources.")) menu.add_option(category_name, "cites", cites) incsrcnotes = BooleanOption(_("Include sources notes"), False) incsrcnotes.set_help(_("Whether to include source notes in the " "Endnotes section. Only works if Include sources is selected.")) menu.add_option(category_name, "incsrcnotes", incsrcnotes) images = BooleanOption(_("Include Photo/Images from Gallery"), True) images.set_help(_("Whether to include images.")) menu.add_option(category_name, "images", images) grampsid = BooleanOption(_("Include Gramps ID"), False) grampsid.set_help(_("Whether to include Gramps ID next to names.")) menu.add_option(category_name, "grampsid", grampsid) ################################ category_name = SECTION_CATEGORY ################################ opt = BooleanListOption(_("Event groups")) opt.set_help(_("Check if a separate section is required.")) for section in SECTION_LIST: if section != SECTION_LIST[0]: opt.add_button(_(section), True) menu.add_option(category_name, "sections", opt) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) filter_list = ReportUtils.get_person_filters(person, True) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value in [0, 2, 3, 4, 5]: # Filters 0, 2, 3, 4 and 5 rely on the center person self.__pid.set_available(True) else: # The rest don't self.__pid.set_available(False) def make_default_style(self, default_style): """Make the default output style for the Individual Complete Report.""" # Paragraph Styles font = FontStyle() font.set_bold(1) font.set_type_face(FONT_SANS_SERIF) font.set_size(16) para = ParagraphStyle() para.set_alignment(PARA_ALIGN_CENTER) para.set_top_margin(ReportUtils.pt2cm(8)) para.set_bottom_margin(ReportUtils.pt2cm(8)) para.set_font(font) para.set_description(_("The style used for the title of the page.")) default_style.add_paragraph_style("IDS-Title", para) font = FontStyle() font.set_bold(1) font.set_type_face(FONT_SANS_SERIF) font.set_size(12) font.set_italic(1) para = ParagraphStyle() para.set_font(font) para.set_top_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_description(_("The style used for category labels.")) default_style.add_paragraph_style("IDS-TableTitle", para) font = FontStyle() font.set_bold(1) font.set_type_face(FONT_SANS_SERIF) font.set_size(12) para = ParagraphStyle() para.set_font(font) para.set_top_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_description(_("The style used for the spouse's name.")) default_style.add_paragraph_style("IDS-Spouse", para) font = FontStyle() font.set_size(12) para = ParagraphStyle() para.set_font(font) para.set_top_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_description(_('The basic style used for the text display.')) default_style.add_paragraph_style("IDS-Normal", para) font = FontStyle() font.set_size(12) font.set_italic(1) para = ParagraphStyle() para.set_font(font) para.set_top_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_description(_('The style used for the section headers.')) default_style.add_paragraph_style("IDS-Section", para) font = FontStyle() font.set_size(8) para = ParagraphStyle() para.set_alignment(PARA_ALIGN_RIGHT) para.set_font(font) para.set_top_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_description(_('A style used for image facts.')) default_style.add_paragraph_style("IDS-ImageNote", para) font = FontStyle() font.set_size(8) para = ParagraphStyle() para.set_alignment(PARA_ALIGN_CENTER) para.set_font(font) para.set_top_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_description(_('A style used for image captions.')) default_style.add_paragraph_style("IDS-ImageCaptionCenter", para) # Table Styles tbl = TableStyle() tbl.set_width(100) tbl.set_columns(2) tbl.set_column_width(0, 20) tbl.set_column_width(1, 80) default_style.add_table_style("IDS-IndTable", tbl) tbl = TableStyle() tbl.set_width(100) tbl.set_columns(2) tbl.set_column_width(0, 50) tbl.set_column_width(1, 50) default_style.add_table_style("IDS-ParentsTable", tbl) cell = TableCellStyle() cell.set_top_border(1) cell.set_bottom_border(1) default_style.add_cell_style("IDS-TableHead", cell) cell = TableCellStyle() default_style.add_cell_style("IDS-NormalCell", cell) cell = TableCellStyle() cell.set_longlist(1) default_style.add_cell_style("IDS-ListCell", cell) tbl = TableStyle() tbl.set_width(100) tbl.set_columns(3) tbl.set_column_width(0,20) tbl.set_column_width(1,50) tbl.set_column_width(2,30) default_style.add_table_style('IDS-PersonTable', tbl) tbl = TableStyle() tbl.set_width(100) tbl.set_columns(2) tbl.set_column_width(0,20) tbl.set_column_width(1,80) default_style.add_table_style('IDS-PersonTable2', tbl) tbl = TableStyle() tbl.set_width(100) tbl.set_columns(5) tbl.set_column_width(0,22) # Type tbl.set_column_width(1,22) # Date tbl.set_column_width(2,16) # Status tbl.set_column_width(3,22) # Temple tbl.set_column_width(4,18) # Place default_style.add_table_style('IDS-OrdinanceTable', tbl) tbl = TableStyle() tbl.set_width(100) tbl.set_columns(6) tbl.set_column_width(0,20) # empty tbl.set_column_width(1,18) # Type tbl.set_column_width(2,18) # Date tbl.set_column_width(3,14) # Status tbl.set_column_width(4,18) # Temple tbl.set_column_width(5,12) # Place default_style.add_table_style('IDS-OrdinanceTable2', tbl) tbl = TableStyle() tbl.set_width(100) tbl.set_columns(3) tbl.set_column_width(0, 33) tbl.set_column_width(1, 33) tbl.set_column_width(2, 34) default_style.add_table_style("IDS-GalleryTable", tbl) Endnotes.add_endnote_styles(default_style)
class CalcEstDateOptions(MenuToolOptions): """ Calculate Estimated Date options """ def __init__(self, name, person_id=None, dbstate=None): self.__db = dbstate.get_database() self.__dbstate = dbstate MenuToolOptions.__init__(self, name, person_id, dbstate) def get_dbstate(self): return self.__dbstate def add_menu_options(self, menu): """ Add the options """ category_name = _("Options") self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help(_("Select filter to restrict people")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self.__update_filters() source_text = StringOption(_("Source text"), _("Calculated Date Estimates")) source_text.set_help(_("Source to remove and/or add")) menu.add_option(category_name, "source_text", source_text) remove = BooleanOption(_("Remove previously added events, notes, and source"), True) remove.set_help(_("Remove calculated events, notes, and source; occurs immediately on Execute")) menu.add_option(category_name, "remove", remove) birth = EnumeratedListOption(_("Birth"), 0) birth.add_item(0, _("Do not add birth events")) birth.add_item(1, _("Add birth events without dates")) birth.add_item(2, _("Add birth events with dates")) birth.set_help( _("Add a birth events with or without estimated dates")) menu.add_option(category_name, "add_birth", birth) death = EnumeratedListOption(_("Death"), 0) death.add_item(0, _("Do not add death events")) death.add_item(1, _("Add death events without dates")) death.add_item(2, _("Add death events with dates")) death.set_help( _("Add death events with or without estimated dates")) menu.add_option(category_name, "add_death", death) # ----------------------------------------------------- num = NumberOption(_("Maximum age"), config.get('behavior.max-age-prob-alive'), 0, 200) num.set_help(_("Maximum age that one can live to")) menu.add_option(category_name, "MAX_AGE_PROB_ALIVE", num) num = NumberOption(_("Maximum sibling age difference"), config.get('behavior.max-sib-age-diff'), 0, 200) num.set_help(_("Maximum age difference between siblings")) menu.add_option(category_name, "MAX_SIB_AGE_DIFF", num) num = NumberOption(_("Average years between generations"), config.get('behavior.avg-generation-gap'), 0, 200) num.set_help(_("Average years between two generations")) menu.add_option(category_name, "AVG_GENERATION_GAP", num) dates = EnumeratedListOption(_("Estimated Dates"), 0) dates.add_item(0, _("Approximate (about)")) dates.add_item(1, _("Extremes (after and before)")) dates.set_help( _("Dates on events are either about or after/before")) menu.add_option(category_name, "dates", dates) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) filter_list = get_person_filters(person, False) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value in [1, 2, 3, 4]: # Filters 0, 2, 3, 4 and 5 rely on the center person self.__pid.set_available(True) else: # The rest don't self.__pid.set_available(False)
def add_menu_options(self, menu): """ Add the options for this report """ category_name = _("Report Options") title = StringOption(_('book|Title'), _('Title of the Book')) title.set_help(_("Title string for the book.")) menu.add_option(category_name, "title", title) subtitle = StringOption(_('Subtitle'), _('Subtitle of the Book')) subtitle.set_help(_("Subtitle string for the book.")) menu.add_option(category_name, "subtitle", subtitle) dateinfo = time.localtime(time.time()) #rname = self.__db.get_researcher().get_name() rname = "researcher name" footer_string = _('Copyright %(year)d %(name)s') % { 'year': dateinfo[0], 'name': rname } footer = StringOption(_('Footer'), footer_string) footer.set_help(_("Footer string for the page.")) menu.add_option(category_name, "footer", footer) # Reload filters to pick any new ones CustomFilters = None #p- from Filters import CustomFilters, GenericFilter from gramps.gen.filters import CustomFilters, GenericFilter # opt = FilterOption(_("Select using filter"), 0) # opt.set_help(_("Select places using a filter")) # filter_list = [] # filter_list.append(GenericFilter()) # filter_list.extend(CustomFilters.get_filters('Source')) # opt.set_filters(filter_list) # menu.add_option(category_name, "filter", opt) # # showpersons = BooleanOption(_("Show persons"), True) # showpersons.set_help(_("Whether to show events and persons mentioned in the note")) # menu.add_option(category_name, "showpersons", showpersons) # # incphotos = BooleanOption(_("Include Photos"), True) # incphotos.set_help(_("Whether to show photos mentioned in the citation")) # menu.add_option(category_name, "incphotos", incphotos) category_name = _("Calc Options") # Reload filters to pick any new ones CustomFilters = None from gramps.gen.filters import CustomFilters, GenericFilter opt = FilterOption(_("Select using filter"), 0) opt.set_help(_("Select places using a filter")) filter_list = [] filter_list.append(GenericFilter()) filter_list.extend(CustomFilters.get_filters('Source')) opt.set_filters(filter_list) menu.add_option(category_name, "filter", opt) # opt = FilterOption(_("Select Person filter"), 0) # opt.set_help(_("Select places using a person filter")) # filter_list = [] # filter_list.append(GenericFilter()) # filter_list.extend(CustomFilters.get_filters('Person')) # opt.set_filters(filter_list) # menu.add_option(category_name, "filter", opt) showallfamilies = BooleanOption( _("Show surnames of all famiies in clans"), True) showallfamilies.set_help( _("Whether to show the names of all families as surname")) menu.add_option(category_name, "showallfamilies", showallfamilies) placeformat = EnumeratedListOption(_("Place Format"), "Default") placeformat.set_items([("default", _("Default")), ("first", _("First")), ("firstplace", _("Firstplace")), ("firstplace-country", _("Firstplace-Country")), ("country", _("Country")), ("long", _("Long"))]) placeformat.set_help(_("If Placename is given long or short")) menu.add_option(category_name, "placeformat", placeformat)
class CalendarOptions(MenuReportOptions): """ Calendar options for graphic calendar """ def __init__(self, name, dbase): self.__db = dbase self.__pid = None self.__filter = None MenuReportOptions.__init__(self, name, dbase) def add_menu_options(self, menu): """ Add the options for the graphical calendar """ ########################## category_name = _("Report Options") add_option = partial(menu.add_option, category_name) ########################## self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Select filter to restrict people that appear on calendar")) add_option("filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Center Person")) self.__pid.set_help(_("The center person for the report")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_private_data_option(menu, category_name) alive = BooleanOption(_("Include only living people"), True) alive.set_help(_("Include only living people in the calendar")) add_option("alive", alive) stdoptions.add_localization_option(menu, category_name) ########################## category_name = _("Content Options") add_option = partial(menu.add_option, category_name) ########################## year = NumberOption(_("Year of calendar"), time.localtime()[0], 1000, 3000) year.set_help(_("Year of calendar")) add_option("year", year) country = EnumeratedListOption(_("Country for holidays"), 0) holiday_table = libholiday.HolidayTable() countries = holiday_table.get_countries() countries.sort() if (len(countries) == 0 or (len(countries) > 0 and countries[0] != '')): countries.insert(0, '') count = 0 for c in countries: country.add_item(count, c) count += 1 country.set_help(_("Select the country to see associated holidays")) add_option("country", country) start_dow = EnumeratedListOption(_("First day of week"), 1) long_days = date_displayer.long_days 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, long_days[count].capitalize()) start_dow.set_help(_("Select the first day of the week for the calendar")) add_option("start_dow", start_dow) 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")) maiden_name.set_help(_("Select married women's displayed surname")) add_option("maiden_name", maiden_name) birthdays = BooleanOption(_("Include birthdays"), True) birthdays.set_help(_("Include birthdays in the calendar")) add_option("birthdays", birthdays) anniversaries = BooleanOption(_("Include anniversaries"), True) anniversaries.set_help(_("Include anniversaries in the calendar")) add_option("anniversaries", anniversaries) ########################## category_name = _("Text Options") add_option = partial(menu.add_option, _("Text Options")) ########################## text1 = StringOption(_("Text Area 1"), _(_TITLE1)) text1.set_help(_("First line of text at bottom of calendar")) add_option("text1", text1) text2 = StringOption(_("Text Area 2"), _(_TITLE2)) text2.set_help(_("Second line of text at bottom of calendar")) add_option("text2", text2) text3 = StringOption(_("Text Area 3"), URL_HOMEPAGE) text3.set_help(_("Third line of text at bottom of calendar")) add_option("text3", text3) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) nfv = self._nf.get_value() filter_list = ReportUtils.get_person_filters(person, include_single=False, name_format=nfv) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value in [1, 2, 3, 4]: # Filters 1, 2, 3 and 4 rely on the center person self.__pid.set_available(True) else: # The rest don't self.__pid.set_available(False) def make_my_style(self, default_style, name, description, size=9, font=FONT_SERIF, justified ="left", color=None, align=PARA_ALIGN_CENTER, shadow = None, italic=0, bold=0, borders=0, indent=None): """ Create paragraph and graphic styles of the same name """ # Paragraph: f = FontStyle() f.set_size(size) f.set_type_face(font) f.set_italic(italic) f.set_bold(bold) p = ParagraphStyle() p.set_font(f) p.set_alignment(align) p.set_description(description) p.set_top_border(borders) p.set_left_border(borders) p.set_bottom_border(borders) p.set_right_border(borders) if indent: p.set(first_indent=indent) if justified == "left": p.set_alignment(PARA_ALIGN_LEFT) elif justified == "right": p.set_alignment(PARA_ALIGN_RIGHT) elif justified == "center": p.set_alignment(PARA_ALIGN_CENTER) default_style.add_paragraph_style(name, p) # Graphics: g = GraphicsStyle() g.set_paragraph_style(name) if shadow: g.set_shadow(*shadow) if color is not None: g.set_fill_color(color) if not borders: g.set_line_width(0) default_style.add_draw_style(name, g) def make_default_style(self, default_style): """ Add the styles used in this report """ self.make_my_style(default_style, "CAL-Title", _('Title text and background color'), 20, bold=1, italic=1, color=(0xEA, 0xEA, 0xEA)) self.make_my_style(default_style, "CAL-Numbers", _('Calendar day numbers'), 13, bold=1) self.make_my_style(default_style, "CAL-Text", _('Daily text display'), 9) self.make_my_style(default_style, "CAL-Holiday", _('Holiday text display'), 9, bold=1, italic=1) self.make_my_style(default_style, "CAL-Daynames", _('Days of the week text'), 12, italic=1, bold=1, color = (0xEA, 0xEA, 0xEA)) self.make_my_style(default_style, "CAL-Text1style", _('Text at bottom, line 1'), 12) self.make_my_style(default_style, "CAL-Text2style", _('Text at bottom, line 2'), 12) self.make_my_style(default_style, "CAL-Text3style", _('Text at bottom, line 3'), 9) self.make_my_style(default_style, "CAL-Border", _('Borders'), borders=True)
class SortEventOptions(MenuToolOptions): """ Define options and provides handling interface. """ def __init__(self, name, person_id=None, dbstate=None): self.__db = dbstate.get_database() MenuToolOptions.__init__(self, name, person_id, dbstate) def add_menu_options(self, menu): """ Define the options for the menu. """ category_name = _("Tool Options") self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help(_("Select the people to sort")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self.__update_filters() sort_by = EnumeratedListOption(_('Sort by'), 0) idx = 0 for item in _get_sort_functions(Sort(self.__db)): sort_by.add_item(idx, item[0]) idx += 1 sort_by.set_help(_("Sorting method to use")) menu.add_option(category_name, "sort_by", sort_by) sort_desc = BooleanOption(_("Sort descending"), False) sort_desc.set_help(_("Set the sort order")) menu.add_option(category_name, "sort_desc", sort_desc) family_events = BooleanOption(_("Include family events"), True) family_events.set_help(_("Sort family events of the person")) menu.add_option(category_name, "family_events", family_events) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value in [1, 2, 3, 4]: # Filters 1, 2, 3 and 4 rely on the center person self.__pid.set_available(True) else: # The rest don't self.__pid.set_available(False) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) filter_list = utils.get_person_filters(person, False) self.__filter.set_filters(filter_list)
class IndivCompleteOptions(MenuReportOptions): """ Defines options and provides handling interface. """ def __init__(self, name, dbase): self.__db = dbase self.__pid = None self.__filter = None MenuReportOptions.__init__(self, name, dbase) def add_menu_options(self, menu): ################################ category_name = _("Report Options") ################################ self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Select the filter to be applied to the report.")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter.")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_private_data_option(menu, category_name) sort = BooleanOption(_("List events chronologically"), True) sort.set_help(_("Whether to sort events into chronological order.")) menu.add_option(category_name, "sort", sort) pageben = BooleanOption(_("Page break before end notes"),False) pageben.set_help( _("Whether to start a new page before the end notes.")) menu.add_option(category_name, "pageben", pageben) stdoptions.add_localization_option(menu, category_name) ################################ category_name = _("Include") ################################ cites = BooleanOption(_("Include Source Information"), True) cites.set_help(_("Whether to cite sources.")) menu.add_option(category_name, "cites", cites) incsrcnotes = BooleanOption(_("Include sources notes"), False) incsrcnotes.set_help(_("Whether to include source notes in the " "Endnotes section. Only works if Include sources is selected.")) menu.add_option(category_name, "incsrcnotes", incsrcnotes) images = BooleanOption(_("Include Photo/Images from Gallery"), True) images.set_help(_("Whether to include images.")) menu.add_option(category_name, "images", images) grampsid = BooleanOption(_("Include Gramps ID"), False) grampsid.set_help(_("Whether to include Gramps ID next to names.")) menu.add_option(category_name, "grampsid", grampsid) ################################ category_name = _("Sections") ################################ opt = BooleanListOption(_("Event groups")) opt.set_help(_("Check if a separate section is required.")) for section in SECTION_LIST: if section != SECTION_LIST[0]: opt.add_button(_(section), True) menu.add_option(category_name, "sections", opt) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) nfv = self._nf.get_value() filter_list = ReportUtils.get_person_filters(person, include_single=True, name_format=nfv) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value in [0, 2, 3, 4, 5]: # Filters 0, 2, 3, 4 and 5 rely on the center person self.__pid.set_available(True) else: # The rest don't self.__pid.set_available(False) def make_default_style(self, default_style): """Make the default output style for the Individual Complete Report.""" # Paragraph Styles font = FontStyle() font.set_bold(1) font.set_type_face(FONT_SANS_SERIF) font.set_size(16) para = ParagraphStyle() para.set_alignment(PARA_ALIGN_CENTER) para.set_top_margin(ReportUtils.pt2cm(8)) para.set_bottom_margin(ReportUtils.pt2cm(8)) para.set_font(font) para.set_description(_("The style used for the title of the page.")) default_style.add_paragraph_style("IDS-Title", para) font = FontStyle() font.set_bold(1) font.set_type_face(FONT_SANS_SERIF) font.set_size(12) font.set_italic(1) para = ParagraphStyle() para.set_font(font) para.set_top_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_description(_("The style used for category labels.")) default_style.add_paragraph_style("IDS-TableTitle", para) font = FontStyle() font.set_bold(1) font.set_type_face(FONT_SANS_SERIF) font.set_size(12) para = ParagraphStyle() para.set_font(font) para.set_top_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_description(_("The style used for the spouse's name.")) default_style.add_paragraph_style("IDS-Spouse", para) font = FontStyle() font.set_size(12) para = ParagraphStyle() para.set_font(font) para.set_top_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_description(_('The basic style used for the text display.')) default_style.add_paragraph_style("IDS-Normal", para) font = FontStyle() font.set_size(12) font.set_italic(1) para = ParagraphStyle() para.set_font(font) para.set_top_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_description(_('The style used for the section headers.')) default_style.add_paragraph_style("IDS-Section", para) font = FontStyle() font.set_size(8) para = ParagraphStyle() para.set_alignment(PARA_ALIGN_RIGHT) para.set_font(font) para.set_top_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_description(_('A style used for image facts.')) default_style.add_paragraph_style("IDS-ImageNote", para) font = FontStyle() font.set_size(8) para = ParagraphStyle() para.set_alignment(PARA_ALIGN_CENTER) para.set_font(font) para.set_top_margin(ReportUtils.pt2cm(3)) para.set_bottom_margin(ReportUtils.pt2cm(3)) para.set_description(_('A style used for image captions.')) default_style.add_paragraph_style("IDS-ImageCaptionCenter", para) # Table Styles tbl = TableStyle() tbl.set_width(100) tbl.set_columns(2) tbl.set_column_width(0, 20) tbl.set_column_width(1, 80) default_style.add_table_style("IDS-IndTable", tbl) tbl = TableStyle() tbl.set_width(100) tbl.set_columns(2) tbl.set_column_width(0, 50) tbl.set_column_width(1, 50) default_style.add_table_style("IDS-ParentsTable", tbl) cell = TableCellStyle() cell.set_top_border(1) cell.set_bottom_border(1) default_style.add_cell_style("IDS-TableHead", cell) cell = TableCellStyle() default_style.add_cell_style("IDS-NormalCell", cell) cell = TableCellStyle() cell.set_longlist(1) default_style.add_cell_style("IDS-ListCell", cell) tbl = TableStyle() tbl.set_width(100) tbl.set_columns(3) tbl.set_column_width(0,20) tbl.set_column_width(1,50) tbl.set_column_width(2,30) default_style.add_table_style('IDS-PersonTable', tbl) tbl = TableStyle() tbl.set_width(100) tbl.set_columns(2) tbl.set_column_width(0,20) tbl.set_column_width(1,80) default_style.add_table_style('IDS-PersonTable2', tbl) tbl = TableStyle() tbl.set_width(100) tbl.set_columns(5) tbl.set_column_width(0,22) # Type tbl.set_column_width(1,22) # Date tbl.set_column_width(2,16) # Status tbl.set_column_width(3,22) # Temple tbl.set_column_width(4,18) # Place default_style.add_table_style('IDS-OrdinanceTable', tbl) tbl = TableStyle() tbl.set_width(100) tbl.set_columns(6) tbl.set_column_width(0,20) # empty tbl.set_column_width(1,18) # Type tbl.set_column_width(2,18) # Date tbl.set_column_width(3,14) # Status tbl.set_column_width(4,18) # Temple tbl.set_column_width(5,12) # Place default_style.add_table_style('IDS-OrdinanceTable2', tbl) tbl = TableStyle() tbl.set_width(100) tbl.set_columns(3) tbl.set_column_width(0, 33) tbl.set_column_width(1, 33) tbl.set_column_width(2, 34) default_style.add_table_style("IDS-GalleryTable", tbl) Endnotes.add_endnote_styles(default_style)
class RecordsReportOptions(MenuReportOptions): """ Defines options and provides handling interface. """ def __init__(self, name, dbase): self.__pid = None self.__filter = None self.__db = dbase MenuReportOptions.__init__(self, name, dbase) def add_menu_options(self, menu): category_name = _("Report Options") self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Determines what people are included in the report.")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self.__update_filters() top_size = NumberOption(_("Number of ranks to display"), 3, 1, 100) menu.add_option(category_name, "top_size", top_size) callname = EnumeratedListOption(_("Use call name"), CALLNAME_DONTUSE) callname.set_items([ (CALLNAME_DONTUSE, _("Don't use call name")), (CALLNAME_REPLACE, _("Replace first names with call name")), (CALLNAME_UNDERLINE_ADD, _("Underline call name in first names / add call name to first name" )) ]) menu.add_option(category_name, "callname", callname) footer = StringOption(_("Footer text"), "") menu.add_option(category_name, "footer", footer) stdoptions.add_private_data_option(menu, category_name) stdoptions.add_localization_option(menu, category_name) for (text, varname, default) in RECORDS: option = BooleanOption(_(text), default) if varname.startswith('person'): category_name = _("Person Records") elif varname.startswith('family'): category_name = _("Family Records") menu.add_option(category_name, varname, option) def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) filter_list = ReportUtils.get_person_filters(person, False) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value in [1, 2, 3, 4]: # Filters 1, 2, 3 and 4 rely on the center person self.__pid.set_available(True) else: # The rest don't self.__pid.set_available(False) def make_default_style(self, default_style): #Paragraph Styles font = FontStyle() font.set_type_face(FONT_SANS_SERIF) font.set_size(16) font.set_bold(True) para = ParagraphStyle() para.set_font(font) para.set_alignment(PARA_ALIGN_CENTER) para.set_description(_("The style used for the report title.")) default_style.add_paragraph_style('REC-Title', para) font = FontStyle() font.set_type_face(FONT_SANS_SERIF) font.set_size(12) font.set_bold(True) para = ParagraphStyle() para.set_font(font) para.set_alignment(PARA_ALIGN_CENTER) para.set_bottom_border(True) para.set_bottom_margin(ReportUtils.pt2cm(8)) para.set_description(_("The style used for the report subtitle.")) default_style.add_paragraph_style('REC-Subtitle', para) font = FontStyle() font.set_size(12) font.set_bold(True) para = ParagraphStyle() para.set_font(font) para.set_top_margin(ReportUtils.pt2cm(6)) para.set_description(_('The style used for headings.')) default_style.add_paragraph_style('REC-Heading', para) font = FontStyle() font.set_size(10) para = ParagraphStyle() para.set_font(font) para.set_left_margin(0.5) para.set_description(_('The basic style used for the text display.')) default_style.add_paragraph_style('REC-Normal', para) font = FontStyle() font.set_size(8) para = ParagraphStyle() para.set_font(font) para.set_alignment(PARA_ALIGN_CENTER) para.set_top_border(True) para.set_top_margin(ReportUtils.pt2cm(8)) para.set_description(_('The style used for the footer.')) default_style.add_paragraph_style('REC-Footer', para)
def add_menu_options(self, menu): ################################ category_name = _("Report Options") add_option = partial(menu.add_option, category_name) ################################ self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Determines what people are included in the graph")) add_option("filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Center Person")) self.__pid.set_help(_("The center person for the report")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) arrow = EnumeratedListOption(_("Arrowhead direction"), 'd') for i in range(0, len(_ARROWS)): arrow.add_item(_ARROWS[i]["value"], _ARROWS[i]["name"]) arrow.set_help(_("Choose the direction that the arrows point.")) add_option("arrow", arrow) color = EnumeratedListOption(_("Graph coloring"), 'filled') for i in range(0, len(_COLORS)): color.add_item(_COLORS[i]["value"], _COLORS[i]["name"]) color.set_help(_("Males will be shown with blue, females " "with red. If the sex of an individual " "is unknown it will be shown with gray.")) add_option("color", color) # see bug report #2180 roundedcorners = BooleanOption(_("Use rounded corners"), False) roundedcorners.set_help(_("Use rounded corners to differentiate " "between women and men.")) add_option("useroundedcorners", roundedcorners) stdoptions.add_gramps_id_option(menu, category_name, ownline=True) ################################ category_name = _("Report Options (2)") add_option = partial(menu.add_option, category_name) ################################ self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_private_data_option(menu, category_name) stdoptions.add_living_people_option(menu, category_name) locale_opt = stdoptions.add_localization_option(menu, category_name) stdoptions.add_date_format_option(menu, category_name, locale_opt) ################################ add_option = partial(menu.add_option, _("Include")) ################################ self.event_choice = EnumeratedListOption(_('Dates and/or Places'), 0) self.event_choice.add_item(0, _('Do not include any dates or places')) self.event_choice.add_item(1, _('Include (birth, marriage, death) ' 'dates, but no places')) self.event_choice.add_item(2, _('Include (birth, marriage, death) ' 'dates, and places')) self.event_choice.add_item(3, _('Include (birth, marriage, death) ' 'dates, and places if no dates')) self.event_choice.add_item(4, _('Include (birth, marriage, death) ' 'years, but no places')) self.event_choice.add_item(5, _('Include (birth, marriage, death) ' 'years, and places')) self.event_choice.add_item(6, _('Include (birth, marriage, death) ' 'places, but no dates')) self.event_choice.add_item(7, _('Include (birth, marriage, death) ' 'dates and places on same line')) self.event_choice.set_help( _("Whether to include dates and/or places")) add_option("event_choice", self.event_choice) url = BooleanOption(_("Include URLs"), False) url.set_help(_("Include a URL in each graph node so " "that PDF and imagemap files can be " "generated that contain active links " "to the files generated by the 'Narrated " "Web Site' report.")) add_option("url", url) self.__show_relships = BooleanOption( _("Include relationship to center person"), False) self.__show_relships.set_help(_("Whether to show every person's " "relationship to the center person")) add_option("increlname", self.__show_relships) self.__show_relships.connect('value-changed', self.__show_relships_changed) self.__include_images = BooleanOption( _('Include thumbnail images of people'), False) self.__include_images.set_help( _("Whether to include thumbnails of people.")) add_option("includeImages", self.__include_images) self.__include_images.connect('value-changed', self.__image_changed) self.__image_on_side = EnumeratedListOption(_("Thumbnail Location"), 0) self.__image_on_side.add_item(0, _('Above the name')) self.__image_on_side.add_item(1, _('Beside the name')) self.__image_on_side.set_help( _("Where the thumbnail image should appear relative to the name")) add_option("imageOnTheSide", self.__image_on_side) #occupation = BooleanOption(_("Include occupation"), False) occupation = EnumeratedListOption(_('Include occupation'), 0) occupation.add_item(0, _('Do not include any occupation')) occupation.add_item(1, _('Include description ' 'of most recent occupation')) occupation.add_item(2, _('Include date, description and place ' 'of all occupations')) occupation.set_help(_("Whether to include the last occupation")) add_option("occupation", occupation) if __debug__: self.__show_ga_gb = BooleanOption(_("Include relationship " "debugging numbers also"), False) self.__show_ga_gb.set_help(_("Whether to include 'Ga' and 'Gb' " "also, to debug the relationship " "calculator")) add_option("advrelinfo", self.__show_ga_gb) ################################ add_option = partial(menu.add_option, _("Graph Style")) ################################ color_males = ColorOption(_('Males'), '#e0e0ff') color_males.set_help(_('The color to use to display men.')) add_option('colormales', color_males) color_females = ColorOption(_('Females'), '#ffe0e0') color_females.set_help(_('The color to use to display women.')) add_option('colorfemales', color_females) color_unknown = ColorOption(_('Unknown'), '#e0e0e0') color_unknown.set_help( _('The color to use when the gender is unknown.') ) add_option('colorunknown', color_unknown) color_family = ColorOption(_('Families'), '#ffffe0') color_family.set_help(_('The color to use to display families.')) add_option('colorfamilies', color_family) dashed = BooleanOption( _("Indicate non-birth relationships with dotted lines"), True) dashed.set_help(_("Non-birth relationships will show up " "as dotted lines in the graph.")) add_option("dashed", dashed) showfamily = BooleanOption(_("Show family nodes"), True) showfamily.set_help(_("Families will show up as ellipses, linked " "to parents and children.")) add_option("showfamily", showfamily)
def add_menu_options(self, menu): """ Add the options for the graphical calendar """ ########################## category_name = _("Report Options") add_option = partial(menu.add_option, category_name) ########################## self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Select filter to restrict people that appear on calendar")) add_option("filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Center Person")) self.__pid.set_help(_("The center person for the report")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) text1 = StringOption(_("Text Area 1"), _(_TITLE1)) text1.set_help(_("First line of text at bottom of calendar")) add_option("text1", text1) text2 = StringOption(_("Text Area 2"), _(_TITLE2)) text2.set_help(_("Second line of text at bottom of calendar")) add_option("text2", text2) text3 = StringOption(_("Text Area 3"), URL_HOMEPAGE) text3.set_help(_("Third line of text at bottom of calendar")) add_option("text3", text3) ########################## category_name = _("Report Options (2)") add_option = partial(menu.add_option, category_name) ########################## self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_private_data_option(menu, category_name) alive = BooleanOption(_("Include only living people"), True) alive.set_help(_("Include only living people in the calendar")) add_option("alive", alive) stdoptions.add_localization_option(menu, category_name) ########################## category_name = _("Content") add_option = partial(menu.add_option, category_name) ########################## year = NumberOption(_("Year of calendar"), time.localtime()[0], 1000, 3000) year.set_help(_("Year of calendar")) add_option("year", year) country = EnumeratedListOption(_("Country for holidays"), 0) holiday_table = libholiday.HolidayTable() countries = holiday_table.get_countries() countries.sort() if (len(countries) == 0 or (len(countries) > 0 and countries[0] != '')): countries.insert(0, '') count = 0 for c in countries: country.add_item(count, c) count += 1 country.set_help(_("Select the country to see associated holidays")) add_option("country", country) start_dow = EnumeratedListOption(_("First day of week"), 1) long_days = date_displayer.long_days 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, long_days[count].capitalize()) start_dow.set_help( _("Select the first day of the week for the calendar")) add_option("start_dow", start_dow) 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")) maiden_name.set_help(_("Select married women's displayed surname")) add_option("maiden_name", maiden_name) birthdays = BooleanOption(_("Include birthdays"), True) birthdays.set_help(_("Whether to include birthdays")) add_option("birthdays", birthdays) anniversaries = BooleanOption(_("Include anniversaries"), True) anniversaries.set_help(_("Whether to include anniversaries")) add_option("anniversaries", anniversaries)
def add_menu_options(self, menu): """ Add the options for the text birthday report """ category_name = _("Report Options") self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help( _("Select the filter to be applied to the report.")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter.")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) stdoptions.add_private_data_option(menu, category_name) alive = BooleanOption(_("Include only living people"), True) alive.set_help(_("Include only living people in the report")) menu.add_option(category_name, "alive", alive) self.__update_filters() stdoptions.add_localization_option(menu, category_name) category_name = _("Content") year = NumberOption(_("Year of report"), time.localtime()[0], 1000, 3000) year.set_help(_("Year of report")) menu.add_option(category_name, "year", year) country = EnumeratedListOption(_("Country for holidays"), 0) holiday_table = libholiday.HolidayTable() countries = holiday_table.get_countries() countries.sort() if (len(countries) == 0 or (len(countries) > 0 and countries[0] != '')): countries.insert(0, '') count = 0 for c in holiday_table.get_countries(): country.add_item(count, c) count += 1 country.set_help(_("Select the country to see associated holidays")) menu.add_option(category_name, "country", country) start_dow = EnumeratedListOption(_("First day of week"), 1) long_days = date_displayer.long_days 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, long_days[count].capitalize()) start_dow.set_help(_("Select the first day of the week for the report")) menu.add_option(category_name, "start_dow", start_dow) 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")) maiden_name.set_help(_("Select married women's displayed surname")) menu.add_option(category_name, "maiden_name", maiden_name) birthdays = BooleanOption(_("Include birthdays"), True) birthdays.set_help(_("Include birthdays in the report")) menu.add_option(category_name, "birthdays", birthdays) anniversaries = BooleanOption(_("Include anniversaries"), True) anniversaries.set_help(_("Include anniversaries in the report")) menu.add_option(category_name, "anniversaries", anniversaries) option = BooleanOption(_("Include relationships to center person"), False) option.set_help(_("Include relationships to center person (slower)")) menu.add_option(category_name, "relationships", option) category_name = _("Text Options") titletext = StringOption(_("Title text"), _(_TITLE0)) titletext.set_help(_("Title of report")) menu.add_option(category_name, "titletext", titletext) text1 = StringOption(_("Text Area 1"), _(_TITLE1)) text1.set_help(_("First line of text at bottom of report")) menu.add_option(category_name, "text1", text1) text2 = StringOption(_("Text Area 2"), _(_TITLE2)) text2.set_help(_("Second line of text at bottom of report")) menu.add_option(category_name, "text2", text2) text3 = StringOption(_("Text Area 3"), URL_HOMEPAGE,) text3.set_help(_("Third line of text at bottom of report")) menu.add_option(category_name, "text3", text3)
def add_menu_options(self, menu): """ Add options to the menu for the place report. """ common_name = _('Report Options') repository_name = _('Repositories') source_name = _('Sources') # Reload filters to pick any new ones CustomFilters = None from gramps.gen.filters import CustomFilters, GenericFilter opt = FilterOption(_("Select using filter"), 0) opt.set_help(_("Selection with a filter")) filter_list = [] filter_list.append(GenericFilter()) filter_list.extend(CustomFilters.get_filters('Repository')) opt.set_filters(filter_list) menu.add_option(repository_name, "filter", opt) from functools import partial addopt = partial(menu.add_option, common_name) raddopt = partial(menu.add_option, repository_name) saddopt = partial(menu.add_option, source_name) incintern = BooleanOption(_("Include repository's urls"), False) incintern.set_help(_('Whether to include urls on repository.')) raddopt('incintern', incintern) incaddres = BooleanOption(_("Include repository's address"), False) incaddres.set_help(_('Whether to include addresses on repository.')) raddopt('incaddres', incaddres) incauthor = BooleanOption(_("Include source's author"), False) incauthor.set_help(_('Whether to include author.')) saddopt('incauthor', incauthor) incabbrev = BooleanOption(_("Include source's abbreviation"), False) incabbrev.set_help(_('Whether to include abbreviation.')) saddopt('incabbrev', incabbrev) incpublic = BooleanOption(_("Include source's publication information"), False) incpublic.set_help(_('Whether to include publication information.')) saddopt('incpublic', incpublic) incdatamp = BooleanOption(_("Include source's data"), False) incdatamp.set_help(_('Whether to include keys and values.')) saddopt('incdatamp', incdatamp) inclunote = BooleanOption(_('Include notes'), False) inclunote.set_help(_('Whether to include notes on repositories and sources.')) addopt('inclunote', inclunote) inclmedia = BooleanOption(_('Include media'), False) inclmedia.set_help(_('Whether to include media.')) addopt('inclmedia', inclmedia) inclcitat = BooleanOption(_('Include citations'), False) inclcitat.set_help(_('Whether to include citations on sources.')) saddopt('inclcitat', inclcitat) incprivat = BooleanOption(_('Include private records'), False) incprivat.set_help(_('Whether to include repositories and sources marked as private.')) addopt('incprivat', incprivat) incempty = BooleanOption(_('Display empty values'), False) incempty.set_help(_('Whether to include key records with empty values.')) addopt('incempty', incempty) stdoptions.add_localization_option(menu, common_name)
def add_menu_options(self, menu): """ Add options to the menu for the statistics report. """ ################################ category_name = _("Report Options") add_option = partial(menu.add_option, category_name) ################################ self.__filter = FilterOption(_("Filter"), 0) self.__filter.set_help(_("Determines what people are included " "in the report.")) add_option("filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter.")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) sortby = EnumeratedListOption(_('Sort chart items by'), _options.SORT_VALUE) for item_idx in range(len(_options.opt_sorts)): item = _options.opt_sorts[item_idx] sortby.add_item(item_idx, item[2]) sortby.set_help(_("Select how the statistical data is sorted.")) add_option("sortby", sortby) reverse = BooleanOption(_("Sort in reverse order"), False) reverse.set_help(_("Check to reverse the sorting order.")) add_option("reverse", reverse) this_year = time.localtime()[0] year_from = NumberOption(_("People Born After"), 1700, 1, this_year) year_from.set_help(_("Birth year from which to include people.")) add_option("year_from", year_from) year_to = NumberOption(_("People Born Before"), this_year, 1, this_year) year_to.set_help(_("Birth year until which to include people")) add_option("year_to", year_to) no_years = BooleanOption(_("Include people without known birth years"), False) no_years.set_help(_("Whether to include people without " "known birth years.")) add_option("no_years", no_years) gender = EnumeratedListOption(_('Genders included'), Person.UNKNOWN) for item_idx in range(len(_options.opt_genders)): item = _options.opt_genders[item_idx] gender.add_item(item[0], item[2]) gender.set_help(_("Select which genders are included into " "statistics.")) add_option("gender", gender) bar_items = NumberOption(_("Max. items for a pie"), 8, 0, 20) bar_items.set_help(_("With fewer items pie chart and legend will be " "used instead of a bar chart.")) add_option("bar_items", bar_items) ################################ category_name = _("Report Options (2)") add_option = partial(menu.add_option, category_name) ################################ self._nf = stdoptions.add_name_format_option(menu, category_name) self._nf.connect('value-changed', self.__update_filters) self.__update_filters() stdoptions.add_private_data_option(menu, category_name) stdoptions.add_living_people_option(menu, category_name) stdoptions.add_localization_option(menu, category_name) ################################ # List of available charts on separate option tabs ################################ idx = 0 third = (len(_Extract.extractors) + 1) // 3 chart_types = [] for (chart_opt, ctuple) in _Extract.extractors.items(): chart_types.append((_(ctuple[1]), chart_opt, ctuple)) sorted_chart_types = sorted(chart_types, key=lambda x: glocale.sort_key(x[0])) for (translated_option_name, opt_name, ctuple) in sorted_chart_types: if idx >= (third * 2): category_name = _("Charts 3") elif idx >= third: category_name = _("Charts 2") else: category_name = _("Charts 1") opt = BooleanOption(translated_option_name, False) opt.set_help(_("Include charts with indicated data.")) menu.add_option(category_name, opt_name, opt) idx += 1 # Enable a couple of charts by default menu.get_option_by_name("data_gender").set_value(True) menu.get_option_by_name("data_ccount").set_value(True) menu.get_option_by_name("data_bmonth").set_value(True)
class PlaceOptions(MenuReportOptions): """ Defines options and provides handling interface. """ def __init__(self, name, dbase): self.__db = dbase self.__filter = None self.__places = None MenuReportOptions.__init__(self, name, dbase) def get_subject(self): """ Return a string that describes the subject of the report. """ subject = "" if self.__filter.get_filter().get_name(): # Use the selected filter's name, if any subject += self.__filter.get_filter().get_name() if self.__places.get_value(): # Add places selected individually, if any for place_id in self.__places.get_value().split(): if subject: subject += " + " place = self.__db.get_place_from_gramps_id(place_id) subject += _pd.display(self.__db, place) return subject def add_menu_options(self, menu): """ Add options to the menu for the place report. """ category_name = _("Report Options") # Reload filters to pick any new ones CustomFilters = None from gramps.gen.filters import CustomFilters, GenericFilter self.__filter = FilterOption(_("Select using filter"), 0) self.__filter.set_help(_("Select places using a filter")) filter_list = [] filter_list.append(GenericFilter()) filter_list.extend(CustomFilters.get_filters('Place')) self.__filter.set_filters(filter_list) menu.add_option(category_name, "filter", self.__filter) self.__places = PlaceListOption(_("Select places individually")) self.__places.set_help(_("List of places to report on")) menu.add_option(category_name, "places", self.__places) center = EnumeratedListOption(_("Center on"), "Event") center.set_items([("Event", _("Event")), ("Person", _("Person"))]) center.set_help(_("If report is event or person centered")) menu.add_option(category_name, "center", center) category_name = _("Report Options (2)") stdoptions.add_name_format_option(menu, category_name) stdoptions.add_private_data_option(menu, category_name) stdoptions.add_living_people_option(menu, category_name) stdoptions.add_localization_option(menu, category_name) def make_default_style(self, default_style): """ Make the default output style for the Place report. """ self.default_style = default_style self.__report_title_style() self.__report_subtitle_style() self.__place_title_style() self.__place_details_style() self.__column_title_style() self.__section_style() self.__event_table_style() self.__details_style() self.__cell_style() self.__table_column_style() def __report_title_style(self): """ Define the style used for the report title """ font = FontStyle() font.set(face=FONT_SANS_SERIF, size=16, bold=1) para = ParagraphStyle() para.set_font(font) para.set_header_level(1) para.set_top_margin(0.25) para.set_bottom_margin(0.25) para.set_alignment(PARA_ALIGN_CENTER) para.set_description(_('The style used for the title.')) self.default_style.add_paragraph_style("PLC-ReportTitle", para) def __report_subtitle_style(self): """ Define the style used for the report subtitle """ font = FontStyle() font.set(face=FONT_SANS_SERIF, size=12, bold=1) para = ParagraphStyle() para.set_font(font) para.set_header_level(1) para.set_top_margin(0.25) para.set_bottom_margin(0.25) para.set_alignment(PARA_ALIGN_CENTER) para.set_description(_('The style used for the subtitle.')) self.default_style.add_paragraph_style("PLC-ReportSubtitle", para) def __place_title_style(self): """ Define the style used for the place title """ font = FontStyle() font.set(face=FONT_SERIF, size=12, italic=0, bold=1) para = ParagraphStyle() para.set_font(font) para.set(first_indent=-1.5, lmargin=1.5) para.set_top_margin(0.75) para.set_bottom_margin(0.25) para.set_description(_('The style used for the section headers.')) self.default_style.add_paragraph_style("PLC-PlaceTitle", para) def __place_details_style(self): """ Define the style used for the place details """ font = FontStyle() font.set(face=FONT_SERIF, size=10) para = ParagraphStyle() para.set_font(font) para.set(first_indent=0.0, lmargin=1.5) para.set_description(_('The style used for details.')) self.default_style.add_paragraph_style("PLC-PlaceDetails", para) def __column_title_style(self): """ Define the style used for the event table column title """ font = FontStyle() font.set(face=FONT_SERIF, size=10, bold=1) para = ParagraphStyle() para.set_font(font) para.set(first_indent=0.0, lmargin=0.0) para.set_description(_('The basic style used for table headings.')) self.default_style.add_paragraph_style("PLC-ColumnTitle", para) def __section_style(self): """ Define the style used for each section """ font = FontStyle() font.set(face=FONT_SERIF, size=10, italic=0, bold=0) para = ParagraphStyle() para.set_font(font) para.set(first_indent=-1.5, lmargin=1.5) para.set_top_margin(0.5) para.set_bottom_margin(0.25) para.set_description(_('The basic style used for the text display.')) self.default_style.add_paragraph_style("PLC-Section", para) def __event_table_style(self): """ Define the style used for event table """ table = TableStyle() table.set_width(100) table.set_columns(4) table.set_column_width(0, 25) table.set_column_width(1, 15) table.set_column_width(2, 35) table.set_column_width(3, 25) self.default_style.add_table_style("PLC-EventTable", table) table.set_width(100) table.set_columns(4) table.set_column_width(0, 35) table.set_column_width(1, 15) table.set_column_width(2, 25) table.set_column_width(3, 25) self.default_style.add_table_style("PLC-PersonTable", table) def __details_style(self): """ Define the style used for person and event details """ font = FontStyle() font.set(face=FONT_SERIF, size=10) para = ParagraphStyle() para.set_font(font) para.set_description(_('The style used for the items and values.')) self.default_style.add_paragraph_style("PLC-Details", para) def __cell_style(self): """ Define the style used for cells in the event table """ cell = TableCellStyle() self.default_style.add_cell_style("PLC-Cell", cell) def __table_column_style(self): """ Define the style used for event table columns """ cell = TableCellStyle() cell.set_bottom_border(1) self.default_style.add_cell_style('PLC-TableColumn', cell)
class RemoveTagOptions(MenuToolOptions): """ Remove tag options """ def __init__(self, name, person_id=None, dbstate=None): self.__db = dbstate.get_database() MenuToolOptions.__init__(self, name, person_id, dbstate) def add_menu_options(self, menu): """ Add the menu options for the Remove Tag Tool """ category_name = _("Options") self.__filter = FilterOption(_("Person Filter"), 0) self.__filter.set_help(_("Select filter to restrict people")) menu.add_option(category_name, "filter", self.__filter) self.__filter.connect('value-changed', self.__filter_changed) self.__pid = PersonOption(_("Filter Person")) self.__pid.set_help(_("The center person for the filter")) menu.add_option(category_name, "pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) all_tags = [] for handle in self.__db.get_tag_handles(sort_handles=True): tag = self.__db.get_tag_from_handle(handle) all_tags.append(tag.get_name()) if len(all_tags) > 0: tag_option = EnumeratedListOption(_('Tag'), all_tags[0]) for tag_name in all_tags: tag_option.add_item(tag_name, tag_name) else: tag_option = EnumeratedListOption(_('Tag'), '') tag_option.add_item('', '') tag_option.set_help(_("The tag to use for the report")) menu.add_option(category_name, "tag", tag_option) self.__update_filters() def __update_filters(self): """ Update the filter list based on the selected person """ gid = self.__pid.get_value() person = self.__db.get_person_from_gramps_id(gid) filter_list = ReportUtils.get_person_filters(person, False) self.__filter.set_filters(filter_list) def __filter_changed(self): """ Handle filter change. If the filter is not specific to a person, disable the person option """ filter_value = self.__filter.get_value() if filter_value in [1, 2, 3, 4]: # Filters 0, 2, 3, 4 and 5 rely on the center person self.__pid.set_available(True) else: # The rest don't self.__pid.set_available(False)
class SetPrivacyOptions(MenuToolOptions): """Handles the Set Privacy Tool menu options.""" def __init__(self, name, person_id=None, dbstate=None): MenuToolOptions.__init__(self, name, person_id, dbstate) def add_menu_options(self, menu): self.person = BooleanOption(_("Persons"), False) menu.add_option(_("Option"), "person", self.person) self.__person_filter = FilterOption(_("Person Filter"), 0) self.__person_filter.set_help(_("Select filter to restrict people")) menu.add_option(_("Option"), "person_filter", self.__person_filter) person_filter_all = GenericFilterFactory("Person")() person_filter_all.name = _("Entire Database") person_filter_list = [person_filter_all ] + CustomFilters.get_filters("Person") self.__person_filter.set_filters(person_filter_list) self.event = BooleanOption(_("Events"), False) menu.add_option(_("Option"), "event", self.event) self.__event_filter = FilterOption(_("Event Filter"), 0) self.__event_filter.set_help(_("Select filter to restrict events")) menu.add_option(_("Option"), "event_filter", self.__event_filter) event_filter_all = GenericFilterFactory("Event")() event_filter_all.name = _("Entire Database") event_filter_list = [event_filter_all ] + CustomFilters.get_filters('Event') self.__event_filter.set_filters(event_filter_list) self.media = BooleanOption(_("Media"), False) menu.add_option(_("Option"), "media", self.media) self.__media_filter = FilterOption(_("Media Filter"), 0) self.__media_filter.set_help(_("Select filter to restrict medias")) menu.add_option(_("Option"), "media_filter", self.__media_filter) media_filter_all = GenericFilterFactory("Media")() media_filter_all.name = _("Entire Database") media_filter_list = [media_filter_all ] + CustomFilters.get_filters('Media') self.__media_filter.set_filters(media_filter_list) self.no_date = BooleanOption(_("Always private if no date."), False) self.no_date.set_help( _("If checked, all objects without a date will " "also be set private.")) menu.add_option(_("Option"), "no_date", self.no_date) self.years = NumberOption(_("Years"), 0, 0, 2000) self.years.set_help( _("The time range in years from today you want to " "set objects private.\n" "'0 years' = remove privacy from all objects.")) menu.add_option(_("Option"), "years", self.years)