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 <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>
36 NewSessionDialog::NewSessionDialog()
37 : ArdourDialog ("New Session Dialog")
39 session_name_label = Gtk::manage(new class Gtk::Label(_("New Session Name :")));
40 m_name = Gtk::manage(new class Gtk::Entry());
41 session_location_label = Gtk::manage(new class Gtk::Label(_("Create Session Directory In :")));
42 m_folder = Gtk::manage(new class Gtk::FileChooserButton(Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER));
43 session_template_label = Gtk::manage(new class Gtk::Label(_("Use Session Template :")));
44 m_template = Gtk::manage(new class Gtk::FileChooserButton());
45 chan_count_label = Gtk::manage(new class Gtk::Label(_("Channel Count")));
46 m_create_control_bus = Gtk::manage(new class Gtk::CheckButton(_("Create Monitor Bus")));
48 Gtk::Adjustment *m_control_bus_channel_count_adj = Gtk::manage(new class Gtk::Adjustment(2, 0, 100, 1, 10, 10));
49 m_control_bus_channel_count = Gtk::manage(new class Gtk::SpinButton(*m_control_bus_channel_count_adj, 1, 0));
51 Gtk::Adjustment *m_master_bus_channel_count_adj = Gtk::manage(new class Gtk::Adjustment(2, 0, 100, 1, 10, 10));
52 m_master_bus_channel_count = Gtk::manage(new class Gtk::SpinButton(*m_master_bus_channel_count_adj, 1, 0));
53 m_create_master_bus = Gtk::manage(new class Gtk::CheckButton(_("Create Master Bus")));
54 advanced_table = Gtk::manage(new class Gtk::Table(2, 2, true));
55 m_connect_inputs = Gtk::manage(new class Gtk::CheckButton(_("Automatically Connect Inputs")));
56 m_limit_input_ports = Gtk::manage(new class Gtk::CheckButton(_("Port Limit")));
58 Gtk::Adjustment *m_input_limit_count_adj = Gtk::manage(new class Gtk::Adjustment(1, 0, 100, 1, 10, 10));
59 m_input_limit_count = Gtk::manage(new class Gtk::SpinButton(*m_input_limit_count_adj, 1, 0));
60 input_port_limit_hbox = Gtk::manage(new class Gtk::HBox(false, 0));
61 input_port_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
62 input_table = Gtk::manage(new class Gtk::Table(2, 2, false));
63 input_port_alignment = Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 1));
64 input_label = Gtk::manage(new class Gtk::Label(_("<b>Track/Bus Inputs</b>")));
65 input_frame = Gtk::manage(new class Gtk::Frame());
66 m_connect_outputs = Gtk::manage(new class Gtk::CheckButton(_("Automatically Connect Outputs")));
67 m_limit_output_ports = Gtk::manage(new class Gtk::CheckButton(_("Port Limit")));
69 Gtk::Adjustment *m_output_limit_count_adj = Gtk::manage(new class Gtk::Adjustment(1, 0, 100, 1, 10, 10));
70 m_output_limit_count = Gtk::manage(new class Gtk::SpinButton(*m_output_limit_count_adj, 1, 0));
71 output_port_limit_hbox = Gtk::manage(new class Gtk::HBox(false, 0));
72 output_port_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
74 Gtk::RadioButton::Group _RadioBGroup_m_connect_outputs_to_master;
75 m_connect_outputs_to_master = Gtk::manage(new class Gtk::RadioButton(_RadioBGroup_m_connect_outputs_to_master, _("Connect to Master Bus")));
76 m_connect_outputs_to_physical = Gtk::manage(new class Gtk::RadioButton(_RadioBGroup_m_connect_outputs_to_master, _("Connect to Physical Outputs")));
77 output_conn_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
78 output_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
79 output_port_alignment = Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 1));
80 output_label = Gtk::manage(new class Gtk::Label(_("<b>Track/Bus Outputs</b>")));
81 output_frame = Gtk::manage(new class Gtk::Frame());
82 advanced_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
83 advanced_label = Gtk::manage(new class Gtk::Label(_("Advanced Options")));
84 advanced_expander = Gtk::manage(new class Gtk::Expander());
85 new_session_table = Gtk::manage(new class Gtk::Table(2, 2, false));
86 m_open_filechooser = Gtk::manage(new class Gtk::FileChooserButton());
87 open_session_hbox = Gtk::manage(new class Gtk::HBox(false, 0));
88 m_treeview = Gtk::manage(new class Gtk::TreeView());
89 recent_scrolledwindow = Gtk::manage(new class Gtk::ScrolledWindow());
90 recent_alignment = Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 1));
91 recent_sesion_label = Gtk::manage(new class Gtk::Label(_("Open Recent Session")));
92 recent_frame = Gtk::manage(new class Gtk::Frame());
93 open_session_vbox = Gtk::manage(new class Gtk::VBox(false, 0));
94 m_notebook = Gtk::manage(new class Gtk::Notebook());
95 session_name_label->set_alignment(0, 0.5);
96 session_name_label->set_padding(0,0);
97 session_name_label->set_line_wrap(false);
98 session_name_label->set_selectable(false);
99 m_name->set_editable(true);
100 m_name->set_max_length(0);
101 m_name->set_has_frame(true);
102 m_name->set_activates_default(true);
103 session_location_label->set_alignment(0,0.5);
104 session_location_label->set_padding(0,0);
105 session_location_label->set_line_wrap(false);
106 session_location_label->set_selectable(false);
107 session_template_label->set_alignment(0,0.5);
108 session_template_label->set_padding(0,0);
109 session_template_label->set_line_wrap(false);
110 session_template_label->set_selectable(false);
111 m_create_control_bus->set_flags(Gtk::CAN_FOCUS);
112 m_create_control_bus->set_relief(Gtk::RELIEF_NORMAL);
113 m_create_control_bus->set_mode(true);
114 m_create_control_bus->set_active(false);
115 m_create_control_bus->set_border_width(0);
116 m_control_bus_channel_count->set_flags(Gtk::CAN_FOCUS);
117 m_control_bus_channel_count->set_update_policy(Gtk::UPDATE_ALWAYS);
118 m_control_bus_channel_count->set_numeric(true);
119 m_control_bus_channel_count->set_digits(0);
120 m_control_bus_channel_count->set_wrap(false);
121 m_control_bus_channel_count->set_sensitive(false);
122 m_master_bus_channel_count->set_flags(Gtk::CAN_FOCUS);
123 m_master_bus_channel_count->set_update_policy(Gtk::UPDATE_ALWAYS);
124 m_master_bus_channel_count->set_numeric(true);
125 m_master_bus_channel_count->set_digits(0);
126 m_master_bus_channel_count->set_wrap(false);
127 open_session_file_label = Gtk::manage(new class Gtk::Label(_("Open Session File :")));
128 open_session_file_label->set_alignment(0, 0.5);
129 m_create_master_bus->set_flags(Gtk::CAN_FOCUS);
130 m_create_master_bus->set_relief(Gtk::RELIEF_NORMAL);
131 m_create_master_bus->set_mode(true);
132 m_create_master_bus->set_active(true);
133 m_create_master_bus->set_border_width(0);
134 advanced_table->set_row_spacings(0);
135 advanced_table->set_col_spacings(0);
136 advanced_table->attach(*chan_count_label, 1, 2, 0, 1, Gtk::AttachOptions(), Gtk::AttachOptions(), 0, 0);
137 advanced_table->attach(*m_create_control_bus, 0, 1, 2, 3, Gtk::FILL, Gtk::AttachOptions(), 0, 0);
138 advanced_table->attach(*m_control_bus_channel_count, 1, 2, 2, 3, Gtk::AttachOptions(), Gtk::AttachOptions(), 0, 0);
139 advanced_table->attach(*m_master_bus_channel_count, 1, 2, 1, 2, Gtk::AttachOptions(), Gtk::AttachOptions(), 0, 0);
140 advanced_table->attach(*m_create_master_bus, 0, 1, 1, 2, Gtk::FILL, Gtk::AttachOptions(), 0, 0);
141 m_connect_inputs->set_flags(Gtk::CAN_FOCUS);
142 m_connect_inputs->set_relief(Gtk::RELIEF_NORMAL);
143 m_connect_inputs->set_mode(true);
144 m_connect_inputs->set_active(false);
145 m_connect_inputs->set_border_width(0);
146 m_limit_input_ports->set_flags(Gtk::CAN_FOCUS);
147 m_limit_input_ports->set_relief(Gtk::RELIEF_NORMAL);
148 m_limit_input_ports->set_mode(true);
149 m_limit_input_ports->set_sensitive(false);
150 m_limit_input_ports->set_border_width(0);
151 m_input_limit_count->set_flags(Gtk::CAN_FOCUS);
152 m_input_limit_count->set_update_policy(Gtk::UPDATE_ALWAYS);
153 m_input_limit_count->set_numeric(true);
154 m_input_limit_count->set_digits(0);
155 m_input_limit_count->set_wrap(false);
156 m_input_limit_count->set_sensitive(false);
157 input_port_limit_hbox->pack_start(*m_limit_input_ports, Gtk::PACK_SHRINK, 6);
158 input_port_limit_hbox->pack_start(*m_input_limit_count, Gtk::PACK_EXPAND_PADDING, 0);
159 input_port_vbox->pack_start(*m_connect_inputs, Gtk::PACK_SHRINK, 0);
160 input_port_vbox->pack_start(*input_port_limit_hbox, Gtk::PACK_EXPAND_PADDING, 0);
161 input_table->set_row_spacings(0);
162 input_table->set_col_spacings(0);
163 input_table->attach(*input_port_vbox, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 6, 6);
164 input_port_alignment->add(*input_table);
165 input_label->set_alignment(0, 0.5);
166 input_label->set_padding(0,0);
167 input_label->set_line_wrap(false);
168 input_label->set_selectable(false);
169 input_label->set_use_markup(true);
170 input_frame->set_shadow_type(Gtk::SHADOW_NONE);
171 input_frame->set_label_align(0,0.5);
172 input_frame->add(*input_port_alignment);
173 input_frame->set_label_widget(*input_label);
174 m_connect_outputs->set_flags(Gtk::CAN_FOCUS);
175 m_connect_outputs->set_relief(Gtk::RELIEF_NORMAL);
176 m_connect_outputs->set_mode(true);
177 m_connect_outputs->set_active(false);
178 m_connect_outputs->set_border_width(0);
179 m_limit_output_ports->set_flags(Gtk::CAN_FOCUS);
180 m_limit_output_ports->set_relief(Gtk::RELIEF_NORMAL);
181 m_limit_output_ports->set_mode(true);
182 m_limit_output_ports->set_sensitive(false);
183 m_limit_output_ports->set_border_width(0);
184 m_output_limit_count->set_flags(Gtk::CAN_FOCUS);
185 m_output_limit_count->set_update_policy(Gtk::UPDATE_ALWAYS);
186 m_output_limit_count->set_numeric(false);
187 m_output_limit_count->set_digits(0);
188 m_output_limit_count->set_wrap(false);
189 m_output_limit_count->set_sensitive(false);
190 output_port_limit_hbox->pack_start(*m_limit_output_ports, Gtk::PACK_SHRINK, 6);
191 output_port_limit_hbox->pack_start(*m_output_limit_count, Gtk::PACK_EXPAND_PADDING, 0);
192 output_port_vbox->pack_start(*m_connect_outputs, Gtk::PACK_SHRINK, 0);
193 output_port_vbox->pack_start(*output_port_limit_hbox, Gtk::PACK_EXPAND_PADDING, 0);
194 m_connect_outputs_to_master->set_flags(Gtk::CAN_FOCUS);
195 m_connect_outputs_to_master->set_relief(Gtk::RELIEF_NORMAL);
196 m_connect_outputs_to_master->set_mode(true);
197 m_connect_outputs_to_master->set_active(false);
198 m_connect_outputs_to_master->set_border_width(0);
199 m_connect_outputs_to_physical->set_flags(Gtk::CAN_FOCUS);
200 m_connect_outputs_to_physical->set_relief(Gtk::RELIEF_NORMAL);
201 m_connect_outputs_to_physical->set_mode(true);
202 m_connect_outputs_to_physical->set_active(false);
203 m_connect_outputs_to_physical->set_border_width(0);
204 output_conn_vbox->pack_start(*m_connect_outputs_to_master, Gtk::PACK_SHRINK, 0);
205 output_conn_vbox->pack_start(*m_connect_outputs_to_physical, Gtk::PACK_SHRINK, 0);
206 output_vbox->set_border_width(6);
207 output_vbox->pack_start(*output_port_vbox);
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_selectable(false);
214 output_label->set_use_markup(true);
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(*input_frame, Gtk::PACK_SHRINK, 12);
221 advanced_vbox->pack_start(*output_frame, Gtk::PACK_SHRINK, 0);
222 advanced_label->set_padding(0,0);
223 advanced_label->set_line_wrap(false);
224 advanced_label->set_selectable(false);
225 advanced_label->set_alignment(0, 0.5);
226 advanced_expander->set_flags(Gtk::CAN_FOCUS);
227 advanced_expander->set_border_width(0);
228 advanced_expander->set_expanded(false);
229 advanced_expander->set_spacing(0);
230 advanced_expander->add(*advanced_vbox);
231 advanced_expander->set_label_widget(*advanced_label);
232 new_session_table->set_border_width(12);
233 new_session_table->set_row_spacings(0);
234 new_session_table->set_col_spacings(0);
235 new_session_table->attach(*session_name_label, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL, 0, 0);
236 new_session_table->attach(*m_name, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
237 new_session_table->attach(*session_location_label, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL, 0, 0);
238 new_session_table->attach(*m_folder, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
239 new_session_table->attach(*session_template_label, 0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 0, 0);
240 new_session_table->attach(*m_template, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0);
241 new_session_table->attach(*advanced_expander, 0, 2, 3, 4, Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 12);
242 chan_count_label->set_padding(0,0);
243 chan_count_label->set_line_wrap(false);
244 chan_count_label->set_selectable(false);
245 open_session_hbox->pack_start(*open_session_file_label, true, true, 12);
246 open_session_hbox->pack_start(*m_open_filechooser, true, true, 12);
247 m_treeview->set_flags(Gtk::CAN_FOCUS);
248 m_treeview->set_headers_visible(true);
249 m_treeview->set_rules_hint(false);
250 m_treeview->set_reorderable(false);
251 m_treeview->set_enable_search(true);
252 m_treeview->set_fixed_height_mode(false);
253 m_treeview->set_hover_selection(false);
254 m_treeview->set_hover_expand(true);
255 m_treeview->set_size_request(-1, 150);
256 recent_scrolledwindow->set_flags(Gtk::CAN_FOCUS);
257 recent_scrolledwindow->set_border_width(6);
258 recent_scrolledwindow->set_shadow_type(Gtk::SHADOW_IN);
259 recent_scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
260 recent_scrolledwindow->property_window_placement().set_value(Gtk::CORNER_TOP_LEFT);
261 recent_scrolledwindow->add(*m_treeview);
262 recent_alignment->add(*recent_scrolledwindow);
263 recent_sesion_label->set_padding(0,0);
264 recent_sesion_label->set_line_wrap(false);
265 recent_sesion_label->set_selectable(false);
266 recent_frame->set_border_width(12);
267 recent_frame->set_shadow_type(Gtk::SHADOW_IN);
268 recent_frame->add(*recent_alignment);
269 recent_frame->set_label_widget(*recent_sesion_label);
270 open_session_vbox->pack_start(*open_session_hbox, Gtk::PACK_SHRINK, 12);
271 open_session_vbox->pack_start(*recent_frame, Gtk::PACK_EXPAND_WIDGET, 0);
272 m_notebook->set_flags(Gtk::CAN_FOCUS);
273 m_notebook->set_scrollable(true);
274 m_notebook->append_page(*new_session_table, _("New Session"));
275 m_notebook->pages().back().set_tab_label_packing(false, true, Gtk::PACK_START);
276 m_notebook->append_page(*open_session_vbox, _("Open Session"));
277 m_notebook->pages().back().set_tab_label_packing(false, true, Gtk::PACK_START);
278 get_vbox()->set_homogeneous(false);
279 get_vbox()->set_spacing(0);
280 get_vbox()->pack_start(*m_notebook, Gtk::PACK_SHRINK, 0);
281 set_title(_("ardour: session control"));
283 //property_window_position().set_value(Gtk::WIN_POS_NONE);
284 set_resizable(false);
285 //property_destroy_with_parent().set_value(false);
286 set_has_separator(false);
287 // add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP);
288 add_button(Gtk::Stock::QUIT, Gtk::RESPONSE_CANCEL);
289 add_button(Gtk::Stock::CLEAR, Gtk::RESPONSE_NONE);
290 m_okbutton = add_button(Gtk::Stock::NEW, Gtk::RESPONSE_OK);
292 recent_model = Gtk::TreeStore::create (recent_columns);
293 m_treeview->set_model (recent_model);
294 m_treeview->append_column (_("Recent Sessions"), recent_columns.visible_name);
295 m_treeview->set_headers_visible (false);
296 m_treeview->get_selection()->set_mode (Gtk::SELECTION_SINGLE);
298 std::string path = ARDOUR::get_user_ardour_path();
300 path = ARDOUR::get_system_data_path();
303 m_template->set_current_folder (path + X_("templates/"));
306 const std::string sys_templates_dir = ARDOUR::get_system_data_path() + X_("templates");
307 if (Glib::file_test(sys_templates_dir, Glib::FILE_TEST_IS_DIR))
308 m_template->add_shortcut_folder(sys_templates_dir);
310 m_template->set_title(_("select template"));
311 Gtk::FileFilter* session_filter = manage (new (Gtk::FileFilter));
312 session_filter->add_pattern(X_("*.ardour"));
313 session_filter->add_pattern(X_("*.ardour.bak"));
314 m_open_filechooser->set_filter (*session_filter);
315 m_open_filechooser->set_current_folder(getenv ("HOME"));
316 m_open_filechooser->set_title(_("select session file"));
318 Gtk::FileFilter* template_filter = manage (new (Gtk::FileFilter));
319 template_filter->add_pattern(X_("*.ardour"));
320 template_filter->add_pattern(X_("*.ardour.bak"));
321 template_filter->add_pattern(X_("*.template"));
322 m_template->set_filter (*template_filter);
324 m_folder->set_current_folder(getenv ("HOME"));
325 m_folder->set_title(_("select directory"));
327 set_default_response (Gtk::RESPONSE_OK);
328 set_response_sensitive (Gtk::RESPONSE_OK, false);
329 set_response_sensitive (Gtk::RESPONSE_NONE, false);
330 m_notebook->set_current_page(0);
332 m_notebook->show_all_children();
334 ///@ connect some signals
336 m_connect_inputs->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::connect_inputs_clicked));
337 m_connect_outputs->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::connect_outputs_clicked));
338 m_limit_input_ports->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::limit_inputs_clicked));
339 m_limit_output_ports->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::limit_outputs_clicked));
340 m_create_master_bus->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::master_bus_button_clicked));
341 m_create_control_bus->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::monitor_bus_button_clicked));
342 m_name->signal_key_release_event().connect(mem_fun (*this, &NewSessionDialog::entry_key_release));
343 m_notebook->signal_switch_page().connect (mem_fun (*this, &NewSessionDialog::notebook_page_changed));
344 m_treeview->get_selection()->signal_changed().connect (mem_fun (*this, &NewSessionDialog::treeview_selection_changed));
345 m_treeview->signal_row_activated().connect (mem_fun (*this, &NewSessionDialog::recent_row_activated));
346 m_open_filechooser->signal_selection_changed ().connect (mem_fun (*this, &NewSessionDialog::file_chosen));
347 m_template->signal_selection_changed ().connect (mem_fun (*this, &NewSessionDialog::template_chosen));
348 m_name->grab_focus();
352 NewSessionDialog::set_session_name(const Glib::ustring& name)
354 m_name->set_text(name);
358 NewSessionDialog::session_name() const
360 std::string str = Glib::filename_from_utf8(m_open_filechooser->get_filename());
361 std::string::size_type position = str.find_last_of ('/');
362 str = str.substr (position+1);
363 position = str.find_last_of ('.');
364 str = str.substr (0, position);
367 XXX what to do if it's a .bak file?
368 load_session doesn't allow it!
370 if ((position = str.rfind(".bak")) != string::npos) {
371 str = str.substr (0, position);
375 if (m_notebook->get_current_page() == 0) {
376 return Glib::filename_from_utf8(m_name->get_text());
378 if (m_treeview->get_selection()->count_selected_rows() == 0) {
379 return Glib::filename_from_utf8(str);
381 Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected();
382 return (*i)[recent_columns.visible_name];
387 NewSessionDialog::session_folder() const
389 if (m_notebook->get_current_page() == 0) {
390 return Glib::filename_from_utf8(m_folder->get_current_folder());
393 if (m_treeview->get_selection()->count_selected_rows() == 0) {
394 return Glib::filename_from_utf8(m_open_filechooser->get_current_folder());
396 Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected();
397 return (*i)[recent_columns.fullpath];
402 NewSessionDialog::use_session_template() const
404 if(m_template->get_filename().empty() && (m_notebook->get_current_page() == 0)) return false;
409 NewSessionDialog::session_template_name() const
411 return Glib::filename_from_utf8(m_template->get_filename());
415 NewSessionDialog::create_master_bus() const
417 return m_create_master_bus->get_active();
421 NewSessionDialog::master_channel_count() const
423 return m_master_bus_channel_count->get_value_as_int();
427 NewSessionDialog::create_control_bus() const
429 return m_create_control_bus->get_active();
433 NewSessionDialog::control_channel_count() const
435 return m_control_bus_channel_count->get_value_as_int();
439 NewSessionDialog::connect_inputs() const
441 return m_connect_inputs->get_active();
445 NewSessionDialog::limit_inputs_used_for_connection() const
447 return m_limit_input_ports->get_active();
451 NewSessionDialog::input_limit_count() const
453 return m_input_limit_count->get_value_as_int();
457 NewSessionDialog::connect_outputs() const
459 return m_connect_outputs->get_active();
463 NewSessionDialog::limit_outputs_used_for_connection() const
465 return m_limit_output_ports->get_active();
469 NewSessionDialog::output_limit_count() const
471 return m_output_limit_count->get_value_as_int();
475 NewSessionDialog::connect_outs_to_master() const
477 return m_connect_outputs_to_master->get_active();
481 NewSessionDialog::connect_outs_to_physical() const
483 return m_connect_outputs_to_physical->get_active();
487 NewSessionDialog::get_current_page()
489 return m_notebook->get_current_page();
494 NewSessionDialog::reset_name()
496 m_name->set_text("");
497 set_response_sensitive (Gtk::RESPONSE_OK, false);
502 NewSessionDialog::entry_key_release (GdkEventKey* ev)
504 if (m_name->get_text() != "") {
505 set_response_sensitive (Gtk::RESPONSE_OK, true);
506 set_response_sensitive (Gtk::RESPONSE_NONE, true);
508 set_response_sensitive (Gtk::RESPONSE_OK, false);
514 NewSessionDialog::notebook_page_changed (GtkNotebookPage* np, uint pagenum)
517 m_okbutton->set_label(_("Open"));
518 set_response_sensitive (Gtk::RESPONSE_NONE, false);
519 m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::OPEN, Gtk::ICON_SIZE_BUTTON)));
520 if (m_treeview->get_selection()->count_selected_rows() == 0) {
521 set_response_sensitive (Gtk::RESPONSE_OK, false);
523 set_response_sensitive (Gtk::RESPONSE_OK, true);
526 if (m_name->get_text() != "") {
527 set_response_sensitive (Gtk::RESPONSE_NONE, true);
529 m_okbutton->set_label(_("New"));
530 m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::NEW, Gtk::ICON_SIZE_BUTTON)));
531 if (m_name->get_text() == "") {
532 set_response_sensitive (Gtk::RESPONSE_OK, false);
534 set_response_sensitive (Gtk::RESPONSE_OK, true);
540 NewSessionDialog::treeview_selection_changed ()
542 if (m_treeview->get_selection()->count_selected_rows() == 0) {
543 if (!m_open_filechooser->get_filename().empty()) {
544 set_response_sensitive (Gtk::RESPONSE_OK, true);
546 set_response_sensitive (Gtk::RESPONSE_OK, false);
549 set_response_sensitive (Gtk::RESPONSE_OK, true);
554 NewSessionDialog::file_chosen ()
556 m_treeview->get_selection()->unselect_all();
558 if (!m_open_filechooser->get_filename().empty()) {
559 set_response_sensitive (Gtk::RESPONSE_OK, true);
561 set_response_sensitive (Gtk::RESPONSE_OK, false);
566 NewSessionDialog::template_chosen ()
568 if (m_template->get_filename() != "" ) {;
569 set_response_sensitive (Gtk::RESPONSE_NONE, true);
571 set_response_sensitive (Gtk::RESPONSE_NONE, false);
576 NewSessionDialog::recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col)
578 response (Gtk::RESPONSE_YES);
582 NewSessionDialog::connect_inputs_clicked ()
584 m_limit_input_ports->set_sensitive(m_connect_inputs->get_active());
588 NewSessionDialog::connect_outputs_clicked ()
590 m_limit_output_ports->set_sensitive(m_connect_outputs->get_active());
594 NewSessionDialog::limit_inputs_clicked ()
596 m_input_limit_count->set_sensitive(m_limit_input_ports->get_active());
600 NewSessionDialog::limit_outputs_clicked ()
602 m_output_limit_count->set_sensitive(m_limit_output_ports->get_active());
606 NewSessionDialog::master_bus_button_clicked ()
608 m_master_bus_channel_count->set_sensitive(m_create_master_bus->get_active());
612 NewSessionDialog::monitor_bus_button_clicked ()
614 m_control_bus_channel_count->set_sensitive(m_create_control_bus->get_active());
618 NewSessionDialog::reset_template()
620 m_template->set_filename("");
624 NewSessionDialog::reset_recent()
626 /* Shamelessly ripped from ardour_ui.cc */
627 std::vector<string *> *sessions;
628 std::vector<string *>::iterator i;
629 RecentSessionsSorter cmp;
631 recent_model->clear ();
633 ARDOUR::RecentSessions rs;
634 ARDOUR::read_recent_sessions (rs);
636 /* sort them alphabetically */
637 sort (rs.begin(), rs.end(), cmp);
638 sessions = new std::vector<std::string*>;
640 for (ARDOUR::RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) {
641 sessions->push_back (new string ((*i).second));
644 for (i = sessions->begin(); i != sessions->end(); ++i) {
646 std::vector<std::string*>* states;
647 std::vector<const gchar*> item;
648 std::string fullpath = *(*i);
650 /* remove any trailing / */
652 if (fullpath[fullpath.length()-1] == '/') {
653 fullpath = fullpath.substr (0, fullpath.length()-1);
656 /* now get available states for this session */
658 if ((states = ARDOUR::Session::possible_states (fullpath)) == 0) {
663 Gtk::TreeModel::Row row = *(recent_model->append());
665 row[recent_columns.visible_name] = Glib::path_get_basename (fullpath);
666 row[recent_columns.fullpath] = fullpath;
668 if (states->size() > 1) {
670 /* add the children */
672 for (std::vector<std::string*>::iterator i2 = states->begin(); i2 != states->end(); ++i2) {
674 Gtk::TreeModel::Row child_row = *(recent_model->append (row.children()));
676 child_row[recent_columns.visible_name] = **i2;
677 child_row[recent_columns.fullpath] = fullpath;
689 NewSessionDialog::reset()
693 set_response_sensitive (Gtk::RESPONSE_NONE, false);