Add support for scripted meta-templates.
[ardour.git] / gtk2_ardour / session_dialog.h
1 /*
2     Copyright (C) 2010 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __gtk2_ardour_session_dialog_h__
21 #define __gtk2_ardour_session_dialog_h__
22
23 #include <string>
24
25 #include <gdkmm/pixbuf.h>
26 #include <gtkmm/label.h>
27 #include <gtkmm/drawingarea.h>
28 #include <gtkmm/expander.h>
29 #include <gtkmm/box.h>
30 #include <gtkmm/radiobutton.h>
31 #include <gtkmm/filechooserbutton.h>
32 #include <gtkmm/scrolledwindow.h>
33 #include <gtkmm/treeview.h>
34 #include <gtkmm/treestore.h>
35 #include <gtkmm/checkbutton.h>
36 #include <gtkmm/table.h>
37 #include <gtkmm/frame.h>
38 #include <gtkmm/spinbutton.h>
39 #include <gtkmm/liststore.h>
40 #include <gtkmm/combobox.h>
41
42 #include "ardour/utils.h"
43
44 #include "ardour_dialog.h"
45
46 class EngineControl;
47
48 class SessionDialog : public ArdourDialog
49 {
50 public:
51         SessionDialog (bool require_new, const std::string& session_name, const std::string& session_path,
52                        const std::string& template_name, bool cancel_not_quit);
53         SessionDialog ();
54         ~SessionDialog ();
55
56         void clear_given ();
57
58         std::string session_name (bool& should_be_new);
59         std::string session_folder ();
60
61         bool use_session_template();
62         std::string session_template_name();
63
64         // advanced session options
65
66         bool create_master_bus() const;
67         int master_channel_count() const;
68
69         bool connect_inputs() const;
70         bool limit_inputs_used_for_connection() const;
71         int input_limit_count() const;
72
73         bool connect_outputs() const;
74         bool limit_outputs_used_for_connection() const;
75         int output_limit_count() const;
76
77         bool connect_outs_to_master() const;
78         bool connect_outs_to_physical() const;
79
80         void set_provided_session(const std::string& session_name, const std::string& session_path) {
81                 _provided_session_name = session_name;
82                 _provided_session_path = session_path;
83         }
84
85 private:
86         bool new_only;
87         std::string _provided_session_name;
88         std::string _provided_session_path;
89
90         bool on_delete_event (GdkEventAny*);
91
92         Gtk::Button* cancel_button;
93         Gtk::Button* open_button;
94         Gtk::Button* back_button;
95         Gtk::Button* quit_button;
96
97         bool back_button_pressed (GdkEventButton*);
98         bool open_button_pressed (GdkEventButton*);
99
100         Gtk::Frame info_frame;
101
102         /* initial choice page */
103
104         void setup_initial_choice_box ();
105         void setup_recent_sessions ();
106         Gtk::VBox ic_vbox;
107         Gtk::Button ic_new_session_button;
108         void new_session_button_clicked ();
109
110         /* recent sessions */
111
112         void setup_existing_session_page ();
113
114         struct RecentSessionsSorter
115         {
116                 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
117                         return ARDOUR::cmp_nocase(a.first, b.first) == -1;
118                 }
119         };
120
121         struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
122                 RecentSessionModelColumns()
123                 {
124                         add (visible_name);
125                         add (tip);
126                         add (fullpath);
127                         add (sample_rate);
128                         add (disk_format);
129                         add (time_modified);
130                         add (time_formatted);
131                 }
132                 Gtk::TreeModelColumn<std::string> visible_name;
133                 Gtk::TreeModelColumn<std::string> tip;
134                 Gtk::TreeModelColumn<std::string> fullpath;
135                 Gtk::TreeModelColumn<std::string> sample_rate;
136                 Gtk::TreeModelColumn<std::string> disk_format;
137                 Gtk::TreeModelColumn<int64_t>     time_modified;
138                 Gtk::TreeModelColumn<std::string> time_formatted;
139         };
140
141         RecentSessionModelColumns    recent_session_columns;
142         Gtk::TreeView                recent_session_display;
143         Glib::RefPtr<Gtk::TreeStore> recent_session_model;
144         Gtk::ScrolledWindow          recent_scroller;
145         Gtk::Label                   recent_label;
146         Gtk::FileChooserButton       existing_session_chooser;
147         int redisplay_recent_sessions ();
148         void recent_session_row_selected ();
149         void recent_session_sort_changed ();
150         void recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
151         bool recent_button_press (GdkEventButton*);
152         void recent_context_mennu (GdkEventButton*);
153         void recent_remove_selected ();
154
155         void existing_session_selected ();
156         void session_selected ();
157
158         /* new sessions */
159
160         void setup_new_session_page ();
161         Gtk::Entry new_name_entry;
162         Gtk::FileChooserButton new_folder_chooser;
163
164         struct SessionTemplateColumns : public Gtk::TreeModel::ColumnRecord {
165                 SessionTemplateColumns () {
166                         add (name);
167                         add (path);
168                         add (desc);
169                 }
170
171                 Gtk::TreeModelColumn<std::string> name;
172                 Gtk::TreeModelColumn<std::string> path;
173                 Gtk::TreeModelColumn<std::string> desc;
174         };
175
176         SessionTemplateColumns session_template_columns;
177         Glib::RefPtr<Gtk::ListStore>  template_model;
178         Gtk::ComboBox template_chooser;
179
180         Gtk::VBox session_new_vbox;
181         Gtk::VBox session_existing_vbox;
182         Gtk::Expander more_new_session_options_button;
183         Gtk::CheckButton use_template_button;
184         std::string load_template_override;
185
186         void template_checkbox_toggled ();
187
188         void more_new_session_options_button_clicked();
189         void new_name_changed ();
190         void new_name_activated ();
191         void populate_session_templates ();
192
193         /* more options for new sessions */
194
195         Gtk::VBox more_options_vbox;
196
197         Gtk::Label chan_count_label_1;
198         Gtk::Label chan_count_label_3;
199         Gtk::Label chan_count_label_4;
200         Gtk::Table advanced_table;
201         Gtk::HBox input_port_limit_hbox;
202         Gtk::VBox input_port_vbox;
203         Gtk::Table input_table;
204         Gtk::HBox input_hbox;
205
206         Gtk::Label bus_label;
207         Gtk::Frame bus_frame;
208         Gtk::Table bus_table;
209         Gtk::HBox bus_hbox;
210
211         Gtk::Label input_label;
212         Gtk::Frame input_frame;
213         Gtk::HBox output_port_limit_hbox;
214         Gtk::VBox output_port_vbox;
215         Gtk::VBox output_conn_vbox;
216         Gtk::VBox output_vbox;
217         Gtk::HBox output_hbox;
218
219         Gtk::Label output_label;
220         Gtk::Frame output_frame;
221         Gtk::VBox advanced_vbox;
222         Gtk::Label advanced_label;
223
224         Gtk::CheckButton _create_master_bus;
225         Gtk::SpinButton _master_bus_channel_count;
226
227         Gtk::CheckButton _connect_inputs;
228         Gtk::CheckButton _limit_input_ports;
229         Gtk::SpinButton _input_limit_count;
230
231         Gtk::CheckButton _connect_outputs;
232         Gtk::CheckButton _limit_output_ports;
233         Gtk::SpinButton _output_limit_count;
234
235         Gtk::RadioButtonGroup connect_outputs_group;
236         Gtk::RadioButton _connect_outputs_to_master;
237         Gtk::RadioButton _connect_outputs_to_physical;
238
239         Gtk::Adjustment _output_limit_count_adj;
240         Gtk::Adjustment _input_limit_count_adj;
241         Gtk::Adjustment _master_bus_channel_count_adj;
242
243         void connect_inputs_clicked ();
244         void connect_outputs_clicked ();
245         void limit_inputs_clicked ();
246         void limit_outputs_clicked ();
247         void master_bus_button_clicked ();
248         void setup_more_options_box ();
249
250         /* --disable plugins UI */
251         Gtk::CheckButton _disable_plugins;
252         void disable_plugins_clicked ();
253
254         /* always there */
255
256         Glib::RefPtr<Pango::Layout> layout;
257
258         bool _existing_session_chooser_used; ///< set to true when the existing session chooser has been used
259
260         Gtk::Label info_scroller_label;
261         std::string::size_type info_scroller_count;
262         bool info_scroller_update();
263         sigc::connection info_scroller_connection;
264         void updates_button_clicked ();
265 };
266
267 #endif /* __gtk2_ardour_session_dialog_h__ */