mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 15:25:01 +01:00
Let user add a route template description on saving route templates
This commit is contained in:
parent
ae51d5fd4e
commit
245154d06a
7 changed files with 40 additions and 49 deletions
|
|
@ -3192,9 +3192,10 @@ ARDOUR_UI::save_template ()
|
||||||
return;
|
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->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::save_template_dialog_response), d));
|
||||||
|
|
||||||
d->show ();
|
d->show ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@
|
||||||
#include "rgb_macros.h"
|
#include "rgb_macros.h"
|
||||||
#include "route_time_axis.h"
|
#include "route_time_axis.h"
|
||||||
#include "route_ui.h"
|
#include "route_ui.h"
|
||||||
|
#include "save_template_dialog.h"
|
||||||
#include "timers.h"
|
#include "timers.h"
|
||||||
#include "ui_config.h"
|
#include "ui_config.h"
|
||||||
#include "utils.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());
|
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;
|
if (response == RESPONSE_ACCEPT) {
|
||||||
std::string safe_name;
|
const string name = d->get_template_name ();
|
||||||
std::string 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,
|
||||||
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"),
|
_("Confirm Template Overwrite"),
|
||||||
_("A template already exists with that name. Do you want to overwrite it?"));
|
_("A template already exists with that name. Do you want to overwrite it?"));
|
||||||
|
|
||||||
if (!overwrite) {
|
if (!overwrite) {
|
||||||
return false;
|
d->show ();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_route->save_as_template (path, name, desc);
|
||||||
|
}
|
||||||
|
|
||||||
_route->save_as_template (path, name);
|
delete d;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -1933,23 +1930,10 @@ RouteUI::save_as_template ()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Prompter prompter (true); // modal
|
SaveTemplateDialog* d = new SaveTemplateDialog (_route->name());
|
||||||
|
|
||||||
prompter.set_title (_("Save As Template"));
|
d->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::save_as_template_dialog_response), d));
|
||||||
prompter.set_prompt (_("Template name:"));
|
d->show ();
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -2415,4 +2399,3 @@ RouteUI::stripable () const
|
||||||
{
|
{
|
||||||
return _route;
|
return _route;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ namespace ArdourWidgets {
|
||||||
class ArdourWindow;
|
class ArdourWindow;
|
||||||
class IOSelectorWindow;
|
class IOSelectorWindow;
|
||||||
class ControlSlaveUI;
|
class ControlSlaveUI;
|
||||||
|
class SaveTemplateDialog;
|
||||||
|
|
||||||
class RoutePinWindowProxy : public WM::ProxyBase
|
class RoutePinWindowProxy : public WM::ProxyBase
|
||||||
{
|
{
|
||||||
|
|
@ -243,7 +244,7 @@ public:
|
||||||
virtual void map_frozen ();
|
virtual void map_frozen ();
|
||||||
|
|
||||||
void adjust_latency ();
|
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 ();
|
void save_as_template ();
|
||||||
|
|
||||||
static Gtkmm2ext::ActiveState solo_active_state (boost::shared_ptr<ARDOUR::Stripable>);
|
static Gtkmm2ext::ActiveState solo_active_state (boost::shared_ptr<ARDOUR::Stripable>);
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,10 @@
|
||||||
using namespace Gtk;
|
using namespace Gtk;
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
|
|
||||||
SaveTemplateDialog::SaveTemplateDialog (const Session& s)
|
SaveTemplateDialog::SaveTemplateDialog (const std::string& name, const std::string& desc)
|
||||||
: ArdourDialog (_("Save as template"))
|
: 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_wrap_mode (Gtk::WRAP_WORD);
|
||||||
_description_editor.set_size_request(400, 300);
|
_description_editor.set_size_request(400, 300);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,20 +21,18 @@
|
||||||
#ifndef __ardour_gtk_save_template_dialog_h__
|
#ifndef __ardour_gtk_save_template_dialog_h__
|
||||||
#define __ardour_gtk_save_template_dialog_h__
|
#define __ardour_gtk_save_template_dialog_h__
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <gtkmm/entry.h>
|
#include <gtkmm/entry.h>
|
||||||
#include <gtkmm/textview.h>
|
#include <gtkmm/textview.h>
|
||||||
|
|
||||||
#include "ardour_dialog.h"
|
#include "ardour_dialog.h"
|
||||||
|
|
||||||
namespace ARDOUR
|
|
||||||
{
|
|
||||||
class Session;
|
|
||||||
}
|
|
||||||
|
|
||||||
class SaveTemplateDialog : public ArdourDialog
|
class SaveTemplateDialog : public ArdourDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SaveTemplateDialog (const ARDOUR::Session& s);
|
SaveTemplateDialog (const std::string& name, const std::string& description = "");
|
||||||
|
|
||||||
std::string get_template_name () const;
|
std::string get_template_name () const;
|
||||||
std::string get_description () const;
|
std::string get_description () const;
|
||||||
|
|
|
||||||
|
|
@ -381,7 +381,7 @@ public:
|
||||||
|
|
||||||
boost::weak_ptr<Route> weakroute ();
|
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;
|
PBD::Signal1<void,void*> SelectedChanged;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4014,7 +4014,7 @@ Route::set_plugin_state_dir (boost::weak_ptr<Processor> p, const std::string& d)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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
|
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);
|
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));
|
XMLNode& node (state (false));
|
||||||
node.set_property (X_("name"), name);
|
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;
|
XMLTree tree;
|
||||||
|
|
||||||
IO::set_name_in_state (*node.children().front(), name);
|
IO::set_name_in_state (*node.children().front(), name);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue