X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=gtk2_ardour%2Fscript_selector.cc;h=794d57797ad225a7d38e9107c38de72943303324;hb=2a9bf034bb21eb684c75711c97f6f730397140ee;hp=31cea38338a807da236ff8fb1b075857090c3654;hpb=75273762976933841b5c0b244c4e8f29158e5519;p=ardour.git diff --git a/gtk2_ardour/script_selector.cc b/gtk2_ardour/script_selector.cc index 31cea38338..794d57797a 100644 --- a/gtk2_ardour/script_selector.cc +++ b/gtk2_ardour/script_selector.cc @@ -16,10 +16,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include +#include +#include + #include "gtkmm2ext/utils.h" #include "script_selector.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace Gtk; @@ -42,22 +46,22 @@ ScriptSelector::ScriptSelector (std::string title, LuaScriptInfo::ScriptType typ l = manage (new Label (_("Type:"), Gtk::ALIGN_END, Gtk::ALIGN_CENTER, false)); l->set_use_markup (); - t->attach (*l, 0, 1, ty, ty+1); - t->attach (_type, 1, 2, ty, ty+1); + t->attach (*l, 0, 1, ty, ty+1, FILL|EXPAND, SHRINK); + t->attach (_type, 1, 2, ty, ty+1, FILL|EXPAND, SHRINK); ++ty; l = manage (new Label (_("Author:"), Gtk::ALIGN_END, Gtk::ALIGN_CENTER, false)); l->set_use_markup (); - t->attach (*l, 0, 1, ty, ty+1); - t->attach (_author, 1, 2, ty, ty+1); + t->attach (*l, 0, 1, ty, ty+1, FILL|EXPAND, SHRINK); + t->attach (_author, 1, 2, ty, ty+1, FILL|EXPAND, SHRINK); ++ty; - l = manage (new Label (_("Description:"), Gtk::ALIGN_END, Gtk::ALIGN_CENTER, false)); - l->set_use_markup (); - t->attach (*l, 0, 1, ty, ty+1); - t->attach (_description, 1, 2, ty, ty+1); + Frame* f = manage(new Frame (_("Description"))); + f->add (_description); + t->attach (*f, 0, 2, ty, ty+1); ++ty; + _description.set_padding (5, 5); _description.set_line_wrap(); get_vbox()->set_spacing (6); @@ -176,17 +180,21 @@ ScriptParameterDialog::ScriptParameterDialog (std::string title, } for (size_t i = 0; i < _lsp.size (); ++i) { - CheckButton* c = manage (new CheckButton (_lsp[i]->title)); Entry* e = manage (new Entry()); - c->set_active (!_lsp[i]->optional); // also if default ?? - c->set_sensitive (_lsp[i]->optional); - e->set_text (_lsp[i]->dflt); - e->set_sensitive (c->get_active ()); + if (_lsp[i]->optional) { + CheckButton* c = manage (new CheckButton (_lsp[i]->title)); + c->set_active (!_lsp[i]->dflt.empty()); + c->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &ScriptParameterDialog::active_changed), i, c, e)); + t->attach (*c, 0, 1, ty, ty+1); + } else { + Label* l = manage (new Label (_lsp[i]->title, Gtk::ALIGN_LEFT)); + t->attach (*l, 0, 1, ty, ty+1); + } - c->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &ScriptParameterDialog::active_changed), i, c, e)); + e->set_text (_lsp[i]->dflt); + e->set_sensitive (!_lsp[i]->dflt.empty()); e->signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &ScriptParameterDialog::value_changed), i, e)); - t->attach (*c, 0, 1, ty, ty+1); t->attach (*e, 1, 2, ty, ty+1); ++ty; } @@ -200,23 +208,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