refactor: move name_format into stdoptions.py
svn: r22009
This commit is contained in:
parent
12777d3fb9
commit
cceb28c5b9
@ -1,7 +1,8 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright 2013 John Ralls <jralls@ceridwen.us>
|
||||
# Copyright (C) 2013 John Ralls <jralls@ceridwen.us>
|
||||
# Copyright (C) 2013 Paul Franklin
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -22,14 +23,17 @@
|
||||
"""
|
||||
Commonly used report options. Call the function, don't copy the code!
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.plug.menu import EnumeratedListOption
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gramps.gen.display.name import displayer as global_name_display
|
||||
from gramps.gen.plug.menu import EnumeratedListOption
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# StandardReportOptions
|
||||
@ -49,3 +53,16 @@ def add_localization_option(menu, category):
|
||||
trans.add_item(languages[language], language)
|
||||
trans.set_help(_("The translation to be used for the report."))
|
||||
menu.add_option(category, "trans", trans)
|
||||
|
||||
def add_name_format_option(menu, category):
|
||||
"""
|
||||
Insert an option for changing the report's name format to a
|
||||
report-specific format instead of the user's Edit=>Preferences choice
|
||||
"""
|
||||
name_format = EnumeratedListOption(_("Name format"), 0)
|
||||
name_format.add_item(0, _("Default"))
|
||||
format_list = global_name_display.get_name_format()
|
||||
for number, name, format_string, whether_active in format_list:
|
||||
name_format.add_item(number, name)
|
||||
name_format.set_help(_("Select the format to display names"))
|
||||
menu.add_option(category, "name_format", name_format)
|
||||
|
@ -50,6 +50,7 @@ from gramps.gen.plug.menu import (BooleanOption, StringOption, NumberOption,
|
||||
from gramps.gen.plug.report import Report
|
||||
from gramps.gen.plug.report import utils as ReportUtils
|
||||
from gramps.gen.plug.report import MenuReportOptions
|
||||
from gramps.gen.plug.report import stdoptions
|
||||
from gramps.gen.utils.alive import probably_alive
|
||||
from gramps.gen.datehandler import displayer as _dd, long_days
|
||||
from gramps.gen.lib import Date, EventRoleType, EventType, Name, NameType, Person, Surname
|
||||
@ -412,7 +413,12 @@ class CalendarOptions(MenuReportOptions):
|
||||
|
||||
def add_menu_options(self, menu):
|
||||
""" Add the options for the graphical calendar """
|
||||
add_option = partial(menu.add_option, _("Report Options"))
|
||||
|
||||
##########################
|
||||
category_name = _("Report 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"))
|
||||
@ -430,14 +436,7 @@ class CalendarOptions(MenuReportOptions):
|
||||
|
||||
self.__update_filters()
|
||||
|
||||
# We must figure out the value of the first option before we can
|
||||
# create the EnumeratedListOption
|
||||
fmt_list = _nd.get_name_format()
|
||||
name_format = EnumeratedListOption(_("Name format"), fmt_list[0][0])
|
||||
for num, name, fmt_str, act in fmt_list:
|
||||
name_format.add_item(num, name)
|
||||
name_format.set_help(_("Select the format to display names"))
|
||||
add_option("name_format", name_format)
|
||||
stdoptions.add_name_format_option(menu, category_name)
|
||||
|
||||
country = EnumeratedListOption(_("Country for holidays"), 0)
|
||||
holiday_table = libholiday.HolidayTable()
|
||||
|
@ -43,8 +43,7 @@ _ = glocale.translation.gettext
|
||||
from gramps.gen.display.name import displayer as global_name_display
|
||||
from gramps.gen.errors import ReportError
|
||||
from gramps.gen.lib import ChildRefType
|
||||
from gramps.gen.plug.menu import (BooleanOption, NumberOption, PersonOption,
|
||||
EnumeratedListOption)
|
||||
from gramps.gen.plug.menu import (BooleanOption, NumberOption, PersonOption)
|
||||
from gramps.gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
|
||||
FONT_SANS_SERIF, INDEX_TYPE_TOC,
|
||||
PARA_ALIGN_CENTER)
|
||||
@ -272,15 +271,7 @@ class AncestorOptions(MenuReportOptions):
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option(category_name, "pid", pid)
|
||||
|
||||
# We must figure out the value of the first option before we can
|
||||
# create the EnumeratedListOption
|
||||
fmt_list = global_name_display.get_name_format()
|
||||
name_format = EnumeratedListOption(_("Name format"), 0)
|
||||
name_format.add_item(0, _("Default"))
|
||||
for num, name, fmt_str, act in fmt_list:
|
||||
name_format.add_item(num, name)
|
||||
name_format.set_help(_("Select the format to display names"))
|
||||
menu.add_option(category_name, "name_format", name_format)
|
||||
stdoptions.add_name_format_option(menu, category_name)
|
||||
|
||||
maxgen = NumberOption(_("Generations"), 10, 1, 100)
|
||||
maxgen.set_help(_("The number of generations to include in the report"))
|
||||
|
@ -52,6 +52,7 @@ from gramps.gen.plug.menu import (BooleanOption, StringOption, NumberOption,
|
||||
from gramps.gen.plug.report import Report
|
||||
from gramps.gen.plug.report import utils as ReportUtils
|
||||
from gramps.gen.plug.report import MenuReportOptions
|
||||
from gramps.gen.plug.report import stdoptions
|
||||
from gramps.gen.utils.alive import probably_alive
|
||||
from gramps.gen.datehandler import displayer as _dd, long_days
|
||||
|
||||
@ -384,13 +385,7 @@ class BirthdayOptions(MenuReportOptions):
|
||||
|
||||
self.__update_filters()
|
||||
|
||||
fmt_list = global_name_display.get_name_format()
|
||||
name_format = EnumeratedListOption(_("Name format"), 0)
|
||||
name_format.add_item(0, _("Default"))
|
||||
for num, name, fmt_str, act in fmt_list:
|
||||
name_format.add_item(num, name)
|
||||
name_format.set_help(_("Select the format to display names"))
|
||||
menu.add_option(category_name, "name_format", name_format)
|
||||
stdoptions.add_name_format_option(menu, category_name)
|
||||
|
||||
country = EnumeratedListOption(_("Country for holidays"), 0)
|
||||
holiday_table = libholiday.HolidayTable()
|
||||
|
@ -52,6 +52,7 @@ from gramps.gen.errors import ReportError
|
||||
from gramps.gen.plug.report import Report
|
||||
from gramps.gen.plug.report import utils as ReportUtils
|
||||
from gramps.gen.plug.report import MenuReportOptions
|
||||
from gramps.gen.plug.report import stdoptions
|
||||
from gramps.gen.datehandler import get_date
|
||||
from gramps.gen.sort import Sort
|
||||
from gramps.gen.utils.db import (get_birth_or_fallback, get_death_or_fallback,
|
||||
@ -394,15 +395,7 @@ class DescendantOptions(MenuReportOptions):
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option(category_name, "pid", pid)
|
||||
|
||||
# We must figure out the value of the first option before we can
|
||||
# create the EnumeratedListOption
|
||||
fmt_list = global_name_display.get_name_format()
|
||||
name_format = EnumeratedListOption(_("Name format"), 0)
|
||||
name_format.add_item(0, _("Default"))
|
||||
for num, name, fmt_str, act in fmt_list:
|
||||
name_format.add_item(num, name)
|
||||
name_format.set_help(_("Select the format to display names"))
|
||||
menu.add_option(category_name, "name_format", name_format)
|
||||
stdoptions.add_name_format_option(menu, category_name)
|
||||
|
||||
numbering = EnumeratedListOption(_("Numbering system"), "Simple")
|
||||
numbering.set_items([
|
||||
|
@ -49,7 +49,7 @@ from gramps.gen.lib import EventType, FamilyRelType, Person, NoteType
|
||||
from gramps.gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
|
||||
FONT_SANS_SERIF, FONT_SERIF,
|
||||
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
|
||||
from gramps.gen.plug.menu import BooleanOption, NumberOption, PersonOption, EnumeratedListOption
|
||||
from gramps.gen.plug.menu import BooleanOption, NumberOption, PersonOption
|
||||
from gramps.gen.plug.report import ( Report, Bibliography )
|
||||
from gramps.gen.plug.report import endnotes
|
||||
from gramps.gen.plug.report import utils as ReportUtils
|
||||
@ -720,15 +720,7 @@ class DetAncestorOptions(MenuReportOptions):
|
||||
pid.set_help(_("The center person for the report"))
|
||||
addopt("pid", pid)
|
||||
|
||||
# We must figure out the value of the first option before we can
|
||||
# create the EnumeratedListOption
|
||||
fmt_list = global_name_display.get_name_format()
|
||||
name_format = EnumeratedListOption(_("Name format"), 0)
|
||||
name_format.add_item(0, _("Default"))
|
||||
for num, name, fmt_str, act in fmt_list:
|
||||
name_format.add_item(num, name)
|
||||
name_format.set_help(_("Select the format to display names"))
|
||||
addopt("name_format", name_format)
|
||||
stdoptions.add_name_format_option(menu, category)
|
||||
|
||||
gen = NumberOption(_("Generations"),10,1,100)
|
||||
gen.set_help(_("The number of generations to include in the report"))
|
||||
|
@ -886,15 +886,7 @@ class DetDescendantOptions(MenuReportOptions):
|
||||
pid.set_help(_("The center person for the report"))
|
||||
add_option("pid", pid)
|
||||
|
||||
# We must figure out the value of the first option before we can
|
||||
# create the EnumeratedListOption
|
||||
fmt_list = global_name_display.get_name_format()
|
||||
name_format = EnumeratedListOption(_("Name format"), 0)
|
||||
name_format.add_item(0, _("Default"))
|
||||
for num, name, fmt_str, act in fmt_list:
|
||||
name_format.add_item(num, name)
|
||||
name_format.set_help(_("Select the format to display names"))
|
||||
add_option("name_format", name_format)
|
||||
stdoptions.add_name_format_option(menu, category)
|
||||
|
||||
numbering = EnumeratedListOption(_("Numbering system"), "Henry")
|
||||
numbering.set_items([
|
||||
|
@ -39,13 +39,15 @@ _ = glocale.translation.gettext
|
||||
#------------------------------------------------------------------------
|
||||
from gramps.gen.display.name import displayer as global_name_display
|
||||
from gramps.gen.errors import ReportError
|
||||
from gramps.gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle, TableStyle,
|
||||
TableCellStyle, FONT_SANS_SERIF, INDEX_TYPE_TOC,
|
||||
PARA_ALIGN_CENTER)
|
||||
from gramps.gen.plug.menu import (PersonOption, EnumeratedListOption)
|
||||
from gramps.gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
|
||||
TableStyle, TableCellStyle,
|
||||
FONT_SANS_SERIF, INDEX_TYPE_TOC,
|
||||
PARA_ALIGN_CENTER)
|
||||
from gramps.gen.plug.menu import PersonOption
|
||||
from gramps.gen.plug.report import Report
|
||||
from gramps.gen.plug.report import utils as ReportUtils
|
||||
from gramps.gen.plug.report import MenuReportOptions
|
||||
from gramps.gen.plug.report import stdoptions
|
||||
from gramps.gen.datehandler import get_date
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
@ -255,16 +257,7 @@ class EndOfLineOptions(MenuReportOptions):
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option(category_name, "pid", pid)
|
||||
|
||||
# We must figure out the value of the first option before we can
|
||||
# create the EnumeratedListOption
|
||||
fmt_list = global_name_display.get_name_format()
|
||||
name_format = EnumeratedListOption(_("Name format"), 0)
|
||||
name_format.add_item(0, _("Default"))
|
||||
for num, name, fmt_str, act in fmt_list:
|
||||
name_format.add_item(num, name)
|
||||
name_format.set_help(_("Select the format to display names"))
|
||||
menu.add_option(category_name, "name_format", name_format)
|
||||
|
||||
stdoptions.add_name_format_option(menu, category_name)
|
||||
|
||||
def make_default_style(self, default_style):
|
||||
"""Make the default output style for the End of Line Report."""
|
||||
|
@ -38,13 +38,15 @@ from functools import partial
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from gramps.gen.lib import EventRoleType, EventType, NoteType, Person
|
||||
from gramps.gen.plug.menu import (BooleanOption, FamilyOption, EnumeratedListOption)
|
||||
from gramps.gen.plug.menu import (BooleanOption, FamilyOption)
|
||||
from gramps.gen.plug.report import Report
|
||||
from gramps.gen.plug.report import utils as ReportUtils
|
||||
from gramps.gen.plug.report import MenuReportOptions
|
||||
from gramps.gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle, TableStyle,
|
||||
TableCellStyle, FONT_SANS_SERIF, FONT_SERIF,
|
||||
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
|
||||
from gramps.gen.plug.report import stdoptions
|
||||
from gramps.gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
|
||||
TableStyle, TableCellStyle,
|
||||
FONT_SANS_SERIF, FONT_SERIF,
|
||||
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
|
||||
from gramps.gen.datehandler import get_date
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.sgettext
|
||||
@ -625,23 +627,15 @@ class FamilyGroupOptions(MenuReportOptions):
|
||||
def add_menu_options(self, menu):
|
||||
|
||||
##########################
|
||||
add_option = partial(menu.add_option, _("Report Options"))
|
||||
category_name = _("Report Options")
|
||||
add_option = partial(menu.add_option, category_name)
|
||||
##########################
|
||||
|
||||
family_id = FamilyOption(_("Center Family"))
|
||||
family_id.set_help(_("The center family for the report"))
|
||||
add_option("family_id", family_id)
|
||||
|
||||
# We must figure out the value of the first option before we can
|
||||
# create the EnumeratedListOption
|
||||
fmt_list = global_name_display.get_name_format()
|
||||
name_format = EnumeratedListOption(_("Name format"), 0)
|
||||
name_format.add_item(0, _("Default"))
|
||||
for num, name, fmt_str, act in fmt_list:
|
||||
name_format.add_item(num, name)
|
||||
name_format.set_help(_("Select the format to display names"))
|
||||
add_option("name_format", name_format)
|
||||
|
||||
stdoptions.add_name_format_option(menu, category_name)
|
||||
|
||||
recursive = BooleanOption(_('Recursive'),False)
|
||||
recursive.set_help(_("Create reports for all descendants "
|
||||
|
@ -43,17 +43,19 @@ from collections import defaultdict
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from gramps.gen.lib import EventRoleType, EventType, Person, NoteType
|
||||
from gramps.gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle, TableStyle,
|
||||
TableCellStyle, FONT_SANS_SERIF, INDEX_TYPE_TOC,
|
||||
PARA_ALIGN_CENTER)
|
||||
from gramps.gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
|
||||
TableStyle, TableCellStyle,
|
||||
FONT_SANS_SERIF, INDEX_TYPE_TOC,
|
||||
PARA_ALIGN_CENTER)
|
||||
from gramps.gen.datehandler import get_date
|
||||
from gramps.gen.plug.menu import (BooleanOption, FilterOption, PersonOption,
|
||||
BooleanListOption, EnumeratedListOption)
|
||||
BooleanListOption)
|
||||
from gramps.gen.plug.report import Report
|
||||
from gramps.gen.plug.report import utils as ReportUtils
|
||||
from gramps.gen.plug.report import MenuReportOptions
|
||||
from gramps.gen.plug.report import Bibliography
|
||||
from gramps.gen.plug.report import endnotes as Endnotes
|
||||
from gramps.gen.plug.report import stdoptions
|
||||
from gramps.gen.display.name import displayer as global_name_display
|
||||
from gramps.gen.utils.file import media_path_full
|
||||
|
||||
@ -691,16 +693,7 @@ class IndivCompleteOptions(MenuReportOptions):
|
||||
menu.add_option(category_name, "pid", self.__pid)
|
||||
self.__pid.connect('value-changed', self.__update_filters)
|
||||
|
||||
# We must figure out the value of the first option before we can
|
||||
# create the EnumeratedListOption
|
||||
fmt_list = global_name_display.get_name_format()
|
||||
name_format = EnumeratedListOption(_("Name format"), 0)
|
||||
name_format.add_item(0, _("Default"))
|
||||
for num, name, fmt_str, act in fmt_list:
|
||||
name_format.add_item(num, name)
|
||||
name_format.set_help(_("Select the format to display names"))
|
||||
menu.add_option(category_name, "name_format", name_format)
|
||||
|
||||
stdoptions.add_name_format_option(menu, category_name)
|
||||
|
||||
self.__update_filters()
|
||||
|
||||
|
@ -44,11 +44,11 @@ from gramps.gen.errors import ReportError
|
||||
from gramps.gen.relationship import get_relationship_calculator
|
||||
from gramps.gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
|
||||
FONT_SANS_SERIF, INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
|
||||
from gramps.gen.plug.menu import (NumberOption, BooleanOption, PersonOption,
|
||||
EnumeratedListOption)
|
||||
from gramps.gen.plug.menu import (NumberOption, BooleanOption, PersonOption)
|
||||
from gramps.gen.plug.report import Report
|
||||
from gramps.gen.plug.report import utils as ReportUtils
|
||||
from gramps.gen.plug.report import MenuReportOptions
|
||||
from gramps.gen.plug.report import stdoptions
|
||||
from gramps.gen.datehandler import get_date
|
||||
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
|
||||
|
||||
@ -342,15 +342,7 @@ class KinshipOptions(MenuReportOptions):
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option(category_name, "pid", pid)
|
||||
|
||||
# We must figure out the value of the first option before we can
|
||||
# create the EnumeratedListOption
|
||||
fmt_list = global_name_display.get_name_format()
|
||||
name_format = EnumeratedListOption(_("Name format"), 0)
|
||||
name_format.add_item(0, _("Default"))
|
||||
for num, name, fmt_str, act in fmt_list:
|
||||
name_format.add_item(num, name)
|
||||
name_format.set_help(_("Select the format to display names"))
|
||||
menu.add_option(category_name, "name_format", name_format)
|
||||
stdoptions.add_name_format_option(menu, category_name)
|
||||
|
||||
maxdescend = NumberOption(_("Max Descendant Generations"), 2, 1, 20)
|
||||
maxdescend.set_help(_("The maximum number of descendant generations"))
|
||||
|
@ -44,13 +44,14 @@ import math
|
||||
#------------------------------------------------------------------------
|
||||
from gramps.gen.display.name import displayer as global_name_display
|
||||
from gramps.gen.errors import ReportError
|
||||
from gramps.gen.plug.menu import PersonOption, EnumeratedListOption
|
||||
from gramps.gen.plug.menu import PersonOption
|
||||
from gramps.gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
|
||||
FONT_SANS_SERIF, PARA_ALIGN_CENTER,
|
||||
INDEX_TYPE_TOC)
|
||||
from gramps.gen.plug.report import Report
|
||||
from gramps.gen.plug.report import utils as ReportUtils
|
||||
from gramps.gen.plug.report import MenuReportOptions
|
||||
from gramps.gen.plug.report import stdoptions
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -187,7 +188,7 @@ class NumberOfAncestorsOptions(MenuReportOptions):
|
||||
|
||||
def add_menu_options(self, menu):
|
||||
"""
|
||||
Add options to the menu for the kinship report.
|
||||
Add options to the menu for the Number of Ancestors report.
|
||||
"""
|
||||
category_name = _("Report Options")
|
||||
|
||||
@ -195,15 +196,7 @@ class NumberOfAncestorsOptions(MenuReportOptions):
|
||||
pid.set_help(_("The center person for the report"))
|
||||
menu.add_option(category_name, "pid", pid)
|
||||
|
||||
# We must figure out the value of the first option before we can
|
||||
# create the EnumeratedListOption
|
||||
fmt_list = global_name_display.get_name_format()
|
||||
name_format = EnumeratedListOption(_("Name format"), 0)
|
||||
name_format.add_item(0, _("Default"))
|
||||
for num, name, fmt_str, act in fmt_list:
|
||||
name_format.add_item(num, name)
|
||||
name_format.set_help(_("Select the format to display names"))
|
||||
menu.add_option(category_name, "name_format", name_format)
|
||||
stdoptions.add_name_format_option(menu, category_name)
|
||||
|
||||
def make_default_style(self, default_style):
|
||||
"""Make the default output style for the Number of Ancestors Report."""
|
||||
|
Loading…
Reference in New Issue
Block a user