Added new methods for using a proxy selection widget for reports

svn: r16315
This commit is contained in:
Doug Blank 2010-12-25 16:59:10 +00:00
parent beac939325
commit da87d78c49
2 changed files with 32 additions and 5 deletions

View File

@ -1468,10 +1468,7 @@ class GuiMenuOptions(object):
widget, label = make_gui_option(option, dialog.dbstate, widget, label = make_gui_option(option, dialog.dbstate,
dialog.uistate, dialog.track) dialog.uistate, dialog.track)
if widget is not None:
if widget is None:
print "UNKNOWN OPTION: ", option
else:
if label: if label:
dialog.add_frame_option(category, dialog.add_frame_option(category,
option.get_label(), option.get_label(),
@ -1487,6 +1484,24 @@ class GuiMenuOptions(object):
option = self.menu.get_option_by_name(name) option = self.menu.get_option_by_name(name)
self.options_dict[name] = option.get_value() self.options_dict[name] = option.get_value()
def init_selection(self, dbstate, uistate):
"""
Initialize selection options for GUI.
"""
pass
def save_selection(self):
"""
Move selection options to handler.
"""
pass
def build_selection(self):
"""
Move selection options to handler.
"""
pass
def make_gui_option(option, dbstate, uistate, track): def make_gui_option(option, dbstate, uistate, track):
""" """
Stand-alone function so that Options can be used in other Stand-alone function so that Options can be used in other
@ -1529,6 +1544,8 @@ def make_gui_option(option, dbstate, uistate, track):
widget = GuiPlaceListOption(option, dbstate, uistate, track) widget = GuiPlaceListOption(option, dbstate, uistate, track)
elif isinstance(option, gen.plug.menu.BooleanListOption): elif isinstance(option, gen.plug.menu.BooleanListOption):
widget = GuiBooleanListOption(option, dbstate, uistate, track) widget = GuiBooleanListOption(option, dbstate, uistate, track)
elif isinstance(option, gen.plug.menu.Option):
return None, None # No Gui representation for this
elif option.__class__ in external_options: elif option.__class__ in external_options:
widget = external_options[option.__class__](option, dbstate, uistate, widget = external_options[option.__class__](option, dbstate, uistate,
track) track)

View File

@ -89,6 +89,7 @@ class ReportDialog(ManagedWindow.ManagedWindow):
self.firstpage_added = False self.firstpage_added = False
self.raw_name = name self.raw_name = name
self.dbstate = dbstate self.dbstate = dbstate
self.uistate = uistate
self.db = dbstate.db self.db = dbstate.db
self.report_name = trans_name self.report_name = trans_name
@ -104,7 +105,7 @@ class ReportDialog(ManagedWindow.ManagedWindow):
self.options = option_class(self.raw_name, self.db) self.options = option_class(self.raw_name, self.db)
except TypeError: except TypeError:
self.options = option_class self.options = option_class
self.options.init_selection(self.dbstate, self.uistate)
self.options.load_previous_values() self.options.load_previous_values()
def build_window_key(self, obj): def build_window_key(self, obj):
@ -168,6 +169,7 @@ class ReportDialog(ManagedWindow.ManagedWindow):
self.window.vbox.add(self.notebook) self.window.vbox.add(self.notebook)
self.setup_report_options_frame() self.setup_report_options_frame()
self.setup_selection_frame()
self.setup_other_frames() self.setup_other_frames()
self.notebook.set_current_page(0) self.notebook.set_current_page(0)
@ -306,6 +308,13 @@ class ReportDialog(ManagedWindow.ManagedWindow):
style = self.options.handler.get_default_stylesheet_name() style = self.options.handler.get_default_stylesheet_name()
self.build_style_menu(style) self.build_style_menu(style)
def setup_selection_frame(self):
widget = self.options.build_selection()
if widget:
l = gtk.Label("<b>%s</b>" % _("Selection Options"))
l.set_use_markup(True)
self.notebook.append_page(widget, l)
def setup_report_options_frame(self): def setup_report_options_frame(self):
"""Set up the report options frame of the dialog. This """Set up the report options frame of the dialog. This
function relies on several report_xxx() customization function relies on several report_xxx() customization
@ -545,6 +554,7 @@ class ReportDialog(ManagedWindow.ManagedWindow):
self.parse_user_options() self.parse_user_options()
# Save options # Save options
self.options.save_selection()
self.options.handler.save_options() self.options.handler.save_options()
def on_cancel(self, *obj): def on_cancel(self, *obj):