X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Froute_ui.cc;h=3107679df7fc7be6cfce10f995cc4f755959943a;hb=7a5adcbe72d9d0762eb42fc897316e7326e273db;hp=17baffe6af09be42fb2b9fe379f5d8d6fa2024b9;hpb=9f4c7a9e9edd260a72f040b036982d4c5da89292;p=ardour.git diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 17baffe6af..3107679df7 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -47,6 +47,9 @@ #include "ardour/audio_diskstream.h" #include "ardour/midi_track.h" #include "ardour/midi_diskstream.h" +#include "ardour/template_utils.h" +#include "ardour/filename_extensions.h" +#include "ardour/directory_names.h" #include "ardour/profile.h" #include "i18n.h" @@ -1195,4 +1198,37 @@ RouteUI::adjust_latency () LatencyDialog dialog (_route->name() + _("latency"), *(_route.get()), _session.frame_rate(), _session.engine().frames_per_cycle()); } - +void +RouteUI::save_as_template () +{ + sys::path path; + Glib::ustring safe_name; + string name; + + path = ARDOUR::user_route_template_directory (); + + if (g_mkdir_with_parents (path.to_string().c_str(), 0755)) { + error << string_compose (_("Cannot create route template directory %1"), path.to_string()) << endmsg; + return; + } + + Prompter p (true); // modal + + p.set_prompt (_("Template name:")); + switch (p.run()) { + case RESPONSE_ACCEPT: + break; + default: + return; + } + + p.hide (); + p.get_result (name, true); + + safe_name = legalize_for_path (name); + safe_name += temp_suffix; + + path /= safe_name; + + _route->save_as_template (path.to_string(), name); +}