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