Let user add a route template description on saving route templates
This commit is contained in:
parent
ae51d5fd4e
commit
245154d06a
|
@ -3192,9 +3192,10 @@ ARDOUR_UI::save_template ()
|
|||
return;
|
||||
}
|
||||
|
||||
SaveTemplateDialog* d = new SaveTemplateDialog (*_session);
|
||||
SaveTemplateDialog* d = new SaveTemplateDialog (_session->name());
|
||||
|
||||
d->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::save_template_dialog_response), d));
|
||||
|
||||
d->show ();
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
#include "rgb_macros.h"
|
||||
#include "route_time_axis.h"
|
||||
#include "route_ui.h"
|
||||
#include "save_template_dialog.h"
|
||||
#include "timers.h"
|
||||
#include "ui_config.h"
|
||||
#include "utils.h"
|
||||
|
@ -1892,33 +1893,29 @@ RouteUI::adjust_latency ()
|
|||
LatencyDialog dialog (_route->name() + _(" latency"), *(_route->output()), _session->frame_rate(), AudioEngine::instance()->samples_per_cycle());
|
||||
}
|
||||
|
||||
bool
|
||||
RouteUI::process_save_template_prompter (Prompter& prompter, const std::string& dir)
|
||||
|
||||
void
|
||||
RouteUI::save_as_template_dialog_response (int response, SaveTemplateDialog* d)
|
||||
{
|
||||
std::string path;
|
||||
std::string safe_name;
|
||||
std::string name;
|
||||
if (response == RESPONSE_ACCEPT) {
|
||||
const string name = d->get_template_name ();
|
||||
const string desc = d->get_description ();
|
||||
const string path = Glib::build_filename(ARDOUR::user_route_template_directory (), name);
|
||||
|
||||
prompter.get_result (name, true);
|
||||
if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) { /* file already exists. */
|
||||
bool overwrite = overwrite_file_dialog (*d,
|
||||
_("Confirm Template Overwrite"),
|
||||
_("A template already exists with that name. Do you want to overwrite it?"));
|
||||
|
||||
safe_name = legalize_for_path (name);
|
||||
safe_name += template_suffix;
|
||||
|
||||
path = Glib::build_filename (dir, safe_name);
|
||||
|
||||
if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) {
|
||||
bool overwrite = overwrite_file_dialog (prompter,
|
||||
_("Confirm Template Overwrite"),
|
||||
_("A template already exists with that name. Do you want to overwrite it?"));
|
||||
|
||||
if (!overwrite) {
|
||||
return false;
|
||||
if (!overwrite) {
|
||||
d->show ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
_route->save_as_template (path, name, desc);
|
||||
}
|
||||
|
||||
_route->save_as_template (path, name);
|
||||
|
||||
return true;
|
||||
delete d;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1933,23 +1930,10 @@ RouteUI::save_as_template ()
|
|||
return;
|
||||
}
|
||||
|
||||
Prompter prompter (true); // modal
|
||||
SaveTemplateDialog* d = new SaveTemplateDialog (_route->name());
|
||||
|
||||
prompter.set_title (_("Save As Template"));
|
||||
prompter.set_prompt (_("Template name:"));
|
||||
prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
|
||||
|
||||
bool finished = false;
|
||||
while (!finished) {
|
||||
switch (prompter.run()) {
|
||||
case RESPONSE_ACCEPT:
|
||||
finished = process_save_template_prompter (prompter, dir);
|
||||
break;
|
||||
default:
|
||||
finished = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
d->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::save_as_template_dialog_response), d));
|
||||
d->show ();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2415,4 +2399,3 @@ RouteUI::stripable () const
|
|||
{
|
||||
return _route;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ namespace ArdourWidgets {
|
|||
class ArdourWindow;
|
||||
class IOSelectorWindow;
|
||||
class ControlSlaveUI;
|
||||
class SaveTemplateDialog;
|
||||
|
||||
class RoutePinWindowProxy : public WM::ProxyBase
|
||||
{
|
||||
|
@ -243,7 +244,7 @@ public:
|
|||
virtual void map_frozen ();
|
||||
|
||||
void adjust_latency ();
|
||||
bool process_save_template_prompter (ArdourWidgets::Prompter& prompter, const std::string& dir);
|
||||
void save_as_template_dialog_response (int response, SaveTemplateDialog* d);
|
||||
void save_as_template ();
|
||||
|
||||
static Gtkmm2ext::ActiveState solo_active_state (boost::shared_ptr<ARDOUR::Stripable>);
|
||||
|
|
|
@ -31,10 +31,10 @@
|
|||
using namespace Gtk;
|
||||
using namespace ARDOUR;
|
||||
|
||||
SaveTemplateDialog::SaveTemplateDialog (const Session& s)
|
||||
SaveTemplateDialog::SaveTemplateDialog (const std::string& name, const std::string& desc)
|
||||
: ArdourDialog (_("Save as template"))
|
||||
{
|
||||
_name_editor.get_buffer()->set_text (s.name() + _("-template"));
|
||||
_name_editor.get_buffer()->set_text (name + _("-template"));
|
||||
_description_editor.set_wrap_mode (Gtk::WRAP_WORD);
|
||||
_description_editor.set_size_request(400, 300);
|
||||
|
||||
|
|
|
@ -21,20 +21,18 @@
|
|||
#ifndef __ardour_gtk_save_template_dialog_h__
|
||||
#define __ardour_gtk_save_template_dialog_h__
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <gtkmm/entry.h>
|
||||
#include <gtkmm/textview.h>
|
||||
|
||||
#include "ardour_dialog.h"
|
||||
|
||||
namespace ARDOUR
|
||||
{
|
||||
class Session;
|
||||
}
|
||||
|
||||
class SaveTemplateDialog : public ArdourDialog
|
||||
{
|
||||
public:
|
||||
SaveTemplateDialog (const ARDOUR::Session& s);
|
||||
SaveTemplateDialog (const std::string& name, const std::string& description = "");
|
||||
|
||||
std::string get_template_name () const;
|
||||
std::string get_description () const;
|
||||
|
|
|
@ -381,7 +381,7 @@ public:
|
|||
|
||||
boost::weak_ptr<Route> weakroute ();
|
||||
|
||||
int save_as_template (const std::string& path, const std::string& name);
|
||||
int save_as_template (const std::string& path, const std::string& name, const std::string& description );
|
||||
|
||||
PBD::Signal1<void,void*> SelectedChanged;
|
||||
|
||||
|
|
|
@ -4014,7 +4014,7 @@ Route::set_plugin_state_dir (boost::weak_ptr<Processor> p, const std::string& d)
|
|||
}
|
||||
|
||||
int
|
||||
Route::save_as_template (const string& path, const string& name)
|
||||
Route::save_as_template (const string& path, const string& name, const string& description)
|
||||
{
|
||||
std::string state_dir = path.substr (0, path.find_last_of ('.')); // strip template_suffix
|
||||
PBD::Unwinder<std::string> uw (_session._template_state_dir, state_dir);
|
||||
|
@ -4022,6 +4022,14 @@ Route::save_as_template (const string& path, const string& name)
|
|||
XMLNode& node (state (false));
|
||||
node.set_property (X_("name"), name);
|
||||
|
||||
if (!description.empty()) {
|
||||
XMLNode* desc = new XMLNode(X_("description"));
|
||||
XMLNode* desc_cont = new XMLNode(X_("content"), description);
|
||||
desc->add_child_nocopy (*desc_cont);
|
||||
|
||||
node.add_child_nocopy (*desc);
|
||||
}
|
||||
|
||||
XMLTree tree;
|
||||
|
||||
IO::set_name_in_state (*node.children().front(), name);
|
||||
|
|
Loading…
Reference in New Issue