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.
22 #include "new_session_dialog.h"
24 #include <ardour/recent_sessions.h>
25 #include <ardour/session.h>
27 #include <pbd/basename.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>
38 NewSessionDialog::NewSessionDialog()
39 : ArdourDialog ("New Session Dialog")
41 session_name_label = Gtk::manage(new class Gtk::Label(_("New Session Name")));
42 m_name = Gtk::manage(new class Gtk::Entry());
43 session_location_label = Gtk::manage(new class Gtk::Label(_("Session Directory")));
44 m_folder = Gtk::manage(new class Gtk::FileChooserButton(Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER));
45 session_template_label = Gtk::manage(new class Gtk::Label(_("Session Template")));
46 m_template = Gtk::manage(new class Gtk::FileChooserButton());
47 chan_count_label = Gtk::manage(new class Gtk::Label(_("Channel Count")));
48 m_create_control_bus = Gtk::manage(new class Gtk::CheckButton(_("Create Monitor Bus")));
50 Gtk::Adjustment *m_control_bus_channel_count_adj = Gtk::manage(new class Gtk::Adjustment(2, 0, 100, 1, 10, 10));
51 m_control_bus_channel_count = Gtk::manage(new class Gtk::SpinButton(*m_control_bus_channel_count_adj, 1, 0));
53 Gtk::Adjustment *m_master_bus_channel_count_adj = Gtk::manage(new class Gtk::Adjustment(2, 0, 100, 1, 10, 10));
54 m_master_bus_channel_count = Gtk::manage(new class Gtk::SpinButton(*m_master_bus_channel_count_adj, 1, 0));
55 m_create_master_bus = Gtk::manage(new class Gtk::CheckButton(_("Create Master Bus")));
56 advanced_table = Gtk::manage(new class Gtk::Table(2, 2, true));
57 options_label = Gtk::manage(new class Gtk::Label(_("Track/Bus Connection Options")));
58 m_connect_inputs = Gtk::manage(new class Gtk::CheckButton(_("Automatically Connect Inputs")));
59 m_limit_input_ports = Gtk::manage(new class Gtk::CheckButton(_("Port Limit")));
61 Gtk::Adjustment *m_input_limit_count_adj = Gtk::manage(new class Gtk::Adjustment(1, 0, 100, 1, 10, 10));
62 m_input_limit_count = Gtk::manage(new class Gtk::SpinButton(*m_input_limit_count_adj, 1, 0));
63 input_port_limit_hbox = Gtk::manage(new class Gtk::HBox(false, 0));
64 input_port_hbox = Gtk::manage(new class Gtk::HBox(false, 0));
65 input_table = Gtk::manage(new class Gtk::Table(2, 2, false));
66 input_port_alignment = Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 1));
67 input_label = Gtk::manage(new class Gtk::Label(_("<b>Input</b>")));
68 input_frame = Gtk::manage(new class Gtk::Frame());
69 m_connect_outputs = Gtk::manage(new class Gtk::CheckButton(_("Automatically Connect Outputs")));
70 m_limit_output_ports = Gtk::manage(new class Gtk::CheckButton(_("Port Limit")));
72 Gtk::Adjustment *m_output_limit_count_adj = Gtk::manage(new class Gtk::Adjustment(1, 0, 100, 1, 10, 10));
73 m_output_limit_count = Gtk::manage(new class Gtk::SpinButton(*m_output_limit_count_adj, 1, 0));
74 output_port_limit_hbox = Gtk::manage(new class Gtk::HBox(false, 0));
75 output_port_hbox = Gtk::manage(new class Gtk::HBox(false, 0));
77 Gtk::RadioButton::Group _RadioBGroup_m_connect_outputs_to_master;
78 m_connect_outputs_to_master = Gtk::manage(new class Gtk::RadioButton(_RadioBGroup_m_connect_outputs_to_master, _("Connect to Master Bus")));
79 m_connect_outputs_to_physical = Gtk::manage(new class Gtk::RadioButton(_RadioBGroup_m_connect_outputs_to_master, _("Connect to Physical Outputs")));
80 output_conn_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
81 output_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
82 output_port_alignment = Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 1));
83 output_label = Gtk::manage(new class Gtk::Label(_("<b>Output</b>")));
84 output_frame = Gtk::manage(new class Gtk::Frame());
85 advanced_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
86 advanced_label = Gtk::manage(new class Gtk::Label(_("<b>Advanced</b>")));
87 advanced_expander = Gtk::manage(new class Gtk::Expander());
88 new_session_table = Gtk::manage(new class Gtk::Table(2, 2, false));
89 m_open_filechooser = Gtk::manage(new class Gtk::FileChooserButton());
90 open_session_hbox = Gtk::manage(new class Gtk::HBox(false, 0));
91 open_session_alignment = Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 1));
92 open_sesion_label = Gtk::manage(new class Gtk::Label(_("Open Session")));
93 open_session_frame = Gtk::manage(new class Gtk::Frame());
94 m_treeview = Gtk::manage(new class Gtk::TreeView());
95 recent_scrolledwindow = Gtk::manage(new class Gtk::ScrolledWindow());
96 recent_alignment = Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 1));
97 recent_sesion_label = Gtk::manage(new class Gtk::Label(_("Open Recent Session")));
98 recent_frame = Gtk::manage(new class Gtk::Frame());
99 open_session_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
100 m_notebook = Gtk::manage(new class Gtk::Notebook());
101 session_name_label->set_alignment(0, 0.5);
102 session_name_label->set_padding(0,0);
103 session_name_label->set_line_wrap(false);
104 session_name_label->set_use_markup(false);
105 session_name_label->set_selectable(false);
106 m_name->set_editable(true);
107 m_name->set_max_length(0);
108 m_name->set_has_frame(true);
109 m_name->set_activates_default(true);
110 session_location_label->set_alignment(0,0.5);
111 session_location_label->set_padding(0,0);
112 session_location_label->set_line_wrap(false);
113 session_location_label->set_use_markup(false);
114 session_location_label->set_selectable(false);
115 session_template_label->set_alignment(0,0.5);
116 session_template_label->set_padding(0,0);
117 session_template_label->set_line_wrap(false);
118 session_template_label->set_use_markup(false);
119 session_template_label->set_selectable(false);
120 m_create_control_bus->set_flags(Gtk::CAN_FOCUS);
121 m_create_control_bus->set_relief(Gtk::RELIEF_NORMAL);
122 m_create_control_bus->set_mode(true);
123 m_create_control_bus->set_active(false);
124 m_control_bus_channel_count->set_flags(Gtk::CAN_FOCUS);
125 m_control_bus_channel_count->set_update_policy(Gtk::UPDATE_ALWAYS);
126 m_control_bus_channel_count->set_numeric(true);
127 m_control_bus_channel_count->set_digits(0);
128 m_control_bus_channel_count->set_wrap(false);
129 m_master_bus_channel_count->set_flags(Gtk::CAN_FOCUS);
130 m_master_bus_channel_count->set_update_policy(Gtk::UPDATE_ALWAYS);
131 m_master_bus_channel_count->set_numeric(true);
132 m_master_bus_channel_count->set_digits(0);
133 m_master_bus_channel_count->set_wrap(false);
134 m_create_master_bus->set_flags(Gtk::CAN_FOCUS);
135 m_create_master_bus->set_relief(Gtk::RELIEF_NORMAL);
136 m_create_master_bus->set_mode(true);
137 m_create_master_bus->set_active(true);
138 advanced_table->set_row_spacings(0);
139 advanced_table->set_col_spacings(0);
140 advanced_table->attach(*chan_count_label, 1, 2, 0, 1, Gtk::AttachOptions(), Gtk::AttachOptions(), 0, 0);
141 advanced_table->attach(*m_create_control_bus, 0, 1, 2, 3, Gtk::FILL, Gtk::AttachOptions(), 0, 0);
142 advanced_table->attach(*m_control_bus_channel_count, 1, 2, 2, 3, Gtk::AttachOptions(), Gtk::AttachOptions(), 0, 0);
143 advanced_table->attach(*m_master_bus_channel_count, 1, 2, 1, 2, Gtk::AttachOptions(), Gtk::AttachOptions(), 0, 0);
144 advanced_table->attach(*m_create_master_bus, 0, 1, 1, 2, Gtk::FILL, Gtk::AttachOptions(), 0, 0);
145 options_label->set_alignment(0, 0.5);
146 options_label->set_padding(0,0);
147 options_label->set_line_wrap(false);
148 options_label->set_use_markup(false);
149 options_label->set_selectable(false);
150 m_connect_inputs->set_flags(Gtk::CAN_FOCUS);
151 m_connect_inputs->set_relief(Gtk::RELIEF_NORMAL);
152 m_connect_inputs->set_mode(true);
153 m_connect_inputs->set_active(false);
154 m_limit_input_ports->set_flags(Gtk::CAN_FOCUS);
155 m_limit_input_ports->set_relief(Gtk::RELIEF_NORMAL);
156 m_limit_input_ports->set_mode(true);
157 m_limit_input_ports->set_active(false);
158 m_input_limit_count->set_flags(Gtk::CAN_FOCUS);
159 m_input_limit_count->set_update_policy(Gtk::UPDATE_ALWAYS);
160 m_input_limit_count->set_numeric(true);
161 m_input_limit_count->set_digits(0);
162 m_input_limit_count->set_wrap(false);
163 input_port_limit_hbox->pack_start(*m_limit_input_ports, Gtk::PACK_SHRINK, 0);
164 input_port_limit_hbox->pack_start(*m_input_limit_count);
165 input_port_hbox->pack_start(*m_connect_inputs, Gtk::PACK_SHRINK, 0);
166 input_port_hbox->pack_start(*input_port_limit_hbox, Gtk::PACK_EXPAND_PADDING, 0);
167 input_table->set_row_spacings(0);
168 input_table->set_col_spacings(0);
169 input_table->attach(*input_port_hbox, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
170 input_port_alignment->add(*input_table);
171 input_label->set_alignment(0, 0.5);
172 input_label->set_padding(0,0);
173 input_label->set_line_wrap(false);
174 input_label->set_use_markup(true);
175 input_label->set_selectable(false);
176 input_frame->set_shadow_type(Gtk::SHADOW_NONE);
177 input_frame->set_label_align(0,0.5);
178 input_frame->add(*input_port_alignment);
179 input_frame->set_label_widget(*input_label);
180 m_connect_outputs->set_flags(Gtk::CAN_FOCUS);
181 m_connect_outputs->set_relief(Gtk::RELIEF_NORMAL);
182 m_connect_outputs->set_mode(true);
183 m_connect_outputs->set_active(false);
184 m_limit_output_ports->set_flags(Gtk::CAN_FOCUS);
185 m_limit_output_ports->set_relief(Gtk::RELIEF_NORMAL);
186 m_limit_output_ports->set_mode(true);
187 m_limit_output_ports->set_active(false);
188 m_output_limit_count->set_flags(Gtk::CAN_FOCUS);
189 m_output_limit_count->set_update_policy(Gtk::UPDATE_ALWAYS);
190 m_output_limit_count->set_numeric(false);
191 m_output_limit_count->set_digits(0);
192 m_output_limit_count->set_wrap(false);
193 output_port_limit_hbox->pack_start(*m_limit_output_ports, Gtk::PACK_SHRINK, 0);
194 output_port_limit_hbox->pack_start(*m_output_limit_count);
195 output_port_hbox->pack_start(*m_connect_outputs, Gtk::PACK_SHRINK, 0);
196 output_port_hbox->pack_start(*output_port_limit_hbox, Gtk::PACK_EXPAND_PADDING, 0);
197 m_connect_outputs_to_master->set_flags(Gtk::CAN_FOCUS);
198 m_connect_outputs_to_master->set_relief(Gtk::RELIEF_NORMAL);
199 m_connect_outputs_to_master->set_mode(true);
200 m_connect_outputs_to_master->set_active(false);
201 m_connect_outputs_to_physical->set_flags(Gtk::CAN_FOCUS);
202 m_connect_outputs_to_physical->set_relief(Gtk::RELIEF_NORMAL);
203 m_connect_outputs_to_physical->set_mode(true);
204 m_connect_outputs_to_physical->set_active(false);
205 output_conn_vbox->pack_start(*m_connect_outputs_to_master, Gtk::PACK_SHRINK, 0);
206 output_conn_vbox->pack_start(*m_connect_outputs_to_physical, Gtk::PACK_SHRINK, 0);
207 output_vbox->pack_start(*output_port_hbox);
208 output_vbox->pack_start(*output_conn_vbox);
209 output_port_alignment->add(*output_vbox);
210 output_label->set_alignment(0, 0.5);
211 output_label->set_padding(0,0);
212 output_label->set_line_wrap(false);
213 output_label->set_use_markup(true);
214 output_label->set_selectable(false);
215 output_frame->set_shadow_type(Gtk::SHADOW_NONE);
216 output_frame->set_label_align(0,0.5);
217 output_frame->add(*output_port_alignment);
218 output_frame->set_label_widget(*output_label);
219 advanced_vbox->pack_start(*advanced_table, Gtk::PACK_SHRINK, 0);
220 advanced_vbox->pack_start(*options_label, Gtk::PACK_SHRINK, 12);
221 advanced_vbox->pack_start(*input_frame);
222 advanced_vbox->pack_start(*output_frame);
223 advanced_label->set_padding(0,0);
224 advanced_label->set_line_wrap(false);
225 advanced_label->set_use_markup(true);
226 advanced_label->set_selectable(false);
227 advanced_expander->set_flags(Gtk::CAN_FOCUS);
228 advanced_expander->set_border_width(12);
229 advanced_expander->set_expanded(false);
230 advanced_expander->set_spacing(0);
231 advanced_expander->add(*advanced_vbox);
232 advanced_expander->set_label_widget(*advanced_label);
233 new_session_table->set_border_width(6);
234 new_session_table->set_row_spacings(0);
235 new_session_table->set_col_spacings(0);
236 new_session_table->attach(*session_name_label, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL, 12, 0);
237 new_session_table->attach(*m_name, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
238 new_session_table->attach(*session_location_label, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL, 12, 0);
239 new_session_table->attach(*m_folder, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
240 new_session_table->attach(*session_template_label, 0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 12, 0);
241 new_session_table->attach(*m_template, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
242 new_session_table->attach(*advanced_expander, 0, 2, 3, 4, Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
243 chan_count_label->set_padding(0,0);
244 chan_count_label->set_line_wrap(false);
245 chan_count_label->set_use_markup(false);
246 chan_count_label->set_selectable(false);
247 open_session_hbox->pack_start(*m_open_filechooser, true, true, 12);
248 open_session_alignment->add(*open_session_hbox);
249 open_sesion_label->set_padding(0,0);
250 open_sesion_label->set_line_wrap(false);
251 open_sesion_label->set_use_markup(false);
252 open_sesion_label->set_selectable(false);
253 open_session_frame->set_border_width(6);
254 open_session_frame->set_shadow_type(Gtk::SHADOW_IN);
255 open_session_frame->set_label_align(0,0.5);
256 open_session_frame->add(*open_session_alignment);
257 open_session_frame->set_label_widget(*open_sesion_label);
258 m_treeview->set_flags(Gtk::CAN_FOCUS);
259 m_treeview->set_headers_visible(true);
260 m_treeview->set_rules_hint(false);
261 m_treeview->set_reorderable(false);
262 m_treeview->set_enable_search(true);
263 m_treeview->set_fixed_height_mode(false);
264 m_treeview->set_hover_selection(false);
265 m_treeview->set_hover_expand(true);
266 m_treeview->set_size_request(-1, 150);
267 recent_scrolledwindow->set_flags(Gtk::CAN_FOCUS);
268 recent_scrolledwindow->set_border_width(10);
269 recent_scrolledwindow->set_shadow_type(Gtk::SHADOW_IN);
270 recent_scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
271 recent_scrolledwindow->property_window_placement().set_value(Gtk::CORNER_TOP_LEFT);
272 recent_scrolledwindow->add(*m_treeview);
273 recent_alignment->add(*recent_scrolledwindow);
274 recent_sesion_label->set_padding(0,0);
275 recent_sesion_label->set_line_wrap(false);
276 recent_sesion_label->set_use_markup(false);
277 recent_sesion_label->set_selectable(false);
278 recent_frame->set_border_width(6);
279 recent_frame->set_shadow_type(Gtk::SHADOW_IN);
280 recent_frame->add(*recent_alignment);
281 recent_frame->set_label_widget(*recent_sesion_label);
282 open_session_vbox->pack_start(*open_session_frame, Gtk::PACK_SHRINK, 0);
283 open_session_vbox->pack_start(*recent_frame, Gtk::PACK_EXPAND_WIDGET, 0);
284 m_notebook->set_flags(Gtk::CAN_FOCUS);
285 m_notebook->set_scrollable(true);
286 m_notebook->append_page(*new_session_table, _("New Session"));
287 m_notebook->pages().back().set_tab_label_packing(false, true, Gtk::PACK_START);
288 m_notebook->append_page(*open_session_vbox, _("Open Session"));
289 m_notebook->pages().back().set_tab_label_packing(false, true, Gtk::PACK_START);
290 get_vbox()->set_homogeneous(false);
291 get_vbox()->set_spacing(0);
292 get_vbox()->pack_start(*m_notebook, Gtk::PACK_SHRINK, 0);
293 set_title(_("ardour: session control"));
295 //property_window_position().set_value(Gtk::WIN_POS_NONE);
296 set_resizable(false);
297 //property_destroy_with_parent().set_value(false);
298 set_has_separator(false);
299 // add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP);
300 add_button(Gtk::Stock::QUIT, Gtk::RESPONSE_CANCEL);
301 add_button(Gtk::Stock::CLEAR, Gtk::RESPONSE_NONE);
302 m_okbutton = add_button(Gtk::Stock::NEW, Gtk::RESPONSE_OK);
304 recent_model = Gtk::TreeStore::create (recent_columns);
305 m_treeview->set_model (recent_model);
306 m_treeview->append_column (_("Recent Sessions"), recent_columns.visible_name);
307 m_treeview->set_headers_visible (false);
308 m_treeview->get_selection()->set_mode (Gtk::SELECTION_SINGLE);
310 std::string path = ARDOUR::get_user_ardour_path();
312 path = ARDOUR::get_system_data_path();
315 m_template->set_current_folder (path + X_("templates/"));
318 Gtk::FileFilter* session_filter = manage (new (Gtk::FileFilter));
319 session_filter->add_pattern(X_("*.ardour"));
320 session_filter->add_pattern(X_("*.ardour.bak"));
321 m_open_filechooser->set_filter (*session_filter);
322 m_open_filechooser->set_current_folder(getenv ("HOME"));
324 Gtk::FileFilter* template_filter = manage (new (Gtk::FileFilter));
325 template_filter->add_pattern(X_("*.ardour"));
326 template_filter->add_pattern(X_("*.ardour.bak"));
327 template_filter->add_pattern(X_("*.template"));
328 m_template->set_filter (*template_filter);
330 m_folder->set_current_folder(getenv ("HOME"));
332 set_default_response (Gtk::RESPONSE_OK);
333 set_response_sensitive (Gtk::RESPONSE_OK, false);
334 set_response_sensitive (Gtk::RESPONSE_NONE, false);
335 m_notebook->set_current_page(0);
337 m_notebook->show_all_children();
339 ///@ connect some signals
341 m_name->signal_key_release_event().connect(mem_fun (*this, &NewSessionDialog::entry_key_release));
342 m_notebook->signal_switch_page().connect (mem_fun (*this, &NewSessionDialog::notebook_page_changed));
343 m_treeview->get_selection()->signal_changed().connect (mem_fun (*this, &NewSessionDialog::treeview_selection_changed));
344 m_treeview->signal_row_activated().connect (mem_fun (*this, &NewSessionDialog::recent_row_activated));
345 m_open_filechooser->signal_selection_changed ().connect (mem_fun (*this, &NewSessionDialog::file_chosen));
346 m_template->signal_selection_changed ().connect (mem_fun (*this, &NewSessionDialog::template_chosen));
347 m_name->grab_focus();
351 NewSessionDialog::set_session_name(const Glib::ustring& name)
353 m_name->set_text(name);
357 NewSessionDialog::session_name() const
359 std::string str = Glib::filename_from_utf8(m_open_filechooser->get_filename());
360 std::string::size_type position = str.find_last_of ('/');
361 str = str.substr (position+1);
362 position = str.find_last_of ('.');
363 str = str.substr (0, position);
366 XXX what to do if it's a .bak file?
367 load_session doesn't allow it!
369 if ((position = str.rfind(".bak")) != string::npos) {
370 str = str.substr (0, position);
374 if (m_notebook->get_current_page() == 0) {
375 return Glib::filename_from_utf8(m_name->get_text());
377 if (m_treeview->get_selection()->count_selected_rows() == 0) {
378 return Glib::filename_from_utf8(str);
380 Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected();
381 return (*i)[recent_columns.visible_name];
386 NewSessionDialog::session_folder() const
388 if (m_notebook->get_current_page() == 0) {
389 return Glib::filename_from_utf8(m_folder->get_current_folder());
392 if (m_treeview->get_selection()->count_selected_rows() == 0) {
393 return Glib::filename_from_utf8(m_open_filechooser->get_current_folder());
395 Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected();
396 return (*i)[recent_columns.fullpath];
401 NewSessionDialog::use_session_template() const
403 if(m_template->get_filename().empty() && (m_notebook->get_current_page() == 0)) return false;
408 NewSessionDialog::session_template_name() const
410 return Glib::filename_from_utf8(m_template->get_filename());
414 NewSessionDialog::create_master_bus() const
416 return m_create_master_bus->get_active();
420 NewSessionDialog::master_channel_count() const
422 return m_master_bus_channel_count->get_value_as_int();
426 NewSessionDialog::create_control_bus() const
428 return m_create_control_bus->get_active();
432 NewSessionDialog::control_channel_count() const
434 return m_control_bus_channel_count->get_value_as_int();
438 NewSessionDialog::connect_inputs() const
440 return m_connect_inputs->get_active();
444 NewSessionDialog::limit_inputs_used_for_connection() const
446 return m_limit_input_ports->get_active();
450 NewSessionDialog::input_limit_count() const
452 return m_input_limit_count->get_value_as_int();
456 NewSessionDialog::connect_outputs() const
458 return m_connect_outputs->get_active();
462 NewSessionDialog::limit_outputs_used_for_connection() const
464 return m_limit_output_ports->get_active();
468 NewSessionDialog::output_limit_count() const
470 return m_output_limit_count->get_value_as_int();
474 NewSessionDialog::connect_outs_to_master() const
476 return m_connect_outputs_to_master->get_active();
480 NewSessionDialog::connect_outs_to_physical() const
482 return m_connect_outputs_to_physical->get_active();
486 NewSessionDialog::get_current_page()
488 return m_notebook->get_current_page();
493 NewSessionDialog::reset_name()
495 m_name->set_text("");
496 set_response_sensitive (Gtk::RESPONSE_OK, false);
501 NewSessionDialog::entry_key_release (GdkEventKey* ev)
503 if (m_name->get_text() != "") {
504 set_response_sensitive (Gtk::RESPONSE_OK, true);
505 set_response_sensitive (Gtk::RESPONSE_NONE, true);
507 set_response_sensitive (Gtk::RESPONSE_OK, false);
513 NewSessionDialog::notebook_page_changed (GtkNotebookPage* np, uint pagenum)
516 m_okbutton->set_label(_("Open"));
517 set_response_sensitive (Gtk::RESPONSE_NONE, false);
518 m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::OPEN, Gtk::ICON_SIZE_BUTTON)));
519 if (m_treeview->get_selection()->count_selected_rows() == 0) {
520 set_response_sensitive (Gtk::RESPONSE_OK, false);
522 set_response_sensitive (Gtk::RESPONSE_OK, true);
525 if (m_name->get_text() != "") {
526 set_response_sensitive (Gtk::RESPONSE_NONE, true);
528 m_okbutton->set_label(_("New"));
529 m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::NEW, Gtk::ICON_SIZE_BUTTON)));
530 if (m_name->get_text() == "") {
531 set_response_sensitive (Gtk::RESPONSE_OK, false);
533 set_response_sensitive (Gtk::RESPONSE_OK, true);
539 NewSessionDialog::treeview_selection_changed ()
541 if (m_treeview->get_selection()->count_selected_rows() == 0) {
542 if (!m_open_filechooser->get_filename().empty()) {
543 set_response_sensitive (Gtk::RESPONSE_OK, true);
545 set_response_sensitive (Gtk::RESPONSE_OK, false);
548 set_response_sensitive (Gtk::RESPONSE_OK, true);
553 NewSessionDialog::file_chosen ()
555 m_treeview->get_selection()->unselect_all();
557 if (!m_open_filechooser->get_filename().empty()) {
558 set_response_sensitive (Gtk::RESPONSE_OK, true);
560 set_response_sensitive (Gtk::RESPONSE_OK, false);
565 NewSessionDialog::template_chosen ()
567 if (m_template->get_filename() != "" ) {;
568 set_response_sensitive (Gtk::RESPONSE_NONE, true);
570 set_response_sensitive (Gtk::RESPONSE_NONE, false);
575 NewSessionDialog::recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col)
577 response (Gtk::RESPONSE_YES);
581 NewSessionDialog::reset_template()
583 m_template->set_filename("");
587 NewSessionDialog::reset_recent()
589 /* Shamelessly ripped from ardour_ui.cc */
590 std::vector<string *> *sessions;
591 std::vector<string *>::iterator i;
592 RecentSessionsSorter cmp;
594 recent_model->clear ();
596 ARDOUR::RecentSessions rs;
597 ARDOUR::read_recent_sessions (rs);
599 /* sort them alphabetically */
600 sort (rs.begin(), rs.end(), cmp);
601 sessions = new std::vector<std::string*>;
603 for (ARDOUR::RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) {
604 sessions->push_back (new string ((*i).second));
607 for (i = sessions->begin(); i != sessions->end(); ++i) {
609 std::vector<std::string*>* states;
610 std::vector<const gchar*> item;
611 std::string fullpath = *(*i);
613 /* remove any trailing / */
615 if (fullpath[fullpath.length()-1] == '/') {
616 fullpath = fullpath.substr (0, fullpath.length()-1);
619 /* now get available states for this session */
621 if ((states = ARDOUR::Session::possible_states (fullpath)) == 0) {
626 Gtk::TreeModel::Row row = *(recent_model->append());
628 row[recent_columns.visible_name] = PBD::basename (fullpath);
629 row[recent_columns.fullpath] = fullpath;
631 if (states->size() > 1) {
633 /* add the children */
635 for (std::vector<std::string*>::iterator i2 = states->begin(); i2 != states->end(); ++i2) {
637 Gtk::TreeModel::Row child_row = *(recent_model->append (row.children()));
639 child_row[recent_columns.visible_name] = **i2;
640 child_row[recent_columns.fullpath] = fullpath;
652 NewSessionDialog::reset()
656 set_response_sensitive (Gtk::RESPONSE_NONE, false);