+
+static std::string http_get_unlogged (const std::string& url) { return ArdourCurl::http_get (url, false); }
+
+/** special cases for Ardour's Mixer UI */
+namespace LuaMixer {
+
+ ProcessorBox::ProcSelection
+ processor_selection () {
+ return ProcessorBox::current_processor_selection ();
+ }
+
+};
+
+////////////////////////////////////////////////////////////////////////////////
+
+static PBD::ScopedConnectionList _luaexecs;
+
+static void reaper (ARDOUR::SystemExec* x)
+{
+ delete x;
+}
+
+static int
+lua_forkexec (lua_State *L)
+{
+ int argc = lua_gettop (L);
+ if (argc == 0) {
+ return luaL_argerror (L, 1, "invalid number of arguments, forkexec (command, ...)");
+ }
+ // args are free()ed in ~SystemExec
+ char** args = (char**) malloc ((argc + 1) * sizeof(char*));
+ for (int i = 0; i < argc; ++i) {
+ args[i] = strdup (luaL_checkstring (L, i + 1));
+ }
+ args[argc] = 0;
+
+ ARDOUR::SystemExec* x = new ARDOUR::SystemExec (args[0], args);
+ x->Terminated.connect (_luaexecs, MISSING_INVALIDATOR, boost::bind (&reaper, x), gui_context());
+
+ if (x->start()) {
+ reaper (x);
+ luabridge::Stack<bool>::push (L, false);
+ return -1;
+ } else {
+ luabridge::Stack<bool>::push (L, false);
+ }
+ return 1;
+}
+
+#ifndef PLATFORM_WINDOWS
+static int
+lua_exec (std::string cmd)
+{
+ // args are free()ed in ~SystemExec
+ char** args = (char**) malloc (4 * sizeof(char*));
+ args[0] = strdup ("/bin/sh");
+ args[1] = strdup ("-c");
+ args[2] = strdup (cmd.c_str());
+ args[3] = 0;
+ ARDOUR::SystemExec x ("/bin/sh", args);
+ if (x.start()) {
+ return -1;
+ }
+ x.wait ();
+ 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.
+ARDOUR::PresentationInfo::order_t
+lua_translate_order (RouteDialogs::InsertAt place)
+{
+ return ARDOUR_UI::instance()->translate_order (place);
+}
+