class FamilyLinesOptions(MenuReportOptions): """ Defines all of the controls necessary to configure the FamilyLines reports. """ def __init__(self, name, dbase): self.limit_parents = None self.max_parents = None self.limit_children = None self.max_children = None self.include_images = None self.image_location = None MenuReportOptions.__init__(self, name, dbase) def add_menu_options(self, menu): # -------------------------------- add_option = partial(menu.add_option, _('People of Interest')) # -------------------------------- person_list = PersonListOption(_('People of interest')) person_list.set_help( _('People of interest are used as a starting ' 'point when determining "family lines".')) add_option('gidlist', person_list) followpar = BooleanOption( _('Follow parents to determine family lines'), True) followpar.set_help( _('Parents and their ancestors will be ' 'considered when determining "family lines".')) add_option('followpar', followpar) followchild = BooleanOption( _('Follow children to determine ' '"family lines"'), True) followchild.set_help( _('Children will be considered when ' 'determining "family lines".')) add_option('followchild', followchild) remove_extra_people = BooleanOption( _('Try to remove extra people and families'), True) remove_extra_people.set_help( _('People and families not directly ' 'related to people of interest will ' 'be removed when determining ' '"family lines".')) add_option('removeextra', remove_extra_people) # ---------------------------- add_option = partial(menu.add_option, _('Family Colours')) # ---------------------------- surname_color = SurnameColorOption(_('Family colours')) surname_color.set_help(_('Colours to use for various family lines.')) add_option('surnamecolors', surname_color) # ------------------------- add_option = partial(menu.add_option, _('Individuals')) # ------------------------- color_males = ColorOption(_('Males'), '#e0e0ff') color_males.set_help(_('The colour to use to display men.')) add_option('colormales', color_males) color_females = ColorOption(_('Females'), '#ffe0e0') color_females.set_help(_('The colour to use to display women.')) add_option('colorfemales', color_females) color_unknown = ColorOption(_('Unknown'), '#e0e0e0') color_unknown.set_help( _('The colour to use ' 'when the gender is unknown.')) add_option('colorunknown', color_unknown) color_family = ColorOption(_('Families'), '#ffffe0') color_family.set_help(_('The colour to use to display families.')) add_option('colorfamilies', color_family) self.limit_parents = BooleanOption(_('Limit the number of ancestors'), False) self.limit_parents.set_help( _('Whether to ' 'limit the number of ancestors.')) add_option('limitparents', self.limit_parents) self.limit_parents.connect('value-changed', self.limit_changed) self.max_parents = NumberOption('', 50, 10, 9999) self.max_parents.set_help( _('The maximum number ' 'of ancestors to include.')) add_option('maxparents', self.max_parents) self.limit_children = BooleanOption( _('Limit the number ' 'of descendants'), False) self.limit_children.set_help( _('Whether to ' 'limit the number of descendants.')) add_option('limitchildren', self.limit_children) self.limit_children.connect('value-changed', self.limit_changed) self.max_children = NumberOption('', 50, 10, 9999) self.max_children.set_help( _('The maximum number ' 'of descendants to include.')) add_option('maxchildren', self.max_children) # -------------------- add_option = partial(menu.add_option, _('Images')) # -------------------- self.include_images = BooleanOption( _('Include ' 'thumbnail images of people'), True) self.include_images.set_help( _('Whether to ' 'include thumbnail images of people.')) add_option('incimages', self.include_images) self.include_images.connect('value-changed', self.images_changed) self.image_location = EnumeratedListOption(_('Thumbnail location'), 0) self.image_location.add_item(0, _('Above the name')) self.image_location.add_item(1, _('Beside the name')) self.image_location.set_help( _('Where the thumbnail image ' 'should appear relative to the name')) add_option('imageonside', self.image_location) # --------------------- add_option = partial(menu.add_option, _('Options')) # --------------------- color = EnumeratedListOption(_("Graph coloring"), "filled") for i in range(len(_COLORS)): color.add_item(_COLORS[i]["value"], _COLORS[i]["name"]) color.set_help( _("Males will be shown with blue, females " "with red, unless otherwise set above for filled. " "If the sex of an individual " "is unknown it will be shown with gray.")) add_option("color", color) use_roundedcorners = BooleanOption(_('Use rounded corners'), False) use_roundedcorners.set_help( _('Use rounded corners to differentiate ' 'between women and men.')) add_option("useroundedcorners", use_roundedcorners) self.include_dates = BooleanOption(_('Include dates'), True) self.include_dates.set_help( _('Whether to include dates for people ' 'and families.')) add_option('incdates', self.include_dates) self.include_dates.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) include_places = BooleanOption(_('Include places'), True) include_places.set_help( _('Whether to include placenames for people ' 'and families.')) add_option('incplaces', include_places) include_num_children = BooleanOption( _('Include the number of children'), True) include_num_children.set_help( _('Whether to include the number of ' 'children for families with more ' 'than 1 child.')) add_option('incchildcnt', include_num_children) include_private = BooleanOption(_('Include private records'), False) include_private.set_help( _('Whether to include names, dates, and ' 'families that are marked as private.')) add_option('incprivate', include_private) self.limit_changed() self.images_changed() def limit_changed(self): """ Handle the change of limiting parents and children. """ self.max_parents.set_available(self.limit_parents.get_value()) self.max_children.set_available(self.limit_children.get_value()) def images_changed(self): """ Handle the change of including images. """ self.image_location.set_available(self.include_images.get_value()) def include_dates_changed(self): """ Enable/disable menu items if dates are required """ if self.include_dates.get_value(): self.justyears.set_available(True) else: self.justyears.set_available(False)
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): ################################ add_option = partial(menu.add_option, _("Report Options")) ################################ 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) 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) ################################ 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 colour to use to display men.')) add_option('colormales', color_males) color_females = ColorOption(_('Females'), '#ffe0e0') color_females.set_help(_('The colour to use to display women.')) add_option('colorfemales', color_females) color_unknown = ColorOption(_('Unknown'), '#e0e0e0') color_unknown.set_help( _('The colour to use when the gender is unknown.')) add_option('colorunknown', color_unknown) color_family = ColorOption(_('Families'), '#ffffe0') color_family.set_help(_('The colour 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()