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