Regenerate gui options because previous configdialog may have deleted them; draw a frame around options that need 'save'.

svn: r14349
This commit is contained in:
Doug Blank 2010-02-13 06:37:50 +00:00
parent c6c653683f
commit b1354d2009
2 changed files with 20 additions and 6 deletions

View File

@ -376,12 +376,21 @@ class Gramplet(object):
Add an option to the GUI gramplet.
"""
from PluginUtils import make_gui_option
#tooltips, dbstate, uistate, track
widget, label = make_gui_option(
option, self.dbstate, self.uistate, [])
self.option_dict.update({option.get_label(): (widget, option)})
option, self.dbstate, self.uistate, [])
self.option_dict.update({option.get_label(): [widget, option]})
self.option_order.append(option.get_label())
def get_gui_option(self, label):
"""
Reconstruct a deleted widget.
"""
from PluginUtils import make_gui_option
dummy, option = self.option_dict[label]
widget, label = make_gui_option(
option, self.dbstate, self.uistate, [])
return widget
def save_update_options(self, obj):
"""
Save a gramplet's options to file.

View File

@ -600,6 +600,7 @@ class GuiGramplet(object):
def make_gui_options(self):
if not self.pui: return
if len(self.pui.option_order) == 0: return
frame = gtk.Frame()
topbox = gtk.VBox()
hbox = gtk.HBox()
labels = gtk.VBox()
@ -611,12 +612,16 @@ class GuiGramplet(object):
label = gtk.Label(item + ":")
label.set_alignment(1.0, 0.5)
labels.add(label)
options.add(self.pui.option_dict[item][0]) # widget
# The original may have been deleted when the dialog closed:
#options.add(self.pui.option_dict[item][0]) # widget
# so we regenerate:
options.add(self.pui.get_gui_option(item)) # widget
save_button = gtk.Button(stock=gtk.STOCK_SAVE)
topbox.add(save_button)
topbox.show_all()
save_button.connect('clicked', self.pui.save_update_options)
return topbox
frame.add(topbox)
frame.show_all()
return frame
def link(self, text, link_type, data, size=None, tooltip=None):
buffer = self.buffer