diff --git a/gtk2_ardour/luainstance.cc b/gtk2_ardour/luainstance.cc index 68fef8920f..a0f247179e 100644 --- a/gtk2_ardour/luainstance.cc +++ b/gtk2_ardour/luainstance.cc @@ -20,6 +20,9 @@ #include #include +#include "pbd/strsplit.h" + +#include "gtkmm2ext/bindings.h" #include "gtkmm2ext/gui_thread.h" #include "ardour/audioengine.h" @@ -424,6 +427,69 @@ lua_exec (std::string cmd) return 0; } #endif + +//////////////////////////////////////////////////////////////////////////////// + +static int +lua_actionlist (lua_State *L) +{ + using namespace std; + + vector paths; + vector labels; + vector tooltips; + vector keys; + vector > actions; + Gtkmm2ext::ActionMap::get_all_actions (paths, labels, tooltips, keys, actions); + + vector::iterator p; + vector::iterator l; + + luabridge::LuaRef action_tbl (luabridge::newTable (L)); + + for (l = labels.begin(), p = paths.begin(); l != labels.end(); ++p, ++l) { + if (l->empty ()) { + continue; + } + + vector parts; + split (*p, parts, '/'); + + if (parts.empty()) { + continue; + } + + //kinda kludgy way to avoid displaying menu items as mappable + if (parts[1] == _("Main_menu")) + continue; + if (parts[1] == _("JACK")) + continue; + if (parts[1] == _("redirectmenu")) + continue; + if (parts[1] == _("Editor_menus")) + continue; + if (parts[1] == _("RegionList")) + continue; + if (parts[1] == _("ProcessorMenu")) + continue; + + /* strip / from the start */ + string path = (*p); + path = path.substr (strlen ("/")); + + if (!action_tbl[parts[1]].isTable()) { + action_tbl[parts[1]] = luabridge::newTable (L); + } + assert (action_tbl[parts[1]].isTable()); + luabridge::LuaRef tbl (action_tbl[parts[1]]); + assert (tbl.isTable()); + tbl[*l] = path; + } + + luabridge::push (L, action_tbl); + return 1; +} + //////////////////////////////////////////////////////////////////////////////// // ARDOUR_UI and instance() are not exposed. @@ -949,6 +1015,8 @@ LuaInstance::register_classes (lua_State* L) .addConst ("Add", Selection::Operation(Selection::Add)) .endNamespace () + .addCFunction ("actionlist", &lua_actionlist) + .endNamespace () // end ArdourUI .beginNamespace ("os")