Adjust template names inside template files
[ardour.git] / gtk2_ardour / template_dialog.h
1 /*
2     Copyright (C) 2010 Paul Davis
3     Author: Johannes Mueller
4
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.
9
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.
14
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.
18
19 */
20
21 #ifndef __gtk2_ardour_template_dialog_h__
22 #define __gtk2_ardour_template_dialog_h__
23
24 #include <vector>
25
26 #include <gtkmm/liststore.h>
27 #include <gtkmm/treeview.h>
28
29 #include "ardour_dialog.h"
30
31 namespace ARDOUR {
32         struct TemplateInfo;
33 }
34
35 class XMLNode;
36
37 class TemplateDialog : public ArdourDialog
38 {
39 public:
40         TemplateDialog ();
41         ~TemplateDialog () {}
42 };
43
44 class TemplateManager : public Gtk::HBox
45 {
46 public:
47         virtual ~TemplateManager () {}
48         virtual void init () = 0;
49
50 protected:
51         TemplateManager ();
52
53         void setup_model (const std::vector<ARDOUR::TemplateInfo>& templates);
54
55         void row_selection_changed ();
56         void render_template_names (Gtk::CellRenderer* rnd, const Gtk::TreeModel::iterator& it);
57         void validate_edit (const Glib::ustring& path_string, const Glib::ustring& new_name);
58         void start_edit ();
59
60         bool key_event (GdkEventKey* ev);
61
62         virtual void rename_template (Gtk::TreeModel::iterator& item, const Glib::ustring& new_name) = 0;
63         virtual void delete_selected_template () = 0;
64
65         bool adjust_plugin_paths (XMLNode* node, const std::string& name, const std::string& new_name) const;
66
67         struct SessionTemplateColumns : public Gtk::TreeModel::ColumnRecord {
68                 SessionTemplateColumns () {
69                         add (name);
70                         add (path);
71                 }
72
73                 Gtk::TreeModelColumn<std::string> name;
74                 Gtk::TreeModelColumn<std::string> path;
75         };
76
77         SessionTemplateColumns _template_columns;
78         Glib::RefPtr<Gtk::ListStore>  _template_model;
79
80         Gtk::TreeView _template_treeview;
81         Gtk::CellRendererText _validating_cellrenderer;
82         Gtk::TreeView::Column _validated_column;
83
84         Gtk::Button _remove_button;
85         Gtk::Button _rename_button;
86 };
87
88 class SessionTemplateManager : public TemplateManager
89 {
90 public:
91         SessionTemplateManager () : TemplateManager () {}
92         ~SessionTemplateManager () {}
93
94         void init ();
95
96 private:
97         void rename_template (Gtk::TreeModel::iterator& item, const Glib::ustring& new_name);
98         void delete_selected_template ();
99 };
100
101
102 class RouteTemplateManager : public TemplateManager
103 {
104 public:
105         RouteTemplateManager () : TemplateManager () {}
106         ~RouteTemplateManager () {}
107
108         void init ();
109
110 private:
111         void rename_template (Gtk::TreeModel::iterator& item, const Glib::ustring& new_name);
112         void delete_selected_template ();
113 };
114
115
116 #endif /* __gtk2_ardour_template_dialog_h__ */