Feature #2393: Allow the use of user-defined (mega)-widgets by MD Nauta; added register_option()
svn: r11861
This commit is contained in:
parent
fc5dcee88b
commit
ef066a3b6a
@ -1415,6 +1415,8 @@ def make_gui_option(option, tooltips, dbstate, uistate, track):
|
||||
"""
|
||||
widget = None
|
||||
label = True
|
||||
pmgr = gen.plug.PluginManager.get_instance()
|
||||
external_options = pmgr.get_external_opt_dict()
|
||||
if tooltips == None:
|
||||
tooltips = gtk.Tooltips()
|
||||
elif type(tooltips) == type(""):
|
||||
@ -1455,6 +1457,9 @@ def make_gui_option(option, tooltips, dbstate, uistate, track):
|
||||
tooltips)
|
||||
elif isinstance(option, gen.plug.menu.PlaceListOption):
|
||||
widget = GuiPlaceListOption(option, dbstate, uistate, track, tooltips)
|
||||
elif option.__class__ in external_options:
|
||||
widget = external_options[option.__class__](option, dbstate, uistate,
|
||||
track, tooltips)
|
||||
else:
|
||||
raise AttributeError(
|
||||
"can't make GuiOption: unknown option type: '%s'" % option)
|
||||
|
@ -106,6 +106,7 @@ class PluginManager(gen.utils.Callback):
|
||||
self.__bkitems_list = []
|
||||
self.__cl_list = []
|
||||
self.__cli_tool_list = []
|
||||
self.__external_opt_dict = {}
|
||||
self.__success_list = []
|
||||
self.__relcalc_class = Relationship.RelationshipCalculator
|
||||
|
||||
@ -269,6 +270,10 @@ class PluginManager(gen.utils.Callback):
|
||||
""" Return the list of command line tool plugins. """
|
||||
return self.__cli_tool_list
|
||||
|
||||
def get_external_opt_dict(self):
|
||||
""" Return the dictionary of external options. """
|
||||
return self.__external_opt_dict
|
||||
|
||||
def get_module_description(self, module):
|
||||
""" Given a module name, return the module description. """
|
||||
return self.__mod2text.get(module, '')
|
||||
@ -563,6 +568,21 @@ class PluginManager(gen.utils.Callback):
|
||||
|
||||
self.__mod2text[mapservice.__module__] = tooltip
|
||||
|
||||
def register_option(self, option, guioption):
|
||||
"""
|
||||
Register an external option.
|
||||
|
||||
Register a mapping from option to guioption for an option
|
||||
that is not native to Gramps but provided by the plugin writer.
|
||||
This should typically be called during initialisation of a
|
||||
ReportOptions class.
|
||||
@param option: the option class
|
||||
@type option: class that inherits from gen.plug.menu.Option
|
||||
@param guioption: the gui-option class
|
||||
@type guioption: class that inherits from gtk.Widget.
|
||||
"""
|
||||
self.__external_opt_dict[option] = guioption;
|
||||
|
||||
def __purge_failed(self):
|
||||
"""
|
||||
Purge the failed plugins from the corresponding lists.
|
||||
|
Loading…
Reference in New Issue
Block a user