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)
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)
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)
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) 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) 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_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) 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) 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 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 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(utils.pt2cm(8)) para.set_description(_('The style used for the footer.')) default_style.add_paragraph_style('REC-Footer', para)
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 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 of the page.")) 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 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 TimeLineOptions(MenuReportOptions): 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() stdoptions.add_name_format_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_private_data_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) 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): """Make the default output style for the Timeline report.""" # Paragraph Styles f = FontStyle() f.set_size(10) f.set_type_face(FONT_SANS_SERIF) p = ParagraphStyle() p.set_font(f) p.set_description(_("The style used for the person's name.")) default_style.add_paragraph_style("TLG-Name", p) f = FontStyle() f.set_size(8) f.set_type_face(FONT_SANS_SERIF) p = ParagraphStyle() p.set_font(f) p.set_alignment(PARA_ALIGN_CENTER) p.set_description(_("The style used for the year labels.")) default_style.add_paragraph_style("TLG-Label", p) f = FontStyle() f.set_size(14) f.set_type_face(FONT_SANS_SERIF) p = ParagraphStyle() p.set_font(f) p.set_alignment(PARA_ALIGN_CENTER) p.set_description(_("The style used for the title of the page.")) default_style.add_paragraph_style("TLG-Title", p) """ 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. """ g = GraphicsStyle() g.set_line_width(0.5) g.set_color((0, 0, 0)) default_style.add_draw_style("TLG-line", g) g = GraphicsStyle() g.set_line_width(0.5) g.set_color((0, 0, 0)) g.set_fill_color((0, 0, 0)) default_style.add_draw_style("TLG-solid", g) g = GraphicsStyle() g.set_line_width(0.5) g.set_color((0, 0, 0)) g.set_fill_color((255, 255, 255)) default_style.add_draw_style("open", g) g = GraphicsStyle() g.set_line_width(0.5) g.set_line_style(DASHED) g.set_color((0, 0, 0)) default_style.add_draw_style("TLG-grid", g) g = GraphicsStyle() g.set_paragraph_style("TLG-Name") g.set_color((0, 0, 0)) g.set_fill_color((255, 255, 255)) g.set_line_width(0) default_style.add_draw_style("TLG-text", g) g = GraphicsStyle() g.set_paragraph_style("TLG-Title") g.set_color((0, 0, 0)) g.set_fill_color((255, 255, 255)) g.set_line_width(0) default_style.add_draw_style("TLG-title", g) g = GraphicsStyle() g.set_paragraph_style("TLG-Label") g.set_color((0, 0, 0)) g.set_fill_color((255, 255, 255)) g.set_line_width(0) default_style.add_draw_style("TLG-label", g)
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._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._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) self.__recursive = BooleanOption(_('Recursive (down)'), False) self.__recursive.set_help( _("Create reports for all descendants " "of this family.")) add_option("recursive", self.__recursive) stdoptions.add_localization_option(menu, category_name) ########################## add_option = partial(menu.add_option, _("Include")) ########################## gramps_ids = BooleanOption(_('Gramps ID'), False) gramps_ids.set_help(_("Whether to include Gramps ID next to names.")) add_option("gramps_ids", gramps_ids) generations = BooleanOption( _("Generation numbers " "(recursive only)"), True) generations.set_help( _("Whether to include the generation on each " "report (recursive only).")) add_option("generations", generations) 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) 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_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) ########################## add_option = partial(menu.add_option, _("Missing Information")) ########################## 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 in [0, 2, 3]: # filters that rely on the center family self.__fid.set_available(True) else: # filters that don't self.__fid.set_available(False) # 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 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 of the page.")) 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) 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_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_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 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 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 == 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 __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, include_single=False) self.__filter.set_filters(filter_list)
class TimeLineOptions(MenuReportOptions): 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._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 __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_default_style(self,default_style): """Make the default output style for the Timeline report.""" # Paragraph Styles f = FontStyle() f.set_size(10) f.set_type_face(FONT_SANS_SERIF) p = ParagraphStyle() p.set_font(f) p.set_description(_("The style used for the person's name.")) default_style.add_paragraph_style("TLG-Name",p) f = FontStyle() f.set_size(8) f.set_type_face(FONT_SANS_SERIF) p = ParagraphStyle() p.set_font(f) p.set_alignment(PARA_ALIGN_CENTER) p.set_description(_("The style used for the year labels.")) default_style.add_paragraph_style("TLG-Label",p) f = FontStyle() f.set_size(14) f.set_type_face(FONT_SANS_SERIF) p = ParagraphStyle() p.set_font(f) p.set_alignment(PARA_ALIGN_CENTER) p.set_description(_("The style used for the title of the page.")) default_style.add_paragraph_style("TLG-Title",p) """ 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. """ g = GraphicsStyle() g.set_line_width(0.5) g.set_color((0,0,0)) default_style.add_draw_style("TLG-line",g) g = GraphicsStyle() g.set_line_width(0.5) g.set_color((0,0,0)) g.set_fill_color((0,0,0)) default_style.add_draw_style("TLG-solid",g) g = GraphicsStyle() g.set_line_width(0.5) g.set_color((0,0,0)) g.set_fill_color((255,255,255)) default_style.add_draw_style("open",g) g = GraphicsStyle() g.set_line_width(0.5) g.set_line_style(DASHED) g.set_color((0,0,0)) default_style.add_draw_style("TLG-grid",g) g = GraphicsStyle() g.set_paragraph_style("TLG-Name") g.set_color((0,0,0)) g.set_fill_color((255,255,255)) g.set_line_width(0) default_style.add_draw_style("TLG-text",g) g = GraphicsStyle() g.set_paragraph_style("TLG-Title") g.set_color((0,0,0)) g.set_fill_color((255,255,255)) g.set_line_width(0) default_style.add_draw_style("TLG-title",g) g = GraphicsStyle() g.set_paragraph_style("TLG-Label") g.set_color((0,0,0)) g.set_fill_color((255,255,255)) g.set_line_width(0) default_style.add_draw_style("TLG-label",g)
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")) add_option("pid", self.__pid) self.__pid.connect('value-changed', self.__update_filters) stdoptions.add_name_format_option(menu, category_name) self.__update_filters() self.incdate = BooleanOption( _("Include Birth, Marriage and Death dates"), True) self.incdate.set_help( _("Include the dates that the individual was " "born, got married and/or died in the graph labels.")) add_option("incdate", self.incdate) self.incdate.connect('value-changed', self.__include_dates_changed) self.justyears = BooleanOption(_("Limit dates to years only"), False) self.justyears.set_help( _("Prints just dates' year, neither " "month or day nor date approximation " "or interval are shown.")) add_option("justyears", self.justyears) use_place = BooleanOption(_("Use place when no date"), True) use_place.set_help( _("When no birth, marriage, or death date is " "available, the correspondent place field " "will be used.")) add_option("use_place", use_place) 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) incid = BooleanOption(_("Include IDs"), False) incid.set_help(_("Include individual and family IDs.")) add_option("incid", incid) 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) 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) 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) stdoptions.add_localization_option(menu, category_name) ################################ 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) filter_list = ReportUtils.get_person_filters(person, False) self.__filter.set_filters(filter_list) def __include_dates_changed(self): """ Enable/disable menu items if dates are required """ if self.incdate.get_value(): self.justyears.set_available(True) else: self.justyears.set_available(False) 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 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 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 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 == 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 __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, include_single=False) self.__filter.set_filters(filter_list)
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._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._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) self.__recursive = BooleanOption(_('Recursive (down)'), False) self.__recursive.set_help(_("Create reports for all descendants " "of this family.")) add_option("recursive", self.__recursive) stdoptions.add_localization_option(menu, category_name) ########################## add_option = partial(menu.add_option, _("Include 1")) ########################## gramps_ids = BooleanOption(_('Gramps ID'), False) gramps_ids.set_help(_("Whether to include Gramps ID next to names.")) add_option("gramps_ids", gramps_ids) 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) 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) ########################## add_option = partial(menu.add_option, _("Include 2")) ########################## 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) generations = BooleanOption(_("Generation numbers " "(recursive only)"), False) generations.set_help(_("Whether to include the generation on each " "report (recursive only).")) add_option("generations", generations) # TODO make insensitive if ... ########################## add_option = partial(menu.add_option, _("Missing Information")) ########################## 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 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 of the page.")) 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) 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_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_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 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 menu 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 tool.""" if self.__is_db_empty(): txt = [_("The Tool requires at least one tag to execute.")] self.empty = TextOption(_("ERROR"), txt) self.empty.set_available(False) menu.add_option(_("ERROR"), "empty", self.empty) return # stop other menu option creation else: self.__general_options(menu) self.__filter_options(menu) def __enum_tag_list(self): """Return an enumerated tag name list.""" tag_list = list(self.db.iter_tags()) if tag_list: L = list(map(lambda x: x.get_name(), tag_list)) return list(enumerate(L)) def __is_db_empty(self): """Check if database has at least one tag.""" try: next(self.db.iter_tag_handles()) except StopIteration: # StopIteration is raised when the category has no objects return True # Empty return False # Not empty def __general_options(self, menu): """Menu Options for general option tab.""" # Add or remove tags menu option self.add_remove = FilterOption(_("Add/Remove"), 0) self.add_remove.set_help(_("Add or remove tags from objects.")) self.add_remove.set_items([(0, _("Add Tags")), (1, _("Remove Tags"))]) menu.add_option(_("General options"), "add_remove", self.add_remove) # category menu option lst = [ _("People"), _("Families"), _("Events"), _("Places"), _("Sources"), _("Citations"), _("Repositories"), _("Media"), _("Notes") ] category_list = list(enumerate(lst)) self.tag_category = FilterOption(_("Category"), 0) self.tag_category.set_help(_("Choose a category.")) menu.add_option(_("General options"), "category", self.tag_category) self.tag_category.set_items(category_list) self.tag_category.connect('value-changed', self.__update_options) # tag name list menu option tag_list = self.__enum_tag_list() self.tag_name = FilterOption(_("Choose Tag"), 0) self.tag_name.set_help(_("Choose a tag to remove.")) menu.add_option(_("General options"), "tag_name", self.tag_name) self.tag_name.set_items(tag_list) def __filter_options(self, menu): """Menu Options for filter option tab.""" self.filter_dict = {} # get all filter rules, used for generic filters all_persons = rules.person.Everyone([]) all_families = rules.family.AllFamilies([]) all_events = rules.event.AllEvents([]) all_places = rules.place.AllPlaces([]) all_sources = rules.source.AllSources([]) all_cits = rules.citation.AllCitations([]) all_repos = rules.repository.AllRepos([]) all_media = rules.media.AllMedia([]) all_notes = rules.note.AllNotes([]) # create a list used for menu filter option creation later lst = [(_("Person Filter"), 'Person', _("Persons"), all_persons), (_("Family Filter"), 'Family', _("Families"), all_families), (_("Event Filter"), 'Event', _("Events"), all_events), (_("Place Filter"), 'Place', _("Places"), all_places), (_("Source Filter"), 'Source', _("Sources"), all_sources), (_("Citation Filter"), 'Citation', _("Citations"), all_cits), (_("Repository Filter"), 'Repository', _("Repositories"), all_repos), (_("Media Filter"), 'Media', _("Media"), all_media), (_("Note Filter"), 'Note', _("Notes"), all_notes)] for entry in lst: # create a filter option for each category e.g. person, events # filter option is a combination of custom filters and # a generic filter for all objects of one category filter_name = FilterOption(entry[0], 0) menu.add_option(_("Filter options"), entry[1].lower(), filter_name) self.filter_dict[entry[1]] = filter_name # custom filter: filter_list = CustomFilters.get_filters(entry[1]) # generic filter: GenericFilter = GenericFilterFactory(entry[1]) all_filter = GenericFilter() all_filter.set_name(_("All %s") % (entry[2])) all_filter.add_rule(entry[3]) # only add the generic filter if it isn't already in the menu all_filter_in_list = False for fltr in filter_list: if fltr.get_name() == all_filter.get_name(): all_filter_in_list = True if not all_filter_in_list: filter_list.insert(0, all_filter) # add the list of custom and generic filters # to the filter option self.filter_dict[entry[1]].set_filters(filter_list) def __update_options(self): """Turn availability on and off depending on user selection.""" lst = [ 'Person', 'Family', 'Event', 'Place', 'Source', 'Citation', 'Repository', 'Media', 'Note' ] for entry in lst: self.filter_dict[entry].set_available(False) value = self.tag_category.get_value() self.filter_dict[lst[value]].set_available(True)
class RemoveTagOptions(MenuToolOptions): """ Class for creating 'Remove Tag Tool' menu options. The options are needed for processing tag removal in :class RemoveTagWindow:. """ def __init__(self, name, person_id=None, dbstate=None): self.__db = dbstate.get_database() MenuToolOptions.__init__(self, name, person_id, dbstate) def get_enum_tag_name_list(self): """ Returns an enumerated tag name list. :rtype: list """ tag_list = list(self.__db.iter_tags()) if tag_list: L = list(map(lambda x: x.get_name(), tag_list)) return list(enumerate(L)) def is_db_empty(self): """ Check if database has at least one person, family and tag. :returns: True or False """ try: next(self.__db.iter_person_handles()) next(self.__db.iter_family_handles()) next(self.__db.iter_tag_handles()) except StopIteration: # StopIteration is raised if at least one category has no objects return True # Empty return False # Not empty def add_menu_options(self, menu): """ Add the menu options for the Remove Tag Tool. """ if self.is_db_empty(): txt = [ _("The Remove Tag Tool requires at least " "one person, family and tag to execute.") ] self.empty = TextOption(_("ERROR"), txt) menu.add_option(_("ERROR"), "empty", self.empty) else: self.__add_tag_category_options(menu) self.__add_person_options(menu) self.__add_family_options(menu) self.filter_dict = {} lst = [("events", _("Event Filter"), "event_filter", 'Event', _("All Events")), ("places", _("Place Filter"), "place_filter", 'Place', _("All Places")), ("sources", _("Source Filter"), "scource_filter", 'Source', _("All Sources")), ("citations", _("Citation Filter"), "cit_filter", 'Citation', _("All Citations")), ("repositories", _("Repository Filter"), "repo_filter", 'Repository', _("All Repositories")), ("media", _("Media Filter"), "media_filter", 'Media', _("All Media")), ("notes", _("Note Filter"), "note_filter", 'Note', _("All Notes"))] for entry in lst: filter_name = FilterOption(entry[1], 0) filter_name.set_help( _("Select filter to restrict {}".format(entry[0]))) menu.add_option(_("Option 2"), entry[2], filter_name) self.filter_dict[entry[3]] = filter_name filter_list = CustomFilters.get_filters(entry[3]) GenericFilter = GenericFilterFactory(entry[3]) all_filter = GenericFilter() all_filter.set_name(entry[4]) all_filter.add_rule(rules.event.AllEvents([])) all_filter_in_list = False for fltr in filter_list: if fltr.get_name() == all_filter.get_name(): all_filter_in_list = True if not all_filter_in_list: filter_list.insert(0, all_filter) self.filter_dict[entry[3]].set_filters(filter_list) def __add_tag_category_options(self, menu): """ Menu Options for general category tab. Users select 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. """ lst = [ "People", "Families", "Events", "Places", "Sources", "Citations", "Repositories", "Media", "Notes" ] category_list = list(enumerate(lst)) self.__tag_category = FilterOption(_("Category"), 0) self.__tag_category.set_help(_("Choose a category.")) menu.add_option(_("Option 1"), "category", self.__tag_category) self.__tag_category.set_items(category_list) self.__tag_category.connect('value-changed', self.__update_options) tag_list = self.get_enum_tag_name_list() self.__tag_name = FilterOption("Remove Tag", 0) self.__tag_name.set_help(_("Choose a tag to remove.")) menu.add_option(_("Option 1"), "tag_name", self.__tag_name) self.__tag_name.set_items(tag_list) def __update_options(self): """ Turn availability on depending on user selection. """ self.__disable_all_options() value = self.__tag_category.get_value() if value == 0: self.__person_filter.set_available(True) self.__filter_changed() elif value == 1: self.__family_filter.set_available(True) self.__family_filter_changed() elif value == 2: self.filter_dict['Event'].set_available(True) elif value == 3: self.filter_dict['Place'].set_available(True) elif value == 4: self.filter_dict['Source'].set_available(True) elif value == 5: self.filter_dict['Citation'].set_available(True) elif value == 6: self.filter_dict['Repository'].set_available(True) elif value == 7: self.filter_dict['Media'].set_available(True) elif value == 8: self.filter_dict['Note'].set_available(True) def __disable_all_options(self): """ Turn all options off, except options 'category' and 'tag_name' """ self.__person_filter.set_available(False) self.__pid.set_available(False) self.__family_filter.set_available(False) self.__fid.set_available(False) for entry in [ 'Event', 'Place', 'Source', 'Citation', 'Repository', 'Media', 'Note' ]: self.filter_dict[entry].set_available(False) def __add_person_options(self, menu): """ Menu Options for person category. Menu Option 'pers_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. :param menu: a menu object where options can be added :type menu: :class Menu: object """ self.__person_filter = FilterOption(_("Person Filter"), 0) self.__person_filter.set_help(_("Select filter to restrict people")) menu.add_option(_("Option 1"), "pers_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(_("Option 1"), "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.__person_filter.set_filters(filter_list) def __filter_changed(self): """ Handle person 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 __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. :param menu: a menu object where options can be added :type menu: :class Menu: object """ self.__family_filter = FilterOption(_("Family Filter"), 0) self.__family_filter.set_help(_("Select filter to restrict families")) menu.add_option(_("Option 1"), "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(_("Option 1"), "fid", self.__fid) self.__fid.connect('value-changed', self.__update_family_filters) 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 family 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)
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)
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 = 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_ga_gb: self.__show_ga_gb.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 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 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 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) 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 __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 """ if self.__show_relships and self.__show_relships.get_value(): self.__pid.set_available(True) 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 __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 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 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 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) 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 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) 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 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 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)
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)