'Saves the config changes to the plugins.
:param widg: the widget who generated the signal
:param plugin: the plugin to save the configuration
First it checks if there\'s some invalid configuration, then gets the
value of each option and save them to the plugin.'

def _save_panel(self, widg, plugin):

    invalid = []
    for opt in self.options:
        if hasattr(opt.widg, 'is_valid'):
            if (not opt.widg.is_valid()):
                invalid.append(opt.get_name())
    if invalid:
        msg = "The    configuration    can't    be    saved,    there    is    a    problem    in    the    following    parameter(s):\n\n"
        msg += '\n-'.join(invalid)
        dlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK, msg)
        dlg.set_title('Configuration    error')
        dlg.run()
        dlg.destroy()
        return
    try:
        for opt in self.options:
            SetOptionsWrapper(opt.set_value, opt.widg.get_value())
        if isinstance(plugin, Plugin):
            SetOptionsWrapper(self.w3af.plugins.set_plugin_options, plugin.ptype, plugin.pname, self.options)
        else:
            SetOptionsWrapper(plugin.set_options, self.options)
    except (BaseFrameworkException, ValueError):
        return
    for opt in self.options:
        opt.widg.save()
    self.w3af.mainwin.profiles.profile_changed(changed=True)
    self.w3af.mainwin.sb('Configuration    saved    successfully')
    self.saved_successfully = True
