From df33e354a559b4e8faa4138babc3cfbeab6062c4 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Tue, 4 Mar 2008 12:24:04 +0000 Subject: [PATCH] 2008-03-04 Douglas S. Blank * src/PluginUtils/_GuiOptions.py (make_gui_option): new stand-alone function that takes Option, returns GuiOption (attempting to make Options useable in additional ways) svn: r10179 --- ChangeLog | 5 ++ src/PluginUtils/_GuiOptions.py | 126 +++++++++++++++++---------------- 2 files changed, 71 insertions(+), 60 deletions(-) diff --git a/ChangeLog b/ChangeLog index 79374228f..36476aed2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-03-04 Douglas S. Blank + * src/PluginUtils/_GuiOptions.py (make_gui_option): + new stand-alone function that takes Option, returns GuiOption + (attempting to make Options useable in additional ways) + 2008-03-03 Frederik De Richter * src/plugins/Desbrowser.py links to wiki manual diff --git a/src/PluginUtils/_GuiOptions.py b/src/PluginUtils/_GuiOptions.py index de1200d1b..07d4beab0 100644 --- a/src/PluginUtils/_GuiOptions.py +++ b/src/PluginUtils/_GuiOptions.py @@ -1192,66 +1192,10 @@ class GuiMenuOptions: if name in self.options_dict: option.set_value(self.options_dict[name]) - found = True - label = True - - if isinstance(option, _MenuOptions.PersonOption): - widget = GuiPersonOption(option, dialog.dbstate, - dialog.uistate, dialog.track, - self.__tooltips) - elif isinstance(option, _MenuOptions.FamilyOption): - widget = GuiFamilyOption(option, dialog.dbstate, - dialog.uistate, dialog.track, - self.__tooltips) - elif isinstance(option, _MenuOptions.NoteOption): - widget = GuiNoteOption(option, dialog.dbstate, - dialog.uistate, dialog.track, - self.__tooltips) - elif isinstance(option, _MenuOptions.MediaOption): - widget = GuiMediaOption(option, dialog.dbstate, - dialog.uistate, dialog.track, - self.__tooltips) - elif isinstance(option, _MenuOptions.PersonListOption): - widget = GuiPersonListOption(option, dialog.dbstate, - dialog.uistate, dialog.track, - self.__tooltips) - elif isinstance(option, _MenuOptions.NumberOption): - widget = GuiNumberOption(option, dialog.dbstate, - dialog.uistate, dialog.track, - self.__tooltips) - elif isinstance(option, _MenuOptions.BooleanOption): - widget = GuiBooleanOption(option, dialog.dbstate, - dialog.uistate, dialog.track, - self.__tooltips) - label = False - elif isinstance(option, _MenuOptions.DestinationOption): - widget = GuiDestinationOption(option, dialog.dbstate, - dialog.uistate, dialog.track, - self.__tooltips) - elif isinstance(option, _MenuOptions.StringOption): - widget = GuiStringOption(option, dialog.dbstate, - dialog.uistate, dialog.track, - self.__tooltips) - elif isinstance(option, _MenuOptions.EnumeratedListOption): - widget = GuiEnumeratedListOption(option, dialog.dbstate, - dialog.uistate, dialog.track, - self.__tooltips) - elif isinstance(option, _MenuOptions.TextOption): - widget = GuiTextOption(option, dialog.dbstate, - dialog.uistate, dialog.track, - self.__tooltips) - elif isinstance(option, _MenuOptions.ColourOption): - widget = GuiColourOption(option, dialog.dbstate, - dialog.uistate, dialog.track, - self.__tooltips) - elif isinstance(option, _MenuOptions.SurnameColourOption): - widget = GuiSurnameColourOption(option, dialog.dbstate, - dialog.uistate, dialog.track, - self.__tooltips) - else: - found = False - - if not found: + widget, label = make_gui_option(option, dialog, + self.__tooltips) + + if widget == None: print "UNKNOWN OPTION: ", option else: if label: @@ -1269,3 +1213,65 @@ class GuiMenuOptions: option = self.menu.get_option_by_name(name) self.options_dict[name] = option.get_value() +def make_gui_option(option, dialog, tooltips): + """ + Stand-alone function so that Options can be used in other + ways, too. Takes an Option and returns a GuiOption. + """ + widget = None + label = True + if isinstance(option, _MenuOptions.PersonOption): + widget = GuiPersonOption(option, dialog.dbstate, + dialog.uistate, dialog.track, + tooltips) + elif isinstance(option, _MenuOptions.FamilyOption): + widget = GuiFamilyOption(option, dialog.dbstate, + dialog.uistate, dialog.track, + tooltips) + elif isinstance(option, _MenuOptions.NoteOption): + widget = GuiNoteOption(option, dialog.dbstate, + dialog.uistate, dialog.track, + tooltips) + elif isinstance(option, _MenuOptions.MediaOption): + widget = GuiMediaOption(option, dialog.dbstate, + dialog.uistate, dialog.track, + tooltips) + elif isinstance(option, _MenuOptions.PersonListOption): + widget = GuiPersonListOption(option, dialog.dbstate, + dialog.uistate, dialog.track, + tooltips) + elif isinstance(option, _MenuOptions.NumberOption): + widget = GuiNumberOption(option, dialog.dbstate, + dialog.uistate, dialog.track, + tooltips) + elif isinstance(option, _MenuOptions.BooleanOption): + widget = GuiBooleanOption(option, dialog.dbstate, + dialog.uistate, dialog.track, + tooltips) + label = False + elif isinstance(option, _MenuOptions.DestinationOption): + widget = GuiDestinationOption(option, dialog.dbstate, + dialog.uistate, dialog.track, + tooltips) + elif isinstance(option, _MenuOptions.StringOption): + widget = GuiStringOption(option, dialog.dbstate, + dialog.uistate, dialog.track, + tooltips) + elif isinstance(option, _MenuOptions.EnumeratedListOption): + widget = GuiEnumeratedListOption(option, dialog.dbstate, + dialog.uistate, dialog.track, + tooltips) + elif isinstance(option, _MenuOptions.TextOption): + widget = GuiTextOption(option, dialog.dbstate, + dialog.uistate, dialog.track, + tooltips) + elif isinstance(option, _MenuOptions.ColourOption): + widget = GuiColourOption(option, dialog.dbstate, + dialog.uistate, dialog.track, + tooltips) + elif isinstance(option, _MenuOptions.SurnameColourOption): + widget = GuiSurnameColourOption(option, dialog.dbstate, + dialog.uistate, dialog.track, + tooltips) + return widget, label +