Change the template pulldown menu into a tree list. Populate the Description view...
[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/textview.h>
34 #include <gtkmm/treeview.h>
35 #include <gtkmm/treestore.h>
36 #include <gtkmm/checkbutton.h>
37 #include <gtkmm/table.h>
38 #include <gtkmm/frame.h>
39 #include <gtkmm/spinbutton.h>
40 #include <gtkmm/liststore.h>
41 #include <gtkmm/combobox.h>
42
43 #include "ardour/utils.h"
44
45 #include "ardour_dialog.h"
46
47 class EngineControl;
48
49 class SessionDialog : public ArdourDialog
50 {
51 public:
52         SessionDialog (bool require_new, const std::string& session_name, const std::string& session_path,
53                        const std::string& template_name, bool cancel_not_quit);
54         SessionDialog ();
55         ~SessionDialog ();
56
57         void clear_given ();
58
59         std::string session_name (bool& should_be_new);
60         std::string session_folder ();
61
62         bool use_session_template();
63         std::string session_template_name();
64
65         // advanced session options
66
67         bool create_master_bus() const;
68         int master_channel_count() const;
69
70         bool connect_inputs() const;
71         bool limit_inputs_used_for_connection() const;
72         int input_limit_count() const;
73
74         bool connect_outputs() const;
75         bool limit_outputs_used_for_connection() const;
76         int output_limit_count() const;
77
78         bool connect_outs_to_master() const;
79         bool connect_outs_to_physical() const;
80
81         void set_provided_session(const std::string& session_name, const std::string& session_path) {
82                 _provided_session_name = session_name;
83                 _provided_session_path = session_path;
84         }
85
86 private:
87         bool new_only;
88         std::string _provided_session_name;
89         std::string _provided_session_path;
90
91         bool on_delete_event (GdkEventAny*);
92
93         Gtk::Button* cancel_button;
94         Gtk::Button* open_button;
95         Gtk::Button* back_button;
96         Gtk::Button* quit_button;
97
98         bool back_button_pressed (GdkEventButton*);
99         bool open_button_pressed (GdkEventButton*);
100
101         Gtk::Frame info_frame;
102
103         /* initial choice page */
104
105         void setup_initial_choice_box ();
106         void setup_recent_sessions ();
107         Gtk::VBox ic_vbox;
108         Gtk::Button ic_new_session_button;
109         void new_session_button_clicked ();
110
111         /* recent sessions */
112
113         void setup_existing_session_page ();
114
115         struct RecentSessionsSorter
116         {
117                 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
118                         return ARDOUR::cmp_nocase(a.first, b.first) == -1;
119                 }
120         };
121
122         struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
123                 RecentSessionModelColumns()
124                 {
125                         add (visible_name);
126                         add (tip);
127                         add (fullpath);
128                         add (sample_rate);
129                         add (disk_format);
130                         add (time_modified);
131                         add (time_formatted);
132                 }
133                 Gtk::TreeModelColumn<std::string> visible_name;
134                 Gtk::TreeModelColumn<std::string> tip;
135                 Gtk::TreeModelColumn<std::string> fullpath;
136                 Gtk::TreeModelColumn<std::string> sample_rate;
137                 Gtk::TreeModelColumn<std::string> disk_format;
138                 Gtk::TreeModelColumn<int64_t>     time_modified;
139                 Gtk::TreeModelColumn<std::string> time_formatted;
140         };
141
142         RecentSessionModelColumns    recent_session_columns;
143         Gtk::TreeView                recent_session_display;
144         Glib::RefPtr<Gtk::TreeStore> recent_session_model;
145         Gtk::ScrolledWindow          recent_scroller;
146         Gtk::Label                   recent_label;
147         Gtk::FileChooserButton       existing_session_chooser;
148         int redisplay_recent_sessions ();
149         void recent_session_row_selected ();
150         void recent_session_sort_changed ();
151         void recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
152         bool recent_button_press (GdkEventButton*);
153         void recent_context_mennu (GdkEventButton*);
154         void recent_remove_selected ();
155
156         void existing_session_selected ();
157         void session_selected ();
158
159         /* new sessions */
160
161         void setup_new_session_page ();
162         Gtk::Entry new_name_entry;
163         Gtk::FileChooserButton new_folder_chooser;
164
165         struct SessionTemplateColumns : public Gtk::TreeModel::ColumnRecord {
166                 SessionTemplateColumns () {
167                         add (name);
168                         add (path);
169                         add (description);
170                         add (created_with);
171                 }
172
173                 Gtk::TreeModelColumn<std::string> name;
174                 Gtk::TreeModelColumn<std::string> path;
175                 Gtk::TreeModelColumn<std::string> description;
176                 Gtk::TreeModelColumn<std::string> created_with;
177         };
178
179         SessionTemplateColumns session_template_columns;
180
181     Glib::RefPtr<Gtk::TreeStore>  template_model;
182     Gtk::TreeView                 template_chooser;
183         Gtk::ScrolledWindow           template_scroller;
184
185         void template_row_selected ();
186
187         Gtk::TextView template_desc;
188
189         Gtk::VBox session_new_vbox;
190         Gtk::VBox session_existing_vbox;
191         Gtk::Expander more_new_session_options_button;
192         std::string load_template_override;
193
194         void more_new_session_options_button_clicked();
195         void new_name_changed ();
196         void new_name_activated ();
197         void populate_session_templates ();
198
199         /* more options for new sessions */
200
201         Gtk::VBox more_options_vbox;
202
203         Gtk::Label chan_count_label_1;
204         Gtk::Label chan_count_label_3;
205         Gtk::Label chan_count_label_4;
206         Gtk::Table advanced_table;
207         Gtk::HBox input_port_limit_hbox;
208         Gtk::VBox input_port_vbox;
209         Gtk::Table input_table;
210         Gtk::HBox input_hbox;
211
212         Gtk::Label bus_label;
213         Gtk::Frame bus_frame;
214         Gtk::Table bus_table;
215         Gtk::HBox bus_hbox;
216
217         Gtk::Label input_label;
218         Gtk::Frame input_frame;
219         Gtk::HBox output_port_limit_hbox;
220         Gtk::VBox output_port_vbox;
221         Gtk::VBox output_conn_vbox;
222         Gtk::VBox output_vbox;
223         Gtk::HBox output_hbox;
224
225         Gtk::Label output_label;
226         Gtk::Frame output_frame;
227         Gtk::VBox advanced_vbox;
228         Gtk::Label advanced_label;
229
230         Gtk::CheckButton _create_master_bus;
231         Gtk::SpinButton _master_bus_channel_count;
232
233         Gtk::CheckButton _connect_inputs;
234         Gtk::CheckButton _limit_input_ports;
235         Gtk::SpinButton _input_limit_count;
236
237         Gtk::CheckButton _connect_outputs;
238         Gtk::CheckButton _limit_output_ports;
239         Gtk::SpinButton _output_limit_count;
240
241         Gtk::RadioButtonGroup connect_outputs_group;
242         Gtk::RadioButton _connect_outputs_to_master;
243         Gtk::RadioButton _connect_outputs_to_physical;
244
245         Gtk::Adjustment _output_limit_count_adj;
246         Gtk::Adjustment _input_limit_count_adj;
247         Gtk::Adjustment _master_bus_channel_count_adj;
248
249         void connect_inputs_clicked ();
250         void connect_outputs_clicked ();
251         void limit_inputs_clicked ();
252         void limit_outputs_clicked ();
253         void master_bus_button_clicked ();
254         void setup_more_options_box ();
255
256         /* --disable plugins UI */
257         Gtk::CheckButton _disable_plugins;
258         void disable_plugins_clicked ();
259
260         /* always there */
261
262         Glib::RefPtr<Pango::Layout> layout;
263
264         bool _existing_session_chooser_used; ///< set to true when the existing session chooser has been used
265
266         Gtk::Label info_scroller_label;
267         std::string::size_type info_scroller_count;
268         bool info_scroller_update();
269         sigc::connection info_scroller_connection;
270         void updates_button_clicked ();
271 };
272
273 #endif /* __gtk2_ardour_session_dialog_h__ */