mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 15:25:01 +01:00
Skip script-setup if there are no parameters (and name is unique)
This commit is contained in:
parent
4b4d64dd7f
commit
8bb26628e3
3 changed files with 32 additions and 12 deletions
|
|
@ -1235,11 +1235,14 @@ LuaInstance::interactive_add (LuaScriptInfo::ScriptType type, int id)
|
||||||
LuaScriptParamList lsp = LuaScriptParams::script_params (spi, param_function);
|
LuaScriptParamList lsp = LuaScriptParams::script_params (spi, param_function);
|
||||||
|
|
||||||
ScriptParameterDialog spd (_("Set Script Parameters"), spi, reg, lsp);
|
ScriptParameterDialog spd (_("Set Script Parameters"), spi, reg, lsp);
|
||||||
switch (spd.run ()) {
|
|
||||||
case Gtk::RESPONSE_ACCEPT:
|
if (!spd.need_interation ()) {
|
||||||
break;
|
switch (spd.run ()) {
|
||||||
default:
|
case Gtk::RESPONSE_ACCEPT:
|
||||||
return false;
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LuaScriptParamPtr lspp (new LuaScriptParam("x-script-origin", "", spi->path, false));
|
LuaScriptParamPtr lspp (new LuaScriptParam("x-script-origin", "", spi->path, false));
|
||||||
|
|
|
||||||
|
|
@ -204,23 +204,38 @@ ScriptParameterDialog::ScriptParameterDialog (std::string title,
|
||||||
update_sensitivity ();
|
update_sensitivity ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool
|
||||||
ScriptParameterDialog::update_sensitivity ()
|
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 ();
|
std::string n = _name_entry.get_text ();
|
||||||
if (n.empty() || std::find (_existing_names.begin(), _existing_names.end(), n) != _existing_names.end()) {
|
if (n.empty() || std::find (_existing_names.begin(), _existing_names.end(), n) != _existing_names.end()) {
|
||||||
_add->set_sensitive (false);
|
return false;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < _lsp.size(); ++i) {
|
for (size_t i = 0; i < _lsp.size(); ++i) {
|
||||||
if (!_lsp[i]->optional && _lsp[i]->value.empty()) {
|
if (!_lsp[i]->optional && _lsp[i]->value.empty()) {
|
||||||
_add->set_sensitive (false);
|
return false;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
_add->set_sensitive (true);
|
void
|
||||||
|
ScriptParameterDialog::update_sensitivity ()
|
||||||
|
{
|
||||||
|
_add->set_sensitive (parameters_ok ());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -60,9 +60,11 @@ class ScriptParameterDialog : public ArdourDialog
|
||||||
public:
|
public:
|
||||||
ScriptParameterDialog (std::string title, const ARDOUR::LuaScriptInfoPtr&, const std::vector<std::string>&, ARDOUR::LuaScriptParamList&);
|
ScriptParameterDialog (std::string title, const ARDOUR::LuaScriptInfoPtr&, const std::vector<std::string>&, ARDOUR::LuaScriptParamList&);
|
||||||
std::string name () { return _name_entry.get_text (); }
|
std::string name () { return _name_entry.get_text (); }
|
||||||
|
bool need_interation () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void update_sensitivity ();
|
void update_sensitivity ();
|
||||||
|
bool parameters_ok () const;
|
||||||
void active_changed (int, Gtk::CheckButton*, Gtk::Entry*);
|
void active_changed (int, Gtk::CheckButton*, Gtk::Entry*);
|
||||||
void value_changed (int, Gtk::Entry*);
|
void value_changed (int, Gtk::Entry*);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue