summaryrefslogtreecommitdiff
path: root/gtk2_ardour/luainstance.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-12-05 01:42:44 +0100
committerRobin Gareus <robin@gareus.org>2017-12-05 01:55:38 +0100
commitd96c516ae90de0e43281578111aef25d9c1532b2 (patch)
tree45233f75defc62b60c509d0ef025cc128a904db6 /gtk2_ardour/luainstance.cc
parentf3be5bb421822aa7644b63eea2317f9849f31d57 (diff)
Add Lua binding to query action-list
Diffstat (limited to 'gtk2_ardour/luainstance.cc')
-rw-r--r--gtk2_ardour/luainstance.cc68
1 files changed, 68 insertions, 0 deletions
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 <cairomm/surface.h>
#include <pango/pangocairo.h>
+#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<string> paths;
+ vector<string> labels;
+ vector<string> tooltips;
+ vector<string> keys;
+ vector<Glib::RefPtr<Gtk::Action> > actions;
+ Gtkmm2ext::ActionMap::get_all_actions (paths, labels, tooltips, keys, actions);
+
+ vector<string>::iterator p;
+ vector<string>::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<string> 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 <Actions>/ from the start */
+ string path = (*p);
+ path = path.substr (strlen ("<Actions>/"));
+
+ 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")