Drop the "Lua" in Lua Action Buttons:
authorBen Loftis <ben@harrisonconsoles.com>
Thu, 7 Dec 2017 15:17:53 +0000 (09:17 -0600)
committerBen Loftis <ben@harrisonconsoles.com>
Thu, 7 Dec 2017 17:08:26 +0000 (11:08 -0600)
Removed the term "Lua", because users were turned off by something they didn't understand.
A special-case Lua script ("Shortcut") allows the user to select an arbitrary Action.
The "Shortcut" script is selected by default, and in this case there is no "Type" or "Author" displayed.
Action-Buttons may still trigger Lua scripts, as a secondary function.

gtk2_ardour/luainstance.cc
gtk2_ardour/rc_option_editor.cc
gtk2_ardour/script_selector.cc
gtk2_ardour/script_selector.h
scripts/_access_action.lua [deleted file]
scripts/access_action.lua [new file with mode: 0644]

index a0f247179ef94e88df595f9c100c130041722bf1..8f9572b98e7da461365eaa4c17461bfe7fd41eea 100644 (file)
@@ -1358,7 +1358,7 @@ LuaInstance::interactive_add (LuaScriptInfo::ScriptType type, int id)
        switch (type) {
                case LuaScriptInfo::EditorAction:
                        reg = lua_action_names ();
-                       title = _("Add Lua Action");
+                       title = _("Add Shortcut or Lua Script");
                        break;
                case LuaScriptInfo::EditorHook:
                        reg = lua_slot_names ();
index 0f33de33ce46178cb06bedd296f95a7bfefff8f6..f5dfcab0a13489b761d789697686cd47d17afe9e 100644 (file)
@@ -3814,7 +3814,7 @@ RCOptionEditor::RCOptionEditor ()
 
        add_option (_("Appearance/Toolbar"),
                        new ColumVisibilityOption (
-                               "action-table-columns", _("Lua Action Script Button Visibility"), 4,
+                               "action-table-columns", _("Display Action-Buttons"), 4,
                                sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::get_action_table_columns),
                                sigc::mem_fun (UIConfiguration::instance(), &UIConfiguration::set_action_table_columns)
                                )
index 94d6e67671d99db51264f115995f4f6ce164878c..ea28c414b60304b30984de2b881c6aaf0d1d0c66 100644 (file)
@@ -31,28 +31,26 @@ using namespace ARDOUR;
 
 ScriptSelector::ScriptSelector (std::string title, LuaScriptInfo::ScriptType type)
        : ArdourDialog (title)
+       , _type_label ("<b>Type:</b>", Gtk::ALIGN_END, Gtk::ALIGN_CENTER)
        , _type ("", Gtk::ALIGN_START, Gtk::ALIGN_CENTER)
+       , _author_label ("<b>Author:</b>", Gtk::ALIGN_END, Gtk::ALIGN_CENTER)
        , _author ("", Gtk::ALIGN_START, Gtk::ALIGN_CENTER)
        , _description ("", Gtk::ALIGN_START, Gtk::ALIGN_START)
        , _scripts (LuaScripting::instance ().scripts (type))
        , _script_type (type)
 {
-       Gtk::Label* l;
-
        Table* t = manage (new Table (3, 2));
        t->set_spacings (6);
 
        int ty = 0;
 
-       l = manage (new Label (_("<b>Type:</b>"), Gtk::ALIGN_END, Gtk::ALIGN_CENTER, false));
-       l->set_use_markup ();
-       t->attach (*l, 0, 1, ty, ty+1, FILL|EXPAND, SHRINK);
+       _type_label.set_use_markup ();
+       t->attach (_type_label, 0, 1, ty, ty+1, FILL|EXPAND, SHRINK);
        t->attach (_type, 1, 2, ty, ty+1, FILL|EXPAND, SHRINK);
        ++ty;
 
-       l = manage (new Label (_("<b>Author:</b>"), Gtk::ALIGN_END, Gtk::ALIGN_CENTER, false));
-       l->set_use_markup ();
-       t->attach (*l, 0, 1, ty, ty+1, FILL|EXPAND, SHRINK);
+       _author_label.set_use_markup ();
+       t->attach (_author_label, 0, 1, ty, ty+1, FILL|EXPAND, SHRINK);
        t->attach (_author, 1, 2, ty, ty+1, FILL|EXPAND, SHRINK);
        ++ty;
 
@@ -81,36 +79,78 @@ ScriptSelector::ScriptSelector (std::string title, LuaScriptInfo::ScriptType typ
 
        setup_list ();
        show_all ();
+       
+       script_combo_changed();
+}
+
+bool
+ScriptSelector::script_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i)
+{
+       _script_combo.set_active (i);
+
+       return _script_combo.get_active_text () == "separator";
 }
 
 void
 ScriptSelector::setup_list ()
 {
        _combocon.block();
+       
        vector<string> script_names;
        for (LuaScriptList::const_iterator s = _scripts.begin(); s != _scripts.end(); ++s) {
-               script_names.push_back ((*s)->name);
+               if ( (*s)->name != "Shortcut" ) {
+                       script_names.push_back ((*s)->name);
+               }
        }
-
-       Gtkmm2ext::set_popdown_strings (_script_combo, script_names);
-       if (script_names.size() > 0) {
-               _script_combo.set_active(0);
-               script_combo_changed ();
+       
+       _script_combo.clear();
+       _script_combo.set_row_separator_func ( sigc::mem_fun (*this, &ScriptSelector::script_separator) );
+
+       _script_combo.append_text ("Shortcut");
+       _script_combo.append_text ("separator");
+       
+       vector<string>::const_iterator i;
+       for (i = script_names.begin(); i != script_names.end(); ++i) {
+               _script_combo.append_text (*i);
        }
+
+       _script_combo.set_active(0);
+       script_combo_changed ();
+
        _combocon.unblock();
 }
 
 void
 ScriptSelector::script_combo_changed ()
 {
-       int i = _script_combo.get_active_row_number();
-       _script = _scripts[i];
+       std::string nm = _script_combo.get_active_text();
+
+       for (LuaScriptList::const_iterator s = _scripts.begin(); s != _scripts.end(); ++s) {
+               if ( (*s)->name == nm ) {
+                       _script = (*s);
+               }
+       }
 
-       _type.set_text(LuaScriptInfo::type2str (_script->type));
-       _author.set_text (_script->author);
-       _description.set_text (_script->description);
+       if (_script) {
+               
+               if (_script->name == "Shortcut" ) {
+                       _type.hide();
+                       _type_label.hide();
+                       _author.hide();
+                       _author_label.hide();
+                       _description.set_text (_script->description);
+               } else {
+                       _type.show();
+                       _type_label.show();
+                       _author.show();
+                       _author_label.show();
+                       _type.set_text(LuaScriptInfo::type2str (_script->type));
+                       _author.set_text (_script->author);
+                       _description.set_text (_script->description);
+               }
 
-       _add->set_sensitive (Glib::file_test(_script->path, Glib::FILE_TEST_EXISTS));
+               _add->set_sensitive (Glib::file_test(_script->path, Glib::FILE_TEST_EXISTS));
+       }
 }
 
 void
index 54c26ee2271fb5c2fe7cbf7dda644ffa90212e44..f8f17f5c021033faf6b309731fadab5ef342c422 100644 (file)
@@ -34,11 +34,14 @@ private:
        void setup_list ();
        void refresh ();
        void script_combo_changed ();
-
+       bool script_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk::TreeModel::iterator &i);
+       
        Gtk::Button* _add;
        Gtk::ComboBoxText _script_combo;
 
+       Gtk::Label  _type_label;
        Gtk::Label  _type;
+       Gtk::Label  _author_label;
        Gtk::Label  _author;
        Gtk::Label  _description;
 
diff --git a/scripts/_access_action.lua b/scripts/_access_action.lua
deleted file mode 100644 (file)
index 11b7ec7..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-ardour {
-       ["type"]    = "EditorAction",
-       name        = "Shortcut",
-       license     = "MIT",
-       author      = "me",
-       description = [[Shortcut call any action]]
-}
-
-function action_params ()
-       local actionlist = {
-               {
-                       type = "dropdown", key = "action", title = "Action", values = ArdourUI:actionlist(),
-                       default = "Save"
-               }
-       }
-
-       local rv = LuaDialog.Dialog ("Select Action", actionlist):run ()
-       if not rv then -- user cancelled
-               return { ["x-script-abort"] = { title = "", preseeded = true} }
-       end
-
-       local action = rv["action"]
-       local name = "Shortcut - " .. action
-       return {
-               ["action"] = { title = "Action to trigger", default = action, preseeded = true},
-               ["x-script-name"] = { title = "Unique Script name", default = name, preseeded = true},
-       }
-end
-
-function factory (params) return function ()
-       local p = params or { }
-       local as = assert (p["action"])
-       local sp = assert (as:find('/'))
-       local group = assert (as:sub(0, sp - 1))
-       local item = assert (as:sub(1 + sp))
-       Editor:access_action (group, item)
-end end
diff --git a/scripts/access_action.lua b/scripts/access_action.lua
new file mode 100644 (file)
index 0000000..b50c638
--- /dev/null
@@ -0,0 +1,37 @@
+ardour {
+       ["type"]    = "EditorAction",
+       name        = "Shortcut",
+       license     = "MIT",
+       author      = "me",
+       description = [[Trigger a keyboard shortcut.  You will be prompted for the shortcut's action in the next step.]]
+}
+
+function action_params ()
+       local actionlist = {
+               {
+                       type = "dropdown", key = "action", title = "Action", values = ArdourUI:actionlist(),
+                       default = "Save"
+               }
+       }
+
+       local rv = LuaDialog.Dialog ("Select Action", actionlist):run ()
+       if not rv then -- user cancelled
+               return { ["x-script-abort"] = { title = "", preseeded = true} }
+       end
+
+       local action = rv["action"]
+       local name = "Shortcut - " .. action
+       return {
+               ["action"] = { title = "Action to trigger", default = action, preseeded = true},
+               ["x-script-name"] = { title = "Unique Script name", default = name, preseeded = true},
+       }
+end
+
+function factory (params) return function ()
+       local p = params or { }
+       local as = assert (p["action"])
+       local sp = assert (as:find('/'))
+       local group = assert (as:sub(0, sp - 1))
+       local item = assert (as:sub(1 + sp))
+       Editor:access_action (group, item)
+end end