tweak startup dialog a bit to correctly save ardour.rc when need; get PROGRAM_NAME...
[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 connect_inputs() const;
48         bool limit_inputs_used_for_connection() const;
49         int input_limit_count() const;
50
51         bool connect_outputs() const;
52         bool limit_outputs_used_for_connection() const;
53         int output_limit_count() const;
54
55         bool connect_outs_to_master() const;
56         bool connect_outs_to_physical() const;
57
58         gint response () const { 
59                 return  _response;
60         }
61
62   private:
63         gint _response;
64         bool config_modified;
65         bool new_user;
66         bool new_only;
67
68         void on_apply ();
69         void on_cancel ();
70         bool on_delete_event (GdkEventAny*);
71         void on_prepare (Gtk::Widget*);
72
73         static ArdourStartup *the_startup;
74
75         Glib::RefPtr<Gdk::Pixbuf> icon_pixbuf;
76
77         void setup_new_user_page ();
78         Glib::RefPtr<Gdk::Pixbuf> splash_pixbuf;
79         Gtk::DrawingArea splash_area;
80         bool splash_expose (GdkEventExpose* ev);
81
82         void setup_first_time_config_page ();
83         void config_changed ();
84
85         /* first page */
86         Gtk::FileChooserButton* default_dir_chooser;
87         void default_dir_changed();
88         void setup_first_page ();
89
90         /* initial choice page */
91
92         void setup_initial_choice_page ();
93         Gtk::VBox ic_vbox;
94         Gtk::RadioButton ic_new_session_button;
95         Gtk::RadioButton ic_existing_session_button;
96         bool initial_button_press(GdkEventButton *);
97         void initial_button_activated();
98
99         /* monitoring choices */
100
101         Gtk::VBox mon_vbox;
102         Gtk::Label monitor_label;
103         Gtk::RadioButton monitor_via_hardware_button;
104         Gtk::RadioButton monitor_via_ardour_button;
105         void setup_monitoring_choice_page ();
106
107         /* monitor section choices */
108
109         Gtk::VBox mon_sec_vbox;
110         Gtk::Label monitor_section_label;
111         Gtk::RadioButton use_monitor_section_button;
112         Gtk::RadioButton no_monitor_section_button;
113         void setup_monitor_section_choice_page ();
114
115         /* session page (could be new or existing) */
116
117         void setup_session_page ();
118         Gtk::VBox session_vbox;
119         Gtk::HBox session_hbox;
120
121         /* recent sessions */
122
123         void setup_existing_session_page ();
124
125         struct RecentSessionsSorter {
126             bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
127                     return cmp_nocase(a.first, b.first) == -1;
128             }
129         };
130
131         struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
132             RecentSessionModelColumns() {
133                     add (visible_name);
134                     add (fullpath);
135             }
136             Gtk::TreeModelColumn<Glib::ustring> visible_name;
137             Gtk::TreeModelColumn<Glib::ustring> fullpath;
138         };
139
140         RecentSessionModelColumns    recent_session_columns;
141         Gtk::TreeView                recent_session_display;
142         Glib::RefPtr<Gtk::TreeStore> recent_session_model;
143         Gtk::ScrolledWindow          recent_scroller;
144         int redisplay_recent_sessions ();
145         void recent_session_row_selected ();
146         void recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
147
148         /* audio setup page */
149
150         void setup_audio_page ();
151         EngineControl* engine_dialog;
152
153         /* new sessions */
154
155         void setup_new_session_page ();
156         Gtk::Entry new_name_entry;
157         Gtk::FileChooserButton new_folder_chooser;
158         Gtk::FileChooserButton session_template_chooser;
159
160         struct SessionTemplateColumns : public Gtk::TreeModel::ColumnRecord {
161                 SessionTemplateColumns () {
162                         add (name);
163                         add (path);
164                 }
165
166                 Gtk::TreeModelColumn<std::string> name;
167                 Gtk::TreeModelColumn<std::string> path;
168         };
169
170         SessionTemplateColumns session_template_columns;
171         Glib::RefPtr<Gtk::ListStore>  template_model;
172         Gtk::ComboBox template_chooser;
173
174         Gtk::VBox session_new_vbox;
175         Gtk::CheckButton more_new_session_options_button;
176         Gtk::RadioButtonGroup session_template_group;
177         Gtk::RadioButton use_session_as_template_button;
178         Gtk::RadioButton use_template_button;
179
180         void more_new_session_options_button_clicked();
181         void new_name_changed ();
182         void populate_session_templates ();
183
184         /* more options for new sessions */
185
186         Gtk::VBox more_options_vbox;
187
188         Gtk::Label chan_count_label_1;
189         Gtk::Label chan_count_label_3;
190         Gtk::Label chan_count_label_4;
191         Gtk::Table advanced_table;
192         Gtk::HBox input_port_limit_hbox;
193         Gtk::VBox input_port_vbox;
194         Gtk::Table input_table;
195         Gtk::HBox input_hbox;
196
197         Gtk::Label bus_label;
198         Gtk::Frame bus_frame;
199         Gtk::Table bus_table;
200         Gtk::HBox bus_hbox;
201
202         Gtk::Label input_label;
203         Gtk::Frame input_frame;
204         Gtk::HBox output_port_limit_hbox;
205         Gtk::VBox output_port_vbox;
206         Gtk::VBox output_conn_vbox;
207         Gtk::VBox output_vbox;
208         Gtk::HBox output_hbox;
209
210         Gtk::Label output_label;
211         Gtk::Frame output_frame;
212         Gtk::VBox advanced_vbox;
213         Gtk::Label advanced_label;
214
215         Gtk::CheckButton _create_master_bus;
216         Gtk::SpinButton _master_bus_channel_count;
217
218         Gtk::CheckButton _connect_inputs;
219         Gtk::CheckButton _limit_input_ports;
220         Gtk::SpinButton _input_limit_count;
221
222         Gtk::CheckButton _connect_outputs;
223         Gtk::CheckButton _limit_output_ports;
224         Gtk::SpinButton _output_limit_count;
225
226         Gtk::RadioButtonGroup connect_outputs_group;
227         Gtk::RadioButton _connect_outputs_to_master;
228         Gtk::RadioButton _connect_outputs_to_physical;
229
230         Gtk::Adjustment _output_limit_count_adj;
231         Gtk::Adjustment _input_limit_count_adj;
232         Gtk::Adjustment _master_bus_channel_count_adj;
233
234         void connect_inputs_clicked ();
235         void connect_outputs_clicked ();
236         void limit_inputs_clicked ();
237         void limit_outputs_clicked ();
238         void master_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 monitor_section_page_index;
257         gint session_page_index;
258         gint initial_choice_index;
259         gint final_page_index;
260         gint session_options_page_index;
261
262         void move_along_now ();
263
264 };
265
266 #endif /* __gtk2_ardour_startup_h__ */