2 Copyright (C) 2005 Paul Davis
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.
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.
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.
21 #include "new_session_dialog.h"
23 #include <ardour/recent_sessions.h>
24 #include <ardour/session.h>
25 #include <ardour/profile.h>
27 #include <gtkmm/entry.h>
28 #include <gtkmm/filechooserbutton.h>
29 #include <gtkmm/spinbutton.h>
30 #include <gtkmm/checkbutton.h>
31 #include <gtkmm/radiobutton.h>
32 #include <gtkmm/filefilter.h>
33 #include <gtkmm/stock.h>
34 #include <gdkmm/cursor.h>
36 #include <gtkmm2ext/window_title.h>
38 using namespace Gtkmm2ext;
42 NewSessionDialog::NewSessionDialog()
43 : ArdourDialog ("session control")
45 in_destructor = false;
46 session_name_label = Gtk::manage(new class Gtk::Label(_("Name :")));
47 m_name = Gtk::manage(new class Gtk::Entry());
48 m_name->set_text(ARDOUR_COMMAND_LINE::session_name);
50 chan_count_label_1 = Gtk::manage(new class Gtk::Label(_("channels")));
51 chan_count_label_2 = Gtk::manage(new class Gtk::Label(_("channels")));
52 chan_count_label_3 = Gtk::manage(new class Gtk::Label(_("channels")));
53 chan_count_label_4 = Gtk::manage(new class Gtk::Label(_("channels")));
55 chan_count_label_1->set_alignment(0,0.5);
56 chan_count_label_1->set_padding(0,0);
57 chan_count_label_1->set_line_wrap(false);
59 chan_count_label_2->set_alignment(0,0.5);
60 chan_count_label_2->set_padding(0,0);
61 chan_count_label_2->set_line_wrap(false);
63 chan_count_label_3->set_alignment(0,0.5);
64 chan_count_label_3->set_padding(0,0);
65 chan_count_label_3->set_line_wrap(false);
67 chan_count_label_4->set_alignment(0,0.5);
68 chan_count_label_4->set_padding(0,0);
69 chan_count_label_4->set_line_wrap(false);
71 bus_label = Gtk::manage(new class Gtk::Label(_("<b>Busses</b>")));
72 input_label = Gtk::manage(new class Gtk::Label(_("<b>Inputs</b>")));
73 output_label = Gtk::manage(new class Gtk::Label(_("<b>Outputs</b>")));
75 session_location_label = Gtk::manage(new class Gtk::Label(_("Create Folder In :")));
76 m_folder = Gtk::manage(new class Gtk::FileChooserButton(Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER));
77 session_template_label = Gtk::manage(new class Gtk::Label(_("Template :")));
78 m_template = Gtk::manage(new class Gtk::FileChooserButton());
79 m_create_control_bus = Gtk::manage(new class Gtk::CheckButton(_("Create Monitor Bus")));
81 Gtk::Adjustment *m_control_bus_channel_count_adj = Gtk::manage(new class Gtk::Adjustment(2, 0, 100, 1, 10, 10));
82 m_control_bus_channel_count = Gtk::manage(new class Gtk::SpinButton(*m_control_bus_channel_count_adj, 1, 0));
84 Gtk::Adjustment *m_master_bus_channel_count_adj = Gtk::manage(new class Gtk::Adjustment(2, 0, 100, 1, 10, 10));
85 m_master_bus_channel_count = Gtk::manage(new class Gtk::SpinButton(*m_master_bus_channel_count_adj, 1, 0));
86 m_create_master_bus = Gtk::manage(new class Gtk::CheckButton(_("Create Master Bus")));
87 advanced_table = Gtk::manage(new class Gtk::Table(2, 2, true));
88 m_connect_inputs = Gtk::manage(new class Gtk::CheckButton(_("Automatically Connect to Physical Inputs")));
89 m_limit_input_ports = Gtk::manage(new class Gtk::CheckButton(_("Use only")));
91 Gtk::Adjustment *m_input_limit_count_adj = Gtk::manage(new class Gtk::Adjustment(1, 0, 100, 1, 10, 10));
92 m_input_limit_count = Gtk::manage(new class Gtk::SpinButton(*m_input_limit_count_adj, 1, 0));
93 input_port_limit_hbox = Gtk::manage(new class Gtk::HBox(false, 0));
94 input_port_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
95 input_table = Gtk::manage(new class Gtk::Table(2, 2, false));
97 bus_frame = Gtk::manage(new class Gtk::Frame());
98 bus_table = Gtk::manage (new Gtk::Table (2, 3, false));
100 input_frame = Gtk::manage(new class Gtk::Frame());
101 m_connect_outputs = Gtk::manage(new class Gtk::CheckButton(_("Automatically Connect Outputs")));
102 m_limit_output_ports = Gtk::manage(new class Gtk::CheckButton(_("Use only")));
104 Gtk::Adjustment *m_output_limit_count_adj = Gtk::manage(new class Gtk::Adjustment(1, 0, 100, 1, 10, 10));
105 m_output_limit_count = Gtk::manage(new class Gtk::SpinButton(*m_output_limit_count_adj, 1, 0));
106 output_port_limit_hbox = Gtk::manage(new class Gtk::HBox(false, 0));
107 output_port_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
109 Gtk::RadioButton::Group _RadioBGroup_m_connect_outputs_to_master;
110 m_connect_outputs_to_master = Gtk::manage(new class Gtk::RadioButton(_RadioBGroup_m_connect_outputs_to_master, _("... to Master Bus")));
111 m_connect_outputs_to_physical = Gtk::manage(new class Gtk::RadioButton(_RadioBGroup_m_connect_outputs_to_master, _("... to Physical Outputs")));
112 output_conn_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
113 output_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
115 output_frame = Gtk::manage(new class Gtk::Frame());
116 advanced_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
117 advanced_label = Gtk::manage(new class Gtk::Label(_("Advanced Options")));
118 advanced_expander = Gtk::manage(new class Gtk::Expander());
119 new_session_table = Gtk::manage(new class Gtk::Table(2, 2, false));
120 m_open_filechooser = Gtk::manage(new class Gtk::FileChooserButton());
121 open_session_hbox = Gtk::manage(new class Gtk::HBox(false, 0));
122 m_treeview = Gtk::manage(new class Gtk::TreeView());
123 recent_scrolledwindow = Gtk::manage(new class Gtk::ScrolledWindow());
125 recent_sesion_label = Gtk::manage(new class Gtk::Label(_("Recent:")));
126 recent_frame = Gtk::manage(new class Gtk::Frame());
127 open_session_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
128 m_notebook = Gtk::manage(new class Gtk::Notebook());
129 session_name_label->set_alignment(0, 0.5);
130 session_name_label->set_padding(6,0);
131 session_name_label->set_line_wrap(false);
132 session_name_label->set_selectable(false);
133 m_name->set_editable(true);
134 m_name->set_max_length(0);
135 m_name->set_has_frame(true);
136 m_name->set_activates_default(true);
137 m_name->set_width_chars (40);
138 session_location_label->set_alignment(0,0.5);
139 session_location_label->set_padding(6,0);
140 session_location_label->set_line_wrap(false);
141 session_location_label->set_selectable(false);
142 session_template_label->set_alignment(0,0.5);
143 session_template_label->set_padding(6,0);
144 session_template_label->set_line_wrap(false);
145 session_template_label->set_selectable(false);
146 m_create_control_bus->set_flags(Gtk::CAN_FOCUS);
147 m_create_control_bus->set_relief(Gtk::RELIEF_NORMAL);
148 m_create_control_bus->set_mode(true);
149 m_create_control_bus->set_active(false);
150 m_create_control_bus->set_border_width(0);
151 m_control_bus_channel_count->set_flags(Gtk::CAN_FOCUS);
152 m_control_bus_channel_count->set_update_policy(Gtk::UPDATE_ALWAYS);
153 m_control_bus_channel_count->set_numeric(true);
154 m_control_bus_channel_count->set_digits(0);
155 m_control_bus_channel_count->set_wrap(false);
156 m_control_bus_channel_count->set_sensitive(false);
157 m_master_bus_channel_count->set_flags(Gtk::CAN_FOCUS);
158 m_master_bus_channel_count->set_update_policy(Gtk::UPDATE_ALWAYS);
159 m_master_bus_channel_count->set_numeric(true);
160 m_master_bus_channel_count->set_digits(0);
161 m_master_bus_channel_count->set_wrap(false);
162 open_session_file_label = Gtk::manage(new class Gtk::Label(_("Browse:")));
163 open_session_file_label->set_alignment(0, 0.5);
164 m_create_master_bus->set_flags(Gtk::CAN_FOCUS);
165 m_create_master_bus->set_relief(Gtk::RELIEF_NORMAL);
166 m_create_master_bus->set_mode(true);
167 m_create_master_bus->set_active(true);
168 m_create_master_bus->set_border_width(0);
169 advanced_table->set_row_spacings(0);
170 advanced_table->set_col_spacings(0);
172 m_connect_inputs->set_flags(Gtk::CAN_FOCUS);
173 m_connect_inputs->set_relief(Gtk::RELIEF_NORMAL);
174 m_connect_inputs->set_mode(true);
175 m_connect_inputs->set_active(true);
176 m_connect_inputs->set_border_width(0);
178 m_limit_input_ports->set_flags(Gtk::CAN_FOCUS);
179 m_limit_input_ports->set_relief(Gtk::RELIEF_NORMAL);
180 m_limit_input_ports->set_mode(true);
181 m_limit_input_ports->set_sensitive(true);
182 m_limit_input_ports->set_border_width(0);
183 m_input_limit_count->set_flags(Gtk::CAN_FOCUS);
184 m_input_limit_count->set_update_policy(Gtk::UPDATE_ALWAYS);
185 m_input_limit_count->set_numeric(true);
186 m_input_limit_count->set_digits(0);
187 m_input_limit_count->set_wrap(false);
188 m_input_limit_count->set_sensitive(false);
190 bus_hbox = Gtk::manage (new Gtk::HBox (false, 0));
191 bus_hbox->pack_start (*bus_table, Gtk::PACK_SHRINK, 18);
193 bus_label->set_alignment(0, 0.5);
194 bus_label->set_padding(0,0);
195 bus_label->set_line_wrap(false);
196 bus_label->set_selectable(false);
197 bus_label->set_use_markup(true);
198 bus_frame->set_shadow_type(Gtk::SHADOW_NONE);
199 bus_frame->set_label_align(0,0.5);
200 bus_frame->add(*bus_hbox);
201 bus_frame->set_label_widget(*bus_label);
203 bus_table->set_row_spacings (0);
204 bus_table->set_col_spacings (0);
205 bus_table->attach (*m_create_master_bus, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
206 bus_table->attach (*m_master_bus_channel_count, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
207 bus_table->attach (*chan_count_label_1, 2, 3, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 6, 0);
208 bus_table->attach (*m_create_control_bus, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
209 bus_table->attach (*m_control_bus_channel_count, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
210 bus_table->attach (*chan_count_label_2, 2, 3, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 6, 0);
212 input_port_limit_hbox->pack_start(*m_limit_input_ports, Gtk::PACK_SHRINK, 6);
213 input_port_limit_hbox->pack_start(*m_input_limit_count, Gtk::PACK_SHRINK, 0);
214 input_port_limit_hbox->pack_start(*chan_count_label_3, Gtk::PACK_SHRINK, 6);
215 input_port_vbox->pack_start(*m_connect_inputs, Gtk::PACK_SHRINK, 0);
216 input_port_vbox->pack_start(*input_port_limit_hbox, Gtk::PACK_EXPAND_PADDING, 0);
217 input_table->set_row_spacings(0);
218 input_table->set_col_spacings(0);
219 input_table->attach(*input_port_vbox, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 6, 6);
221 input_hbox = Gtk::manage (new Gtk::HBox (false, 0));
222 input_hbox->pack_start (*input_table, Gtk::PACK_SHRINK, 18);
224 input_label->set_alignment(0, 0.5);
225 input_label->set_padding(0,0);
226 input_label->set_line_wrap(false);
227 input_label->set_selectable(false);
228 input_label->set_use_markup(true);
229 input_frame->set_shadow_type(Gtk::SHADOW_NONE);
230 input_frame->set_label_align(0,0.5);
231 input_frame->add(*input_hbox);
232 input_frame->set_label_widget(*input_label);
234 m_connect_outputs->set_flags(Gtk::CAN_FOCUS);
235 m_connect_outputs->set_relief(Gtk::RELIEF_NORMAL);
236 m_connect_outputs->set_mode(true);
237 m_connect_outputs->set_active(true);
238 m_connect_outputs->set_border_width(0);
239 m_limit_output_ports->set_flags(Gtk::CAN_FOCUS);
240 m_limit_output_ports->set_relief(Gtk::RELIEF_NORMAL);
241 m_limit_output_ports->set_mode(true);
242 m_limit_output_ports->set_sensitive(true);
243 m_limit_output_ports->set_border_width(0);
244 m_output_limit_count->set_flags(Gtk::CAN_FOCUS);
245 m_output_limit_count->set_update_policy(Gtk::UPDATE_ALWAYS);
246 m_output_limit_count->set_numeric(false);
247 m_output_limit_count->set_digits(0);
248 m_output_limit_count->set_wrap(false);
249 m_output_limit_count->set_sensitive(false);
250 output_port_limit_hbox->pack_start(*m_limit_output_ports, Gtk::PACK_SHRINK, 6);
251 output_port_limit_hbox->pack_start(*m_output_limit_count, Gtk::PACK_SHRINK, 0);
252 output_port_limit_hbox->pack_start(*chan_count_label_4, Gtk::PACK_SHRINK, 6);
253 m_connect_outputs_to_master->set_flags(Gtk::CAN_FOCUS);
254 m_connect_outputs_to_master->set_relief(Gtk::RELIEF_NORMAL);
255 m_connect_outputs_to_master->set_mode(true);
256 m_connect_outputs_to_master->set_active(false);
257 m_connect_outputs_to_master->set_border_width(0);
258 m_connect_outputs_to_physical->set_flags(Gtk::CAN_FOCUS);
259 m_connect_outputs_to_physical->set_relief(Gtk::RELIEF_NORMAL);
260 m_connect_outputs_to_physical->set_mode(true);
261 m_connect_outputs_to_physical->set_active(false);
262 m_connect_outputs_to_physical->set_border_width(0);
263 output_conn_vbox->pack_start(*m_connect_outputs, Gtk::PACK_SHRINK, 0);
264 output_conn_vbox->pack_start(*m_connect_outputs_to_master, Gtk::PACK_SHRINK, 0);
265 output_conn_vbox->pack_start(*m_connect_outputs_to_physical, Gtk::PACK_SHRINK, 0);
266 output_vbox->set_border_width(6);
268 output_port_vbox->pack_start(*output_port_limit_hbox, Gtk::PACK_SHRINK, 0);
270 output_vbox->pack_start(*output_conn_vbox);
271 output_vbox->pack_start(*output_port_vbox);
273 output_label->set_alignment(0, 0.5);
274 output_label->set_padding(0,0);
275 output_label->set_line_wrap(false);
276 output_label->set_selectable(false);
277 output_label->set_use_markup(true);
278 output_frame->set_shadow_type(Gtk::SHADOW_NONE);
279 output_frame->set_label_align(0,0.5);
281 output_hbox = Gtk::manage (new Gtk::HBox (false, 0));
282 output_hbox->pack_start (*output_vbox, Gtk::PACK_SHRINK, 18);
284 output_frame->add(*output_hbox);
285 output_frame->set_label_widget(*output_label);
287 advanced_vbox->pack_start(*advanced_table, Gtk::PACK_SHRINK, 0);
288 advanced_vbox->pack_start(*bus_frame, Gtk::PACK_SHRINK, 6);
289 advanced_vbox->pack_start(*input_frame, Gtk::PACK_SHRINK, 6);
290 advanced_vbox->pack_start(*output_frame, Gtk::PACK_SHRINK, 0);
291 advanced_label->set_padding(0,0);
292 advanced_label->set_line_wrap(false);
293 advanced_label->set_selectable(false);
294 advanced_label->set_alignment(0, 0.5);
295 advanced_expander->set_flags(Gtk::CAN_FOCUS);
296 advanced_expander->set_border_width(0);
297 advanced_expander->set_expanded(false);
298 advanced_expander->set_spacing(0);
299 advanced_expander->add(*advanced_vbox);
300 advanced_expander->set_label_widget(*advanced_label);
301 new_session_table->set_border_width(12);
302 new_session_table->set_row_spacings(6);
303 new_session_table->set_col_spacings(0);
304 new_session_table->attach(*session_name_label, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL, 0, 0);
305 new_session_table->attach(*m_name, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
306 new_session_table->attach(*session_location_label, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL, 0, 0);
307 new_session_table->attach(*m_folder, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
308 new_session_table->attach(*session_template_label, 0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 0, 0);
309 new_session_table->attach(*m_template, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
311 if (!ARDOUR::Profile->get_sae()) {
312 new_session_table->attach(*advanced_expander, 0, 2, 3, 4, Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 6);
315 open_session_hbox->pack_start(*open_session_file_label, false, false, 12);
316 open_session_hbox->pack_start(*m_open_filechooser, true, true, 12);
317 m_treeview->set_flags(Gtk::CAN_FOCUS);
318 m_treeview->set_headers_visible(true);
319 m_treeview->set_rules_hint(false);
320 m_treeview->set_reorderable(false);
321 m_treeview->set_enable_search(true);
322 m_treeview->set_fixed_height_mode(false);
323 m_treeview->set_hover_selection(false);
324 m_treeview->set_size_request(-1, 150);
325 recent_scrolledwindow->set_flags(Gtk::CAN_FOCUS);
326 recent_scrolledwindow->set_border_width(6);
327 recent_scrolledwindow->set_shadow_type(Gtk::SHADOW_IN);
328 recent_scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
329 recent_scrolledwindow->property_window_placement().set_value(Gtk::CORNER_TOP_LEFT);
330 recent_scrolledwindow->add(*m_treeview);
332 recent_sesion_label->set_padding(0,0);
333 recent_sesion_label->set_line_wrap(false);
334 recent_sesion_label->set_selectable(false);
335 recent_frame->set_border_width(12);
336 recent_frame->set_shadow_type(Gtk::SHADOW_NONE);
337 recent_frame->add(*recent_scrolledwindow);
338 recent_frame->set_label_widget(*recent_sesion_label);
339 open_session_vbox->pack_start(*recent_frame, Gtk::PACK_EXPAND_WIDGET, 0);
340 open_session_vbox->pack_start(*open_session_hbox, Gtk::PACK_SHRINK, 12);
342 m_notebook->set_flags(Gtk::CAN_FOCUS);
343 m_notebook->set_scrollable(true);
344 m_notebook->append_page(*new_session_table, _("New Session"));
345 m_notebook->pages().back().set_tab_label_packing(false, true, Gtk::PACK_START);
346 m_notebook->append_page(*open_session_vbox, _("Open Session"));
347 m_notebook->pages().back().set_tab_label_packing(false, true, Gtk::PACK_START);
349 get_vbox()->set_homogeneous(false);
350 get_vbox()->set_spacing(0);
351 get_vbox()->pack_start(*m_notebook, Gtk::PACK_SHRINK, 0);
353 WindowTitle title(Glib::get_application_name());
354 title += _("Session Control");
355 set_title(title.get_string());
358 //property_window_position().set_value(Gtk::WIN_POS_NONE);
359 set_resizable(false);
360 //property_destroy_with_parent().set_value(false);
361 set_has_separator(false);
362 // add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP);
363 add_button(Gtk::Stock::QUIT, Gtk::RESPONSE_CANCEL);
364 add_button(Gtk::Stock::CLEAR, Gtk::RESPONSE_NONE);
365 m_okbutton = add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
367 recent_model = Gtk::TreeStore::create (recent_columns);
368 m_treeview->set_model (recent_model);
369 m_treeview->append_column (_("Recent Sessions"), recent_columns.visible_name);
370 m_treeview->set_headers_visible (false);
371 m_treeview->get_selection()->set_mode (Gtk::SELECTION_SINGLE);
373 std::string path = ARDOUR::get_user_ardour_path();
376 path = ARDOUR::get_system_data_path();
379 const char * const template_dir_name = X_("templates");
382 string user_template_path = path + template_dir_name;
384 if (Glib::file_test(user_template_path, Glib::FILE_TEST_IS_DIR))
386 m_template->set_current_folder (user_template_path);
390 const std::string sys_templates_dir = ARDOUR::get_system_data_path() + template_dir_name;
392 if (Glib::file_test(sys_templates_dir, Glib::FILE_TEST_IS_DIR))
394 m_template->add_shortcut_folder(sys_templates_dir);
397 m_template->set_title(_("select template"));
398 Gtk::FileFilter* session_filter = manage (new (Gtk::FileFilter));
399 session_filter->add_pattern(X_("*.ardour"));
400 session_filter->add_pattern(X_("*.ardour.bak"));
401 m_open_filechooser->set_filter (*session_filter);
402 m_open_filechooser->set_current_folder(getenv ("HOME"));
403 m_open_filechooser->set_title(_("select session file"));
405 Gtk::FileFilter* template_filter = manage (new (Gtk::FileFilter));
406 template_filter->add_pattern(X_("*.ardour"));
407 template_filter->add_pattern(X_("*.ardour.bak"));
408 template_filter->add_pattern(X_("*.template"));
409 m_template->set_filter (*template_filter);
411 m_folder->set_current_folder(getenv ("HOME"));
412 m_folder->set_title(_("select directory"));
414 on_new_session_page = true;
415 m_notebook->set_current_page(0);
417 m_notebook->show_all_children();
420 set_default_response (Gtk::RESPONSE_OK);
421 if (!ARDOUR_COMMAND_LINE::session_name.length()) {
422 set_response_sensitive (Gtk::RESPONSE_OK, false);
423 set_response_sensitive (Gtk::RESPONSE_NONE, false);
425 set_response_sensitive (Gtk::RESPONSE_OK, true);
426 set_response_sensitive (Gtk::RESPONSE_NONE, true);
429 ///@ connect some signals
431 m_connect_inputs->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::connect_inputs_clicked));
432 m_connect_outputs->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::connect_outputs_clicked));
433 m_limit_input_ports->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::limit_inputs_clicked));
434 m_limit_output_ports->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::limit_outputs_clicked));
435 m_create_master_bus->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::master_bus_button_clicked));
436 m_create_control_bus->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::monitor_bus_button_clicked));
437 m_name->signal_changed().connect(mem_fun (*this, &NewSessionDialog::on_new_session_name_entry_changed));
438 m_notebook->signal_switch_page().connect (mem_fun (*this, &NewSessionDialog::notebook_page_changed));
439 m_treeview->get_selection()->signal_changed().connect (mem_fun (*this, &NewSessionDialog::treeview_selection_changed));
440 m_treeview->signal_row_activated().connect (mem_fun (*this, &NewSessionDialog::recent_row_activated));
441 m_open_filechooser->signal_selection_changed ().connect (mem_fun (*this, &NewSessionDialog::file_chosen));
442 m_template->signal_selection_changed ().connect (mem_fun (*this, &NewSessionDialog::template_chosen));
443 m_name->grab_focus();
446 NewSessionDialog::~NewSessionDialog()
448 in_destructor = true;
452 NewSessionDialog::set_have_engine (bool yn)
455 cerr << "removing audio page\n";
456 m_notebook->remove_page (engine_control);
458 cerr << "appending audio page\n";
459 m_notebook->append_page (engine_control, _("Audio Setup"));
460 m_notebook->show_all_children();
465 NewSessionDialog::set_session_name(const Glib::ustring& name)
467 m_name->set_text(name);
471 NewSessionDialog::set_session_folder(const Glib::ustring& dir)
477 NewSessionDialog::session_name() const
479 std::string str = Glib::filename_from_utf8(m_open_filechooser->get_filename());
480 std::string::size_type position = str.find_last_of ('/');
481 str = str.substr (position+1);
482 position = str.find_last_of ('.');
483 str = str.substr (0, position);
486 XXX what to do if it's a .bak file?
487 load_session doesn't allow it!
489 if ((position = str.rfind(".bak")) != string::npos) {
490 str = str.substr (0, position);
494 if (m_notebook->get_current_page() == 0) {
495 return Glib::filename_from_utf8(m_name->get_text());
497 if (m_treeview->get_selection()->count_selected_rows() == 0) {
498 return Glib::filename_from_utf8(str);
500 Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected();
501 return (*i)[recent_columns.visible_name];
506 NewSessionDialog::session_folder() const
508 if (m_notebook->get_current_page() == 0) {
509 return Glib::filename_from_utf8(m_folder->get_current_folder());
512 if (m_treeview->get_selection()->count_selected_rows() == 0) {
513 return Glib::filename_from_utf8(m_open_filechooser->get_current_folder());
515 Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected();
516 return (*i)[recent_columns.fullpath];
521 NewSessionDialog::use_session_template() const
523 if(m_template->get_filename().empty() && (m_notebook->get_current_page() == 0)) return false;
528 NewSessionDialog::session_template_name() const
530 return Glib::filename_from_utf8(m_template->get_filename());
534 NewSessionDialog::create_master_bus() const
536 return m_create_master_bus->get_active();
540 NewSessionDialog::master_channel_count() const
542 return m_master_bus_channel_count->get_value_as_int();
546 NewSessionDialog::create_control_bus() const
548 return m_create_control_bus->get_active();
552 NewSessionDialog::control_channel_count() const
554 return m_control_bus_channel_count->get_value_as_int();
558 NewSessionDialog::connect_inputs() const
560 return m_connect_inputs->get_active();
564 NewSessionDialog::limit_inputs_used_for_connection() const
566 return m_limit_input_ports->get_active();
570 NewSessionDialog::input_limit_count() const
572 return m_input_limit_count->get_value_as_int();
576 NewSessionDialog::connect_outputs() const
578 return m_connect_outputs->get_active();
582 NewSessionDialog::limit_outputs_used_for_connection() const
584 return m_limit_output_ports->get_active();
588 NewSessionDialog::output_limit_count() const
590 return m_output_limit_count->get_value_as_int();
594 NewSessionDialog::connect_outs_to_master() const
596 return m_connect_outputs_to_master->get_active();
600 NewSessionDialog::connect_outs_to_physical() const
602 return m_connect_outputs_to_physical->get_active();
606 NewSessionDialog::get_current_page()
608 return m_notebook->get_current_page();
612 NewSessionDialog::set_current_page(int page)
614 return m_notebook->set_current_page (page);
618 NewSessionDialog::reset_name()
620 m_name->set_text("");
621 set_response_sensitive (Gtk::RESPONSE_OK, false);
626 NewSessionDialog::on_new_session_name_entry_changed ()
628 if (m_name->get_text() != "") {
629 set_response_sensitive (Gtk::RESPONSE_OK, true);
630 set_response_sensitive (Gtk::RESPONSE_NONE, true);
632 set_response_sensitive (Gtk::RESPONSE_OK, false);
637 NewSessionDialog::notebook_page_changed (GtkNotebookPage* np, uint pagenum)
644 on_new_session_page = false;
645 set_response_sensitive (Gtk::RESPONSE_NONE, false);
646 if (m_treeview->get_selection()->count_selected_rows() == 0) {
647 set_response_sensitive (Gtk::RESPONSE_OK, false);
649 set_response_sensitive (Gtk::RESPONSE_OK, true);
652 on_new_session_page = true;
653 if (m_name->get_text() != "") {
654 set_response_sensitive (Gtk::RESPONSE_NONE, true);
656 if (m_name->get_text() == "") {
657 set_response_sensitive (Gtk::RESPONSE_OK, false);
659 set_response_sensitive (Gtk::RESPONSE_OK, true);
665 NewSessionDialog::treeview_selection_changed ()
667 if (m_treeview->get_selection()->count_selected_rows() == 0) {
668 if (!m_open_filechooser->get_filename().empty()) {
669 set_response_sensitive (Gtk::RESPONSE_OK, true);
671 set_response_sensitive (Gtk::RESPONSE_OK, false);
674 set_response_sensitive (Gtk::RESPONSE_OK, true);
679 NewSessionDialog::file_chosen ()
681 if (on_new_session_page) return;
683 m_treeview->get_selection()->unselect_all();
685 get_window()->set_cursor(Gdk::Cursor(Gdk::WATCH));
687 if (!m_open_filechooser->get_filename().empty()) {
688 set_response_sensitive (Gtk::RESPONSE_OK, true);
689 response (Gtk::RESPONSE_OK);
691 set_response_sensitive (Gtk::RESPONSE_OK, false);
696 NewSessionDialog::template_chosen ()
698 if (m_template->get_filename() != "" ) {;
699 set_response_sensitive (Gtk::RESPONSE_NONE, true);
701 set_response_sensitive (Gtk::RESPONSE_NONE, false);
706 NewSessionDialog::recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col)
708 response (Gtk::RESPONSE_YES);
712 NewSessionDialog::connect_inputs_clicked ()
714 m_limit_input_ports->set_sensitive(m_connect_inputs->get_active());
716 if (m_connect_inputs->get_active() && m_limit_input_ports->get_active()) {
717 m_input_limit_count->set_sensitive(true);
719 m_input_limit_count->set_sensitive(false);
724 NewSessionDialog::connect_outputs_clicked ()
726 m_limit_output_ports->set_sensitive(m_connect_outputs->get_active());
728 if (m_connect_outputs->get_active() && m_limit_output_ports->get_active()) {
729 m_output_limit_count->set_sensitive(true);
731 m_output_limit_count->set_sensitive(false);
736 NewSessionDialog::limit_inputs_clicked ()
738 m_input_limit_count->set_sensitive(m_limit_input_ports->get_active());
742 NewSessionDialog::limit_outputs_clicked ()
744 m_output_limit_count->set_sensitive(m_limit_output_ports->get_active());
748 NewSessionDialog::master_bus_button_clicked ()
750 m_master_bus_channel_count->set_sensitive(m_create_master_bus->get_active());
754 NewSessionDialog::monitor_bus_button_clicked ()
756 m_control_bus_channel_count->set_sensitive(m_create_control_bus->get_active());
760 NewSessionDialog::reset_template()
762 m_template->set_filename("");
766 NewSessionDialog::reset_recent()
768 /* Shamelessly ripped from ardour_ui.cc */
769 std::vector<string *> *sessions;
770 std::vector<string *>::iterator i;
771 RecentSessionsSorter cmp;
773 recent_model->clear ();
775 ARDOUR::RecentSessions rs;
776 ARDOUR::read_recent_sessions (rs);
778 /* sort them alphabetically */
779 sort (rs.begin(), rs.end(), cmp);
780 sessions = new std::vector<std::string*>;
782 for (ARDOUR::RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) {
783 sessions->push_back (new string ((*i).second));
786 for (i = sessions->begin(); i != sessions->end(); ++i) {
788 std::vector<std::string*>* states;
789 std::vector<const gchar*> item;
790 std::string fullpath = *(*i);
792 /* remove any trailing / */
794 if (fullpath[fullpath.length()-1] == '/') {
795 fullpath = fullpath.substr (0, fullpath.length()-1);
798 /* now get available states for this session */
800 if ((states = ARDOUR::Session::possible_states (fullpath)) == 0) {
805 Gtk::TreeModel::Row row = *(recent_model->append());
807 row[recent_columns.visible_name] = Glib::path_get_basename (fullpath);
808 row[recent_columns.fullpath] = fullpath;
810 if (states->size()) {
812 /* add the children */
814 for (std::vector<std::string*>::iterator i2 = states->begin(); i2 != states->end(); ++i2) {
816 Gtk::TreeModel::Row child_row = *(recent_model->append (row.children()));
818 child_row[recent_columns.visible_name] = **i2;
819 child_row[recent_columns.fullpath] = fullpath;
831 NewSessionDialog::reset()
835 set_response_sensitive (Gtk::RESPONSE_NONE, false);