Skip script-setup if there are no parameters (and name is unique)
This commit is contained in:
parent
4b4d64dd7f
commit
8bb26628e3
|
@ -1235,11 +1235,14 @@ LuaInstance::interactive_add (LuaScriptInfo::ScriptType type, int id)
|
|||
LuaScriptParamList lsp = LuaScriptParams::script_params (spi, param_function);
|
||||
|
||||
ScriptParameterDialog spd (_("Set Script Parameters"), spi, reg, lsp);
|
||||
switch (spd.run ()) {
|
||||
case Gtk::RESPONSE_ACCEPT:
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
|
||||
if (!spd.need_interation ()) {
|
||||
switch (spd.run ()) {
|
||||
case Gtk::RESPONSE_ACCEPT:
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
LuaScriptParamPtr lspp (new LuaScriptParam("x-script-origin", "", spi->path, false));
|
||||
|
|
|
@ -204,23 +204,38 @@ ScriptParameterDialog::ScriptParameterDialog (std::string title,
|
|||
update_sensitivity ();
|
||||
}
|
||||
|
||||
void
|
||||
ScriptParameterDialog::update_sensitivity ()
|
||||
bool
|
||||
ScriptParameterDialog::need_interation () const
|
||||
{
|
||||
if (_lsp.size () > 0) {
|
||||
return false;
|
||||
}
|
||||
if (!parameters_ok ()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ScriptParameterDialog::parameters_ok () const
|
||||
{
|
||||
std::string n = _name_entry.get_text ();
|
||||
if (n.empty() || std::find (_existing_names.begin(), _existing_names.end(), n) != _existing_names.end()) {
|
||||
_add->set_sensitive (false);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < _lsp.size(); ++i) {
|
||||
if (!_lsp[i]->optional && _lsp[i]->value.empty()) {
|
||||
_add->set_sensitive (false);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
_add->set_sensitive (true);
|
||||
void
|
||||
ScriptParameterDialog::update_sensitivity ()
|
||||
{
|
||||
_add->set_sensitive (parameters_ok ());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -60,9 +60,11 @@ class ScriptParameterDialog : public ArdourDialog
|
|||
public:
|
||||
ScriptParameterDialog (std::string title, const ARDOUR::LuaScriptInfoPtr&, const std::vector<std::string>&, ARDOUR::LuaScriptParamList&);
|
||||
std::string name () { return _name_entry.get_text (); }
|
||||
bool need_interation () const;
|
||||
|
||||
private:
|
||||
void update_sensitivity ();
|
||||
bool parameters_ok () const;
|
||||
void active_changed (int, Gtk::CheckButton*, Gtk::Entry*);
|
||||
void value_changed (int, Gtk::Entry*);
|
||||
|
||||
|
|
Loading…
Reference in New Issue