2 Copyright (C) 2010 Paul Davis
3 Author: Johannes Mueller
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include <glib/gstdio.h>
27 #include <gtkmm/filechooserdialog.h>
28 #include <gtkmm/frame.h>
29 #include <gtkmm/liststore.h>
30 #include <gtkmm/notebook.h>
31 #include <gtkmm/progressbar.h>
32 #include <gtkmm/separator.h>
33 #include <gtkmm/scrolledwindow.h>
34 #include <gtkmm/stock.h>
35 #include <gtkmm/textview.h>
36 #include <gtkmm/treeiter.h>
37 #include <gtkmm/treeview.h>
39 #include "pbd/basename.h"
40 #include "pbd/error.h"
41 #include "pbd/file_archive.h"
42 #include "pbd/file_utils.h"
44 #include "pbd/xml++.h"
46 #include "gtkmm2ext/gui_thread.h"
48 #include "ardour/filesystem_paths.h"
49 #include "ardour/template_utils.h"
51 #include "progress_reporter.h"
53 #include "template_dialog.h"
58 using namespace ARDOUR;
60 class TemplateManager : public Gtk::HBox,
61 public ProgressReporter
64 virtual ~TemplateManager () {}
67 void handle_dirty_description ();
69 PBD::Signal0<void> TemplatesImported;
74 void setup_model (const std::vector<ARDOUR::TemplateInfo>& templates);
76 void row_selection_changed ();
78 virtual void delete_selected_template () = 0;
79 bool adjust_plugin_paths (XMLNode* node, const std::string& name, const std::string& new_name) const;
81 struct SessionTemplateColumns : public Gtk::TreeModel::ColumnRecord {
82 SessionTemplateColumns () {
88 Gtk::TreeModelColumn<std::string> name;
89 Gtk::TreeModelColumn<std::string> path;
90 Gtk::TreeModelColumn<std::string> description;
93 Glib::RefPtr<Gtk::ListStore> _template_model;
94 SessionTemplateColumns _template_columns;
96 Gtk::TreeModel::const_iterator _current_selection;
98 Gtk::ProgressBar _progress_bar;
99 std::string _current_action;
102 void render_template_names (Gtk::CellRenderer* rnd, const Gtk::TreeModel::iterator& it);
103 void validate_edit (const Glib::ustring& path_string, const Glib::ustring& new_name);
106 void set_desc_dirty ();
108 bool key_event (GdkEventKey* ev);
110 virtual void get_templates (vector<TemplateInfo>& templates) const = 0;
112 virtual void rename_template (Gtk::TreeModel::iterator& item, const Glib::ustring& new_name) = 0;
114 virtual void save_template_desc ();
116 void export_all_templates ();
117 void import_template_set ();
119 virtual std::string templates_dir () const = 0;
120 virtual std::string template_file (const Gtk::TreeModel::const_iterator& item) const = 0;
122 virtual bool adjust_xml_tree (XMLTree& tree, const std::string& old_name, const std::string& new_name) const = 0;
124 Gtk::TreeView _template_treeview;
125 Gtk::CellRendererText _validating_cellrenderer;
126 Gtk::TreeView::Column _validated_column;
128 Gtk::TextView _description_editor;
129 Gtk::Button _save_desc;
132 Gtk::Button _remove_button;
133 Gtk::Button _rename_button;
135 Gtk::Button _export_all_templates_button;
136 Gtk::Button _import_template_set_button;
138 void update_progress_gui (float p);
141 class SessionTemplateManager : public TemplateManager
144 SessionTemplateManager () : TemplateManager () {}
145 ~SessionTemplateManager () {}
147 void get_templates (vector<TemplateInfo>& templates) const;
150 void rename_template (Gtk::TreeModel::iterator& item, const Glib::ustring& new_name);
151 void delete_selected_template ();
153 std::string templates_dir () const;
154 std::string template_file (const Gtk::TreeModel::const_iterator& item) const;
156 bool adjust_xml_tree (XMLTree& tree, const std::string& old_name, const std::string& new_name) const;
160 class RouteTemplateManager : public TemplateManager
163 RouteTemplateManager () : TemplateManager () {}
164 ~RouteTemplateManager () {}
166 void get_templates (vector<TemplateInfo>& templates) const;
169 void rename_template (Gtk::TreeModel::iterator& item, const Glib::ustring& new_name);
170 void delete_selected_template ();
172 std::string templates_dir () const;
173 std::string template_file (const Gtk::TreeModel::const_iterator& item) const;
175 bool adjust_xml_tree (XMLTree& tree, const std::string& old_name, const std::string& new_name) const;
180 TemplateDialog::TemplateDialog ()
181 : ArdourDialog ("Manage Templates")
183 Notebook* nb = manage (new Notebook);
185 SessionTemplateManager* session_tm = manage (new SessionTemplateManager);
186 nb->append_page (*session_tm, _("Session Templates"));
188 RouteTemplateManager* route_tm = manage (new RouteTemplateManager);
189 nb->append_page (*route_tm, _("Track Templates"));
191 get_vbox()->pack_start (*nb);
192 add_button (_("Ok"), Gtk::RESPONSE_OK);
194 get_vbox()->show_all();
199 session_tm->TemplatesImported.connect (*this, invalidator (*this), boost::bind (&RouteTemplateManager::init, route_tm), gui_context ());
200 route_tm->TemplatesImported.connect (*this, invalidator (*this), boost::bind (&SessionTemplateManager::init, session_tm), gui_context ());
202 signal_hide().connect (sigc::mem_fun (session_tm, &TemplateManager::handle_dirty_description));
203 signal_hide().connect (sigc::mem_fun (route_tm, &TemplateManager::handle_dirty_description));
204 nb->signal_switch_page().connect (boost::bind (&TemplateManager::handle_dirty_description, session_tm));
205 nb->signal_switch_page().connect (boost::bind (&TemplateManager::handle_dirty_description, route_tm));
208 TemplateManager::TemplateManager ()
210 , ProgressReporter ()
211 , _save_desc (_("Save Description"))
212 , _desc_dirty (false)
213 , _remove_button (_("Remove"))
214 , _rename_button (_("Rename"))
215 , _export_all_templates_button (_("Export all"))
216 , _import_template_set_button (_("Import"))
218 _template_model = ListStore::create (_template_columns);
219 _template_treeview.set_model (_template_model);
221 _validated_column.set_title (_("Template Name"));
222 _validated_column.pack_start (_validating_cellrenderer);
223 _template_treeview.append_column (_validated_column);
224 _validating_cellrenderer.property_editable() = true;
226 _validated_column.set_cell_data_func (_validating_cellrenderer, sigc::mem_fun (*this, &TemplateManager::render_template_names));
227 _validating_cellrenderer.signal_edited().connect (sigc::mem_fun (*this, &TemplateManager::validate_edit));
228 _template_treeview.signal_cursor_changed().connect (sigc::mem_fun (*this, &TemplateManager::row_selection_changed));
229 _template_treeview.signal_key_press_event().connect (sigc::mem_fun (*this, &TemplateManager::key_event));
231 ScrolledWindow* sw = manage (new ScrolledWindow);
232 sw->property_hscrollbar_policy() = POLICY_AUTOMATIC;
233 sw->add (_template_treeview);
234 sw->set_size_request (300, 200);
236 VBox* vb_btns = manage (new VBox);
237 vb_btns->set_spacing (4);
238 vb_btns->pack_start (_rename_button, false, false);
239 vb_btns->pack_start (_remove_button, false, false);
240 vb_btns->pack_start (_save_desc, false, false);
242 _rename_button.set_sensitive (false);
243 _rename_button.signal_clicked().connect (sigc::mem_fun (*this, &TemplateManager::start_edit));
244 _remove_button.set_sensitive (false);
245 _remove_button.signal_clicked().connect (sigc::mem_fun (*this, &TemplateManager::delete_selected_template));
247 vb_btns->pack_start (*(manage (new VSeparator ())));
249 vb_btns->pack_start (_export_all_templates_button, false, false);
250 vb_btns->pack_start (_import_template_set_button, false, false);
252 _export_all_templates_button.set_sensitive (false);
253 _export_all_templates_button.signal_clicked().connect (sigc::mem_fun (*this, &TemplateManager::export_all_templates));
255 _import_template_set_button.set_sensitive (true);
256 _import_template_set_button.signal_clicked().connect (sigc::mem_fun (*this, &TemplateManager::import_template_set));
260 VBox* vb = manage (new VBox);
261 vb->pack_start (*sw);
262 vb->pack_start (_progress_bar);
264 Frame* desc_frame = manage (new Frame (_("Description")));
266 _description_editor.set_wrap_mode (Gtk::WRAP_WORD);
267 _description_editor.set_size_request (300,400);
268 _description_editor.set_border_width (6);
270 _save_desc.set_sensitive (false);
271 _save_desc.signal_clicked().connect (sigc::mem_fun (*this, &TemplateManager::save_template_desc));
273 _description_editor.get_buffer()->signal_changed().connect (sigc::mem_fun (*this, &TemplateManager::set_desc_dirty));
275 desc_frame->add (_description_editor);
278 pack_start (*desc_frame);
279 pack_start (*vb_btns);
281 show_all_children ();
282 _progress_bar.hide ();
286 TemplateManager::init ()
288 vector<TemplateInfo> templates;
289 get_templates (templates);
290 setup_model (templates);
292 _progress_bar.hide ();
293 _description_editor.set_sensitive (false);
294 _save_desc.set_sensitive (false);
298 TemplateManager::setup_model (const vector<TemplateInfo>& templates)
300 _template_model->clear ();
302 for (vector<TemplateInfo>::const_iterator it = templates.begin(); it != templates.end(); ++it) {
304 row = *(_template_model->append ());
306 row[_template_columns.name] = it->name;
307 row[_template_columns.path] = it->path;
308 row[_template_columns.description] = it->description;
311 _export_all_templates_button.set_sensitive (!templates.empty ());
315 TemplateManager::handle_dirty_description ()
317 if (_desc_dirty && _current_selection) {
318 ArdourDialog dlg (_("Description not saved"), true);
319 const string name = _current_selection->get_value (_template_columns.name);
320 Label msg (string_compose (_("The discription of template \"%1\" has been modfied but has not been saved yet.\n"
321 "Do you want to save it?"), name));
322 dlg.get_vbox()->pack_start (msg);
324 dlg.add_button (_("Save"), RESPONSE_ACCEPT);
325 dlg.add_button (_("Discard"), RESPONSE_REJECT);
326 dlg.set_default_response (RESPONSE_REJECT);
328 int response = dlg.run ();
330 if (response == RESPONSE_ACCEPT) {
331 save_template_desc ();
333 _description_editor.get_buffer()->set_text (_current_selection->get_value (_template_columns.description));
341 TemplateManager::row_selection_changed ()
343 if (_current_selection) {
344 handle_dirty_description ();
346 _description_editor.get_buffer()->set_text ("");
350 _current_selection = _template_treeview.get_selection()->get_selected ();
351 if (_current_selection) {
352 const string desc = _current_selection->get_value (_template_columns.description);
353 _description_editor.get_buffer()->set_text (desc);
355 _save_desc.set_sensitive (false);
358 _description_editor.set_sensitive (_current_selection);
359 _rename_button.set_sensitive (_current_selection);
360 _remove_button.set_sensitive (_current_selection);
364 TemplateManager::render_template_names (Gtk::CellRenderer*, const Gtk::TreeModel::iterator& it)
367 _validating_cellrenderer.property_text () = it->get_value (_template_columns.name);
372 TemplateManager::validate_edit (const Glib::ustring& path_string, const Glib::ustring& new_name)
374 const TreePath path (path_string);
375 TreeModel::iterator current = _template_model->get_iter (path);
377 if (current->get_value (_template_columns.name) == new_name) {
381 TreeModel::Children rows = _template_model->children ();
384 for (TreeModel::Children::const_iterator it = rows.begin(); it != rows.end(); ++it) {
385 if (it->get_value (_template_columns.name) == new_name) {
392 error << string_compose (_("Template of name \"%1\" already exists"), new_name) << endmsg;
397 rename_template (current, new_name);
401 TemplateManager::start_edit ()
403 TreeModel::Path path;
405 _template_treeview.get_cursor (path, col);
406 _template_treeview.set_cursor (path, *col, /*set_editing =*/ true);
410 TemplateManager::set_desc_dirty ()
413 _save_desc.set_sensitive (true);
417 TemplateManager::save_template_desc ()
419 const string file_path = template_file (_current_selection);
421 const string desc_txt = _description_editor.get_buffer()->get_text ();
422 _current_selection->set_value (_template_columns.description, desc_txt);
426 if (!tree.read(file_path)) {
427 error << string_compose (_("Could not parse template file \"%1\"."), file_path) << endmsg;
431 tree.root()->remove_nodes (X_("description"));
432 XMLNode* desc = new XMLNode (X_("description"));
434 XMLNode* dn = new XMLNode (X_("content"), desc_txt);
435 desc->add_child_nocopy (*dn);
437 tree.root()->add_child_nocopy (*desc);
439 if (!tree.write ()) {
440 error << string_compose(X_("Could not write to template file \"%1\"."), file_path) << endmsg;
444 _save_desc.set_sensitive (false);
449 TemplateManager::key_event (GdkEventKey* ev)
451 if (ev->keyval == GDK_KEY_F2) {
455 if (ev->keyval == GDK_KEY_Delete) {
456 delete_selected_template ();
464 bool accept_all_files (string const &, void *)
469 static void _set_progress (Progress* p, size_t n, size_t t)
471 p->set_progress (float (n) / float(t));
476 TemplateManager::export_all_templates ()
479 char* td = g_dir_make_tmp ("ardour-templates-XXXXXX", &err);
482 error << string_compose(_("Could not make tmpdir: %1"), err->message) << endmsg;
485 const string tmpdir (td);
487 g_clear_error (&err);
489 FileChooserDialog dialog(_("Save Exported Template Archive"), FILE_CHOOSER_ACTION_SAVE);
490 dialog.set_filename (X_("templates.tar.xz"));
492 dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
493 dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
495 FileFilter archive_filter;
496 archive_filter.add_pattern (X_("*.tar.xz"));
497 archive_filter.set_name (_("Template archives"));
498 dialog.add_filter (archive_filter);
500 int result = dialog.run ();
502 if (result != RESPONSE_OK || !dialog.get_filename().length()) {
503 PBD::remove_directory (tmpdir);
507 string filename = dialog.get_filename ();
508 if (filename.compare (filename.size () - 7, 7, ".tar.xz")) {
509 filename += ".tar.xz";
512 if (g_file_test (filename.c_str(), G_FILE_TEST_EXISTS)) {
513 ArdourDialog dlg (_("File exists"), true);
514 Label msg (string_compose (_("The file %1 already exists."), filename));
515 dlg.get_vbox()->pack_start (msg);
517 dlg.add_button (_("Overwrite"), RESPONSE_ACCEPT);
518 dlg.add_button (_("Cancel"), RESPONSE_REJECT);
519 dlg.set_default_response (RESPONSE_REJECT);
523 if (result == RESPONSE_REJECT) {
524 PBD::remove_directory (tmpdir);
529 PBD::copy_recurse (templates_dir (), Glib::build_filename (tmpdir, Glib::path_get_basename (templates_dir ())));
531 vector<string> files;
532 PBD::find_files_matching_regex (files, tmpdir, string ("\\.template$"), /* recurse = */ true);
534 vector<string>::const_iterator it;
535 for (it = files.begin(); it != files.end(); ++it) {
536 const string bn = PBD::basename_nosuffix (*it);
537 const string old_path = Glib::build_filename (templates_dir (), bn);
538 const string new_path = Glib::build_filename ("$TEMPLATEDIR", bn);
541 if (!tree.read (*it)) {
544 if (adjust_xml_tree (tree, old_path, new_path)) {
549 find_files_matching_filter (files, tmpdir, accept_all_files, 0, false, true, true);
551 std::map<std::string, std::string> filemap;
552 for (it = files.begin(); it != files.end(); ++it) {
553 filemap[*it] = it->substr (tmpdir.size()+1, it->size() - tmpdir.size() - 1);
556 _current_action = _("Exporting templates");
558 PBD::FileArchive ar (filename);
559 PBD::ScopedConnectionList progress_connection;
560 ar.progress.connect_same_thread (progress_connection, boost::bind (&_set_progress, this, _1, _2));
563 PBD::remove_directory (tmpdir);
567 TemplateManager::import_template_set ()
569 FileChooserDialog dialog (_("Import template archives"));
570 dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
571 dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
573 FileFilter archive_filter;
574 archive_filter.add_pattern (X_("*.tar.xz"));
575 archive_filter.set_name (_("Template archives"));
576 dialog.add_filter (archive_filter);
578 int result = dialog.run ();
580 if (result != RESPONSE_OK || !dialog.get_filename().length()) {
584 _current_action = _("Importing templates");
586 FileArchive ar (dialog.get_filename ());
587 PBD::ScopedConnectionList progress_connection;
588 ar.progress.connect_same_thread (progress_connection, boost::bind (&_set_progress, this, _1, _2));
589 ar.inflate (user_config_directory ());
591 vector<string> files;
592 PBD::find_files_matching_regex (files, templates_dir (), string ("\\.template$"), /* recurse = */ true);
594 vector<string>::const_iterator it;
595 for (it = files.begin(); it != files.end(); ++it) {
596 const string bn = PBD::basename_nosuffix (*it);
597 const string old_path = Glib::build_filename ("$TEMPLATEDIR", bn);
598 const string new_path = Glib::build_filename (templates_dir (), bn);
601 if (!tree.read (*it)) {
604 if (adjust_xml_tree (tree, old_path, new_path)) {
610 TemplatesImported (); /* emit signal */
614 TemplateManager::adjust_plugin_paths (XMLNode* node, const string& name, const string& new_name) const
616 bool adjusted = false;
618 const XMLNodeList& procs = node->children (X_("Processor"));
619 XMLNodeConstIterator pit;
620 for (pit = procs.begin(); pit != procs.end(); ++pit) {
621 XMLNode* lv2_node = (*pit)->child (X_("lv2"));
627 if (!lv2_node->get_property (X_("template-dir"), template_dir)) {
631 const int suffix_pos = template_dir.size() - name.size();
632 if (suffix_pos < 0) {
633 cerr << "Template name\"" << name << "\" longer than template-dir \"" << template_dir << "\", WTH?" << endl;
637 if (template_dir.compare (suffix_pos, template_dir.size(), name)) {
638 cerr << "Template name \"" << name << "\" no suffix of template-dir \"" << template_dir << "\"" << endl;
642 const string new_template_dir = template_dir.substr (0, suffix_pos) + new_name;
643 lv2_node->set_property (X_("template-dir"), new_template_dir);
652 TemplateManager::update_progress_gui (float p)
655 _progress_bar.hide ();
659 _progress_bar.show ();
660 _progress_bar.set_text (_current_action);
661 _progress_bar.set_fraction (p);
665 SessionTemplateManager::get_templates (vector<TemplateInfo>& templates) const
667 find_session_templates (templates, /* read_xml = */ true);
670 void RouteTemplateManager::get_templates (vector<TemplateInfo>& templates) const
672 find_route_templates (templates);
678 SessionTemplateManager::rename_template (TreeModel::iterator& item, const Glib::ustring& new_name_)
680 const string old_path = item->get_value (_template_columns.path);
681 const string old_name = item->get_value (_template_columns.name);
682 const string new_name = string (new_name_);
684 const string old_file_old_path = Glib::build_filename (old_path, old_name+".template");
688 if (!tree.read(old_file_old_path)) {
689 error << string_compose (_("Could not parse template file \"%1\"."), old_file_old_path) << endmsg;
692 XMLNode* root = tree.root();
694 const XMLNode* const routes_node = root->child (X_("Routes"));
696 const XMLNodeList& routes = routes_node->children (X_("Route"));
697 XMLNodeConstIterator rit;
698 for (rit = routes.begin(); rit != routes.end(); ++rit) {
699 adjust_plugin_paths (*rit, old_name, new_name);
703 const string new_file_old_path = Glib::build_filename (old_path, new_name+".template");
705 tree.set_filename (new_file_old_path);
707 if (!tree.write ()) {
708 error << string_compose(_("Could not write to new template file \"%1\"."), new_file_old_path);
712 const string new_path = Glib::build_filename (user_template_directory (), new_name);
714 if (g_rename (old_path.c_str(), new_path.c_str()) != 0) {
715 error << string_compose (_("Could not rename template directory from \"%1\" to \"%2\": %3"),
716 old_path, new_path, strerror (errno)) << endmsg;
717 g_unlink (new_file_old_path.c_str());
721 const string old_file_new_path = Glib::build_filename (new_path, old_name+".template");
722 if (g_unlink (old_file_new_path.c_str())) {
723 error << string_compose (X_("Could not delete old template file \"%1\": %2"),
724 old_file_new_path, strerror (errno)) << endmsg;
727 item->set_value (_template_columns.name, new_name);
728 item->set_value (_template_columns.path, new_path);
732 SessionTemplateManager::delete_selected_template ()
734 if (!_current_selection) {
738 PBD::remove_directory (_current_selection->get_value (_template_columns.path));
740 _template_model->erase (_current_selection);
741 _current_selection = TreeIter ();
742 row_selection_changed ();
746 SessionTemplateManager::templates_dir () const
748 return user_template_directory ();
753 SessionTemplateManager::template_file (const TreeModel::const_iterator& item) const
755 const string path = item->get_value (_template_columns.path);
756 const string name = item->get_value (_template_columns.name);
757 return Glib::build_filename (path, name+".template");
761 SessionTemplateManager::adjust_xml_tree (XMLTree& tree, const std::string& old_name, const std::string& new_name) const
763 bool adjusted = false;
764 XMLNode* root = tree.root();
766 const XMLNode* const routes_node = root->child (X_("Routes"));
768 const XMLNodeList& routes = routes_node->children (X_("Route"));
769 XMLNodeConstIterator rit;
770 for (rit = routes.begin(); rit != routes.end(); ++rit) {
771 if (adjust_plugin_paths (*rit, old_name, new_name)) {
782 RouteTemplateManager::rename_template (TreeModel::iterator& item, const Glib::ustring& new_name)
784 const string old_name = item->get_value (_template_columns.name);
785 const string old_filepath = item->get_value (_template_columns.path);
786 const string new_filepath = Glib::build_filename (user_route_template_directory(), new_name+".template");
789 if (!tree.read (old_filepath)) {
790 error << string_compose (_("Could not parse template file \"%1\"."), old_filepath) << endmsg;
793 tree.root()->set_property (X_("name"), new_name);
794 tree.root()->children().front()->set_property (X_("name"), new_name);
796 const bool adjusted = adjust_plugin_paths (tree.root(), old_name, string (new_name));
798 const string old_state_dir = Glib::build_filename (user_route_template_directory(), old_name);
799 const string new_state_dir = Glib::build_filename (user_route_template_directory(), new_name);
802 if (g_file_test (old_state_dir.c_str(), G_FILE_TEST_EXISTS)) {
803 if (g_rename (old_state_dir.c_str(), new_state_dir.c_str()) != 0) {
804 error << string_compose (_("Could not rename state dir \"%1\" to \"%22\": %3"), old_state_dir, new_state_dir, strerror (errno)) << endmsg;
810 tree.set_filename (new_filepath);
812 if (!tree.write ()) {
813 error << string_compose(_("Could not write new template file \"%1\"."), new_filepath) << endmsg;
815 g_rename (new_state_dir.c_str(), old_state_dir.c_str());
820 if (g_unlink (old_filepath.c_str()) != 0) {
821 error << string_compose (_("Could not remove old template file \"%1\": %2"), old_filepath, strerror (errno)) << endmsg;
824 item->set_value (_template_columns.name, string (new_name));
825 item->set_value (_template_columns.path, new_filepath);
829 RouteTemplateManager::delete_selected_template ()
831 if (!_current_selection) {
835 const string file_path = _current_selection->get_value (_template_columns.path);
837 if (g_unlink (file_path.c_str()) != 0) {
838 error << string_compose(_("Could not delete template file \"%1\": %2"), file_path, strerror (errno)) << endmsg;
841 PBD::remove_directory (Glib::build_filename (user_route_template_directory (),
842 _current_selection->get_value (_template_columns.name)));
844 _template_model->erase (_current_selection);
845 row_selection_changed ();
849 RouteTemplateManager::templates_dir () const
851 return user_route_template_directory ();
856 RouteTemplateManager::template_file (const TreeModel::const_iterator& item) const
858 return item->get_value (_template_columns.path);
862 RouteTemplateManager::adjust_xml_tree (XMLTree& tree, const std::string& old_name, const std::string& new_name) const
864 return adjust_plugin_paths (tree.root(), old_name, string (new_name));