mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 15:54:57 +01:00
Let the user add a template description on saving session templates
This commit is contained in:
parent
908369ab3e
commit
ae51d5fd4e
7 changed files with 151 additions and 37 deletions
|
|
@ -169,6 +169,7 @@ typedef uint64_t microseconds_t;
|
||||||
#include "route_time_axis.h"
|
#include "route_time_axis.h"
|
||||||
#include "route_params_ui.h"
|
#include "route_params_ui.h"
|
||||||
#include "save_as_dialog.h"
|
#include "save_as_dialog.h"
|
||||||
|
#include "save_template_dialog.h"
|
||||||
#include "script_selector.h"
|
#include "script_selector.h"
|
||||||
#include "session_archive_dialog.h"
|
#include "session_archive_dialog.h"
|
||||||
#include "session_dialog.h"
|
#include "session_dialog.h"
|
||||||
|
|
@ -3158,60 +3159,43 @@ ARDOUR_UI::transport_rec_enable_blink (bool onoff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
ARDOUR_UI::process_save_template_prompter (Prompter& prompter)
|
ARDOUR_UI::save_template_dialog_response (int response, SaveTemplateDialog* d)
|
||||||
{
|
{
|
||||||
string name;
|
if (response == RESPONSE_ACCEPT) {
|
||||||
|
const string name = d->get_template_name ();
|
||||||
|
const string desc = d->get_description ();
|
||||||
|
|
||||||
prompter.get_result (name);
|
int failed = _session->save_template (name, desc);
|
||||||
|
|
||||||
if (name.length()) {
|
|
||||||
int failed = _session->save_template (name);
|
|
||||||
|
|
||||||
if (failed == -2) { /* file already exists. */
|
if (failed == -2) { /* file already exists. */
|
||||||
bool overwrite = overwrite_file_dialog (prompter,
|
bool overwrite = overwrite_file_dialog (*d,
|
||||||
_("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) {
|
||||||
_session->save_template (name, true);
|
_session->save_template (name, desc, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
d->show ();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
delete d;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ARDOUR_UI::save_template ()
|
ARDOUR_UI::save_template ()
|
||||||
{
|
{
|
||||||
Prompter prompter (true);
|
|
||||||
|
|
||||||
if (!check_audioengine (_main_window)) {
|
if (!check_audioengine (_main_window)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
prompter.set_name (X_("Prompter"));
|
SaveTemplateDialog* d = new SaveTemplateDialog (*_session);
|
||||||
prompter.set_title (_("Save Template"));
|
|
||||||
prompter.set_prompt (_("Name for template:"));
|
|
||||||
prompter.set_initial_text(_session->name() + _("-template"));
|
|
||||||
prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
|
|
||||||
|
|
||||||
bool finished = false;
|
d->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::save_template_dialog_response), d));
|
||||||
while (!finished) {
|
d->show ();
|
||||||
switch (prompter.run()) {
|
|
||||||
case RESPONSE_ACCEPT:
|
|
||||||
finished = process_save_template_prompter (prompter);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
finished = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARDOUR_UI::manage_templates ()
|
void ARDOUR_UI::manage_templates ()
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,7 @@ class MainClock;
|
||||||
class Mixer_UI;
|
class Mixer_UI;
|
||||||
class PublicEditor;
|
class PublicEditor;
|
||||||
class SaveAsDialog;
|
class SaveAsDialog;
|
||||||
|
class SaveTemplateDialog;
|
||||||
class SessionDialog;
|
class SessionDialog;
|
||||||
class SessionOptionEditorWindow;
|
class SessionOptionEditorWindow;
|
||||||
class Splash;
|
class Splash;
|
||||||
|
|
@ -621,7 +622,7 @@ private:
|
||||||
|
|
||||||
void open_session ();
|
void open_session ();
|
||||||
void open_recent_session ();
|
void open_recent_session ();
|
||||||
bool process_save_template_prompter (ArdourWidgets::Prompter& prompter);
|
void save_template_dialog_response (int response, SaveTemplateDialog* d);
|
||||||
void save_template ();
|
void save_template ();
|
||||||
void manage_templates ();
|
void manage_templates ();
|
||||||
|
|
||||||
|
|
|
||||||
71
gtk2_ardour/save_template_dialog.cc
Normal file
71
gtk2_ardour/save_template_dialog.cc
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2017 Paul Davis
|
||||||
|
Author: Johannes Mueller
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gtkmm/box.h>
|
||||||
|
#include <gtkmm/frame.h>
|
||||||
|
#include <gtkmm/label.h>
|
||||||
|
#include <gtkmm/stock.h>
|
||||||
|
|
||||||
|
#include "pbd/i18n.h"
|
||||||
|
#include "ardour/session.h"
|
||||||
|
|
||||||
|
#include "save_template_dialog.h"
|
||||||
|
|
||||||
|
using namespace Gtk;
|
||||||
|
using namespace ARDOUR;
|
||||||
|
|
||||||
|
SaveTemplateDialog::SaveTemplateDialog (const Session& s)
|
||||||
|
: ArdourDialog (_("Save as template"))
|
||||||
|
{
|
||||||
|
_name_editor.get_buffer()->set_text (s.name() + _("-template"));
|
||||||
|
_description_editor.set_wrap_mode (Gtk::WRAP_WORD);
|
||||||
|
_description_editor.set_size_request(400, 300);
|
||||||
|
|
||||||
|
HBox* hb = manage (new HBox);
|
||||||
|
hb->set_spacing (8);
|
||||||
|
Label* lb = manage (new Label(_("Template name:")));
|
||||||
|
hb->pack_start (*lb, false, true);
|
||||||
|
hb->pack_start (_name_editor, true, true);
|
||||||
|
|
||||||
|
Frame* fd = manage (new Frame(_("Description:")));
|
||||||
|
fd->add (_description_editor);
|
||||||
|
|
||||||
|
get_vbox()->set_spacing (8);
|
||||||
|
get_vbox()->pack_start (*fd);
|
||||||
|
get_vbox()->pack_start (*hb);
|
||||||
|
|
||||||
|
add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||||
|
add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
|
||||||
|
|
||||||
|
show_all_children ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string
|
||||||
|
SaveTemplateDialog::get_template_name () const
|
||||||
|
{
|
||||||
|
return _name_editor.get_buffer()->get_text();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string
|
||||||
|
SaveTemplateDialog::get_description () const
|
||||||
|
{
|
||||||
|
return _description_editor.get_buffer()->get_text();
|
||||||
|
}
|
||||||
47
gtk2_ardour/save_template_dialog.h
Normal file
47
gtk2_ardour/save_template_dialog.h
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2017 Paul Davis
|
||||||
|
Author: Johannes Mueller
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __ardour_gtk_save_template_dialog_h__
|
||||||
|
#define __ardour_gtk_save_template_dialog_h__
|
||||||
|
|
||||||
|
#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);
|
||||||
|
|
||||||
|
std::string get_template_name () const;
|
||||||
|
std::string get_description () const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Gtk::Entry _name_editor;
|
||||||
|
Gtk::TextView _description_editor;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __ardour_gtk_save_template_dialog_h__ */
|
||||||
|
|
@ -218,6 +218,7 @@ gtk2_ardour_sources = [
|
||||||
'route_ui.cc',
|
'route_ui.cc',
|
||||||
'ruler_dialog.cc',
|
'ruler_dialog.cc',
|
||||||
'save_as_dialog.cc',
|
'save_as_dialog.cc',
|
||||||
|
'save_template_dialog.cc',
|
||||||
'search_path_option.cc',
|
'search_path_option.cc',
|
||||||
'script_selector.cc',
|
'script_selector.cc',
|
||||||
'selection.cc',
|
'selection.cc',
|
||||||
|
|
|
||||||
|
|
@ -531,7 +531,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
|
||||||
int archive_session (const std::string&, const std::string&, ArchiveEncode compress_audio = FLAC_16BIT, bool only_used_sources = false, Progress* p = 0);
|
int archive_session (const std::string&, const std::string&, ArchiveEncode compress_audio = FLAC_16BIT, bool only_used_sources = false, Progress* p = 0);
|
||||||
|
|
||||||
int restore_state (std::string snapshot_name);
|
int restore_state (std::string snapshot_name);
|
||||||
int save_template (std::string template_name, bool replace_existing = false);
|
int save_template (const std::string& template_name, const std::string& description = "", bool replace_existing = false);
|
||||||
int save_history (std::string snapshot_name = "");
|
int save_history (std::string snapshot_name = "");
|
||||||
int restore_history (std::string snapshot_name);
|
int restore_history (std::string snapshot_name);
|
||||||
void remove_state (std::string snapshot_name);
|
void remove_state (std::string snapshot_name);
|
||||||
|
|
|
||||||
|
|
@ -2356,7 +2356,7 @@ Session::XMLSourceFactory (const XMLNode& node)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Session::save_template (string template_name, bool replace_existing)
|
Session::save_template (const string& template_name, const string& description, bool replace_existing)
|
||||||
{
|
{
|
||||||
if ((_state_of_the_state & CannotSave) || template_name.empty ()) {
|
if ((_state_of_the_state & CannotSave) || template_name.empty ()) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -2411,12 +2411,22 @@ Session::save_template (string template_name, bool replace_existing)
|
||||||
SessionSaveUnderway (); /* EMIT SIGNAL */
|
SessionSaveUnderway (); /* EMIT SIGNAL */
|
||||||
|
|
||||||
XMLTree tree;
|
XMLTree tree;
|
||||||
|
XMLNode* root;
|
||||||
{
|
{
|
||||||
PBD::Unwinder<std::string> uw (_template_state_dir, template_dir_path);
|
PBD::Unwinder<std::string> uw (_template_state_dir, template_dir_path);
|
||||||
tree.set_root (&get_template());
|
root = &get_template();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!description.empty()) {
|
||||||
|
XMLNode* desc = new XMLNode(X_("description"));
|
||||||
|
XMLNode* desc_cont = new XMLNode(X_("content"), description);
|
||||||
|
desc->add_child_nocopy (*desc_cont);
|
||||||
|
|
||||||
|
root->add_child_nocopy (*desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
tree.set_root (root);
|
||||||
|
|
||||||
if (!tree.write (template_file_path)) {
|
if (!tree.write (template_file_path)) {
|
||||||
error << _("template not saved") << endmsg;
|
error << _("template not saved") << endmsg;
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue