From ba24f287ca27680bedeabb05620182c60a1611c4 Mon Sep 17 00:00:00 2001 From: Len Ovens Date: Sat, 29 Apr 2017 22:47:24 -0700 Subject: [PATCH] Make -A open action list in a browser instead of command terminal. --- gtk2_ardour/ardour_ui.cc | 65 ++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 13 deletions(-) diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index c45bc08166..d01a92ebf6 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -747,16 +747,16 @@ ARDOUR_UI::post_engine () string ver_in = revision; string ver = ver_in.substr(0, ver_in.find("-")); - cout << "\n

Menu actions

" << endl; - cout << "" << endl; - cout << "

\n Every single menu item in " << PROGRAM_NAME << "'s GUI is accessible by control" << endl; - cout << " surfaces or scripts.\n

\n" << endl; - cout << "

\n The list below shows all available values of action-name as of" << endl; - cout << " " << PROGRAM_NAME << " " << ver << ". You can get the current list at any" << endl; - cout << " time by running " << PROGRAM_NAME << " with the -A flag.\n

\n" << endl; - cout << "\n " << endl; - cout << " " << endl; - cout << " \n " << endl; + stringstream output; + output << "\n

Menu actions

" << endl; + output << "

\n Every single menu item in " << PROGRAM_NAME << "'s GUI is accessible by control" << endl; + output << " surfaces or scripts.\n

\n" << endl; + output << "

\n The list below shows all available values of action-name as of" << endl; + output << " " << PROGRAM_NAME << " " << ver << ". You can get the current list at any" << endl; + output << " time by running " << PROGRAM_NAME << " with the -A flag.\n

\n" << endl; + output << "
Action NameMenu Name
\n " << endl; + output << " " << endl; + output << " \n " << endl; Gtkmm2ext::ActionMap::get_all_actions (paths, labels, tooltips, keys, actions); @@ -764,10 +764,49 @@ ARDOUR_UI::post_engine () vector::iterator l; for (p = paths.begin(), l = labels.begin(); p != paths.end(); ++p, ++l) { - cout << " " << endl; + output << " " << endl; } - cout << " \n
Action NameMenu Name
" << (*p).substr (9, string::npos); - cout << "" << *l << "
" << (*p).substr (9, string::npos); + output << "" << *l << "
" << endl; + output << " \n " << endl; + + // output this mess to a browser for easiest X-platform use + // it is not pretty HTML, but it works and it's main purpose + // is to create raw html to fit in Ardour's manual with no editing + gchar* file_name; + GError *err = NULL; + gint fd; + + if ((fd = g_file_open_tmp ("akprintXXXXXX.html", &file_name, &err)) < 0) { + if (err) { + error << string_compose (_("Could not open temporary file to print bindings (%1)"), err->message) << endmsg; + g_error_free (err); + } + return; + } + +#ifdef PLATFORM_WINDOWS + ::close (fd); +#endif + + err = NULL; + + if (!g_file_set_contents (file_name, output.str().c_str(), output.str().size(), &err)) { +#ifndef PLATFORM_WINDOWS + ::close (fd); +#endif + g_unlink (file_name); + if (err) { + error << string_compose (_("Could not save bindings to file (%1)"), err->message) << endmsg; + g_error_free (err); + } + return; + } + +#ifndef PLATFORM_WINDOWS + ::close (fd); +#endif + + PBD::open_uri (string_compose ("file:///%1", file_name)); halt_connection.disconnect (); AudioEngine::instance()->stop ();