major rearrangement of startup/session loading code
[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/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 #include "ardour_dialog.h"
45
46 class EngineControl;
47
48 class SessionDialog : public ArdourDialog {
49   public:
50         SessionDialog (bool require_new, const std::string& session_name, const std::string& session_path, const std::string& template_name);
51         ~SessionDialog ();
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         // advanced session options
60
61         bool create_master_bus() const;
62         int master_channel_count() const;
63
64         bool connect_inputs() const;
65         bool limit_inputs_used_for_connection() const;
66         int input_limit_count() const;
67
68         bool connect_outputs() const;
69         bool limit_outputs_used_for_connection() const;
70         int output_limit_count() const;
71
72         bool connect_outs_to_master() const;
73         bool connect_outs_to_physical() const;
74
75   private:
76         bool new_only;
77         std::string _provided_session_name;
78         std::string _provided_session_path;
79
80         bool on_delete_event (GdkEventAny*);
81
82         Gtk::Button* cancel_button;
83         Gtk::Button* open_button;
84         Gtk::Button* back_button;
85         Gtk::Button* quit_button;
86
87         bool back_button_pressed (GdkEventButton*);
88
89         /* initial choice page */
90
91         void setup_initial_choice_box ();
92         Gtk::VBox ic_vbox;
93         Gtk::Button ic_new_session_button;
94         void new_session_button_clicked ();
95
96         /* recent sessions */
97
98         void setup_existing_session_page ();
99
100         struct RecentSessionsSorter {
101             bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
102                     return cmp_nocase(a.first, b.first) == -1;
103             }
104         };
105
106         struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
107             RecentSessionModelColumns() {
108                     add (visible_name);
109                     add (tip);
110                     add (fullpath);
111             }
112             Gtk::TreeModelColumn<std::string> visible_name;
113             Gtk::TreeModelColumn<std::string> tip;
114             Gtk::TreeModelColumn<std::string> fullpath;
115         };
116
117         RecentSessionModelColumns    recent_session_columns;
118         Gtk::TreeView                recent_session_display;
119         Glib::RefPtr<Gtk::TreeStore> recent_session_model;
120         Gtk::ScrolledWindow          recent_scroller;
121         Gtk::Label                   recent_label;
122         Gtk::FileChooserButton       existing_session_chooser;
123         int redisplay_recent_sessions ();
124         void recent_session_row_selected ();
125         void recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
126
127         void existing_session_selected ();
128         void session_selected ();
129
130         /* new sessions */
131
132         void setup_new_session_page ();
133         Gtk::Entry new_name_entry;
134         Gtk::FileChooserButton new_folder_chooser;
135
136         struct SessionTemplateColumns : public Gtk::TreeModel::ColumnRecord {
137                 SessionTemplateColumns () {
138                         add (name);
139                         add (path);
140                 }
141
142                 Gtk::TreeModelColumn<std::string> name;
143                 Gtk::TreeModelColumn<std::string> path;
144         };
145
146         SessionTemplateColumns session_template_columns;
147         Glib::RefPtr<Gtk::ListStore>  template_model;
148         Gtk::ComboBox template_chooser;
149
150         Gtk::VBox session_new_vbox;
151         Gtk::VBox session_existing_vbox;
152         Gtk::Expander more_new_session_options_button;
153         Gtk::CheckButton use_template_button;
154         std::string load_template_override;
155
156         void more_new_session_options_button_clicked();
157         void new_name_changed ();
158         void new_name_activated ();
159         void populate_session_templates ();
160
161         /* more options for new sessions */
162
163         Gtk::VBox more_options_vbox;
164
165         Gtk::Label chan_count_label_1;
166         Gtk::Label chan_count_label_3;
167         Gtk::Label chan_count_label_4;
168         Gtk::Table advanced_table;
169         Gtk::HBox input_port_limit_hbox;
170         Gtk::VBox input_port_vbox;
171         Gtk::Table input_table;
172         Gtk::HBox input_hbox;
173
174         Gtk::Label bus_label;
175         Gtk::Frame bus_frame;
176         Gtk::Table bus_table;
177         Gtk::HBox bus_hbox;
178
179         Gtk::Label input_label;
180         Gtk::Frame input_frame;
181         Gtk::HBox output_port_limit_hbox;
182         Gtk::VBox output_port_vbox;
183         Gtk::VBox output_conn_vbox;
184         Gtk::VBox output_vbox;
185         Gtk::HBox output_hbox;
186
187         Gtk::Label output_label;
188         Gtk::Frame output_frame;
189         Gtk::VBox advanced_vbox;
190         Gtk::Label advanced_label;
191
192         Gtk::CheckButton _create_master_bus;
193         Gtk::SpinButton _master_bus_channel_count;
194
195         Gtk::CheckButton _connect_inputs;
196         Gtk::CheckButton _limit_input_ports;
197         Gtk::SpinButton _input_limit_count;
198
199         Gtk::CheckButton _connect_outputs;
200         Gtk::CheckButton _limit_output_ports;
201         Gtk::SpinButton _output_limit_count;
202
203         Gtk::RadioButtonGroup connect_outputs_group;
204         Gtk::RadioButton _connect_outputs_to_master;
205         Gtk::RadioButton _connect_outputs_to_physical;
206
207         Gtk::Adjustment _output_limit_count_adj;
208         Gtk::Adjustment _input_limit_count_adj;
209         Gtk::Adjustment _master_bus_channel_count_adj;
210
211         void connect_inputs_clicked ();
212         void connect_outputs_clicked ();
213         void limit_inputs_clicked ();
214         void limit_outputs_clicked ();
215         void master_bus_button_clicked ();
216         void setup_more_options_box ();
217
218         /* always there */
219
220         Glib::RefPtr<Pango::Layout> layout;
221
222         bool _existing_session_chooser_used; ///< set to true when the existing session chooser has been used
223
224         Gtk::Label info_scroller_label;
225         std::string::size_type info_scroller_count;
226         bool info_scroller_update();
227         sigc::connection info_scroller_connection;
228         void updates_button_clicked ();
229 };
230
231 #endif /* __gtk2_ardour_session_dialog_h__ */