fix logic problems with startup assistant; make initial page buttons of startup activ...
[ardour.git] / gtk2_ardour / startup.h
1 #ifndef __gtk2_ardour_startup_h__
2 #define __gtk2_ardour_startup_h__
3
4 #include <string>
5
6 #include <gdkmm/pixbuf.h>
7 #include <gtkmm/assistant.h>
8 #include <gtkmm/label.h>
9 #include <gtkmm/drawingarea.h>
10 #include <gtkmm/box.h>
11 #include <gtkmm/radiobutton.h>
12 #include <gtkmm/filechooserbutton.h>
13 #include <gtkmm/scrolledwindow.h>
14 #include <gtkmm/treeview.h>
15 #include <gtkmm/treestore.h>
16 #include <gtkmm/checkbutton.h>
17 #include <gtkmm/table.h>
18 #include <gtkmm/frame.h>
19 #include <gtkmm/spinbutton.h>
20 #include <gtkmm/liststore.h>
21 #include <gtkmm/combobox.h>
22
23 #include "ardour/utils.h"
24
25 class EngineControl;
26
27 class ArdourStartup : public Gtk::Assistant {
28   public:
29         ArdourStartup ();
30         ~ArdourStartup ();
31
32         void set_new_only (bool);
33
34         Glib::ustring session_name (bool& should_be_new);
35         Glib::ustring session_folder ();
36
37         bool use_session_template();
38         Glib::ustring session_template_name();
39
40         EngineControl* engine_control() { return engine_dialog; }
41
42         // advanced session options
43
44         bool create_master_bus() const;
45         int master_channel_count() const;
46
47         bool create_control_bus() const;
48         int control_channel_count() const;
49
50         bool connect_inputs() const;
51         bool limit_inputs_used_for_connection() const;
52         int input_limit_count() const;
53
54         bool connect_outputs() const;
55         bool limit_outputs_used_for_connection() const;
56         int output_limit_count() const;
57
58         bool connect_outs_to_master() const;
59         bool connect_outs_to_physical() const;
60
61         gint response () const { 
62                 return  _response;
63         }
64
65   private:
66         gint _response;
67         bool config_modified;
68         bool new_user;
69         bool new_only;
70
71         void on_apply ();
72         void on_cancel ();
73         bool on_delete_event (GdkEventAny*);
74         void on_prepare (Gtk::Widget*);
75
76         static ArdourStartup *the_startup;
77
78         Glib::RefPtr<Gdk::Pixbuf> icon_pixbuf;
79
80         void setup_new_user_page ();
81         Glib::RefPtr<Gdk::Pixbuf> splash_pixbuf;
82         Gtk::DrawingArea splash_area;
83         bool splash_expose (GdkEventExpose* ev);
84
85         void setup_first_time_config_page ();
86
87         /* first page */
88         Gtk::FileChooserButton* default_dir_chooser;
89         void default_dir_changed();
90         void setup_first_page ();
91
92         /* initial choice page */
93
94         void setup_initial_choice_page ();
95         Gtk::VBox ic_vbox;
96         Gtk::RadioButton ic_new_session_button;
97         Gtk::RadioButton ic_existing_session_button;
98         bool initial_button_press(GdkEventButton *);
99         void initial_button_activated();
100
101         /* monitoring choices */
102
103         Gtk::VBox mon_vbox;
104         Gtk::Label monitor_label;
105         Gtk::RadioButton monitor_via_hardware_button;
106         Gtk::RadioButton monitor_via_ardour_button;
107         void setup_monitoring_choice_page ();
108
109         /* session page (could be new or existing) */
110
111         void setup_session_page ();
112         Gtk::VBox session_vbox;
113         Gtk::HBox session_hbox;
114
115         /* recent sessions */
116
117         void setup_existing_session_page ();
118
119         struct RecentSessionsSorter {
120             bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
121                     return cmp_nocase(a.first, b.first) == -1;
122             }
123         };
124
125         struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
126             RecentSessionModelColumns() {
127                     add (visible_name);
128                     add (fullpath);
129             }
130             Gtk::TreeModelColumn<Glib::ustring> visible_name;
131             Gtk::TreeModelColumn<Glib::ustring> fullpath;
132         };
133
134         RecentSessionModelColumns    recent_session_columns;
135         Gtk::TreeView                recent_session_display;
136         Glib::RefPtr<Gtk::TreeStore> recent_session_model;
137         Gtk::ScrolledWindow          recent_scroller;
138         int redisplay_recent_sessions ();
139         void recent_session_row_selected ();
140         void recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
141
142         /* audio setup page */
143
144         void setup_audio_page ();
145         EngineControl* engine_dialog;
146
147         /* new sessions */
148
149         void setup_new_session_page ();
150         Gtk::Entry new_name_entry;
151         Gtk::FileChooserButton new_folder_chooser;
152         Gtk::FileChooserButton session_template_chooser;
153
154         struct SessionTemplateColumns : public Gtk::TreeModel::ColumnRecord {
155                 SessionTemplateColumns () {
156                         add (name);
157                         add (path);
158                 }
159
160                 Gtk::TreeModelColumn<std::string> name;
161                 Gtk::TreeModelColumn<std::string> path;
162         };
163
164         SessionTemplateColumns session_template_columns;
165         Glib::RefPtr<Gtk::ListStore>  template_model;
166         Gtk::ComboBox template_chooser;
167
168         Gtk::VBox session_new_vbox;
169         Gtk::CheckButton more_new_session_options_button;
170         Gtk::RadioButtonGroup session_template_group;
171         Gtk::RadioButton use_session_as_template_button;
172         Gtk::RadioButton use_template_button;
173
174         void more_new_session_options_button_clicked();
175         void new_name_changed ();
176         void populate_session_templates ();
177
178         /* more options for new sessions */
179
180         Gtk::VBox more_options_vbox;
181
182         Gtk::Label chan_count_label_1;
183         Gtk::Label chan_count_label_2;
184         Gtk::Label chan_count_label_3;
185         Gtk::Label chan_count_label_4;
186         Gtk::Table advanced_table;
187         Gtk::HBox input_port_limit_hbox;
188         Gtk::VBox input_port_vbox;
189         Gtk::Table input_table;
190         Gtk::HBox input_hbox;
191
192         Gtk::Label bus_label;
193         Gtk::Frame bus_frame;
194         Gtk::Table bus_table;
195         Gtk::HBox bus_hbox;
196
197         Gtk::Label input_label;
198         Gtk::Frame input_frame;
199         Gtk::HBox output_port_limit_hbox;
200         Gtk::VBox output_port_vbox;
201         Gtk::VBox output_conn_vbox;
202         Gtk::VBox output_vbox;
203         Gtk::HBox output_hbox;
204
205         Gtk::Label output_label;
206         Gtk::Frame output_frame;
207         Gtk::VBox advanced_vbox;
208         Gtk::Label advanced_label;
209
210         Gtk::CheckButton _create_master_bus;
211         Gtk::SpinButton _master_bus_channel_count;
212
213         Gtk::CheckButton _create_control_bus;
214         Gtk::SpinButton _control_bus_channel_count;
215
216         Gtk::CheckButton _connect_inputs;
217         Gtk::CheckButton _limit_input_ports;
218         Gtk::SpinButton _input_limit_count;
219
220         Gtk::CheckButton _connect_outputs;
221         Gtk::CheckButton _limit_output_ports;
222         Gtk::SpinButton _output_limit_count;
223
224         Gtk::RadioButtonGroup connect_outputs_group;
225         Gtk::RadioButton _connect_outputs_to_master;
226         Gtk::RadioButton _connect_outputs_to_physical;
227
228         Gtk::Adjustment _output_limit_count_adj;
229         Gtk::Adjustment _input_limit_count_adj;
230         Gtk::Adjustment _control_bus_channel_count_adj;
231         Gtk::Adjustment _master_bus_channel_count_adj;
232
233         void connect_inputs_clicked ();
234         void connect_outputs_clicked ();
235         void limit_inputs_clicked ();
236         void limit_outputs_clicked ();
237         void master_bus_button_clicked ();
238         void monitor_bus_button_clicked ();
239         void setup_more_options_page ();
240
241         /* final page */
242
243         void setup_final_page ();
244         Gtk::Label final_page;
245
246         /* always there */
247
248         Glib::RefPtr<Pango::Layout> layout;
249
250         /* page indices */
251
252         gint audio_page_index;
253         gint new_user_page_index;
254         gint default_folder_page_index;
255         gint monitoring_page_index;
256         gint session_page_index;
257         gint initial_choice_index;
258         gint final_page_index;
259         gint session_options_page_index;
260
261         void move_along_now ();
262
263 };
264
265 #endif /* __gtk2_ardour_startup_h__ */