Use std::string and Glib::build_filename in gtk2_ardour
[ardour.git] / gtk2_ardour / startup.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_startup_h__
21 #define __gtk2_ardour_startup_h__
22
23 #include <string>
24
25 #include <gdkmm/pixbuf.h>
26 #include <gtkmm/assistant.h>
27 #include <gtkmm/label.h>
28 #include <gtkmm/drawingarea.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 class EngineControl;
45
46 class ArdourStartup : public Gtk::Assistant {
47   public:
48         ArdourStartup ();
49         ~ArdourStartup ();
50
51         void set_new_only (bool);
52         void set_load_template( std::string load_template );
53
54         std::string session_name (bool& should_be_new);
55         std::string session_folder ();
56
57         bool use_session_template();
58         std::string session_template_name();
59
60         EngineControl* engine_control() { return engine_dialog; }
61
62         // advanced session options
63
64         bool create_master_bus() const;
65         int master_channel_count() const;
66
67         bool connect_inputs() const;
68         bool limit_inputs_used_for_connection() const;
69         int input_limit_count() const;
70
71         bool connect_outputs() const;
72         bool limit_outputs_used_for_connection() const;
73         int output_limit_count() const;
74
75         bool connect_outs_to_master() const;
76         bool connect_outs_to_physical() const;
77
78         gint response () const {
79                 return  _response;
80         }
81
82   private:
83         gint _response;
84         bool config_modified;
85         bool new_user;
86         bool new_only;
87
88         std::string been_here_before_path () const;
89
90         void on_apply ();
91         void on_cancel ();
92         bool on_delete_event (GdkEventAny*);
93         void on_prepare (Gtk::Widget*);
94
95         static ArdourStartup *the_startup;
96
97         Glib::RefPtr<Gdk::Pixbuf> icon_pixbuf;
98
99         void setup_new_user_page ();
100         Glib::RefPtr<Gdk::Pixbuf> splash_pixbuf;
101         Gtk::DrawingArea splash_area;
102         bool splash_expose (GdkEventExpose* ev);
103
104         void setup_first_time_config_page ();
105         void config_changed ();
106
107         /* first page */
108         Gtk::FileChooserButton* default_dir_chooser;
109         void default_dir_changed();
110         void setup_first_page ();
111
112         /* initial choice page */
113
114         void setup_initial_choice_page ();
115         Gtk::VBox ic_vbox;
116         Gtk::RadioButton ic_new_session_button;
117         Gtk::RadioButton ic_existing_session_button;
118         bool initial_button_clicked(GdkEventButton*);
119         void initial_button_activated();
120
121         /* monitoring choices */
122
123         Gtk::VBox mon_vbox;
124         Gtk::Label monitor_label;
125         Gtk::RadioButton monitor_via_hardware_button;
126         Gtk::RadioButton monitor_via_ardour_button;
127         void setup_monitoring_choice_page ();
128
129         /* monitor section choices */
130
131         Gtk::VBox mon_sec_vbox;
132         Gtk::Label monitor_section_label;
133         Gtk::RadioButton use_monitor_section_button;
134         Gtk::RadioButton no_monitor_section_button;
135         void setup_monitor_section_choice_page ();
136
137         /* session page (could be new or existing) */
138
139         void setup_session_page ();
140         Gtk::VBox session_vbox;
141         Gtk::HBox session_hbox;
142
143         /* recent sessions */
144
145         void setup_existing_session_page ();
146
147         struct RecentSessionsSorter {
148             bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
149                     return cmp_nocase(a.first, b.first) == -1;
150             }
151         };
152
153         struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
154             RecentSessionModelColumns() {
155                     add (visible_name);
156                     add (fullpath);
157             }
158             Gtk::TreeModelColumn<std::string> visible_name;
159             Gtk::TreeModelColumn<std::string> fullpath;
160         };
161
162         RecentSessionModelColumns    recent_session_columns;
163         Gtk::TreeView                recent_session_display;
164         Glib::RefPtr<Gtk::TreeStore> recent_session_model;
165         Gtk::ScrolledWindow          recent_scroller;
166         Gtk::FileChooserButton       existing_session_chooser;
167         int redisplay_recent_sessions ();
168         void recent_session_row_selected ();
169         void recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
170
171         void existing_session_selected ();
172
173         /* audio setup page */
174
175         void setup_audio_page ();
176         EngineControl* engine_dialog;
177
178         /* new sessions */
179
180         void setup_new_session_page ();
181         Gtk::Entry new_name_entry;
182         Gtk::FileChooserButton new_folder_chooser;
183         Gtk::FileChooserButton session_template_chooser;
184         void new_name_mapped ();
185
186         struct SessionTemplateColumns : public Gtk::TreeModel::ColumnRecord {
187                 SessionTemplateColumns () {
188                         add (name);
189                         add (path);
190                 }
191
192                 Gtk::TreeModelColumn<std::string> name;
193                 Gtk::TreeModelColumn<std::string> path;
194         };
195
196         SessionTemplateColumns session_template_columns;
197         Glib::RefPtr<Gtk::ListStore>  template_model;
198         Gtk::ComboBox template_chooser;
199
200         Gtk::VBox session_new_vbox;
201         Gtk::VBox session_existing_vbox;
202         Gtk::CheckButton more_new_session_options_button;
203         Gtk::RadioButtonGroup session_template_group;
204         Gtk::RadioButton use_session_as_template_button;
205         Gtk::RadioButton use_template_button;
206         std::string load_template_override;
207
208         void more_new_session_options_button_clicked();
209         void new_name_changed ();
210         void populate_session_templates ();
211
212         /* more options for new sessions */
213
214         Gtk::VBox more_options_vbox;
215
216         Gtk::Label chan_count_label_1;
217         Gtk::Label chan_count_label_3;
218         Gtk::Label chan_count_label_4;
219         Gtk::Table advanced_table;
220         Gtk::HBox input_port_limit_hbox;
221         Gtk::VBox input_port_vbox;
222         Gtk::Table input_table;
223         Gtk::HBox input_hbox;
224
225         Gtk::Label bus_label;
226         Gtk::Frame bus_frame;
227         Gtk::Table bus_table;
228         Gtk::HBox bus_hbox;
229
230         Gtk::Label input_label;
231         Gtk::Frame input_frame;
232         Gtk::HBox output_port_limit_hbox;
233         Gtk::VBox output_port_vbox;
234         Gtk::VBox output_conn_vbox;
235         Gtk::VBox output_vbox;
236         Gtk::HBox output_hbox;
237
238         Gtk::Label output_label;
239         Gtk::Frame output_frame;
240         Gtk::VBox advanced_vbox;
241         Gtk::Label advanced_label;
242
243         Gtk::CheckButton _create_master_bus;
244         Gtk::SpinButton _master_bus_channel_count;
245
246         Gtk::CheckButton _connect_inputs;
247         Gtk::CheckButton _limit_input_ports;
248         Gtk::SpinButton _input_limit_count;
249
250         Gtk::CheckButton _connect_outputs;
251         Gtk::CheckButton _limit_output_ports;
252         Gtk::SpinButton _output_limit_count;
253
254         Gtk::RadioButtonGroup connect_outputs_group;
255         Gtk::RadioButton _connect_outputs_to_master;
256         Gtk::RadioButton _connect_outputs_to_physical;
257
258         Gtk::Adjustment _output_limit_count_adj;
259         Gtk::Adjustment _input_limit_count_adj;
260         Gtk::Adjustment _master_bus_channel_count_adj;
261
262         void connect_inputs_clicked ();
263         void connect_outputs_clicked ();
264         void limit_inputs_clicked ();
265         void limit_outputs_clicked ();
266         void master_bus_button_clicked ();
267         void setup_more_options_page ();
268
269         /* final page */
270
271         void setup_final_page ();
272         Gtk::Label final_page;
273
274         /* always there */
275
276         Glib::RefPtr<Pango::Layout> layout;
277
278         /* page indices */
279
280         gint audio_page_index;
281         gint new_user_page_index;
282         gint default_folder_page_index;
283         gint monitoring_page_index;
284         gint monitor_section_page_index;
285         gint session_page_index;
286         gint initial_choice_index;
287         gint final_page_index;
288         gint session_options_page_index;
289
290         void move_along_now ();
291
292         bool _existing_session_chooser_used; ///< set to true when the existing session chooser has been used
293         void setup_prerelease_page ();
294 };
295
296 #endif /* __gtk2_ardour_startup_h__ */