2e7f2e454a376b9b3785f0a754ce8eb6c1abf4a1
[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 TemplateDialog : public ArdourDialog
36 {
37 public:
38         TemplateDialog ();
39         ~TemplateDialog () {}
40 };
41
42 class TemplateManager : public Gtk::HBox
43 {
44 public:
45         virtual ~TemplateManager () {}
46         virtual void init () = 0;
47
48 protected:
49         TemplateManager ();
50
51         void setup_model (const std::vector<ARDOUR::TemplateInfo>& templates);
52
53         void row_selection_changed ();
54         void render_template_names (Gtk::CellRenderer* rnd, const Gtk::TreeModel::iterator& it);
55         void validate_edit (const Glib::ustring& path_string, const Glib::ustring& new_name);
56         void start_edit ();
57
58         bool key_event (GdkEventKey* ev);
59
60         virtual void rename_template (Gtk::TreeModel::iterator& item, const Glib::ustring& new_name) = 0;
61         virtual void delete_selected_template () = 0;
62
63         struct SessionTemplateColumns : public Gtk::TreeModel::ColumnRecord {
64                 SessionTemplateColumns () {
65                         add (name);
66                         add (path);
67                 }
68
69                 Gtk::TreeModelColumn<std::string> name;
70                 Gtk::TreeModelColumn<std::string> path;
71         };
72
73         SessionTemplateColumns _template_columns;
74         Glib::RefPtr<Gtk::ListStore>  _template_model;
75
76         Gtk::TreeView _template_treeview;
77         Gtk::CellRendererText _validating_cellrenderer;
78         Gtk::TreeView::Column _validated_column;
79
80         Gtk::Button _remove_button;
81         Gtk::Button _rename_button;
82 };
83
84 class SessionTemplateManager : public TemplateManager
85 {
86 public:
87         SessionTemplateManager () : TemplateManager () {}
88         ~SessionTemplateManager () {}
89
90         void init ();
91
92 private:
93         void rename_template (Gtk::TreeModel::iterator& item, const Glib::ustring& new_name);
94         void delete_selected_template ();
95 };
96
97
98 class RouteTemplateManager : public TemplateManager
99 {
100 public:
101         RouteTemplateManager () : TemplateManager () {}
102         ~RouteTemplateManager () {}
103
104         void init ();
105
106 private:
107         void rename_template (Gtk::TreeModel::iterator& item, const Glib::ustring& new_name);
108         void delete_selected_template ();
109 };
110
111
112 #endif /* __gtk2_ardour_template_dialog_h__ */