def __get_holidays(self):
     """ Get the holidays for the specified country and year """
     holiday_table = libholiday.HolidayTable()
     country = holiday_table.get_countries()[self.country]
     holiday_table.load_holidays(self.year, country)
     for month in range(1, 13):
         for day in range(1, 32):
             holiday_names = holiday_table.get_holidays(month, day)
             for holiday_name in holiday_names:
                 self.add_day_item(self._(holiday_name), month, day)
Beispiel #2
0
    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 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)