diff --git a/src/PluginUtils/_GuiOptions.py b/src/PluginUtils/_GuiOptions.py index 2a4aed0fc..0ae5f203f 100644 --- a/src/PluginUtils/_GuiOptions.py +++ b/src/PluginUtils/_GuiOptions.py @@ -52,7 +52,7 @@ from QuestionDialog import OptionDialog from Selectors import selector_factory from BasicUtils import name_displayer as _nd from Filters import GenericFilter, Rules -import _MenuOptions +import gen #------------------------------------------------------------------------ # @@ -160,7 +160,7 @@ class GuiStringOption(gtk.Entry): def __init__(self, option, dbstate, uistate, track, tooltip): """ @param option: The option to display. - @type option: MenuOption.StringOption + @type option: gen.plug.menu.StringOption @return: nothing """ gtk.Entry.__init__(self) @@ -177,10 +177,10 @@ class GuiStringOption(gtk.Entry): #------------------------------------------------------------------------- # -# GuiColourOption class +# GuiColorOption class # #------------------------------------------------------------------------- -class GuiColourOption(gtk.ColorButton): +class GuiColorOption(gtk.ColorButton): """ This class displays an option that allows the selection of a colour. """ @@ -385,7 +385,7 @@ class GuiPersonOption(gtk.HBox): def __init__(self, option, dbstate, uistate, track, tooltip): """ @param option: The option to display. - @type option: MenuOption.PersonOption + @type option: gen.plug.menu.PersonOption @return: nothing """ gtk.HBox.__init__(self) @@ -476,7 +476,7 @@ class GuiFamilyOption(gtk.HBox): def __init__(self, option, dbstate, uistate, track, tooltip): """ @param option: The option to display. - @type option: MenuOption.FamilyOption + @type option: gen.plug.menu.FamilyOption @return: nothing """ gtk.HBox.__init__(self) @@ -615,7 +615,7 @@ class GuiNoteOption(gtk.HBox): def __init__(self, option, dbstate, uistate, track, tooltip): """ @param option: The option to display. - @type option: MenuOption.NoteOption + @type option: gen.plug.menu.NoteOption @return: nothing """ gtk.HBox.__init__(self) @@ -697,7 +697,7 @@ class GuiMediaOption(gtk.HBox): def __init__(self, option, dbstate, uistate, track, tooltip): """ @param option: The option to display. - @type option: MenuOption.MediaOption + @type option: gen.plug.menu.MediaOption @return: nothing """ gtk.HBox.__init__(self) @@ -774,7 +774,7 @@ class GuiPersonListOption(gtk.HBox): def __init__(self, option, dbstate, uistate, track, tooltip): """ @param option: The option to display. - @type option: MenuOption.PersonListOption + @type option: gen.plug.menu.PersonListOption @return: nothing """ gtk.HBox.__init__(self) @@ -914,7 +914,7 @@ class GuiPlaceListOption(gtk.HBox): def __init__(self, option, dbstate, uistate, track, tooltip): """ @param option: The option to display. - @type option: MenuOption.PlaceListOption + @type option: gen.plug.menu.PlaceListOption @return: nothing """ gtk.HBox.__init__(self) @@ -1014,10 +1014,10 @@ class GuiPlaceListOption(gtk.HBox): #------------------------------------------------------------------------- # -# GuiSurnameColourOption class +# GuiSurnameColorOption class # #------------------------------------------------------------------------- -class GuiSurnameColourOption(gtk.HBox): +class GuiSurnameColorOption(gtk.HBox): """ This class displays a widget that allows multiple surnames to be selected from the database, and to assign a colour (not necessarily @@ -1026,7 +1026,7 @@ class GuiSurnameColourOption(gtk.HBox): def __init__(self, option, dbstate, uistate, track, tooltip): """ @param option: The option to display. - @type option: MenuOption.SurnameColourOption + @type option: gen.plug.menu.SurnameColorOption @return: nothing """ gtk.HBox.__init__(self) @@ -1179,7 +1179,7 @@ class GuiDestinationOption(gtk.HBox): def __init__(self, option, dbstate, uistate, track, tooltip): """ @param option: The option to display. - @type option: MenuOption.StringOption + @type option: gen.plug.menu.DestinationOption @return: nothing """ gtk.HBox.__init__(self) @@ -1274,10 +1274,11 @@ class GuiStyleOption(GuiEnumeratedListOption): def __init__(self, option, dbstate, uistate, track, tooltip): """ @param option: The option to display. - @type option: MenuOption.StyleOption + @type option: gen.plug.menu.StyleOption @return: nothing """ - GuiEnumeratedListOption.__init__(self, option, dbstate, uistate, track, tooltip) + GuiEnumeratedListOption.__init__(self, option, dbstate, + uistate, track, tooltip) self.__option = option self.__button = gtk.Button("%s..." % _("Style Editor")) @@ -1313,7 +1314,7 @@ class GuiMenuOptions: options to a GTK dialog. """ def __init__(self): - self.menu = _MenuOptions.Menu() + self.menu = gen.plug.menu.Menu() # Fill options_dict with report/tool defaults: self.options_dict = {} @@ -1389,66 +1390,41 @@ def make_gui_option(option, tooltips, dbstate, uistate, track): """ widget = None label = True - if isinstance(option, _MenuOptions.PersonOption): - widget = GuiPersonOption(option, dbstate, - uistate, track, - tooltips) - elif isinstance(option, _MenuOptions.FamilyOption): - widget = GuiFamilyOption(option, dbstate, - uistate, track, - tooltips) - elif isinstance(option, _MenuOptions.NoteOption): - widget = GuiNoteOption(option, dbstate, - uistate, track, - tooltips) - elif isinstance(option, _MenuOptions.MediaOption): - widget = GuiMediaOption(option, dbstate, - uistate, track, - tooltips) - elif isinstance(option, _MenuOptions.PersonListOption): - widget = GuiPersonListOption(option, dbstate, - uistate, track, - tooltips) - elif isinstance(option, _MenuOptions.NumberOption): - widget = GuiNumberOption(option, dbstate, - uistate, track, - tooltips) - elif isinstance(option, _MenuOptions.BooleanOption): - widget = GuiBooleanOption(option, dbstate, - uistate, track, - tooltips) + if isinstance(option, gen.plug.menu.PersonOption): + widget = GuiPersonOption(option, dbstate, uistate, track, tooltips) + elif isinstance(option, gen.plug.menu.FamilyOption): + widget = GuiFamilyOption(option, dbstate, uistate, track, tooltips) + elif isinstance(option, gen.plug.menu.NoteOption): + widget = GuiNoteOption(option, dbstate, uistate, track, tooltips) + elif isinstance(option, gen.plug.menu.MediaOption): + widget = GuiMediaOption(option, dbstate, uistate, track, tooltips) + elif isinstance(option, gen.plug.menu.PersonListOption): + widget = GuiPersonListOption(option, dbstate, uistate, track, tooltips) + elif isinstance(option, gen.plug.menu.NumberOption): + widget = GuiNumberOption(option, dbstate, uistate, track, tooltips) + elif isinstance(option, gen.plug.menu.BooleanOption): + widget = GuiBooleanOption(option, dbstate, uistate, track, tooltips) label = False - elif isinstance(option, _MenuOptions.DestinationOption): - widget = GuiDestinationOption(option, dbstate, - uistate, track, - tooltips) - elif isinstance(option, _MenuOptions.StringOption): - widget = GuiStringOption(option, dbstate, - uistate, track, - tooltips) - elif isinstance(option, _MenuOptions.StyleOption): + elif isinstance(option, gen.plug.menu.DestinationOption): + widget = GuiDestinationOption(option, dbstate, uistate, track, tooltips) + elif isinstance(option, gen.plug.menu.StringOption): + widget = GuiStringOption(option, dbstate, uistate, track, tooltips) + elif isinstance(option, gen.plug.menu.StyleOption): widget = GuiStyleOption(option, dbstate, uistate, track, tooltips) - elif isinstance(option, _MenuOptions.EnumeratedListOption): - widget = GuiEnumeratedListOption(option, dbstate, - uistate, track, - tooltips) - elif isinstance(option, _MenuOptions.TextOption): - widget = GuiTextOption(option, dbstate, - uistate, track, - tooltips) - elif isinstance(option, _MenuOptions.ColourOption): - widget = GuiColourOption(option, dbstate, - uistate, track, - tooltips) - elif isinstance(option, _MenuOptions.SurnameColourOption): - widget = GuiSurnameColourOption(option, dbstate, - uistate, track, - tooltips) - elif isinstance(option, _MenuOptions.PlaceListOption): - widget = GuiPlaceListOption(option, dbstate, - uistate, track, - tooltips) + elif isinstance(option, gen.plug.menu.EnumeratedListOption): + widget = GuiEnumeratedListOption(option, dbstate, uistate, track, + tooltips) + elif isinstance(option, gen.plug.menu.TextOption): + widget = GuiTextOption(option, dbstate, uistate, track, tooltips) + elif isinstance(option, gen.plug.menu.ColorOption): + widget = GuiColorOption(option, dbstate, uistate, track, tooltips) + elif isinstance(option, gen.plug.menu.SurnameColorOption): + widget = GuiSurnameColorOption(option, dbstate, uistate, track, + tooltips) + elif isinstance(option, gen.plug.menu.PlaceListOption): + widget = GuiPlaceListOption(option, dbstate, uistate, track, tooltips) else: - raise AttributeError("can't make GuiOption: unknown option type: '%s'" % option) + raise AttributeError( + "can't make GuiOption: unknown option type: '%s'" % option) return widget, label diff --git a/src/PluginUtils/_MenuOptions.py b/src/PluginUtils/_MenuOptions.py deleted file mode 100644 index 168f1139e..000000000 --- a/src/PluginUtils/_MenuOptions.py +++ /dev/null @@ -1,802 +0,0 @@ -# -# Gramps - a GTK+/GNOME based genealogy program -# -# Copyright (C) 2007-2008 Brian G. Matherly -# Copyright (C) 2008 Gary Burton -# -# 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 -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# $Id$ - -""" -Abstracted option handling. -""" -#------------------------------------------------------------------------- -# -# gramps modules -# -#------------------------------------------------------------------------- -import gen.utils - -#------------------------------------------------------------------------- -# -# Option class -# -#------------------------------------------------------------------------- -class Option(gen.utils.Callback): - """ - This class serves as a base class for all options. All Options must - minimally provide the services provided by this class. Options are allowed - to add additional functionality. - """ - - __signals__ = { 'value-changed' : None, - 'avail-changed' : None} - - def __init__(self, label, value): - """ - @param label: A friendly label to be applied to this option. - Example: "Exclude living people" - @type label: string - @param value: An initial value for this option. - Example: True - @type value: The type will depend on the type of option. - @return: nothing - """ - gen.utils.Callback.__init__(self) - self.__value = value - self.__label = label - self.__help_str = "" - self.__available = True - - def get_label(self): - """ - Get the friendly label for this option. - - @return: string - """ - return self.__label - - def set_label(self, label): - """ - Set the friendly label for this option. - - @param label: A friendly label to be applied to this option. - Example: "Exclude living people" - @type label: string - @return: nothing - """ - self.__label = label - - def get_value(self): - """ - Get the value of this option. - - @return: The option value. - """ - return self.__value - - def set_value(self, value): - """ - Set the value of this option. - - @param value: A value for this option. - Example: True - @type value: The type will depend on the type of option. - @return: nothing - """ - self.__value = value - self.emit('value-changed') - - def get_help(self): - """ - Get the help information for this option. - - @return: A string that provides additional help beyond the label. - """ - return self.__help_str - - def set_help(self, help_text): - """ - Set the help information for this option. - - @param help: A string that provides additional help beyond the label. - Example: "Whether to include or exclude people who are calculated - to be alive at the time of the generation of this report" - @type value: string - @return: nothing - """ - self.__help_str = help_text - - def set_available(self, avail): - """ - Set the availability of this option. - - @param avail: An indicator of whether this option is currently - available. True indicates that the option is available. False indicates - that the option is not available. - @type avail: Bool - @return: nothing - """ - if avail != self.__available: - self.__available = avail - self.emit('avail-changed') - - def get_available(self): - """ - Get the availability of this option. - - @return: A Bool indicating the availablity of this option. - True indicates that the option is available. - False indicates that the option is not available. - """ - return self.__available - -#------------------------------------------------------------------------- -# -# StringOption class -# -#------------------------------------------------------------------------- -class StringOption(Option): - """ - This class describes an option that is a simple one-line string. - """ - def __init__(self, label, value): - """ - @param label: A friendly label to be applied to this option. - Example: "Page header" - @type label: string - @param value: An initial value for this option. - Example: "Generated by GRAMPS" - @type value: string - @return: nothing - """ - Option.__init__(self, label, value) - -#------------------------------------------------------------------------- -# -# ColourOption class -# -#------------------------------------------------------------------------- -class ColourOption(Option): - """ - This class describes an option that allows the selection of a colour. - """ - def __init__(self, label, value): - """ - @param label: A friendly label to be applied to this option. - Example: "Males" - @type label: string - @param value: An initial value for this option. - Example: "#ff00a0" - @type value: string - @return: nothing - """ - Option.__init__(self, label, value) - -#------------------------------------------------------------------------- -# -# NumberOption class -# -#------------------------------------------------------------------------- -class NumberOption(Option): - """ - This class describes an option that is a simple number with defined maximum - and minimum values. - """ - def __init__(self, label, value, min_val, max_val, step = 1): - """ - @param label: A friendly label to be applied to this option. - Example: "Number of generations to include" - @type label: string - @param value: An initial value for this option. - Example: 5 - @type value: int - @param min: The minimum value for this option. - Example: 1 - @type min: int - @param max: The maximum value for this option. - Example: 10 - @type value: int - @param step: The step size for this option. - Example: 0.01 - @type value: int or float - @return: nothing - """ - Option.__init__(self, label, value) - self.__min = min_val - self.__max = max_val - self.__step = step - - def get_min(self): - """ - Get the minimum value for this option. - - @return: an int that represents the minimum value for this option. - """ - return self.__min - - def get_max(self): - """ - Get the maximum value for this option. - - @return: an int that represents the maximum value for this option. - """ - return self.__max - - def get_step(self): - """ - Get the step size for this option. - - @return: an int that represents the step size for this option. - """ - return self.__step - -#------------------------------------------------------------------------- -# -# TextOption class -# -#------------------------------------------------------------------------- -class TextOption(Option): - """ - This class describes an option that is a multi-line string. - """ - def __init__(self, label, value): - """ - @param label: A friendly label to be applied to this option. - Example: "Page header" - @type label: string - @param value: An initial value for this option. - Example: "Generated by GRAMPS\nCopyright 2007" - @type value: string - @return: nothing - """ - Option.__init__(self, label, value) - -#------------------------------------------------------------------------- -# -# BooleanOption class -# -#------------------------------------------------------------------------- -class BooleanOption(Option): - """ - This class describes an option that is a boolean (True or False). - """ - def __init__(self, label, value): - """ - @param label: A friendly label to be applied to this option. - Example: "Exclude living people" - @type label: string - @param value: An initial value for this option. - Example: True - @type value: boolean - @return: nothing - """ - Option.__init__(self, label, value) - -#------------------------------------------------------------------------- -# -# EnumeratedListOption class -# -#------------------------------------------------------------------------- -class EnumeratedListOption(Option): - """ - This class describes an option that provides a finite number of values. - Each possible value is assigned a value and a description. - """ - - __signals__ = { 'options-changed' : None } - - def __init__(self, label, value): - """ - @param label: A friendly label to be applied to this option. - Example: "Paper Size" - @type label: string - @param value: An initial value for this option. - Example: 5 - @type value: int - @return: nothing - """ - Option.__init__(self, label, value) - self.__items = [] - - def add_item(self, value, description): - """ - Add an item to the list of possible values. - - @param value: The value that corresponds to this item. - Example: 5 - @type value: int - @param description: A description of this value. - Example: "8.5 x 11" - @type description: string - @return: nothing - """ - self.__items.append((value, description)) - self.emit('options-changed') - - def set_items(self, items): - """ - Add a list of items to the list of possible values. - - @param items: A list of tuples containing value, description pairs. - Example: [ (5,"8.5 x 11"), (6,"11 x 17")] - @type items: array - @return: nothing - """ - self.__items = items - self.emit('options-changed') - - def get_items(self): - """ - Get all the possible values for this option. - - @return: an array of tuples containing (value,description) pairs. - """ - return self.__items - - def clear(self): - """ - Clear all possible values from this option. - - @return: nothing. - """ - self.__items = [] - self.emit('options-changed') - - def set_value(self, value): - """ - Set the value of this option. - - @param value: A value for this option. - Example: True - @type value: The type will depend on the type of option. - @return: nothing - """ - found = False - for (opt_value, opt_description) in self.__items: - if value == opt_value: - found = True - - if found: - Option.set_value(self, value) - else: - print "Value %s not found for option %s" % ( str(value), - self.get_label() ) - -#------------------------------------------------------------------------- -# -# FilterOption class -# -#------------------------------------------------------------------------- -class FilterOption(EnumeratedListOption): - """ - This class describes an option that provides a list of person filters. - Each possible value represents one of the possible filters. - """ - def __init__(self, label, value): - """ - @param label: A friendly label to be applied to this option. - Example: "Filter" - @type label: string - @param value: A default value for the option. - Example: 1 - @type label: int - @return: nothing - """ - EnumeratedListOption.__init__(self, label, value) - self.__filters = [] - - def set_filters(self, filter_list): - """ - Set the list of filters available to be chosen from. - - @param filter_list: An array of person filters. - @type filter_list: array - @return: nothing - """ - items = [] - curval = self.get_value() - - value = 0 - for filt in filter_list: - items.append((value, filt.get_name())) - value += 1 - - self.__filters = filter_list - self.clear() - self.set_items( items ) - - self.set_value(curval) - - def get_filter(self): - """ - Return the currently selected filter object. - - @return: A filter object. - """ - return self.__filters[self.get_value()] - -#------------------------------------------------------------------------- -# -# PersonOption class -# -#------------------------------------------------------------------------- -class PersonOption(StringOption): - """ - This class describes an option that allows a person from the - database to be selected. - """ - def __init__(self, label): - """ - @param label: A friendly label to be applied to this option. - Example: "Center Person" - @type label: string - @param value: A Gramps ID of a person for this option. - Example: "p11" - @type value: string - @return: nothing - """ - StringOption.__init__(self, label, "") - -#------------------------------------------------------------------------- -# -# FamilyOption class -# -#------------------------------------------------------------------------- -class FamilyOption(StringOption): - """ - This class describes an option that allows a family from the - database to be selected. - """ - def __init__(self, label): - """ - @param label: A friendly label to be applied to this option. - Example: "Center Family" - @type label: string - @param value: A Gramps ID of a family for this option. - Example: "f11" - @type value: string - @return: nothing - """ - StringOption.__init__(self, label, "") - -#------------------------------------------------------------------------- -# -# NoteOption class -# -#------------------------------------------------------------------------- -class NoteOption(StringOption): - """ - This class describes an option that allows a note from the - database to be selected. - """ - def __init__(self, label): - """ - @param label: A friendly label to be applied to this option. - Example: "Title Note" - @type label: string - @param value: A Gramps ID of a note for this option. - Example: "n11" - @type value: string - @return: nothing - """ - StringOption.__init__(self, label, "") - -#------------------------------------------------------------------------- -# -# MediaOption class -# -#------------------------------------------------------------------------- -class MediaOption(StringOption): - """ - This class describes an option that allows a media object from the - database to be selected. - """ - def __init__(self, label): - """ - @param label: A friendly label to be applied to this option. - Example: "Image" - @type label: string - @param value: A Gramps ID of a media object for this option. - Example: "m11" - @type value: string - @return: nothing - """ - StringOption.__init__(self, label, "") - -#------------------------------------------------------------------------- -# -# PersonListOption class -# -#------------------------------------------------------------------------- -class PersonListOption(Option): - """ - This class describes a widget that allows multiple people from the - database to be selected. - """ - def __init__(self, label): - """ - @param label: A friendly label to be applied to this option. - Example: "People of interest" - @type label: string - @param value: A set of GIDs as initial values for this option. - Example: "111 222 333 444" - @type value: string - @return: nothing - """ - Option.__init__(self, label, "") - -#------------------------------------------------------------------------- -# -# PlaceListOption class -# -#------------------------------------------------------------------------- -class PlaceListOption(Option): - """ - This class describes a widget that allows multiple places from the - database to be selected. - """ - def __init__(self, label): - """ - @param label: A label to be applied to this option. - Example: "Places" - @type label: string - @param value: A set of GIDs as initial values for this option. - Example: "111 222 333 444" - @type value: string - @return: nothing - """ - Option.__init__(self, label, "") - -#------------------------------------------------------------------------- -# -# SurnameColourOption class -# -#------------------------------------------------------------------------- -class SurnameColourOption(Option): - """ - This class describes a widget that allows multiple surnames to be - selected from the database, and to assign a colour (not necessarily - unique) to each one. - """ - def __init__(self, label): - """ - @param label: A friendly label to be applied to this option. - Example: "Family lines" - @type label: string - @param value: A set of surnames and colours. - Example: "surname1 colour1 surname2 colour2" - @type value: string - @return: nothing - """ - Option.__init__(self, label, "") - -#------------------------------------------------------------------------- -# -# DestinationOption class -# -#------------------------------------------------------------------------- -class DestinationOption(StringOption): - """ - This class describes an option that specifies a destination file or path. - The destination can be a directory or a file. If the destination is a file, - the extension can be specified. - """ - - __signals__ = { 'options-changed' : None } - - def __init__(self, label, value): - """ - @param label: A friendly label to be applied to this option. - Example: "File Name" - @type label: string - @param value: A default destination for this option. - Example: "/home/username/Desktop/" - Example: "/home/username/Desktop/report.pdf" - @type value: string - @param is_directory: Specifies whether the destination is a directory - or a file. - @type value: bool - @return: nothing - """ - StringOption.__init__(self, label, value) - self.__is_directory = False - self.__extension = "" - - def set_directory_entry(self, is_directory): - """ - @param is_directory: Specifies whether the destination is a directory - or a file. - @type value: bool - @return: nothing - """ - self.__is_directory = is_directory - self.emit('options-changed') - - def get_directory_entry(self): - """ - @return: True if the destination is a directory. False if the - destination is a file. - """ - return self.__is_directory - - def set_extension(self, extension): - """ - @param extension: Specifies the extension for the destination file. - @type value: str - @return: nothing - """ - self.__extension = extension - - def get_extension(self): - """ - @return: The extension for the destination file. - """ - return self.__extension - -#------------------------------------------------------------------------- -# -# StyleOption class -# -#------------------------------------------------------------------------- -class StyleOption(EnumeratedListOption): - """ - This class describes an option that allows the use to select a style sheet. - """ - - def __init__(self, label, default_style, module_name): - """ - @param label: A friendly label to be applied to this option. - Example: "Style" - @type label: string - @param default_style: A BaseDoc.StyleSheet instance which provides the - default styles. - @type default_style: BaseDoc.StyleSheet - @param module_name: The name of the module the style sheets belong to. - Example: "web_cal" - @type module_name: string - @return: nothing - """ - import BaseDoc - EnumeratedListOption.__init__(self, label, "default") - - self.__default_style = default_style - self.__default_style.set_name("default") - self.__style_file = "%s_style.xml" % module_name - style_list = BaseDoc.StyleSheetList(self.__style_file, - self.__default_style) - for style_name in style_list.get_style_names(): - self.add_item(style_name, style_name) - - def get_default_style(self): - """ Get the default style """ - return self.__default_style - - def get_style_file(self): - """ Get the name of the style file """ - return self.__style_file - - def get_style(self): - """ Get the selected style """ - import BaseDoc - style_list = BaseDoc.StyleSheetList(self.__style_file, - self.__default_style) - return style_list.get_style_sheet(self.get_value()) - -#------------------------------------------------------------------------- -# -# Menu class -# -#------------------------------------------------------------------------- -class Menu: - """ - Introduction - ============ - A Menu is used to maintain a collection of options that need to be - represented to the user in a non-implementation specific way. The options - can be described using the various option classes. A menu contains many - options and associates them with a unique name and category. - - Usage - ===== - Menus are used in the following way. - - 1. Create a option object and configure all the attributes of the option. - 2. Add the option to the menu by specifying the option, name and category. - 3. Add as many options as necessary. - 4. When all the options are added, the menu can be stored and passed to - the part of the system that will actually represent the menu to - the user. - """ - def __init__(self): - # __options holds all the options by their category - self.__options = {} - # __categories holds the order of all categories - self.__categories = [] - - def add_option(self, category, name, option): - """ - Add an option to the menu. - - @param category: A label that describes the category that the option - belongs to. - Example: "Report Options" - @type category: string - @param name: A name that is unique to this option. - Example: "generations" - @type name: string - @param option: The option instance to be added to this menu. - @type option: Option - @return: nothing - """ - if category not in self.__options: - self.__categories.append(category) - self.__options[category] = [] - self.__options[category].append((name, option)) - - def get_categories(self): - """ - Get a list of categories in this menu. - - @return: a list of strings - """ - return self.__categories - - def get_option_names(self, category): - """ - Get a list of option names for the specified category. - - @return: a list of strings - """ - names = [] - for (name, option) in self.__options[category]: - names.append(name) - return names - - def get_option(self, category, name): - """ - Get an option with the specified category and name. - - @return: an Option instance or None on failure. - """ - for (oname, option) in self.__options[category]: - if oname == name: - return option - return None - - def get_all_option_names(self): - """ - Get a list of all the option names in this menu. - - @return: a list of strings - """ - names = [] - for category in self.__options: - for (name, option) in self.__options[category]: - names.append(name) - return names - - def get_option_by_name(self, name): - """ - Get an option with the specified name. - - @return: an Option instance or None on failure. - """ - for category in self.__options.keys(): - for (oname, option) in self.__options[category]: - if oname == name: - return option - return None diff --git a/src/PluginUtils/_PluginMgr.py b/src/PluginUtils/_PluginMgr.py index 030804c56..b8b3dcf5e 100644 --- a/src/PluginUtils/_PluginMgr.py +++ b/src/PluginUtils/_PluginMgr.py @@ -45,7 +45,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------- from ReportBase import MODE_GUI, MODE_CLI, MODE_BKI, book_categories -import gen +import gen.utils import Relationship #------------------------------------------------------------------------- diff --git a/src/PluginUtils/__init__.py b/src/PluginUtils/__init__.py index 507455c2e..a276cc488 100644 --- a/src/PluginUtils/__init__.py +++ b/src/PluginUtils/__init__.py @@ -21,11 +21,6 @@ # # $Id$ # -from _MenuOptions import (NumberOption, BooleanOption, TextOption, - EnumeratedListOption, FilterOption, StringOption, - ColourOption, PersonOption, PersonListOption, - SurnameColourOption, FamilyOption, DestinationOption, - NoteOption, MediaOption, StyleOption, PlaceListOption) from _GuiOptions import GuiMenuOptions, make_gui_option from _Options import Options, OptionListCollection, OptionList, OptionHandler diff --git a/src/ReportBase/_CommandLineReport.py b/src/ReportBase/_CommandLineReport.py index f048e86ac..0958b10b1 100644 --- a/src/ReportBase/_CommandLineReport.py +++ b/src/ReportBase/_CommandLineReport.py @@ -41,6 +41,7 @@ log = logging.getLogger(".") # #------------------------------------------------------------------------- import PluginUtils +import gen import Utils import BaseDoc from BasicUtils import name_displayer @@ -70,7 +71,7 @@ def _validate_options(options, dbase): for name in menu.get_all_option_names(): option = menu.get_option_by_name(name) - if isinstance(option, PluginUtils.PersonOption): + if isinstance(option, gen.plug.menu.PersonOption): pid = option.get_value() person = dbase.get_person_from_gramps_id(pid) if not person: @@ -83,7 +84,7 @@ def _validate_options(options, dbase): if person: option.set_value(person.get_gramps_id()) - elif isinstance(option, PluginUtils.FamilyOption): + elif isinstance(option, gen.plug.menu.FamilyOption): fid = option.get_value() family = dbase.get_family_from_gramps_id(fid) if not family: @@ -200,7 +201,7 @@ class CommandLineReport: self.options_dict[name] = option.get_value() self.options_help[name] = [ "", option.get_help() ] - if isinstance(option, PluginUtils.PersonOption): + if isinstance(option, gen.plug.menu.PersonOption): id_list = [] for person_handle in self.database.get_person_handles(): person = self.database.get_person_from_handle(person_handle) @@ -208,7 +209,7 @@ class CommandLineReport: person.get_gramps_id(), name_displayer.display(person))) self.options_help[name].append(id_list) - elif isinstance(option, PluginUtils.FamilyOption): + elif isinstance(option, gen.plug.menu.FamilyOption): id_list = [] for fhandle in self.database.get_family_handles(): family = self.database.get_family_from_handle(fhandle) @@ -228,31 +229,31 @@ class CommandLineReport: (family.get_gramps_id(), fname, mname) id_list.append(text) self.options_help[name].append(id_list) - elif isinstance(option, PluginUtils.NoteOption): + elif isinstance(option, gen.plug.menu.NoteOption): id_list = [] for nhandle in self.database.get_note_handles(): note = self.database.get_note_from_handle(nhandle) id_list.append(note.get_gramps_id()) self.options_help[name].append(id_list) - elif isinstance(option, PluginUtils.MediaOption): + elif isinstance(option, gen.plug.menu.MediaOption): id_list = [] for mhandle in self.database.get_media_object_handles(): mobject = self.database.get_object_from_handle(mhandle) id_list.append(mobject.get_gramps_id()) self.options_help[name].append(id_list) - elif isinstance(option, PluginUtils.PersonListOption): + elif isinstance(option, gen.plug.menu.PersonListOption): self.options_help[name].append("") - elif isinstance(option, PluginUtils.NumberOption): + elif isinstance(option, gen.plug.menu.NumberOption): self.options_help[name].append("A number") - elif isinstance(option, PluginUtils.BooleanOption): + elif isinstance(option, gen.plug.menu.BooleanOption): self.options_help[name].append(["0\tno", "1\tyes"]) - elif isinstance(option, PluginUtils.DestinationOption): + elif isinstance(option, gen.plug.menu.DestinationOption): self.options_help[name].append("A file system path") - elif isinstance(option, PluginUtils.StringOption): + elif isinstance(option, gen.plug.menu.StringOption): self.options_help[name].append("Any text") - elif isinstance(option, PluginUtils.TextOption): + elif isinstance(option, gen.plug.menu.TextOption): self.options_help[name].append("Any text") - elif isinstance(option, PluginUtils.EnumeratedListOption): + elif isinstance(option, gen.plug.menu.EnumeratedListOption): ilist = [] for (value, description) in option.get_items(): ilist.append("%s\t%s" % (value, description)) diff --git a/src/ReportBase/_GraphvizReportDialog.py b/src/ReportBase/_GraphvizReportDialog.py index 9d22b6785..74c05e9b1 100644 --- a/src/ReportBase/_GraphvizReportDialog.py +++ b/src/ReportBase/_GraphvizReportDialog.py @@ -54,7 +54,7 @@ from ReportBase import CATEGORY_GRAPHVIZ from _ReportDialog import ReportDialog from _FileEntry import FileEntry from _PaperMenu import PaperFrame -from PluginUtils import NumberOption, EnumeratedListOption, TextOption +from gen.plug.menu import NumberOption, TextOption, EnumeratedListOption #------------------------------------------------------------------------------- # diff --git a/src/gen/__init__.py b/src/gen/__init__.py index 3ce961702..0cba99044 100644 --- a/src/gen/__init__.py +++ b/src/gen/__init__.py @@ -18,4 +18,4 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -__all__ = [ "proxy", "db", "lib", "utils" ] +__all__ = [ "proxy", "db", "lib", "utils", "plug" ] diff --git a/src/gen/plug/Makefile.am b/src/gen/plug/Makefile.am new file mode 100644 index 000000000..5cf826ddf --- /dev/null +++ b/src/gen/plug/Makefile.am @@ -0,0 +1,25 @@ +# This is the src/gen/plug level Makefile for Gramps +# We could use GNU make's ':=' syntax for nice wildcard use, +# but that is not necessarily portable. +# If not using GNU make, then list all .py files individually + +SUBDIRS = \ + menu + +pkgdatadir = $(datadir)/@PACKAGE@/gen/plug + +pkgdata_PYTHON = \ + __init__.py + +pkgpyexecdir = @pkgpyexecdir@/gen/plug +pkgpythondir = @pkgpythondir@/gen/plug + + +# Clean up all the byte-compiled files +MOSTLYCLEANFILES = *pyc *pyo + +GRAMPS_PY_MODPATH = "../../" + +pycheck: + (export PYTHONPATH=$(GRAMPS_PY_MODPATH); \ + pychecker $(pkgdata_PYTHON)); diff --git a/src/gen/plug/__init__.py b/src/gen/plug/__init__.py new file mode 100644 index 000000000..a55de30ef --- /dev/null +++ b/src/gen/plug/__init__.py @@ -0,0 +1,24 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2008 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +""" +The "plug" package for handling plugins in Gramps. +""" + +__all__ = [ "opt" ] diff --git a/src/gen/plug/menu/Makefile.am b/src/gen/plug/menu/Makefile.am new file mode 100644 index 000000000..86956f42e --- /dev/null +++ b/src/gen/plug/menu/Makefile.am @@ -0,0 +1,40 @@ +# This is the src/gen/plug/menu level Makefile for Gramps +# We could use GNU make's ':=' syntax for nice wildcard use, +# but that is not necessarily portable. +# If not using GNU make, then list all .py files individually + +pkgdatadir = $(datadir)/@PACKAGE@/gen/plug/menu + +pkgdata_PYTHON = \ + __init__.py \ + _boolean.py \ + _color.py \ + _destination.py \ + _enumeratedlist.py \ + _family.py \ + _filter.py \ + _media.py \ + _menu.py \ + _note.py \ + _number.py \ + _option.py \ + _person.py \ + _personlist.py \ + _placelist.py \ + _sring.py \ + _style.py \ + _surnamecolor.py \ + _text.py + +pkgpyexecdir = @pkgpyexecdir@/gen/plug/menu +pkgpythondir = @pkgpythondir@/gen/plug/menu + + +# Clean up all the byte-compiled files +MOSTLYCLEANFILES = *pyc *pyo + +GRAMPS_PY_MODPATH = "../../../" + +pycheck: + (export PYTHONPATH=$(GRAMPS_PY_MODPATH); \ + pychecker $(pkgdata_PYTHON)); diff --git a/src/gen/plug/menu/__init__.py b/src/gen/plug/menu/__init__.py new file mode 100644 index 000000000..0bddd7a15 --- /dev/null +++ b/src/gen/plug/menu/__init__.py @@ -0,0 +1,41 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2008 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your ) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +""" +The menu package for allowing plugins to specify options in a generic way. +""" + +from _menu import Menu +from _option import Option +from _string import StringOption +from _color import ColorOption +from _number import NumberOption +from _text import TextOption +from _boolean import BooleanOption +from _enumeratedlist import EnumeratedListOption +from _filter import FilterOption +from _person import PersonOption +from _family import FamilyOption +from _note import NoteOption +from _media import MediaOption +from _personlist import PersonListOption +from _placelist import PlaceListOption +from _surnamecolor import SurnameColorOption +from _destination import DestinationOption +from _style import StyleOption diff --git a/src/gen/plug/menu/_boolean.py b/src/gen/plug/menu/_boolean.py new file mode 100644 index 000000000..17910935e --- /dev/null +++ b/src/gen/plug/menu/_boolean.py @@ -0,0 +1,53 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id$ + +""" +Option class representing a boolean (yes/no, true/false). +""" + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +from gen.plug.menu import Option + +#------------------------------------------------------------------------- +# +# BooleanOption class +# +#------------------------------------------------------------------------- +class BooleanOption(Option): + """ + This class describes an option that is a boolean (True or False). + """ + def __init__(self, label, value): + """ + @param label: A friendly label to be applied to this option. + Example: "Exclude living people" + @type label: string + @param value: An initial value for this option. + Example: True + @type value: boolean + @return: nothing + """ + Option.__init__(self, label, value) diff --git a/src/gen/plug/menu/_color.py b/src/gen/plug/menu/_color.py new file mode 100644 index 000000000..dbf729afd --- /dev/null +++ b/src/gen/plug/menu/_color.py @@ -0,0 +1,53 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id$ + +""" +Option class representing a color. +""" + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +from gen.plug.menu import Option + +#------------------------------------------------------------------------- +# +# ColorOption class +# +#------------------------------------------------------------------------- +class ColorOption(Option): + """ + This class describes an option that allows the selection of a color. + """ + def __init__(self, label, value): + """ + @param label: A friendly label to be applied to this option. + Example: "Males" + @type label: string + @param value: An initial value for this option. + Example: "#ff00a0" + @type value: string + @return: nothing + """ + Option.__init__(self, label, value) diff --git a/src/gen/plug/menu/_destination.py b/src/gen/plug/menu/_destination.py new file mode 100644 index 000000000..ae67da3f7 --- /dev/null +++ b/src/gen/plug/menu/_destination.py @@ -0,0 +1,95 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id$ + +""" +Option class representing a file destination. +""" + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +from gen.plug.menu import StringOption + +#------------------------------------------------------------------------- +# +# DestinationOption class +# +#------------------------------------------------------------------------- +class DestinationOption(StringOption): + """ + This class describes an option that specifies a destination file or path. + The destination can be a directory or a file. If the destination is a file, + the extension can be specified. + """ + + __signals__ = { 'options-changed' : None } + + def __init__(self, label, value): + """ + @param label: A friendly label to be applied to this option. + Example: "File Name" + @type label: string + @param value: A default destination for this option. + Example: "/home/username/Desktop/" + Example: "/home/username/Desktop/report.pdf" + @type value: string + @param is_directory: Specifies whether the destination is a directory + or a file. + @type value: bool + @return: nothing + """ + StringOption.__init__(self, label, value) + self.__is_directory = False + self.__extension = "" + + def set_directory_entry(self, is_directory): + """ + @param is_directory: Specifies whether the destination is a directory + or a file. + @type value: bool + @return: nothing + """ + self.__is_directory = is_directory + self.emit('options-changed') + + def get_directory_entry(self): + """ + @return: True if the destination is a directory. False if the + destination is a file. + """ + return self.__is_directory + + def set_extension(self, extension): + """ + @param extension: Specifies the extension for the destination file. + @type value: str + @return: nothing + """ + self.__extension = extension + + def get_extension(self): + """ + @return: The extension for the destination file. + """ + return self.__extension diff --git a/src/gen/plug/menu/_enumeratedlist.py b/src/gen/plug/menu/_enumeratedlist.py new file mode 100644 index 000000000..96ae08173 --- /dev/null +++ b/src/gen/plug/menu/_enumeratedlist.py @@ -0,0 +1,122 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id$ + +""" +Option class representing an enumerated list of possible values. +""" + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +from gen.plug.menu import Option + +#------------------------------------------------------------------------- +# +# EnumeratedListOption class +# +#------------------------------------------------------------------------- +class EnumeratedListOption(Option): + """ + This class describes an option that provides a finite number of values. + Each possible value is assigned a value and a description. + """ + + __signals__ = { 'options-changed' : None } + + def __init__(self, label, value): + """ + @param label: A friendly label to be applied to this option. + Example: "Paper Size" + @type label: string + @param value: An initial value for this option. + Example: 5 + @type value: int + @return: nothing + """ + Option.__init__(self, label, value) + self.__items = [] + + def add_item(self, value, description): + """ + Add an item to the list of possible values. + + @param value: The value that corresponds to this item. + Example: 5 + @type value: int + @param description: A description of this value. + Example: "8.5 x 11" + @type description: string + @return: nothing + """ + self.__items.append((value, description)) + self.emit('options-changed') + + def set_items(self, items): + """ + Add a list of items to the list of possible values. + + @param items: A list of tuples containing value, description pairs. + Example: [ (5,"8.5 x 11"), (6,"11 x 17")] + @type items: array + @return: nothing + """ + self.__items = items + self.emit('options-changed') + + def get_items(self): + """ + Get all the possible values for this option. + + @return: an array of tuples containing (value,description) pairs. + """ + return self.__items + + def clear(self): + """ + Clear all possible values from this option. + + @return: nothing. + """ + self.__items = [] + self.emit('options-changed') + + def set_value(self, value): + """ + Set the value of this option. + + @param value: A value for this option. + Example: True + @type value: The type will depend on the type of option. + @return: nothing + """ + found = False + for (opt_value, opt_description) in self.__items: + if value == opt_value: + found = True + + if found: + Option.set_value(self, value) + else: + print "Value %s not found for option %s" % ( str(value), + self.get_label() ) diff --git a/src/gen/plug/menu/_family.py b/src/gen/plug/menu/_family.py new file mode 100644 index 000000000..6a966e31f --- /dev/null +++ b/src/gen/plug/menu/_family.py @@ -0,0 +1,54 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id$ + +""" +Option class representing a family. +""" + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +from gen.plug.menu import StringOption + +#------------------------------------------------------------------------- +# +# FamilyOption class +# +#------------------------------------------------------------------------- +class FamilyOption(StringOption): + """ + This class describes an option that allows a family from the + database to be selected. + """ + def __init__(self, label): + """ + @param label: A friendly label to be applied to this option. + Example: "Center Family" + @type label: string + @param value: A Gramps ID of a family for this option. + Example: "f11" + @type value: string + @return: nothing + """ + StringOption.__init__(self, label, "") diff --git a/src/gen/plug/menu/_filter.py b/src/gen/plug/menu/_filter.py new file mode 100644 index 000000000..d6b906512 --- /dev/null +++ b/src/gen/plug/menu/_filter.py @@ -0,0 +1,85 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id$ + +""" +Option class representing a list of filters. +""" + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +from gen.plug.menu import EnumeratedListOption + +#------------------------------------------------------------------------- +# +# FilterOption class +# +#------------------------------------------------------------------------- +class FilterOption(EnumeratedListOption): + """ + This class describes an option that provides a list of person filters. + Each possible value represents one of the possible filters. + """ + def __init__(self, label, value): + """ + @param label: A friendly label to be applied to this option. + Example: "Filter" + @type label: string + @param value: A default value for the option. + Example: 1 + @type label: int + @return: nothing + """ + EnumeratedListOption.__init__(self, label, value) + self.__filters = [] + + def set_filters(self, filter_list): + """ + Set the list of filters available to be chosen from. + + @param filter_list: An array of person filters. + @type filter_list: array + @return: nothing + """ + items = [] + curval = self.get_value() + + value = 0 + for filt in filter_list: + items.append((value, filt.get_name())) + value += 1 + + self.__filters = filter_list + self.clear() + self.set_items( items ) + + self.set_value(curval) + + def get_filter(self): + """ + Return the currently selected filter object. + + @return: A filter object. + """ + return self.__filters[self.get_value()] diff --git a/src/gen/plug/menu/_media.py b/src/gen/plug/menu/_media.py new file mode 100644 index 000000000..472a272ec --- /dev/null +++ b/src/gen/plug/menu/_media.py @@ -0,0 +1,54 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id$ + +""" +Option class representing a media object. +""" + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +from gen.plug.menu import StringOption + +#------------------------------------------------------------------------- +# +# MediaOption class +# +#------------------------------------------------------------------------- +class MediaOption(StringOption): + """ + This class describes an option that allows a media object from the + database to be selected. + """ + def __init__(self, label): + """ + @param label: A friendly label to be applied to this option. + Example: "Image" + @type label: string + @param value: A Gramps ID of a media object for this option. + Example: "m11" + @type value: string + @return: nothing + """ + StringOption.__init__(self, label, "") diff --git a/src/gen/plug/menu/_menu.py b/src/gen/plug/menu/_menu.py new file mode 100644 index 000000000..a35c3f73d --- /dev/null +++ b/src/gen/plug/menu/_menu.py @@ -0,0 +1,130 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id$ + +""" +Abstracted option handling. +""" + +#------------------------------------------------------------------------- +# +# Menu class +# +#------------------------------------------------------------------------- +class Menu: + """ + Introduction + ============ + A Menu is used to maintain a collection of options that need to be + represented to the user in a non-implementation specific way. The options + can be described using the various option classes. A menu contains many + options and associates them with a unique name and category. + + Usage + ===== + Menus are used in the following way. + + 1. Create an option object and configure all the attributes of the option. + 2. Add the option to the menu by specifying the option, name and category. + 3. Add as many options as necessary. + 4. When all the options are added, the menu can be stored and passed to + the part of the system that will actually represent the menu to + the user. + """ + def __init__(self): + # __options holds all the options by their category + self.__options = {} + # __categories holds the order of all categories + self.__categories = [] + + def add_option(self, category, name, option): + """ + Add an option to the menu. + + @param category: A label that describes the category that the option + belongs to. + Example: "Report Options" + @type category: string + @param name: A name that is unique to this option. + Example: "generations" + @type name: string + @param option: The option instance to be added to this menu. + @type option: gen.plug.menu.Option + @return: nothing + """ + if category not in self.__options: + self.__categories.append(category) + self.__options[category] = [] + self.__options[category].append((name, option)) + + def get_categories(self): + """ + Get a list of categories in this menu. + + @return: a list of strings + """ + return self.__categories + + def get_option_names(self, category): + """ + Get a list of option names for the specified category. + + @return: a list of strings + """ + names = [] + for (name, option) in self.__options[category]: + names.append(name) + return names + + def get_option(self, category, name): + """ + Get an option with the specified category and name. + + @return: an Option instance or None on failure. + """ + for (oname, option) in self.__options[category]: + if oname == name: + return option + return None + + def get_all_option_names(self): + """ + Get a list of all the option names in this menu. + + @return: a list of strings + """ + names = [] + for category in self.__options: + for (name, option) in self.__options[category]: + names.append(name) + return names + + def get_option_by_name(self, name): + """ + Get an option with the specified name. + + @return: an Option instance or None on failure. + """ + for category in self.__options.keys(): + for (oname, option) in self.__options[category]: + if oname == name: + return option + return None diff --git a/src/gen/plug/menu/_note.py b/src/gen/plug/menu/_note.py new file mode 100644 index 000000000..fc0bd6d59 --- /dev/null +++ b/src/gen/plug/menu/_note.py @@ -0,0 +1,54 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id$ + +""" +Option class representing a string. +""" + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +from gen.plug.menu import StringOption + +#------------------------------------------------------------------------- +# +# NoteOption class +# +#------------------------------------------------------------------------- +class NoteOption(StringOption): + """ + This class describes an option that allows a note from the + database to be selected. + """ + def __init__(self, label): + """ + @param label: A friendly label to be applied to this option. + Example: "Title Note" + @type label: string + @param value: A Gramps ID of a note for this option. + Example: "n11" + @type value: string + @return: nothing + """ + StringOption.__init__(self, label, "") diff --git a/src/gen/plug/menu/_number.py b/src/gen/plug/menu/_number.py new file mode 100644 index 000000000..8dcb77805 --- /dev/null +++ b/src/gen/plug/menu/_number.py @@ -0,0 +1,90 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id$ + +""" +Option class representing a number. +""" + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +from gen.plug.menu import Option + +#------------------------------------------------------------------------- +# +# NumberOption class +# +#------------------------------------------------------------------------- +class NumberOption(Option): + """ + This class describes an option that is a simple number with defined maximum + and minimum values. + """ + def __init__(self, label, value, min_val, max_val, step = 1): + """ + @param label: A friendly label to be applied to this option. + Example: "Number of generations to include" + @type label: string + @param value: An initial value for this option. + Example: 5 + @type value: int + @param min: The minimum value for this option. + Example: 1 + @type min: int + @param max: The maximum value for this option. + Example: 10 + @type value: int + @param step: The step size for this option. + Example: 0.01 + @type value: int or float + @return: nothing + """ + Option.__init__(self, label, value) + self.__min = min_val + self.__max = max_val + self.__step = step + + def get_min(self): + """ + Get the minimum value for this option. + + @return: an int that represents the minimum value for this option. + """ + return self.__min + + def get_max(self): + """ + Get the maximum value for this option. + + @return: an int that represents the maximum value for this option. + """ + return self.__max + + def get_step(self): + """ + Get the step size for this option. + + @return: an int that represents the step size for this option. + """ + return self.__step diff --git a/src/gen/plug/menu/_option.py b/src/gen/plug/menu/_option.py new file mode 100644 index 000000000..74aa3e995 --- /dev/null +++ b/src/gen/plug/menu/_option.py @@ -0,0 +1,146 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id$ + +""" +The base option class for all other option classes. +""" + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +import gen.utils + +#------------------------------------------------------------------------- +# +# Option class +# +#------------------------------------------------------------------------- +class Option(gen.utils.Callback): + """ + This class serves as a base class for all options. All Options must + minimally provide the services provided by this class. Options are allowed + to add additional functionality. + """ + + __signals__ = { 'value-changed' : None, + 'avail-changed' : None} + + def __init__(self, label, value): + """ + @param label: A friendly label to be applied to this option. + Example: "Exclude living people" + @type label: string + @param value: An initial value for this option. + Example: True + @type value: The type will depend on the type of option. + @return: nothing + """ + gen.utils.Callback.__init__(self) + self.__value = value + self.__label = label + self.__help_str = "" + self.__available = True + + def get_label(self): + """ + Get the friendly label for this option. + + @return: string + """ + return self.__label + + def set_label(self, label): + """ + Set the friendly label for this option. + + @param label: A friendly label to be applied to this option. + Example: "Exclude living people" + @type label: string + @return: nothing + """ + self.__label = label + + def get_value(self): + """ + Get the value of this option. + + @return: The option value. + """ + return self.__value + + def set_value(self, value): + """ + Set the value of this option. + + @param value: A value for this option. + Example: True + @type value: The type will depend on the type of option. + @return: nothing + """ + self.__value = value + self.emit('value-changed') + + def get_help(self): + """ + Get the help information for this option. + + @return: A string that provides additional help beyond the label. + """ + return self.__help_str + + def set_help(self, help_text): + """ + Set the help information for this option. + + @param help: A string that provides additional help beyond the label. + Example: "Whether to include or exclude people who are calculated + to be alive at the time of the generation of this report" + @type value: string + @return: nothing + """ + self.__help_str = help_text + + def set_available(self, avail): + """ + Set the availability of this option. + + @param avail: An indicator of whether this option is currently + available. True indicates that the option is available. False indicates + that the option is not available. + @type avail: Bool + @return: nothing + """ + if avail != self.__available: + self.__available = avail + self.emit('avail-changed') + + def get_available(self): + """ + Get the availability of this option. + + @return: A Bool indicating the availablity of this option. + True indicates that the option is available. + False indicates that the option is not available. + """ + return self.__available diff --git a/src/gen/plug/menu/_person.py b/src/gen/plug/menu/_person.py new file mode 100644 index 000000000..a7c41b139 --- /dev/null +++ b/src/gen/plug/menu/_person.py @@ -0,0 +1,54 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id$ + +""" +Option class representing a person. +""" + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +from gen.plug.menu import StringOption + +#------------------------------------------------------------------------- +# +# PersonOption class +# +#------------------------------------------------------------------------- +class PersonOption(StringOption): + """ + This class describes an option that allows a person from the + database to be selected. + """ + def __init__(self, label): + """ + @param label: A friendly label to be applied to this option. + Example: "Center Person" + @type label: string + @param value: A Gramps ID of a person for this option. + Example: "p11" + @type value: string + @return: nothing + """ + StringOption.__init__(self, label, "") diff --git a/src/gen/plug/menu/_personlist.py b/src/gen/plug/menu/_personlist.py new file mode 100644 index 000000000..3e56a23ed --- /dev/null +++ b/src/gen/plug/menu/_personlist.py @@ -0,0 +1,55 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id$ + +""" +Option class representing a list of people. +""" + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +from gen.plug.menu import Option + + +#------------------------------------------------------------------------- +# +# PersonListOption class +# +#------------------------------------------------------------------------- +class PersonListOption(Option): + """ + This class describes a widget that allows multiple people from the + database to be selected. + """ + def __init__(self, label): + """ + @param label: A friendly label to be applied to this option. + Example: "People of interest" + @type label: string + @param value: A set of GIDs as initial values for this option. + Example: "111 222 333 444" + @type value: string + @return: nothing + """ + Option.__init__(self, label, "") diff --git a/src/gen/plug/menu/_placelist.py b/src/gen/plug/menu/_placelist.py new file mode 100644 index 000000000..3a67d1848 --- /dev/null +++ b/src/gen/plug/menu/_placelist.py @@ -0,0 +1,54 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id$ + +""" +Option class representing a list of places. +""" + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +from gen.plug.menu import Option + +#------------------------------------------------------------------------- +# +# PlaceListOption class +# +#------------------------------------------------------------------------- +class PlaceListOption(Option): + """ + This class describes a widget that allows multiple places from the + database to be selected. + """ + def __init__(self, label): + """ + @param label: A label to be applied to this option. + Example: "Places" + @type label: string + @param value: A set of GIDs as initial values for this option. + Example: "111 222 333 444" + @type value: string + @return: nothing + """ + Option.__init__(self, label, "") diff --git a/src/gen/plug/menu/_string.py b/src/gen/plug/menu/_string.py new file mode 100644 index 000000000..ec6064d73 --- /dev/null +++ b/src/gen/plug/menu/_string.py @@ -0,0 +1,53 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id$ + +""" +Option class representing a string. +""" + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +from gen.plug.menu import Option + +#------------------------------------------------------------------------- +# +# StringOption class +# +#------------------------------------------------------------------------- +class StringOption(Option): + """ + This class describes an option that is a simple one-line string. + """ + def __init__(self, label, value): + """ + @param label: A friendly label to be applied to this option. + Example: "Page header" + @type label: string + @param value: An initial value for this option. + Example: "Generated by GRAMPS" + @type value: string + @return: nothing + """ + Option.__init__(self, label, value) diff --git a/src/gen/plug/menu/_style.py b/src/gen/plug/menu/_style.py new file mode 100644 index 000000000..040838aa4 --- /dev/null +++ b/src/gen/plug/menu/_style.py @@ -0,0 +1,80 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id$ + +""" +Option class representing a document style. +""" + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +from gen.plug.menu import EnumeratedListOption +import BaseDoc + +#------------------------------------------------------------------------- +# +# StyleOption class +# +#------------------------------------------------------------------------- +class StyleOption(EnumeratedListOption): + """ + This class describes an option that allows the use to select a style sheet. + """ + + def __init__(self, label, default_style, module_name): + """ + @param label: A friendly label to be applied to this option. + Example: "Style" + @type label: string + @param default_style: A BaseDoc.StyleSheet instance which provides the + default styles. + @type default_style: BaseDoc.StyleSheet + @param module_name: The name of the module the style sheets belong to. + Example: "web_cal" + @type module_name: string + @return: nothing + """ + EnumeratedListOption.__init__(self, label, "default") + + self.__default_style = default_style + self.__default_style.set_name("default") + self.__style_file = "%s_style.xml" % module_name + style_list = BaseDoc.StyleSheetList(self.__style_file, + self.__default_style) + for style_name in style_list.get_style_names(): + self.add_item(style_name, style_name) + + def get_default_style(self): + """ Get the default style """ + return self.__default_style + + def get_style_file(self): + """ Get the name of the style file """ + return self.__style_file + + def get_style(self): + """ Get the selected style """ + style_list = BaseDoc.StyleSheetList(self.__style_file, + self.__default_style) + return style_list.get_style_sheet(self.get_value()) diff --git a/src/gen/plug/menu/_surnamecolor.py b/src/gen/plug/menu/_surnamecolor.py new file mode 100644 index 000000000..8b835cf27 --- /dev/null +++ b/src/gen/plug/menu/_surnamecolor.py @@ -0,0 +1,55 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id$ + +""" +Option class representing color/surname mappings. +""" + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +from gen.plug.menu import Option + +#------------------------------------------------------------------------- +# +# SurnameColorOption class +# +#------------------------------------------------------------------------- +class SurnameColorOption(Option): + """ + This class describes a widget that allows multiple surnames to be + selected from the database, and to assign a color (not necessarily + unique) to each one. + """ + def __init__(self, label): + """ + @param label: A friendly label to be applied to this option. + Example: "Family lines" + @type label: string + @param value: A set of surnames and colours. + Example: "surname1 colour1 surname2 colour2" + @type value: string + @return: nothing + """ + Option.__init__(self, label, "") diff --git a/src/gen/plug/menu/_text.py b/src/gen/plug/menu/_text.py new file mode 100644 index 000000000..1acd357e3 --- /dev/null +++ b/src/gen/plug/menu/_text.py @@ -0,0 +1,53 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Gary Burton +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# $Id$ + +""" +Option class representing a block of text. +""" + +#------------------------------------------------------------------------- +# +# gramps modules +# +#------------------------------------------------------------------------- +from gen.plug.menu import Option + +#------------------------------------------------------------------------- +# +# TextOption class +# +#------------------------------------------------------------------------- +class TextOption(Option): + """ + This class describes an option that is a multi-line string. + """ + def __init__(self, label, value): + """ + @param label: A friendly label to be applied to this option. + Example: "Page header" + @type label: string + @param value: An initial value for this option. + Example: "Generated by GRAMPS\nCopyright 2007" + @type value: string + @return: nothing + """ + Option.__init__(self, label, value) diff --git a/src/plugins/AncestorReport.py b/src/plugins/AncestorReport.py index 39482be0d..3cc269567 100644 --- a/src/plugins/AncestorReport.py +++ b/src/plugins/AncestorReport.py @@ -36,8 +36,8 @@ from gettext import gettext as _ # gramps modules # #------------------------------------------------------------------------ -from PluginUtils import PluginManager, NumberOption, \ - BooleanOption, PersonOption +from PluginUtils import PluginManager +from gen.plug.menu import BooleanOption, NumberOption, PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI import BaseDoc diff --git a/src/plugins/AncestorTree.py b/src/plugins/AncestorTree.py index a7ae39751..50e565393 100644 --- a/src/plugins/AncestorTree.py +++ b/src/plugins/AncestorTree.py @@ -38,8 +38,8 @@ from gettext import gettext as _ #------------------------------------------------------------------------ import BaseDoc from SubstKeywords import SubstKeywords -from PluginUtils import PluginManager, \ - NumberOption, BooleanOption, TextOption, PersonOption +from PluginUtils import PluginManager +from gen.plug.menu import BooleanOption, NumberOption, TextOption, PersonOption from ReportBase import Report, ReportUtils, CATEGORY_DRAW, MenuReportOptions, \ MODE_GUI, MODE_BKI, MODE_CLI from BasicUtils import name_displayer diff --git a/src/plugins/BookReport.py b/src/plugins/BookReport.py index 1ca12cd2b..033c73b2c 100644 --- a/src/plugins/BookReport.py +++ b/src/plugins/BookReport.py @@ -73,7 +73,7 @@ import Errors import BaseDoc from QuestionDialog import WarningDialog, ErrorDialog from PluginUtils import PluginManager -from PluginUtils import PersonOption, FilterOption, FamilyOption +from gen.plug.menu import PersonOption, FilterOption, FamilyOption import ManagedWindow # Import from specific modules in ReportBase diff --git a/src/plugins/CalculateEstimatedDates.py b/src/plugins/CalculateEstimatedDates.py index 8cc2a2775..9dc1d09b3 100644 --- a/src/plugins/CalculateEstimatedDates.py +++ b/src/plugins/CalculateEstimatedDates.py @@ -36,9 +36,9 @@ import time # GRAMPS modules # #------------------------------------------------------------------------ -from PluginUtils import Tool, PluginManager, PluginWindows, \ - MenuToolOptions, BooleanOption, FilterOption, StringOption, \ - NumberOption, PersonOption +from PluginUtils import Tool, PluginManager, PluginWindows, MenuToolOptions +from gen.plug.menu import BooleanOption, NumberOption, StringOption, \ + FilterOption, PersonOption import gen.lib import Config from BasicUtils import name_displayer diff --git a/src/plugins/Calendar.py b/src/plugins/Calendar.py index 8e8899cf6..9090730fc 100644 --- a/src/plugins/Calendar.py +++ b/src/plugins/Calendar.py @@ -41,8 +41,8 @@ from PluginUtils import PluginManager from ReportBase import (Report, ReportUtils, MenuReportOptions, CATEGORY_DRAW, CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI) -from PluginUtils import (NumberOption, BooleanOption, StringOption, - FilterOption, EnumeratedListOption, PersonOption) +from gen.plug.menu import BooleanOption, StringOption, NumberOption, \ + EnumeratedListOption, FilterOption, PersonOption import GrampsLocale import gen.lib from Utils import probably_alive, ProgressMeter diff --git a/src/plugins/CustomBookText.py b/src/plugins/CustomBookText.py index 9869092d4..113857af9 100644 --- a/src/plugins/CustomBookText.py +++ b/src/plugins/CustomBookText.py @@ -41,7 +41,8 @@ from gettext import gettext as _ # gramps modules # #------------------------------------------------------------------------ -from PluginUtils import PluginManager, TextOption +from PluginUtils import PluginManager +from gen.plug.menu import TextOption from ReportBase import Report, MenuReportOptions, CATEGORY_TEXT, MODE_BKI import BaseDoc diff --git a/src/plugins/DescendReport.py b/src/plugins/DescendReport.py index 4471dbc0c..2f3a4afe1 100644 --- a/src/plugins/DescendReport.py +++ b/src/plugins/DescendReport.py @@ -35,7 +35,8 @@ from gettext import gettext as _ # GRAMPS modules # #------------------------------------------------------------------------ -from PluginUtils import PluginManager, NumberOption, PersonOption +from PluginUtils import PluginManager +from gen.plug.menu import NumberOption, PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI import BaseDoc diff --git a/src/plugins/DescendTree.py b/src/plugins/DescendTree.py index 0776e3691..a828ef57c 100644 --- a/src/plugins/DescendTree.py +++ b/src/plugins/DescendTree.py @@ -29,8 +29,8 @@ # #------------------------------------------------------------------------ from BasicUtils import name_displayer -from PluginUtils import PluginManager, NumberOption, BooleanOption, \ - TextOption, PersonOption +from PluginUtils import PluginManager +from gen.plug.menu import TextOption, NumberOption, BooleanOption, PersonOption from ReportBase import Report, MenuReportOptions, \ ReportUtils, CATEGORY_DRAW, MODE_GUI, MODE_BKI, MODE_CLI from SubstKeywords import SubstKeywords diff --git a/src/plugins/DetAncestralReport.py b/src/plugins/DetAncestralReport.py index 7f43a042b..d520cf5cb 100644 --- a/src/plugins/DetAncestralReport.py +++ b/src/plugins/DetAncestralReport.py @@ -38,8 +38,8 @@ from gettext import gettext as _ # #------------------------------------------------------------------------ import gen.lib -from PluginUtils import PluginManager, NumberOption, \ - BooleanOption, PersonOption +from PluginUtils import PluginManager +from gen.plug.menu import BooleanOption, NumberOption, PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI from ReportBase import Bibliography, Endnotes diff --git a/src/plugins/DetDescendantReport.py b/src/plugins/DetDescendantReport.py index f10e74985..bcccdd7de 100644 --- a/src/plugins/DetDescendantReport.py +++ b/src/plugins/DetDescendantReport.py @@ -39,8 +39,8 @@ from gettext import gettext as _ # #------------------------------------------------------------------------ import gen.lib -from PluginUtils import PluginManager, NumberOption, \ - BooleanOption, PersonOption +from PluginUtils import PluginManager +from gen.plug.menu import BooleanOption, NumberOption, PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI from ReportBase import Bibliography, Endnotes diff --git a/src/plugins/EndOfLineReport.py b/src/plugins/EndOfLineReport.py index 4c57b27a3..b33e4f35f 100644 --- a/src/plugins/EndOfLineReport.py +++ b/src/plugins/EndOfLineReport.py @@ -34,7 +34,8 @@ from gettext import gettext as _ # gramps modules # #------------------------------------------------------------------------ -from PluginUtils import PluginManager, PersonOption +from PluginUtils import PluginManager +from gen.plug.menu import PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI import BaseDoc diff --git a/src/plugins/FamilyGroup.py b/src/plugins/FamilyGroup.py index 0588ac482..2141a6ff3 100644 --- a/src/plugins/FamilyGroup.py +++ b/src/plugins/FamilyGroup.py @@ -29,7 +29,8 @@ # #------------------------------------------------------------------------ import gen.lib -from PluginUtils import PluginManager, BooleanOption, FamilyOption +from PluginUtils import PluginManager +from gen.plug.menu import BooleanOption, FamilyOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI import BaseDoc diff --git a/src/plugins/FanChart.py b/src/plugins/FanChart.py index 92678e16a..a6f9b47c0 100644 --- a/src/plugins/FanChart.py +++ b/src/plugins/FanChart.py @@ -35,7 +35,7 @@ from gettext import gettext as _ #------------------------------------------------------------------------ import BaseDoc from PluginUtils import PluginManager -from PluginUtils import NumberOption, EnumeratedListOption, PersonOption +from gen.plug.menu import EnumeratedListOption, NumberOption, PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_DRAW, \ MODE_GUI, MODE_BKI, MODE_CLI from SubstKeywords import SubstKeywords diff --git a/src/plugins/GVFamilyLines.py b/src/plugins/GVFamilyLines.py index b16cd658f..dd0e8d1b7 100644 --- a/src/plugins/GVFamilyLines.py +++ b/src/plugins/GVFamilyLines.py @@ -51,8 +51,10 @@ import ThumbNails from DateHandler import displayer as _dd from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_GRAPHVIZ, MODE_GUI -from PluginUtils import PluginManager, EnumeratedListOption, BooleanOption, \ - NumberOption, ColourOption, PersonListOption, SurnameColourOption +from PluginUtils import PluginManager +from gen.plug.menu import NumberOption, ColorOption, BooleanOption, \ + EnumeratedListOption, PersonListOption, \ + SurnameColorOption #------------------------------------------------------------------------ # @@ -131,7 +133,7 @@ class FamilyLinesOptions(MenuReportOptions): category = _('Family Colours') # ---------------------------- - surname_color = SurnameColourOption(_('Family colours')) + surname_color = SurnameColorOption(_('Family colours')) surname_color.set_help(_('Colours to use for various family lines.')) menu.add_option(category, 'surnamecolors', surname_color) diff --git a/src/plugins/GVHourGlass.py b/src/plugins/GVHourGlass.py index dba08809d..2e499db0d 100644 --- a/src/plugins/GVHourGlass.py +++ b/src/plugins/GVHourGlass.py @@ -36,8 +36,9 @@ from gettext import gettext as _ # GRAMPS modules # #------------------------------------------------------------------------ -from PluginUtils import PluginManager, NumberOption, PersonOption, \ - BooleanOption, EnumeratedListOption +from PluginUtils import PluginManager +from gen.plug.menu import PersonOption, BooleanOption, NumberOption, \ + EnumeratedListOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ MODE_GUI, MODE_CLI, CATEGORY_GRAPHVIZ from BasicUtils import name_displayer diff --git a/src/plugins/GVRelGraph.py b/src/plugins/GVRelGraph.py index 80de53df5..c33ae9d65 100644 --- a/src/plugins/GVRelGraph.py +++ b/src/plugins/GVRelGraph.py @@ -43,8 +43,9 @@ from TransUtils import sgettext as _ # GRAMPS modules # #------------------------------------------------------------------------ -from PluginUtils import PluginManager, FilterOption, \ - EnumeratedListOption, BooleanOption, PersonOption +from PluginUtils import PluginManager +from gen.plug.menu import BooleanOption, EnumeratedListOption, FilterOption, \ + PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ MODE_GUI, MODE_CLI, CATEGORY_GRAPHVIZ from BasicUtils import name_displayer diff --git a/src/plugins/IndivComplete.py b/src/plugins/IndivComplete.py index 030a5054f..59f243054 100644 --- a/src/plugins/IndivComplete.py +++ b/src/plugins/IndivComplete.py @@ -37,8 +37,8 @@ from gettext import gettext as _ import gen.lib import BaseDoc import DateHandler -from PluginUtils import PluginManager, FilterOption, BooleanOption, \ - PersonOption +from PluginUtils import PluginManager +from gen.plug.menu import BooleanOption, FilterOption, PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI from ReportBase import Bibliography, Endnotes diff --git a/src/plugins/KinshipReport.py b/src/plugins/KinshipReport.py index 17cec5787..8c5e551f4 100644 --- a/src/plugins/KinshipReport.py +++ b/src/plugins/KinshipReport.py @@ -35,8 +35,8 @@ from string import capitalize # gramps modules # #------------------------------------------------------------------------ -from PluginUtils import PluginManager, NumberOption, \ - BooleanOption, PersonOption +from PluginUtils import PluginManager +from gen.plug.menu import NumberOption, BooleanOption, PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI import BaseDoc diff --git a/src/plugins/MarkerReport.py b/src/plugins/MarkerReport.py index 4b2408f63..2e5b63807 100644 --- a/src/plugins/MarkerReport.py +++ b/src/plugins/MarkerReport.py @@ -34,7 +34,8 @@ from gettext import gettext as _ # GRAMPS modules # #------------------------------------------------------------------------ -from PluginUtils import PluginManager, EnumeratedListOption +from PluginUtils import PluginManager +from gen.plug.menu import EnumeratedListOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI import BaseDoc diff --git a/src/plugins/NarrativeWeb.py b/src/plugins/NarrativeWeb.py index b502d1a1c..d167fbed7 100644 --- a/src/plugins/NarrativeWeb.py +++ b/src/plugins/NarrativeWeb.py @@ -73,10 +73,10 @@ import gen.lib import const from GrampsCfg import get_researcher import Sort -from PluginUtils import (PluginManager, FilterOption, EnumeratedListOption, - PersonOption, BooleanOption, NumberOption, - StringOption, DestinationOption, NoteOption, - MediaOption) +from PluginUtils import PluginManager +from gen.plug.menu import PersonOption, NumberOption, StringOption, \ + BooleanOption, EnumeratedListOption, FilterOption, \ + NoteOption, MediaOption, DestinationOption from ReportBase import (Report, ReportUtils, MenuReportOptions, CATEGORY_WEB, MODE_GUI, MODE_CLI, Bibliography) import Utils diff --git a/src/plugins/NumberOfAncestorsReport.py b/src/plugins/NumberOfAncestorsReport.py index f67e10ace..a9453fced 100644 --- a/src/plugins/NumberOfAncestorsReport.py +++ b/src/plugins/NumberOfAncestorsReport.py @@ -38,7 +38,8 @@ import math # GRAMPS modules # #------------------------------------------------------------------------ -from PluginUtils import PluginManager, PersonOption +from PluginUtils import PluginManager +from gen.plug.menu import PersonOption from ReportBase import Report, MenuReportOptions, ReportUtils, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI from BasicUtils import name_displayer diff --git a/src/plugins/PlaceReport.py b/src/plugins/PlaceReport.py index cf412ab93..7c49ef30f 100644 --- a/src/plugins/PlaceReport.py +++ b/src/plugins/PlaceReport.py @@ -34,7 +34,8 @@ from gettext import gettext as _ # gramps modules # #------------------------------------------------------------------------ -from PluginUtils import PluginManager, PlaceListOption, FilterOption +from PluginUtils import PluginManager +from gen.plug.menu import FilterOption, PlaceListOption from ReportBase import Report, MenuReportOptions, \ CATEGORY_TEXT, MODE_GUI, MODE_BKI, MODE_CLI import BaseDoc diff --git a/src/plugins/SimpleBookTitle.py b/src/plugins/SimpleBookTitle.py index d3b628c27..e8001eefd 100644 --- a/src/plugins/SimpleBookTitle.py +++ b/src/plugins/SimpleBookTitle.py @@ -33,7 +33,8 @@ from TransUtils import sgettext as _ # gramps modules # #------------------------------------------------------------------------ -from PluginUtils import PluginManager, NumberOption, StringOption, MediaOption +from PluginUtils import PluginManager +from gen.plug.menu import StringOption, MediaOption, NumberOption from Utils import media_path_full from ReportBase import Report, MenuReportOptions, CATEGORY_TEXT, MODE_BKI import BaseDoc diff --git a/src/plugins/StatisticsChart.py b/src/plugins/StatisticsChart.py index 154ba13c5..ce84f7674 100644 --- a/src/plugins/StatisticsChart.py +++ b/src/plugins/StatisticsChart.py @@ -45,8 +45,8 @@ from gen.lib import Person, FamilyRelType, EventType # gender and report type names import BaseDoc from PluginUtils import PluginManager -from PluginUtils import BooleanOption, FilterOption, PersonOption, \ - EnumeratedListOption, NumberOption +from gen.plug.menu import BooleanOption, NumberOption, EnumeratedListOption, \ + FilterOption, PersonOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_DRAW, MODE_GUI, MODE_BKI, MODE_CLI import DateHandler diff --git a/src/plugins/TimeLine.py b/src/plugins/TimeLine.py index bfbd711e0..0021e42db 100644 --- a/src/plugins/TimeLine.py +++ b/src/plugins/TimeLine.py @@ -38,8 +38,7 @@ from TransUtils import sgettext as _ # #------------------------------------------------------------------------ from PluginUtils import PluginManager -from PluginUtils import FilterOption, EnumeratedListOption, \ - PersonOption +from gen.plug.menu import PersonOption, FilterOption, EnumeratedListOption from ReportBase import Report, ReportUtils, MenuReportOptions, \ CATEGORY_DRAW, MODE_GUI, MODE_BKI, MODE_CLI pt2cm = ReportUtils.pt2cm diff --git a/src/plugins/WebCal.py b/src/plugins/WebCal.py index cd1815ca1..3f70f0fec 100644 --- a/src/plugins/WebCal.py +++ b/src/plugins/WebCal.py @@ -80,8 +80,9 @@ from GrampsCfg import get_researcher from PluginUtils import PluginManager from ReportBase import (Report, ReportUtils, MenuReportOptions, CATEGORY_WEB, MODE_GUI) -from PluginUtils import FilterOption, EnumeratedListOption, PersonOption, \ - BooleanOption, NumberOption, StringOption, DestinationOption +from gen.plug.menu import BooleanOption, NumberOption, StringOption, \ + EnumeratedListOption, FilterOption, PersonOption, \ + DestinationOption import Utils import GrampsLocale from QuestionDialog import ErrorDialog, WarningDialog