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_state_utils.h>
25 #include <ardour/template_utils.h>
26 #include <ardour/session.h>
27 #include <ardour/profile.h>
29 #include <gtkmm/entry.h>
30 #include <gtkmm/filechooserbutton.h>
31 #include <gtkmm/spinbutton.h>
32 #include <gtkmm/checkbutton.h>
33 #include <gtkmm/radiobutton.h>
34 #include <gtkmm/filefilter.h>
35 #include <gtkmm/stock.h>
36 #include <gdkmm/cursor.h>
38 #include <gtkmm2ext/window_title.h>
40 using namespace Gtkmm2ext;
41 using namespace ARDOUR;
47 NewSessionDialog::NewSessionDialog()
48 : ArdourDialog ("session control")
50 in_destructor = false;
51 session_name_label = Gtk::manage(new class Gtk::Label(_("Name :")));
52 m_name = Gtk::manage(new class Gtk::Entry());
53 m_name->set_text(ARDOUR_COMMAND_LINE::session_name);
55 chan_count_label_1 = Gtk::manage(new class Gtk::Label(_("channels")));
56 chan_count_label_2 = Gtk::manage(new class Gtk::Label(_("channels")));
57 chan_count_label_3 = Gtk::manage(new class Gtk::Label(_("channels")));
58 chan_count_label_4 = Gtk::manage(new class Gtk::Label(_("channels")));
60 chan_count_label_1->set_alignment(0,0.5);
61 chan_count_label_1->set_padding(0,0);
62 chan_count_label_1->set_line_wrap(false);
64 chan_count_label_2->set_alignment(0,0.5);
65 chan_count_label_2->set_padding(0,0);
66 chan_count_label_2->set_line_wrap(false);
68 chan_count_label_3->set_alignment(0,0.5);
69 chan_count_label_3->set_padding(0,0);
70 chan_count_label_3->set_line_wrap(false);
72 chan_count_label_4->set_alignment(0,0.5);
73 chan_count_label_4->set_padding(0,0);
74 chan_count_label_4->set_line_wrap(false);
76 bus_label = Gtk::manage(new class Gtk::Label(_("<b>Busses</b>")));
77 input_label = Gtk::manage(new class Gtk::Label(_("<b>Inputs</b>")));
78 output_label = Gtk::manage(new class Gtk::Label(_("<b>Outputs</b>")));
80 session_location_label = Gtk::manage(new class Gtk::Label(_("Create Folder In :")));
81 m_folder = Gtk::manage(new class Gtk::FileChooserButton(Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER));
82 session_template_label = Gtk::manage(new class Gtk::Label(_("Template :")));
83 m_template = Gtk::manage(new class Gtk::FileChooserButton());
84 m_create_control_bus = Gtk::manage(new class Gtk::CheckButton(_("Create Monitor Bus")));
86 Gtk::Adjustment *m_control_bus_channel_count_adj = Gtk::manage(new class Gtk::Adjustment(2, 0, 100, 1, 10, 10));
87 m_control_bus_channel_count = Gtk::manage(new class Gtk::SpinButton(*m_control_bus_channel_count_adj, 1, 0));
89 Gtk::Adjustment *m_master_bus_channel_count_adj = Gtk::manage(new class Gtk::Adjustment(2, 0, 100, 1, 10, 10));
90 m_master_bus_channel_count = Gtk::manage(new class Gtk::SpinButton(*m_master_bus_channel_count_adj, 1, 0));
91 m_create_master_bus = Gtk::manage(new class Gtk::CheckButton(_("Create Master Bus")));
92 advanced_table = Gtk::manage(new class Gtk::Table(2, 2, true));
93 m_connect_inputs = Gtk::manage(new class Gtk::CheckButton(_("Automatically Connect to Physical Inputs")));
94 m_limit_input_ports = Gtk::manage(new class Gtk::CheckButton(_("Use only")));
96 Gtk::Adjustment *m_input_limit_count_adj = Gtk::manage(new class Gtk::Adjustment(1, 0, 100, 1, 10, 10));
97 m_input_limit_count = Gtk::manage(new class Gtk::SpinButton(*m_input_limit_count_adj, 1, 0));
98 input_port_limit_hbox = Gtk::manage(new class Gtk::HBox(false, 0));
99 input_port_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
100 input_table = Gtk::manage(new class Gtk::Table(2, 2, false));
102 bus_frame = Gtk::manage(new class Gtk::Frame());
103 bus_table = Gtk::manage (new Gtk::Table (2, 3, false));
105 input_frame = Gtk::manage(new class Gtk::Frame());
106 m_connect_outputs = Gtk::manage(new class Gtk::CheckButton(_("Automatically Connect Outputs")));
107 m_limit_output_ports = Gtk::manage(new class Gtk::CheckButton(_("Use only")));
109 Gtk::Adjustment *m_output_limit_count_adj = Gtk::manage(new class Gtk::Adjustment(1, 0, 100, 1, 10, 10));
110 m_output_limit_count = Gtk::manage(new class Gtk::SpinButton(*m_output_limit_count_adj, 1, 0));
111 output_port_limit_hbox = Gtk::manage(new class Gtk::HBox(false, 0));
112 output_port_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
114 Gtk::RadioButton::Group _RadioBGroup_m_connect_outputs_to_master;
115 m_connect_outputs_to_master = Gtk::manage(new class Gtk::RadioButton(_RadioBGroup_m_connect_outputs_to_master, _("... to Master Bus")));
116 m_connect_outputs_to_physical = Gtk::manage(new class Gtk::RadioButton(_RadioBGroup_m_connect_outputs_to_master, _("... to Physical Outputs")));
117 output_conn_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
118 output_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
120 output_frame = Gtk::manage(new class Gtk::Frame());
121 advanced_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
122 advanced_label = Gtk::manage(new class Gtk::Label(_("Advanced Options")));
123 advanced_expander = Gtk::manage(new class Gtk::Expander());
124 new_session_table = Gtk::manage(new class Gtk::Table(2, 2, false));
125 m_open_filechooser = Gtk::manage(new class Gtk::FileChooserButton());
126 open_session_hbox = Gtk::manage(new class Gtk::HBox(false, 0));
127 m_treeview = Gtk::manage(new class Gtk::TreeView());
128 recent_scrolledwindow = Gtk::manage(new class Gtk::ScrolledWindow());
130 recent_sesion_label = Gtk::manage(new class Gtk::Label(_("Recent:")));
131 recent_frame = Gtk::manage(new class Gtk::Frame());
132 open_session_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
133 m_notebook = Gtk::manage(new class Gtk::Notebook());
134 session_name_label->set_alignment(0, 0.5);
135 session_name_label->set_padding(6,0);
136 session_name_label->set_line_wrap(false);
137 session_name_label->set_selectable(false);
138 m_name->set_editable(true);
139 m_name->set_max_length(0);
140 m_name->set_has_frame(true);
141 m_name->set_activates_default(true);
142 m_name->set_width_chars (40);
143 session_location_label->set_alignment(0,0.5);
144 session_location_label->set_padding(6,0);
145 session_location_label->set_line_wrap(false);
146 session_location_label->set_selectable(false);
147 session_template_label->set_alignment(0,0.5);
148 session_template_label->set_padding(6,0);
149 session_template_label->set_line_wrap(false);
150 session_template_label->set_selectable(false);
151 m_create_control_bus->set_flags(Gtk::CAN_FOCUS);
152 m_create_control_bus->set_relief(Gtk::RELIEF_NORMAL);
153 m_create_control_bus->set_mode(true);
154 m_create_control_bus->set_active(false);
155 m_create_control_bus->set_border_width(0);
156 m_control_bus_channel_count->set_flags(Gtk::CAN_FOCUS);
157 m_control_bus_channel_count->set_update_policy(Gtk::UPDATE_ALWAYS);
158 m_control_bus_channel_count->set_numeric(true);
159 m_control_bus_channel_count->set_digits(0);
160 m_control_bus_channel_count->set_wrap(false);
161 m_control_bus_channel_count->set_sensitive(false);
162 m_master_bus_channel_count->set_flags(Gtk::CAN_FOCUS);
163 m_master_bus_channel_count->set_update_policy(Gtk::UPDATE_ALWAYS);
164 m_master_bus_channel_count->set_numeric(true);
165 m_master_bus_channel_count->set_digits(0);
166 m_master_bus_channel_count->set_wrap(false);
167 open_session_file_label = Gtk::manage(new class Gtk::Label(_("Browse:")));
168 open_session_file_label->set_alignment(0, 0.5);
169 m_create_master_bus->set_flags(Gtk::CAN_FOCUS);
170 m_create_master_bus->set_relief(Gtk::RELIEF_NORMAL);
171 m_create_master_bus->set_mode(true);
172 m_create_master_bus->set_active(true);
173 m_create_master_bus->set_border_width(0);
174 advanced_table->set_row_spacings(0);
175 advanced_table->set_col_spacings(0);
177 m_connect_inputs->set_flags(Gtk::CAN_FOCUS);
178 m_connect_inputs->set_relief(Gtk::RELIEF_NORMAL);
179 m_connect_inputs->set_mode(true);
180 m_connect_inputs->set_active(true);
181 m_connect_inputs->set_border_width(0);
183 m_limit_input_ports->set_flags(Gtk::CAN_FOCUS);
184 m_limit_input_ports->set_relief(Gtk::RELIEF_NORMAL);
185 m_limit_input_ports->set_mode(true);
186 m_limit_input_ports->set_sensitive(true);
187 m_limit_input_ports->set_border_width(0);
188 m_input_limit_count->set_flags(Gtk::CAN_FOCUS);
189 m_input_limit_count->set_update_policy(Gtk::UPDATE_ALWAYS);
190 m_input_limit_count->set_numeric(true);
191 m_input_limit_count->set_digits(0);
192 m_input_limit_count->set_wrap(false);
193 m_input_limit_count->set_sensitive(false);
195 bus_hbox = Gtk::manage (new Gtk::HBox (false, 0));
196 bus_hbox->pack_start (*bus_table, Gtk::PACK_SHRINK, 18);
198 bus_label->set_alignment(0, 0.5);
199 bus_label->set_padding(0,0);
200 bus_label->set_line_wrap(false);
201 bus_label->set_selectable(false);
202 bus_label->set_use_markup(true);
203 bus_frame->set_shadow_type(Gtk::SHADOW_NONE);
204 bus_frame->set_label_align(0,0.5);
205 bus_frame->add(*bus_hbox);
206 bus_frame->set_label_widget(*bus_label);
208 bus_table->set_row_spacings (0);
209 bus_table->set_col_spacings (0);
210 bus_table->attach (*m_create_master_bus, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
211 bus_table->attach (*m_master_bus_channel_count, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
212 bus_table->attach (*chan_count_label_1, 2, 3, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 6, 0);
213 bus_table->attach (*m_create_control_bus, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
214 bus_table->attach (*m_control_bus_channel_count, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
215 bus_table->attach (*chan_count_label_2, 2, 3, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 6, 0);
217 input_port_limit_hbox->pack_start(*m_limit_input_ports, Gtk::PACK_SHRINK, 6);
218 input_port_limit_hbox->pack_start(*m_input_limit_count, Gtk::PACK_SHRINK, 0);
219 input_port_limit_hbox->pack_start(*chan_count_label_3, Gtk::PACK_SHRINK, 6);
220 input_port_vbox->pack_start(*m_connect_inputs, Gtk::PACK_SHRINK, 0);
221 input_port_vbox->pack_start(*input_port_limit_hbox, Gtk::PACK_EXPAND_PADDING, 0);
222 input_table->set_row_spacings(0);
223 input_table->set_col_spacings(0);
224 input_table->attach(*input_port_vbox, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 6, 6);
226 input_hbox = Gtk::manage (new Gtk::HBox (false, 0));
227 input_hbox->pack_start (*input_table, Gtk::PACK_SHRINK, 18);
229 input_label->set_alignment(0, 0.5);
230 input_label->set_padding(0,0);
231 input_label->set_line_wrap(false);
232 input_label->set_selectable(false);
233 input_label->set_use_markup(true);
234 input_frame->set_shadow_type(Gtk::SHADOW_NONE);
235 input_frame->set_label_align(0,0.5);
236 input_frame->add(*input_hbox);
237 input_frame->set_label_widget(*input_label);
239 m_connect_outputs->set_flags(Gtk::CAN_FOCUS);
240 m_connect_outputs->set_relief(Gtk::RELIEF_NORMAL);
241 m_connect_outputs->set_mode(true);
242 m_connect_outputs->set_active(true);
243 m_connect_outputs->set_border_width(0);
244 m_limit_output_ports->set_flags(Gtk::CAN_FOCUS);
245 m_limit_output_ports->set_relief(Gtk::RELIEF_NORMAL);
246 m_limit_output_ports->set_mode(true);
247 m_limit_output_ports->set_sensitive(true);
248 m_limit_output_ports->set_border_width(0);
249 m_output_limit_count->set_flags(Gtk::CAN_FOCUS);
250 m_output_limit_count->set_update_policy(Gtk::UPDATE_ALWAYS);
251 m_output_limit_count->set_numeric(false);
252 m_output_limit_count->set_digits(0);
253 m_output_limit_count->set_wrap(false);
254 m_output_limit_count->set_sensitive(false);
255 output_port_limit_hbox->pack_start(*m_limit_output_ports, Gtk::PACK_SHRINK, 6);
256 output_port_limit_hbox->pack_start(*m_output_limit_count, Gtk::PACK_SHRINK, 0);
257 output_port_limit_hbox->pack_start(*chan_count_label_4, Gtk::PACK_SHRINK, 6);
258 m_connect_outputs_to_master->set_flags(Gtk::CAN_FOCUS);
259 m_connect_outputs_to_master->set_relief(Gtk::RELIEF_NORMAL);
260 m_connect_outputs_to_master->set_mode(true);
261 m_connect_outputs_to_master->set_active(false);
262 m_connect_outputs_to_master->set_border_width(0);
263 m_connect_outputs_to_physical->set_flags(Gtk::CAN_FOCUS);
264 m_connect_outputs_to_physical->set_relief(Gtk::RELIEF_NORMAL);
265 m_connect_outputs_to_physical->set_mode(true);
266 m_connect_outputs_to_physical->set_active(false);
267 m_connect_outputs_to_physical->set_border_width(0);
268 output_conn_vbox->pack_start(*m_connect_outputs, Gtk::PACK_SHRINK, 0);
269 output_conn_vbox->pack_start(*m_connect_outputs_to_master, Gtk::PACK_SHRINK, 0);
270 output_conn_vbox->pack_start(*m_connect_outputs_to_physical, Gtk::PACK_SHRINK, 0);
271 output_vbox->set_border_width(6);
273 output_port_vbox->pack_start(*output_port_limit_hbox, Gtk::PACK_SHRINK, 0);
275 output_vbox->pack_start(*output_conn_vbox);
276 output_vbox->pack_start(*output_port_vbox);
278 output_label->set_alignment(0, 0.5);
279 output_label->set_padding(0,0);
280 output_label->set_line_wrap(false);
281 output_label->set_selectable(false);
282 output_label->set_use_markup(true);
283 output_frame->set_shadow_type(Gtk::SHADOW_NONE);
284 output_frame->set_label_align(0,0.5);
286 output_hbox = Gtk::manage (new Gtk::HBox (false, 0));
287 output_hbox->pack_start (*output_vbox, Gtk::PACK_SHRINK, 18);
289 output_frame->add(*output_hbox);
290 output_frame->set_label_widget(*output_label);
292 advanced_vbox->pack_start(*advanced_table, Gtk::PACK_SHRINK, 0);
293 advanced_vbox->pack_start(*bus_frame, Gtk::PACK_SHRINK, 6);
294 advanced_vbox->pack_start(*input_frame, Gtk::PACK_SHRINK, 6);
295 advanced_vbox->pack_start(*output_frame, Gtk::PACK_SHRINK, 0);
296 advanced_label->set_padding(0,0);
297 advanced_label->set_line_wrap(false);
298 advanced_label->set_selectable(false);
299 advanced_label->set_alignment(0, 0.5);
300 advanced_expander->set_flags(Gtk::CAN_FOCUS);
301 advanced_expander->set_border_width(0);
302 advanced_expander->set_expanded(false);
303 advanced_expander->set_spacing(0);
304 advanced_expander->add(*advanced_vbox);
305 advanced_expander->set_label_widget(*advanced_label);
306 new_session_table->set_border_width(12);
307 new_session_table->set_row_spacings(6);
308 new_session_table->set_col_spacings(0);
309 new_session_table->attach(*session_name_label, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL, 0, 0);
310 new_session_table->attach(*m_name, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
311 new_session_table->attach(*session_location_label, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL, 0, 0);
312 new_session_table->attach(*m_folder, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
313 new_session_table->attach(*session_template_label, 0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 0, 0);
314 new_session_table->attach(*m_template, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
316 if (!ARDOUR::Profile->get_sae()) {
317 new_session_table->attach(*advanced_expander, 0, 2, 3, 4, Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 6);
320 open_session_hbox->pack_start(*open_session_file_label, false, false, 12);
321 open_session_hbox->pack_start(*m_open_filechooser, true, true, 12);
322 m_treeview->set_flags(Gtk::CAN_FOCUS);
323 m_treeview->set_headers_visible(true);
324 m_treeview->set_rules_hint(false);
325 m_treeview->set_reorderable(false);
326 m_treeview->set_enable_search(true);
327 m_treeview->set_fixed_height_mode(false);
328 m_treeview->set_hover_selection(false);
329 m_treeview->set_size_request(-1, 150);
330 recent_scrolledwindow->set_flags(Gtk::CAN_FOCUS);
331 recent_scrolledwindow->set_border_width(6);
332 recent_scrolledwindow->set_shadow_type(Gtk::SHADOW_IN);
333 recent_scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
334 recent_scrolledwindow->property_window_placement().set_value(Gtk::CORNER_TOP_LEFT);
335 recent_scrolledwindow->add(*m_treeview);
337 recent_sesion_label->set_padding(0,0);
338 recent_sesion_label->set_line_wrap(false);
339 recent_sesion_label->set_selectable(false);
340 recent_frame->set_border_width(12);
341 recent_frame->set_shadow_type(Gtk::SHADOW_NONE);
342 recent_frame->add(*recent_scrolledwindow);
343 recent_frame->set_label_widget(*recent_sesion_label);
344 open_session_vbox->pack_start(*recent_frame, Gtk::PACK_EXPAND_WIDGET, 0);
345 open_session_vbox->pack_start(*open_session_hbox, Gtk::PACK_SHRINK, 12);
346 m_notebook->set_flags(Gtk::CAN_FOCUS);
347 m_notebook->set_scrollable(true);
348 get_vbox()->set_homogeneous(false);
349 get_vbox()->set_spacing(0);
350 get_vbox()->pack_start(*m_notebook, Gtk::PACK_SHRINK, 0);
353 icon setting is done again in the editor (for the whole app),
354 but its all chickens and eggs at this point.
357 list<Glib::RefPtr<Gdk::Pixbuf> > window_icons;
358 Glib::RefPtr<Gdk::Pixbuf> icon;
360 if ((icon = ::get_icon ("ardour_icon_16px")) != 0) {
361 window_icons.push_back (icon);
363 if ((icon = ::get_icon ("ardour_icon_22px")) != 0) {
364 window_icons.push_back (icon);
366 if ((icon = ::get_icon ("ardour_icon_32px")) != 0) {
367 window_icons.push_back (icon);
369 if ((icon = ::get_icon ("ardour_icon_48px")) != 0) {
370 window_icons.push_back (icon);
372 if (!window_icons.empty()) {
373 set_icon_list (window_icons);
376 WindowTitle title(Glib::get_application_name());
377 title += _("Session Control");
378 set_title(title.get_string());
381 //property_window_position().set_value(Gtk::WIN_POS_NONE);
382 set_resizable(false);
383 //property_destroy_with_parent().set_value(false);
384 set_has_separator(false);
385 // add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP);
386 add_button(Gtk::Stock::QUIT, Gtk::RESPONSE_CANCEL);
387 add_button(Gtk::Stock::CLEAR, Gtk::RESPONSE_NONE);
388 m_okbutton = add_button(Gtk::Stock::NEW, Gtk::RESPONSE_OK);
390 recent_model = Gtk::TreeStore::create (recent_columns);
391 m_treeview->set_model (recent_model);
392 m_treeview->append_column (_("Recent Sessions"), recent_columns.visible_name);
393 m_treeview->set_headers_visible (false);
394 m_treeview->get_selection()->set_mode (Gtk::SELECTION_SINGLE);
396 if (is_directory (user_template_directory ()))
398 m_template->set_current_folder (user_template_directory().to_string());
400 else if (is_directory (system_template_directory ()))
402 m_template->set_current_folder (system_template_directory().to_string());
405 if (is_directory (system_template_directory ()))
407 m_template->add_shortcut_folder (system_template_directory().to_string());
410 m_template->set_title(_("select template"));
411 Gtk::FileFilter* session_filter = manage (new (Gtk::FileFilter));
412 session_filter->add_pattern(X_("*.ardour"));
413 session_filter->add_pattern(X_("*.ardour.bak"));
414 m_open_filechooser->set_filter (*session_filter);
415 m_open_filechooser->set_current_folder(getenv ("HOME"));
416 m_open_filechooser->set_title(_("select session file"));
418 Gtk::FileFilter* template_filter = manage (new (Gtk::FileFilter));
419 template_filter->add_pattern(X_("*.template"));
420 m_template->set_filter (*template_filter);
422 m_folder->set_current_folder(getenv ("HOME"));
423 m_folder->set_title(_("select directory"));
425 m_notebook->set_current_page(0);
427 m_notebook->show_all_children();
430 set_default_response (Gtk::RESPONSE_OK);
431 if (!ARDOUR_COMMAND_LINE::session_name.length()) {
432 set_response_sensitive (Gtk::RESPONSE_OK, false);
433 set_response_sensitive (Gtk::RESPONSE_NONE, false);
435 set_response_sensitive (Gtk::RESPONSE_OK, true);
436 set_response_sensitive (Gtk::RESPONSE_NONE, true);
439 ///@ connect some signals
441 m_connect_inputs->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::connect_inputs_clicked));
442 m_connect_outputs->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::connect_outputs_clicked));
443 m_limit_input_ports->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::limit_inputs_clicked));
444 m_limit_output_ports->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::limit_outputs_clicked));
445 m_create_master_bus->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::master_bus_button_clicked));
446 m_create_control_bus->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::monitor_bus_button_clicked));
447 m_name->signal_changed().connect(mem_fun (*this, &NewSessionDialog::on_new_session_name_entry_changed));
448 m_notebook->signal_switch_page().connect (mem_fun (*this, &NewSessionDialog::notebook_page_changed));
449 m_treeview->get_selection()->signal_changed().connect (mem_fun (*this, &NewSessionDialog::treeview_selection_changed));
450 m_treeview->signal_row_activated().connect (mem_fun (*this, &NewSessionDialog::recent_row_activated));
451 m_open_filechooser->signal_selection_changed ().connect (mem_fun (*this, &NewSessionDialog::file_chosen));
452 m_template->signal_selection_changed ().connect (mem_fun (*this, &NewSessionDialog::template_chosen));
454 page_set = Pages (0);
457 NewSessionDialog::~NewSessionDialog()
459 in_destructor = true;
463 NewSessionDialog::run ()
466 /* nothing to display */
467 return Gtk::RESPONSE_OK;
470 return ArdourDialog::run ();
474 NewSessionDialog::set_have_engine (bool yn)
477 m_notebook->remove_page (engine_control);
478 page_set = Pages (page_set & ~EnginePage);
480 if (!(page_set & EnginePage)) {
481 m_notebook->append_page (engine_control, _("Audio Setup"));
482 m_notebook->show_all_children();
483 page_set = Pages (page_set | EnginePage);
490 NewSessionDialog::set_existing_session (bool yn)
494 if (page_set & NewPage) {
495 m_notebook->remove_page (*new_session_table);
496 page_set = Pages (page_set & ~NewPage);
499 if (page_set & OpenPage) {
500 m_notebook->remove_page (*open_session_vbox);
501 page_set = Pages (page_set & ~OpenPage);
505 if (!(page_set & NewPage)) {
506 m_notebook->append_page(*new_session_table, _("New Session"));
507 m_notebook->pages().back().set_tab_label_packing(false, true, Gtk::PACK_START);
508 page_set = Pages (page_set | NewPage);
510 if (!(page_set & OpenPage)) {
511 m_notebook->append_page(*open_session_vbox, _("Open Session"));
512 m_notebook->pages().back().set_tab_label_packing(false, true, Gtk::PACK_START);
513 page_set = Pages (page_set | OpenPage);
516 m_notebook->show_all_children();
521 NewSessionDialog::set_session_name (const Glib::ustring& name)
523 m_name->set_text (name);
527 NewSessionDialog::set_session_folder(const Glib::ustring& dir)
529 m_folder->set_current_folder (dir);
533 NewSessionDialog::session_name() const
535 std::string str = Glib::filename_from_utf8(m_open_filechooser->get_filename());
536 std::string::size_type position = str.find_last_of ('/');
537 str = str.substr (position+1);
538 position = str.find_last_of ('.');
539 str = str.substr (0, position);
542 XXX what to do if it's a .bak file?
543 load_session doesn't allow it!
545 if ((position = str.rfind(".bak")) != string::npos) {
546 str = str.substr (0, position);
550 int page = m_notebook->get_current_page();
552 if (page == 0 || page == 2) {
553 /* new or audio setup pages */
554 return Glib::filename_from_utf8(m_name->get_text());
556 if (m_treeview->get_selection()->count_selected_rows() == 0) {
557 return Glib::filename_from_utf8(str);
559 Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected();
560 return (*i)[recent_columns.visible_name];
565 NewSessionDialog::session_folder() const
567 if (m_notebook->get_current_page() == 0) {
568 return Glib::filename_from_utf8(m_folder->get_filename());
571 if (m_treeview->get_selection()->count_selected_rows() == 0) {
572 const string filename(Glib::filename_from_utf8(m_open_filechooser->get_filename()));
573 return Glib::path_get_dirname(filename);
575 Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected();
576 return (*i)[recent_columns.fullpath];
581 NewSessionDialog::use_session_template() const
583 if(m_template->get_filename().empty() && (m_notebook->get_current_page() == 0)) return false;
588 NewSessionDialog::session_template_name() const
590 return Glib::filename_from_utf8(m_template->get_filename());
594 NewSessionDialog::create_master_bus() const
596 return m_create_master_bus->get_active();
600 NewSessionDialog::master_channel_count() const
602 return m_master_bus_channel_count->get_value_as_int();
606 NewSessionDialog::create_control_bus() const
608 return m_create_control_bus->get_active();
612 NewSessionDialog::control_channel_count() const
614 return m_control_bus_channel_count->get_value_as_int();
618 NewSessionDialog::connect_inputs() const
620 return m_connect_inputs->get_active();
624 NewSessionDialog::limit_inputs_used_for_connection() const
626 return m_limit_input_ports->get_active();
630 NewSessionDialog::input_limit_count() const
632 return m_input_limit_count->get_value_as_int();
636 NewSessionDialog::connect_outputs() const
638 return m_connect_outputs->get_active();
642 NewSessionDialog::limit_outputs_used_for_connection() const
644 return m_limit_output_ports->get_active();
648 NewSessionDialog::output_limit_count() const
650 return m_output_limit_count->get_value_as_int();
654 NewSessionDialog::connect_outs_to_master() const
656 return m_connect_outputs_to_master->get_active();
660 NewSessionDialog::connect_outs_to_physical() const
662 return m_connect_outputs_to_physical->get_active();
666 NewSessionDialog::get_current_page() const
668 return m_notebook->get_current_page();
671 NewSessionDialog::Pages
672 NewSessionDialog::which_page ()
674 int num = m_notebook->get_current_page();
676 if (page_set == NewPage) {
679 } else if (page_set == OpenPage) {
682 } else if (page_set == EnginePage) {
685 } else if (page_set == NewPage|OpenPage) {
693 } else if (page_set == NewPage|EnginePage) {
701 } else if (page_set == NewPage|EnginePage|OpenPage) {
711 } else if (page_set == OpenPage|EnginePage) {
722 NewSessionDialog::set_current_page(int page)
724 return m_notebook->set_current_page (page);
728 NewSessionDialog::reset_name()
730 m_name->set_text("");
731 set_response_sensitive (Gtk::RESPONSE_OK, false);
735 NewSessionDialog::on_new_session_name_entry_changed ()
737 if (m_name->get_text() != "") {
738 set_response_sensitive (Gtk::RESPONSE_OK, true);
739 set_response_sensitive (Gtk::RESPONSE_NONE, true);
741 set_response_sensitive (Gtk::RESPONSE_OK, false);
746 NewSessionDialog::notebook_page_changed (GtkNotebookPage* np, uint pagenum)
752 switch (which_page()) {
754 on_new_session_page = false;
755 m_okbutton->set_label(_("Open"));
756 m_okbutton->set_image (*(manage (new Gtk::Image (Gtk::Stock::OPEN, Gtk::ICON_SIZE_BUTTON))));
757 set_response_sensitive (Gtk::RESPONSE_NONE, false);
758 m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::OPEN, Gtk::ICON_SIZE_BUTTON)));
759 if (m_treeview->get_selection()->count_selected_rows() == 0) {
760 set_response_sensitive (Gtk::RESPONSE_OK, false);
762 set_response_sensitive (Gtk::RESPONSE_OK, true);
767 on_new_session_page = false;
768 m_okbutton->set_label(_("Open"));
769 m_okbutton->set_image (*(manage (new Gtk::Image (Gtk::Stock::OPEN, Gtk::ICON_SIZE_BUTTON))));
770 set_response_sensitive (Gtk::RESPONSE_NONE, false);
771 set_response_sensitive (Gtk::RESPONSE_OK, true);
775 m_okbutton->set_label(_("New"));
776 m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::NEW, Gtk::ICON_SIZE_BUTTON)));
777 m_okbutton->set_label(_("New"));
778 m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::NEW, Gtk::ICON_SIZE_BUTTON)));
779 if (m_name->get_text() == "") {
780 set_response_sensitive (Gtk::RESPONSE_OK, false);
781 m_name->grab_focus();
783 set_response_sensitive (Gtk::RESPONSE_OK, true);
789 NewSessionDialog::treeview_selection_changed ()
791 if (m_treeview->get_selection()->count_selected_rows() == 0) {
792 if (!m_open_filechooser->get_filename().empty()) {
793 set_response_sensitive (Gtk::RESPONSE_OK, true);
795 set_response_sensitive (Gtk::RESPONSE_OK, false);
798 set_response_sensitive (Gtk::RESPONSE_OK, true);
803 NewSessionDialog::file_chosen ()
805 switch (which_page()) {
813 m_treeview->get_selection()->unselect_all();
815 Glib::RefPtr<Gdk::Window> win (get_window());
818 win->set_cursor(Gdk::Cursor(Gdk::WATCH));
821 if (!m_open_filechooser->get_filename().empty()) {
822 set_response_sensitive (Gtk::RESPONSE_OK, true);
823 response (Gtk::RESPONSE_OK);
825 set_response_sensitive (Gtk::RESPONSE_OK, false);
830 NewSessionDialog::template_chosen ()
832 if (m_template->get_filename() != "" ) {;
833 set_response_sensitive (Gtk::RESPONSE_NONE, true);
835 set_response_sensitive (Gtk::RESPONSE_NONE, false);
840 NewSessionDialog::recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col)
842 response (Gtk::RESPONSE_YES);
846 NewSessionDialog::connect_inputs_clicked ()
848 m_limit_input_ports->set_sensitive(m_connect_inputs->get_active());
850 if (m_connect_inputs->get_active() && m_limit_input_ports->get_active()) {
851 m_input_limit_count->set_sensitive(true);
853 m_input_limit_count->set_sensitive(false);
858 NewSessionDialog::connect_outputs_clicked ()
860 m_limit_output_ports->set_sensitive(m_connect_outputs->get_active());
862 if (m_connect_outputs->get_active() && m_limit_output_ports->get_active()) {
863 m_output_limit_count->set_sensitive(true);
865 m_output_limit_count->set_sensitive(false);
870 NewSessionDialog::limit_inputs_clicked ()
872 m_input_limit_count->set_sensitive(m_limit_input_ports->get_active());
876 NewSessionDialog::limit_outputs_clicked ()
878 m_output_limit_count->set_sensitive(m_limit_output_ports->get_active());
882 NewSessionDialog::master_bus_button_clicked ()
884 m_master_bus_channel_count->set_sensitive(m_create_master_bus->get_active());
888 NewSessionDialog::monitor_bus_button_clicked ()
890 m_control_bus_channel_count->set_sensitive(m_create_control_bus->get_active());
894 NewSessionDialog::reset_template()
896 m_template->set_filename("");
900 NewSessionDialog::reset_recent()
902 std::vector<sys::path> session_directories;
903 RecentSessionsSorter cmp;
905 recent_model->clear ();
907 ARDOUR::RecentSessions rs;
908 ARDOUR::read_recent_sessions (rs);
910 // sort them alphabetically
911 sort (rs.begin(), rs.end(), cmp);
913 for (ARDOUR::RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) {
914 session_directories.push_back ((*i).second);
917 for (vector<sys::path>::const_iterator i = session_directories.begin();
918 i != session_directories.end(); ++i)
920 std::vector<sys::path> state_file_paths;
922 // now get available states for this session
924 get_state_files_in_directory (*i, state_file_paths);
926 if (state_file_paths.empty()) {
931 std::vector<string> state_file_names(get_file_names_no_extension (state_file_paths));
933 Gtk::TreeModel::Row row = *(recent_model->append());
935 const string fullpath = (*i).to_string();
937 row[recent_columns.visible_name] = Glib::path_get_basename (fullpath);
938 row[recent_columns.fullpath] = fullpath;
940 if (state_file_names.size() > 1) {
944 for (std::vector<std::string>::iterator i2 = state_file_names.begin();
945 i2 != state_file_names.end(); ++i2)
948 Gtk::TreeModel::Row child_row = *(recent_model->append (row.children()));
950 child_row[recent_columns.visible_name] = *i2;
951 child_row[recent_columns.fullpath] = fullpath;
958 NewSessionDialog::reset()
962 set_response_sensitive (Gtk::RESPONSE_NONE, false);