diff --git a/gramps/gen/plug/report/_options.py b/gramps/gen/plug/report/_options.py index e79e1b791..c8044d2fb 100644 --- a/gramps/gen/plug/report/_options.py +++ b/gramps/gen/plug/report/_options.py @@ -5,6 +5,7 @@ # Copyright (C) 2008,2011 Gary Burton # Copyright (C) 2010 Jakim Friant # Copyright (C) 2011-2012 Paul Franklin +# Copyright (C) 2012 Brian G. Matherly # # 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 @@ -34,10 +35,6 @@ Report option handling, including saving and parsing. #------------------------------------------------------------------------- import os import copy -from xml.sax.saxutils import escape - -def escxml(word): - return escape(word, {'"' : '"'}) #------------------------------------------------------------------------- # @@ -45,6 +42,15 @@ def escxml(word): # #------------------------------------------------------------------------- from xml.sax import make_parser, SAXParseException +from xml.sax.saxutils import escape + +#------------------------------------------------------------------------ +# +# Set up logging +# +#------------------------------------------------------------------------ +import logging +LOG = logging.getLogger(".plug.report.options") #------------------------------------------------------------------------- # @@ -60,6 +66,9 @@ from .. import _options from .. import MenuOptions from gramps.gen.utils.cast import get_type_converter +def escxml(word): + return escape(word, {'"' : '"'}) + #------------------------------------------------------------------------- # # List of options for a single report @@ -934,6 +943,15 @@ class MenuReportOptions(MenuOptions, ReportOptions): if menu_option: menu_option.set_value(self.options_dict[optname]) + def get_subject(self): + """ + Return a string that describes the subject of the report. + + This method MUST be overridden by subclasses. + """ + LOG.warning("get_subject not implemented for %s" % self.name) + return "" + #------------------------------------------------------------------------- # # DocOptionHandler class diff --git a/gramps/gui/plug/report/_bookdialog.py b/gramps/gui/plug/report/_bookdialog.py index a616da784..9da3c7ca2 100644 --- a/gramps/gui/plug/report/_bookdialog.py +++ b/gramps/gui/plug/report/_bookdialog.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2007 Donald N. Allingham -# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2007-2012 Brian G. Matherly # Copyright (C) 2010 Jakim Friant # Copyright (C) 2012 Nick Hall # Copyright (C) 2011-2016 Paul Franklin @@ -61,7 +61,7 @@ from ...listmodel import ListModel from gramps.gen.errors import FilterError, ReportError from ...pluginmanager import GuiPluginManager from ...dialog import WarningDialog, ErrorDialog, QuestionDialog2 -from gramps.gen.plug.menu import PersonOption, FilterOption, FamilyOption +from gramps.gen.plug.menu import PersonOption, FamilyOption from gramps.gen.plug.docgen import StyleSheet from ...managedwindow import ManagedWindow, set_titles from ...glade import Glade @@ -135,62 +135,6 @@ def _initialize_options(options, dbstate, uistate): else: print("No family specified for ", name) -def _get_subject(options, dbase): - """ - Attempts to determine the subject of a set of options. The subject would - likely be a person (using a PersonOption) or a filter (using a - FilterOption) - - options: The ReportOptions class - dbase: the database for which it corresponds - """ - if not hasattr(options, "menu"): - return "" - menu = options.menu - - option_names = menu.get_all_option_names() - if not option_names: - return _("Entire Database") - - for name in option_names: - option = menu.get_option_by_name(name) - - if isinstance(option, FilterOption): - return option.get_filter().get_name() - - elif isinstance(option, PersonOption): - gid = option.get_value() - person = dbase.get_person_from_gramps_id(gid) - return _nd.display(person) - - elif isinstance(option, FamilyOption): - family = dbase.get_family_from_gramps_id(option.get_value()) - if not family: - return "" - family_id = family.get_gramps_id() - fhandle = family.get_father_handle() - mhandle = family.get_mother_handle() - - if fhandle: - father = dbase.get_person_from_handle(fhandle) - father_name = _nd.display(father) - else: - father_name = _("unknown father") - - if mhandle: - mother = dbase.get_person_from_handle(mhandle) - mother_name = _nd.display(mother) - else: - mother_name = _("unknown mother") - - name = _("%(father_name)s and %(mother_name)s (%(family_id)s)" - ) % {'father_name' : father_name, - 'mother_name' : mother_name, - 'family_id' : family_id} - return name - - return "" - #------------------------------------------------------------------------ # # BookList Display class @@ -526,7 +470,7 @@ class BookSelector(ManagedWindow): data = [item.get_translated_name(), item.get_category(), item.get_name()] - data[2] = _get_subject(item.option_class, self._db) + data[2] = item.option_class.get_subject() self.book_model.add(data) def on_add_clicked(self, obj): @@ -542,7 +486,7 @@ class BookSelector(ManagedWindow): list(range(self.avail_nr_cols))) item = BookItem(self._db, data[2]) _initialize_options(item.option_class, self.dbstate, self.uistate) - data[2] = _get_subject(item.option_class, self._db) + data[2] = item.option_class.get_subject() self.book_model.add(data) self.book.append_item(item) @@ -621,7 +565,7 @@ class BookSelector(ManagedWindow): # rest of dialog is unresponsive, release when finished style = option_class.handler.get_default_stylesheet_name() item.set_style_name(style) - subject = _get_subject(option_class, self._db) + subject = option_class.get_subject() self.book_model.model.set_value(the_iter, 2, subject) self.book.set_item(row, item) item_dialog.close() diff --git a/gramps/plugins/drawreport/ancestortree.py b/gramps/plugins/drawreport/ancestortree.py index 6fdabe59b..546ca7f22 100644 --- a/gramps/plugins/drawreport/ancestortree.py +++ b/gramps/plugins/drawreport/ancestortree.py @@ -1,7 +1,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham -# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2007-2012 Brian G. Matherly # Copyright (C) 2010 Jakim Friant # Copyright (C) 2014 Paul Franklin # Copyright (C) 2010-2015 Craig J. Anderson @@ -48,6 +48,7 @@ from gramps.gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle, from gramps.plugins.lib.libtreebase import * from gramps.plugins.lib.librecurse import AscendPerson from gramps.gen.proxy import CacheProxyDb +from gramps.gen.display.name import displayer as _nd PT2CM = utils.pt2cm #cm2pt = utils.cm2pt @@ -767,18 +768,26 @@ class AncestorTreeOptions(MenuReportOptions): """ def __init__(self, name, dbase): + self.__db = dbase + self.__pid = None self.box_Y_sf = None self.box_shadow_sf = None MenuReportOptions.__init__(self, name, dbase) + def get_subject(self): + """ Return a string that describes the subject of the report. """ + gid = self.__pid.get_value() + person = self.__db.get_person_from_gramps_id(gid) + return _nd.display(person) + def add_menu_options(self, menu): ################## category_name = _("Tree Options") - pid = PersonOption(_("Center Person")) - pid.set_help(_("The center person for the tree")) - menu.add_option(category_name, "pid", pid) + self.__pid = PersonOption(_("Center Person")) + self.__pid.set_help(_("The center person for the tree")) + menu.add_option(category_name, "pid", self.__pid) stdoptions.add_name_format_option(menu, category_name) diff --git a/gramps/plugins/drawreport/calendarreport.py b/gramps/plugins/drawreport/calendarreport.py index 8eeb040dc..d5888c4cb 100644 --- a/gramps/plugins/drawreport/calendarreport.py +++ b/gramps/plugins/drawreport/calendarreport.py @@ -1,7 +1,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham -# Copyright (C) 2008-2009 Brian G. Matherly +# Copyright (C) 2008-2012 Brian G. Matherly # Copyright (C) 2010 Jakim Friant # Copyright (C) 2012-2014 Paul Franklin # @@ -457,6 +457,10 @@ class CalendarOptions(MenuReportOptions): self.__filter = None MenuReportOptions.__init__(self, name, dbase) + def get_subject(self): + """ Return a string that describes the subject of the report. """ + return self.__filter.get_filter().get_name() + def add_menu_options(self, menu): """ Add the options for the graphical calendar """ diff --git a/gramps/plugins/drawreport/descendtree.py b/gramps/plugins/drawreport/descendtree.py index 05f92aebc..3d8545fa9 100644 --- a/gramps/plugins/drawreport/descendtree.py +++ b/gramps/plugins/drawreport/descendtree.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham -# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2007-2012 Brian G. Matherly # Copyright (C) 2010 Jakim Friant # Copyright (C) 2009-2010 Craig J. Anderson # Copyright (C) 2014 Paul Franklin @@ -44,6 +44,8 @@ from gramps.gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle, FONT_SANS_SERIF, PARA_ALIGN_CENTER) from gramps.plugins.lib.libtreebase import * from gramps.gen.proxy import CacheProxyDb +from gramps.gen.display.name import displayer as _nd +from gramps.gen.utils.db import family_name PT2CM = utils.pt2cm @@ -1497,6 +1499,19 @@ class DescendTreeOptions(MenuReportOptions): self.box_shadow_sf = None MenuReportOptions.__init__(self, name, dbase) + def get_subject(self): + """ Return a string that describes the subject of the report. """ + gid = self.__pid.get_value() + if self.name.split(",")[0] == _RPT_NAME: + person = self.__db.get_person_from_gramps_id(gid) + if person: + return _nd.display(person) + else: + family = self.__db.get_family_from_gramps_id(gid) + if family: + return family_name(family, self.__db) + return "" + def add_menu_options(self, menu): """ Add options to the menu for the descendant report. diff --git a/gramps/plugins/drawreport/fanchart.py b/gramps/plugins/drawreport/fanchart.py index 2e4088bea..46946a2d1 100644 --- a/gramps/plugins/drawreport/fanchart.py +++ b/gramps/plugins/drawreport/fanchart.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2006 Donald N. Allingham -# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2007-2012 Brian G. Matherly # Copyright (C) 2010 Jakim Friant # Copyright (C) 2012-2014 Paul Franklin # Copyright (C) 2012 Nicolas Adenis-Lamarre @@ -59,6 +59,7 @@ from gramps.gen.config import config from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback from gramps.gen.lib import EventType from gramps.gen.proxy import CacheProxyDb +from gramps.gen.display.name import displayer as _nd #------------------------------------------------------------------------ # @@ -667,19 +668,26 @@ class FanChartOptions(MenuReportOptions): """ options for fanchart report """ def __init__(self, name, dbase): + self.__db = dbase + self.__pid = None self.max_generations = 11 - MenuReportOptions.__init__(self, name, dbase) + def get_subject(self): + """ Return a string that describes the subject of the report. """ + gid = self.__pid.get_value() + person = self.__db.get_person_from_gramps_id(gid) + return _nd.display(person) + def add_menu_options(self, menu): """ Add options to the menu for the fan chart. """ category_name = _("Report Options") - pid = PersonOption(_("Center Person")) - pid.set_help(_("The center person for the report")) - menu.add_option(category_name, "pid", pid) + self.__pid = PersonOption(_("Center Person")) + self.__pid.set_help(_("The center person for the report")) + menu.add_option(category_name, "pid", self.__pid) stdoptions.add_private_data_option(menu, category_name) diff --git a/gramps/plugins/drawreport/statisticschart.py b/gramps/plugins/drawreport/statisticschart.py index 04a1a0de1..a72887011 100644 --- a/gramps/plugins/drawreport/statisticschart.py +++ b/gramps/plugins/drawreport/statisticschart.py @@ -3,7 +3,7 @@ # # Copyright (C) 2003-2006 Donald N. Allingham # Copyright (C) 2004-2005 Eero Tamminen -# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2007-2012 Brian G. Matherly # Copyright (C) 2008 Peter Landgren # Copyright (C) 2010 Jakim Friant # Copyright (C) 2012-2016 Paul Franklin @@ -971,6 +971,10 @@ class StatisticsChartOptions(MenuReportOptions): 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. diff --git a/gramps/plugins/drawreport/timeline.py b/gramps/plugins/drawreport/timeline.py index 58b736081..dd5c84d93 100644 --- a/gramps/plugins/drawreport/timeline.py +++ b/gramps/plugins/drawreport/timeline.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2007 Donald N. Allingham -# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2007-2012 Brian G. Matherly # Copyright (C) 2010 Jakim Friant # Copyright (C) 2012-2016 Paul Franklin # @@ -407,6 +407,10 @@ class TimeLineOptions(MenuReportOptions): 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") diff --git a/gramps/plugins/textreport/alphabeticalindex.py b/gramps/plugins/textreport/alphabeticalindex.py index eade10da5..e45e43be9 100644 --- a/gramps/plugins/textreport/alphabeticalindex.py +++ b/gramps/plugins/textreport/alphabeticalindex.py @@ -1,6 +1,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2012 Nick Hall +# Copyright (C) 2012 Brian G. Matherly # Copyright (C) 2012-2014 Paul Franklin # # This program is free software; you can redistribute it and/or modify @@ -83,6 +84,10 @@ class AlphabeticalIndexOptions(MenuReportOptions): self.__db = dbase MenuReportOptions.__init__(self, name, dbase) + def get_subject(self): + """ Return a string that describes the subject of the report. """ + return _('Entire Book') + def add_menu_options(self, menu): """ Add the options for this report """ category_name = _("Report Options") diff --git a/gramps/plugins/textreport/ancestorreport.py b/gramps/plugins/textreport/ancestorreport.py index 8b6decb79..bce11b67a 100644 --- a/gramps/plugins/textreport/ancestorreport.py +++ b/gramps/plugins/textreport/ancestorreport.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham -# Copyright (C) 2007-2009 Brian G. Matherly +# Copyright (C) 2007-2012 Brian G. Matherly # Copyright (C) 2010 Jakim Friant # Copyright (C) 2012-2014 Paul Franklin # @@ -49,6 +49,7 @@ from gramps.gen.plug.report import MenuReportOptions from gramps.gen.plug.report import stdoptions from gramps.plugins.lib.libnarrate import Narrator from gramps.gen.proxy import CacheProxyDb +from gramps.gen.display.name import displayer as _nd #------------------------------------------------------------------------ # @@ -263,17 +264,25 @@ class AncestorOptions(MenuReportOptions): """ def __init__(self, name, dbase): + self.__db = dbase + self.__pid = None MenuReportOptions.__init__(self, name, dbase) + def get_subject(self): + """ Return a string that describes the subject of the report. """ + gid = self.__pid.get_value() + person = self.__db.get_person_from_gramps_id(gid) + return _nd.display(person) + def add_menu_options(self, menu): """ Add options to the menu for the ancestor report. """ category_name = _("Report Options") - pid = PersonOption(_("Center Person")) - pid.set_help(_("The center person for the report")) - menu.add_option(category_name, "pid", pid) + self.__pid = PersonOption(_("Center Person")) + self.__pid.set_help(_("The center person for the report")) + menu.add_option(category_name, "pid", self.__pid) stdoptions.add_name_format_option(menu, category_name) diff --git a/gramps/plugins/textreport/birthdayreport.py b/gramps/plugins/textreport/birthdayreport.py index e39ea96b7..8de38434d 100644 --- a/gramps/plugins/textreport/birthdayreport.py +++ b/gramps/plugins/textreport/birthdayreport.py @@ -1,7 +1,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham -# Copyright (C) 2008-2009 Brian G. Matherly +# Copyright (C) 2008-2012 Brian G. Matherly # Copyright (C) 2009 Rob G. Healey # Copyright (C) 2010 Jakim Friant # Copyright (C) 2012-2014 Paul Franklin @@ -405,6 +405,10 @@ class BirthdayOptions(MenuReportOptions): 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 """ diff --git a/gramps/plugins/textreport/custombooktext.py b/gramps/plugins/textreport/custombooktext.py index 8bd242b19..ef5736d21 100644 --- a/gramps/plugins/textreport/custombooktext.py +++ b/gramps/plugins/textreport/custombooktext.py @@ -1,7 +1,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2006 Donald N. Allingham -# Copyright (C) 2008 Brian G. Matherly +# Copyright (C) 2008,2012 Brian G. Matherly # Copyright (C) 2010 Jakim Friant # Copyright (C) 2012 Paul Franklin # @@ -122,23 +122,36 @@ class CustomTextOptions(MenuReportOptions): """ def __init__(self, name, dbase): + self.__top = None + self.__mid = None + self.__bot = None MenuReportOptions.__init__(self, name, dbase) def add_menu_options(self, menu): category_name = _("Text") - top = TextOption(_("Initial Text"), [""]) - top.set_help(_("Text to display at the top.")) - menu.add_option(category_name, "top", top) + self.__top = TextOption(_("Initial Text"), [""]) + self.__top.set_help(_("Text to display at the top.")) + menu.add_option(category_name, "top", self.__top) - mid = TextOption(_("Middle Text"), [""]) - mid.set_help(_("Text to display in the middle")) - menu.add_option(category_name, "mid", mid) + self.__mid = TextOption(_("Middle Text"), [""]) + self.__mid.set_help(_("Text to display in the middle")) + menu.add_option(category_name, "mid", self.__mid) - bot = TextOption(_("Final Text"), [""]) - bot.set_help(_("Text to display last.")) - menu.add_option(category_name, "bot", bot) + self.__bot = TextOption(_("Final Text"), [""]) + self.__bot.set_help(_("Text to display last.")) + menu.add_option(category_name, "bot", self.__bot) + + def get_subject(self): + """ Return a string that describes the subject of the report. """ + if len(self.__top.get_value()[0]) > 0: + return self.__top.get_value()[0] + if len(self.__mid.get_value()[0]) > 0: + return self.__mid.get_value()[0] + if len(self.__bot.get_value()[0]) > 0: + return self.__bot.get_value()[0] + return "" def make_default_style(self, default_style): """Make the default output style for the Custom Text report.""" diff --git a/gramps/plugins/textreport/descendreport.py b/gramps/plugins/textreport/descendreport.py index c366a02a4..301ada5bd 100644 --- a/gramps/plugins/textreport/descendreport.py +++ b/gramps/plugins/textreport/descendreport.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham -# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2007-2012 Brian G. Matherly # Copyright (C) 2009 Gary Burton # Copyright (C) 2010 Craig J. Anderson # Copyright (C) 2010 Jakim Friant @@ -56,6 +56,7 @@ from gramps.gen.utils.db import (get_birth_or_fallback, get_death_or_fallback, get_divorce_or_fallback) from gramps.gen.proxy import CacheProxyDb from gramps.gen.display.place import displayer as _pd +from gramps.gen.display.name import displayer as _nd #------------------------------------------------------------------------ # @@ -412,14 +413,22 @@ class DescendantOptions(MenuReportOptions): """ def __init__(self, name, dbase): + self.__db = dbase + self.__pid = None MenuReportOptions.__init__(self, name, dbase) + def get_subject(self): + """ Return a string that describes the subject of the report. """ + gid = self.__pid.get_value() + person = self.__db.get_person_from_gramps_id(gid) + return _nd.display(person) + def add_menu_options(self, menu): category_name = _("Report Options") - pid = PersonOption(_("Center Person")) - pid.set_help(_("The center person for the report")) - menu.add_option(category_name, "pid", pid) + self.__pid = PersonOption(_("Center Person")) + self.__pid.set_help(_("The center person for the report")) + menu.add_option(category_name, "pid", self.__pid) stdoptions.add_name_format_option(menu, category_name) diff --git a/gramps/plugins/textreport/detancestralreport.py b/gramps/plugins/textreport/detancestralreport.py index b5a29b7ae..198c5355b 100644 --- a/gramps/plugins/textreport/detancestralreport.py +++ b/gramps/plugins/textreport/detancestralreport.py @@ -4,7 +4,7 @@ # # Copyright (C) 2000-2002 Bruce J. DeGrasse # Copyright (C) 2000-2007 Donald N. Allingham -# Copyright (C) 2007-2009 Brian G. Matherly +# Copyright (C) 2007-2012 Brian G. Matherly # Copyright (C) 2008 James Friedmann # Copyright (C) 2009 Benny Malengier # Copyright (C) 2010 Jakim Friant @@ -60,6 +60,7 @@ from gramps.gen.plug.report import stdoptions from gramps.plugins.lib.libnarrate import Narrator from gramps.gen.display.place import displayer as _pd from gramps.gen.proxy import CacheProxyDb +from gramps.gen.display.name import displayer as _nd #------------------------------------------------------------------------ # @@ -761,8 +762,16 @@ class DetAncestorOptions(MenuReportOptions): """ def __init__(self, name, dbase): + self.__db = dbase + self.__pid = None MenuReportOptions.__init__(self, name, dbase) + def get_subject(self): + """ Return a string that describes the subject of the report. """ + gid = self.__pid.get_value() + person = self.__db.get_person_from_gramps_id(gid) + return _nd.display(person) + def add_menu_options(self, menu): from functools import partial @@ -770,9 +779,9 @@ class DetAncestorOptions(MenuReportOptions): category = _("Report Options") addopt = partial(menu.add_option, category) - pid = PersonOption(_("Center Person")) - pid.set_help(_("The center person for the report")) - addopt("pid", pid) + self.__pid = PersonOption(_("Center Person")) + self.__pid.set_help(_("The center person for the report")) + addopt("pid", self.__pid) start_number = NumberOption(_("Sosa-Stradonitz number"), 1, 1, 16384) start_number.set_help( diff --git a/gramps/plugins/textreport/detdescendantreport.py b/gramps/plugins/textreport/detdescendantreport.py index 4bf5fb528..5b60690fd 100644 --- a/gramps/plugins/textreport/detdescendantreport.py +++ b/gramps/plugins/textreport/detdescendantreport.py @@ -4,7 +4,7 @@ # # Copyright (C) 2000-2002 Bruce J. DeGrasse # Copyright (C) 2000-2007 Donald N. Allingham -# Copyright (C) 2007-2009 Brian G. Matherly +# Copyright (C) 2007-2012 Brian G. Matherly # Copyright (C) 2007 Robert Cawley # Copyright (C) 2008-2009 James Friedmann # Copyright (C) 2009 Benny Malengier @@ -59,6 +59,7 @@ from gramps.gen.plug.report import MenuReportOptions from gramps.gen.plug.report import stdoptions from gramps.plugins.lib.libnarrate import Narrator from gramps.gen.display.place import displayer as _pd +from gramps.gen.display.name import displayer as _nd from gramps.gen.proxy import CacheProxyDb #------------------------------------------------------------------------ @@ -911,8 +912,16 @@ class DetDescendantOptions(MenuReportOptions): """ def __init__(self, name, dbase): + self.__db = dbase + self.__pid = None MenuReportOptions.__init__(self, name, dbase) + def get_subject(self): + """ Return a string that describes the subject of the report. """ + gid = self.__pid.get_value() + person = self.__db.get_person_from_gramps_id(gid) + return _nd.display(person) + def add_menu_options(self, menu): """ Add options to the menu for the detailed descendant report. @@ -922,9 +931,9 @@ class DetDescendantOptions(MenuReportOptions): category = _("Report Options") add_option = partial(menu.add_option, category) - pid = PersonOption(_("Center Person")) - pid.set_help(_("The center person for the report")) - add_option("pid", pid) + self.__pid = PersonOption(_("Center Person")) + self.__pid.set_help(_("The center person for the report")) + add_option("pid", self.__pid) stdoptions.add_name_format_option(menu, category) diff --git a/gramps/plugins/textreport/endoflinereport.py b/gramps/plugins/textreport/endoflinereport.py index 1564b5c34..bbc6b8d1e 100644 --- a/gramps/plugins/textreport/endoflinereport.py +++ b/gramps/plugins/textreport/endoflinereport.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2007-2012 Brian G. Matherly # Copyright (C) 2010 Jakim Friant # Copyright (C) 2013-2014 Paul Franklin # @@ -46,6 +46,7 @@ from gramps.gen.plug.report import utils from gramps.gen.plug.report import MenuReportOptions from gramps.gen.plug.report import stdoptions from gramps.gen.proxy import CacheProxyDb +from gramps.gen.display.name import displayer as _nd #------------------------------------------------------------------------ # @@ -251,17 +252,25 @@ class EndOfLineOptions(MenuReportOptions): """ def __init__(self, name, dbase): + self.__db = dbase + self.__pid = None MenuReportOptions.__init__(self, name, dbase) + def get_subject(self): + """ Return a string that describes the subject of the report. """ + gid = self.__pid.get_value() + person = self.__db.get_person_from_gramps_id(gid) + return _nd.display(person) + def add_menu_options(self, menu): """ Add options to the menu for the End of Line report. """ category_name = _("Report Options") - pid = PersonOption(_("Center Person")) - pid.set_help(_("The center person for the report")) - menu.add_option(category_name, "pid", pid) + self.__pid = PersonOption(_("Center Person")) + self.__pid.set_help(_("The center person for the report")) + menu.add_option(category_name, "pid", self.__pid) stdoptions.add_name_format_option(menu, category_name) diff --git a/gramps/plugins/textreport/familygroup.py b/gramps/plugins/textreport/familygroup.py index 3399273b1..02bf24f6c 100644 --- a/gramps/plugins/textreport/familygroup.py +++ b/gramps/plugins/textreport/familygroup.py @@ -694,6 +694,10 @@ class FamilyGroupOptions(MenuReportOptions): 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): ########################## diff --git a/gramps/plugins/textreport/indivcomplete.py b/gramps/plugins/textreport/indivcomplete.py index af72a25d9..a42d145f4 100644 --- a/gramps/plugins/textreport/indivcomplete.py +++ b/gramps/plugins/textreport/indivcomplete.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2007 Donald N. Allingham -# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2007-2012 Brian G. Matherly # Copyright (C) 2009 Nick Hall # Copyright (C) 2009 Benny Malengier # Copyright (C) 2010 Jakim Friant @@ -980,6 +980,10 @@ class IndivCompleteOptions(MenuReportOptions): 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") diff --git a/gramps/plugins/textreport/kinshipreport.py b/gramps/plugins/textreport/kinshipreport.py index a30ad8266..868beaf81 100644 --- a/gramps/plugins/textreport/kinshipreport.py +++ b/gramps/plugins/textreport/kinshipreport.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2007-2012 Brian G. Matherly # Copyright (C) 2009 Gary Burton # Contribution 2009 by Reinhard Mueller # Copyright (C) 2010 Jakim Friant @@ -49,6 +49,7 @@ from gramps.gen.plug.report import MenuReportOptions from gramps.gen.plug.report import stdoptions from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback from gramps.gen.proxy import CacheProxyDb +from gramps.gen.display.name import displayer as _nd #------------------------------------------------------------------------ # @@ -337,17 +338,25 @@ class KinshipOptions(MenuReportOptions): """ def __init__(self, name, dbase): + self.__db = dbase + self.__pid = None MenuReportOptions.__init__(self, name, dbase) + def get_subject(self): + """ Return a string that describes the subject of the report. """ + gid = self.__pid.get_value() + person = self.__db.get_person_from_gramps_id(gid) + return _nd.display(person) + def add_menu_options(self, menu): """ Add options to the menu for the kinship report. """ category_name = _("Report Options") - pid = PersonOption(_("Center Person")) - pid.set_help(_("The center person for the report")) - menu.add_option(category_name, "pid", pid) + self.__pid = PersonOption(_("Center Person")) + self.__pid.set_help(_("The center person for the report")) + menu.add_option(category_name, "pid", self.__pid) stdoptions.add_name_format_option(menu, category_name) diff --git a/gramps/plugins/textreport/notelinkreport.py b/gramps/plugins/textreport/notelinkreport.py index 489f0a825..d0f34bc30 100644 --- a/gramps/plugins/textreport/notelinkreport.py +++ b/gramps/plugins/textreport/notelinkreport.py @@ -150,6 +150,11 @@ class NoteLinkReport(Report): # #------------------------------------------------------------------------ class NoteLinkOptions(MenuReportOptions): + + def get_subject(self): + """ Return a string that describes the subject of the report. """ + return _('Entire Database') + def add_menu_options(self, menu): """ Add options to the menu for the tag report. diff --git a/gramps/plugins/textreport/numberofancestorsreport.py b/gramps/plugins/textreport/numberofancestorsreport.py index 46c0b1cf1..2779374f3 100644 --- a/gramps/plugins/textreport/numberofancestorsreport.py +++ b/gramps/plugins/textreport/numberofancestorsreport.py @@ -4,7 +4,7 @@ # Copyright (C) 2001 Jesper Zedlitz # Copyright (C) 2004-2006 Donald Allingham # Copyright (C) 2007 Johan Gonqvist -# Copyright (C) 2008 Brian G. Matherly +# Copyright (C) 2008,2012 Brian G. Matherly # Copyright (C) 2010 Jakim Friant # Copyright (C) 2013-2014 Paul Franklin # @@ -48,6 +48,7 @@ from gramps.gen.plug.report import Report from gramps.gen.plug.report import utils from gramps.gen.plug.report import MenuReportOptions from gramps.gen.plug.report import stdoptions +from gramps.gen.display.name import displayer as _nd #------------------------------------------------------------------------ # @@ -185,17 +186,25 @@ class NumberOfAncestorsOptions(MenuReportOptions): Defines options for the NumberOfAncestorsReport. """ def __init__(self, name, dbase): + self.__db = dbase + self.__pid = None MenuReportOptions.__init__(self, name, dbase) + def get_subject(self): + """ Return a string that describes the subject of the report. """ + gid = self.__pid.get_value() + person = self.__db.get_person_from_gramps_id(gid) + return _nd.display(person) + def add_menu_options(self, menu): """ Add options to the menu for the Number of Ancestors report. """ category_name = _("Report Options") - pid = PersonOption(_("Center Person")) - pid.set_help(_("The center person for the report")) - menu.add_option(category_name, "pid", pid) + self.__pid = PersonOption(_("Center Person")) + self.__pid.set_help(_("The center person for the report")) + menu.add_option(category_name, "pid", self.__pid) stdoptions.add_name_format_option(menu, category_name) diff --git a/gramps/plugins/textreport/placereport.py b/gramps/plugins/textreport/placereport.py index b2ef917fb..0b7c57b96 100644 --- a/gramps/plugins/textreport/placereport.py +++ b/gramps/plugins/textreport/placereport.py @@ -405,8 +405,26 @@ class PlaceOptions(MenuReportOptions): """ def __init__(self, name, dbase): + self.__db = dbase + self.__filter = None + self.__places = None MenuReportOptions.__init__(self, name, dbase) + def get_subject(self): + """ Return a string that describes the subject of the report. """ + subject = "" + if self.__filter.get_filter().get_name(): + # Use the selected filter's name, if any + subject += self.__filter.get_filter().get_name() + if self.__places.get_value(): + # Add places selected individually, if any + for place_id in self.__places.get_value().split(): + if subject: + subject += " + " + place = self.__db.get_place_from_gramps_id(place_id) + subject += _pd.display(self.__db, place) + return subject + def add_menu_options(self, menu): """ Add options to the menu for the place report. @@ -417,17 +435,17 @@ class PlaceOptions(MenuReportOptions): CustomFilters = None from gramps.gen.filters import CustomFilters, GenericFilter - opt = FilterOption(_("Select using filter"), 0) - opt.set_help(_("Select places using a filter")) + self.__filter = FilterOption(_("Select using filter"), 0) + self.__filter.set_help(_("Select places using a filter")) filter_list = [] filter_list.append(GenericFilter()) filter_list.extend(CustomFilters.get_filters('Place')) - opt.set_filters(filter_list) - menu.add_option(category_name, "filter", opt) + self.__filter.set_filters(filter_list) + menu.add_option(category_name, "filter", self.__filter) - places = PlaceListOption(_("Select places individually")) - places.set_help(_("List of places to report on")) - menu.add_option(category_name, "places", places) + self.__places = PlaceListOption(_("Select places individually")) + self.__places.set_help(_("List of places to report on")) + menu.add_option(category_name, "places", self.__places) stdoptions.add_private_data_option(menu, category_name) diff --git a/gramps/plugins/textreport/recordsreport.py b/gramps/plugins/textreport/recordsreport.py index 43c5e336d..7cbce4ea1 100644 --- a/gramps/plugins/textreport/recordsreport.py +++ b/gramps/plugins/textreport/recordsreport.py @@ -4,6 +4,7 @@ # # Copyright (C) 2008-2011 Reinhard Müller # Copyright (C) 2010 Jakim Friant +# Copyright (C) 2012 Brian G. Matherly # Copyright (C) 2013-2016 Paul Franklin # # This program is free software; you can redistribute it and/or modify @@ -206,6 +207,10 @@ class RecordsReportOptions(MenuReportOptions): 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") diff --git a/gramps/plugins/textreport/simplebooktitle.py b/gramps/plugins/textreport/simplebooktitle.py index 21e13927c..afffa2540 100644 --- a/gramps/plugins/textreport/simplebooktitle.py +++ b/gramps/plugins/textreport/simplebooktitle.py @@ -1,7 +1,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2003-2006 Donald N. Allingham -# Copyright (C) 2008 Brian G. Matherly +# Copyright (C) 2008,2012 Brian G. Matherly # Copyright (C) 2010 Jakim Friant # Copyright (C) 2011 Paul Franklin # @@ -125,13 +125,17 @@ class SimpleBookTitleOptions(MenuReportOptions): self.__db = dbase MenuReportOptions.__init__(self, name, dbase) + def get_subject(self): + """ Return a string that describes the subject of the report. """ + return self.__title.get_value() + def add_menu_options(self, menu): """ Add the options for this report """ category_name = _("Report Options") - title = StringOption(_('book|Title'), _('Title of the Book')) - title.set_help(_("Title string for the book.")) - menu.add_option(category_name, "title", title) + self.__title = StringOption(_('book|Title'), _('Title of the Book')) + self.__title.set_help(_("Title string for the book.")) + menu.add_option(category_name, "title", self.__title) subtitle = StringOption(_('Subtitle'), _('Subtitle of the Book')) subtitle.set_help(_("Subtitle string for the book.")) diff --git a/gramps/plugins/textreport/summary.py b/gramps/plugins/textreport/summary.py index 7ebb1570c..41095846d 100644 --- a/gramps/plugins/textreport/summary.py +++ b/gramps/plugins/textreport/summary.py @@ -2,7 +2,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000-2006 Donald N. Allingham -# Copyright (C) 2008 Brian G. Matherly +# Copyright (C) 2008,2012 Brian G. Matherly # Copyright (C) 2010 Jakim Friant # Copyright (C) 2013-2014 Paul Franklin # @@ -276,6 +276,10 @@ class SummaryOptions(MenuReportOptions): def __init__(self, name, dbase): MenuReportOptions.__init__(self, name, dbase) + def get_subject(self): + """ Return a string that describes the subject of the report. """ + return _('Entire Database') + def add_menu_options(self, menu): """ Add options to the menu for the summary report. diff --git a/gramps/plugins/textreport/tableofcontents.py b/gramps/plugins/textreport/tableofcontents.py index 29b5d9a8e..30f07d39a 100644 --- a/gramps/plugins/textreport/tableofcontents.py +++ b/gramps/plugins/textreport/tableofcontents.py @@ -1,6 +1,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2012 Nick Hall +# Copyright (C) 2012 Brian G. Matherly # Copyright (C) 2012-2014 Paul Franklin # # This program is free software; you can redistribute it and/or modify @@ -82,6 +83,10 @@ class TableOfContentsOptions(MenuReportOptions): self.__db = dbase MenuReportOptions.__init__(self, name, dbase) + def get_subject(self): + """ Return a string that describes the subject of the report. """ + return _('Entire Book') + def add_menu_options(self, menu): """ Add the options for this report """ category_name = _("Report Options") diff --git a/gramps/plugins/textreport/tagreport.py b/gramps/plugins/textreport/tagreport.py index d5498be42..4d47efe00 100644 --- a/gramps/plugins/textreport/tagreport.py +++ b/gramps/plugins/textreport/tagreport.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2007-2012 Brian G. Matherly # Copyright (C) 2009 Gary Burton # Copyright (C) 2010 Jakim Friant # Copyright (C) 2010 Nick Hall @@ -883,6 +883,10 @@ class TagOptions(MenuReportOptions): self.__db = dbase MenuReportOptions.__init__(self, name, dbase) + def get_subject(self): + """ Return a string that describes the subject of the report. """ + return self.__tag_option.get_value() + def add_menu_options(self, menu): """ Add options to the menu for the tag report. @@ -895,15 +899,15 @@ class TagOptions(MenuReportOptions): all_tags.append(tag.get_name()) if len(all_tags) > 0: - tag_option = EnumeratedListOption(_('Tag'), all_tags[0]) + self.__tag_option = EnumeratedListOption(_('Tag'), all_tags[0]) for tag_name in all_tags: - tag_option.add_item(tag_name, tag_name) + self.__tag_option.add_item(tag_name, tag_name) else: - tag_option = EnumeratedListOption(_('Tag'), '') - tag_option.add_item('', '') + self.__tag_option = EnumeratedListOption(_('Tag'), '') + self.__tag_option.add_item('', '') - tag_option.set_help(_("The tag to use for the report")) - menu.add_option(category_name, "tag", tag_option) + self.__tag_option.set_help(_("The tag to use for the report")) + menu.add_option(category_name, "tag", self.__tag_option) stdoptions.add_name_format_option(menu, category_name)