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/"));
305 m_template->set_title(_("select template"));
306 Gtk::FileFilter* session_filter = manage (new (Gtk::FileFilter));
307 session_filter->add_pattern(X_("*.ardour"));
308 session_filter->add_pattern(X_("*.ardour.bak"));
309 m_open_filechooser->set_filter (*session_filter);
310 m_open_filechooser->set_current_folder(getenv ("HOME"));
311 m_open_filechooser->set_title(_("select session file"));
313 Gtk::FileFilter* template_filter = manage (new (Gtk::FileFilter));
314 template_filter->add_pattern(X_("*.ardour"));
315 template_filter->add_pattern(X_("*.ardour.bak"));
316 template_filter->add_pattern(X_("*.template"));
317 m_template->set_filter (*template_filter);
319 m_folder->set_current_folder(getenv ("HOME"));
320 m_folder->set_title(_("select directory"));
322 set_default_response (Gtk::RESPONSE_OK);
323 set_response_sensitive (Gtk::RESPONSE_OK, false);
324 set_response_sensitive (Gtk::RESPONSE_NONE, false);
325 m_notebook->set_current_page(0);
327 m_notebook->show_all_children();
329 ///@ connect some signals
331 m_connect_inputs->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::connect_inputs_clicked));
332 m_connect_outputs->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::connect_outputs_clicked));
333 m_limit_input_ports->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::limit_inputs_clicked));
334 m_limit_output_ports->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::limit_outputs_clicked));
335 m_create_master_bus->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::master_bus_button_clicked));
336 m_create_control_bus->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::monitor_bus_button_clicked));
337 m_name->signal_key_release_event().connect(mem_fun (*this, &NewSessionDialog::entry_key_release));
338 m_notebook->signal_switch_page().connect (mem_fun (*this, &NewSessionDialog::notebook_page_changed));
339 m_treeview->get_selection()->signal_changed().connect (mem_fun (*this, &NewSessionDialog::treeview_selection_changed));
340 m_treeview->signal_row_activated().connect (mem_fun (*this, &NewSessionDialog::recent_row_activated));
341 m_open_filechooser->signal_selection_changed ().connect (mem_fun (*this, &NewSessionDialog::file_chosen));
342 m_template->signal_selection_changed ().connect (mem_fun (*this, &NewSessionDialog::template_chosen));
343 m_name->grab_focus();
347 NewSessionDialog::set_session_name(const Glib::ustring& name)
349 m_name->set_text(name);
353 NewSessionDialog::session_name() const
355 std::string str = Glib::filename_from_utf8(m_open_filechooser->get_filename());
356 std::string::size_type position = str.find_last_of ('/');
357 str = str.substr (position+1);
358 position = str.find_last_of ('.');
359 str = str.substr (0, position);
362 XXX what to do if it's a .bak file?
363 load_session doesn't allow it!
365 if ((position = str.rfind(".bak")) != string::npos) {
366 str = str.substr (0, position);
370 if (m_notebook->get_current_page() == 0) {
371 return Glib::filename_from_utf8(m_name->get_text());
373 if (m_treeview->get_selection()->count_selected_rows() == 0) {
374 return Glib::filename_from_utf8(str);
376 Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected();
377 return (*i)[recent_columns.visible_name];
382 NewSessionDialog::session_folder() const
384 if (m_notebook->get_current_page() == 0) {
385 return Glib::filename_from_utf8(m_folder->get_current_folder());
388 if (m_treeview->get_selection()->count_selected_rows() == 0) {
389 return Glib::filename_from_utf8(m_open_filechooser->get_current_folder());
391 Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected();
392 return (*i)[recent_columns.fullpath];
397 NewSessionDialog::use_session_template() const
399 if(m_template->get_filename().empty() && (m_notebook->get_current_page() == 0)) return false;
404 NewSessionDialog::session_template_name() const
406 return Glib::filename_from_utf8(m_template->get_filename());
410 NewSessionDialog::create_master_bus() const
412 return m_create_master_bus->get_active();
416 NewSessionDialog::master_channel_count() const
418 return m_master_bus_channel_count->get_value_as_int();
422 NewSessionDialog::create_control_bus() const
424 return m_create_control_bus->get_active();
428 NewSessionDialog::control_channel_count() const
430 return m_control_bus_channel_count->get_value_as_int();
434 NewSessionDialog::connect_inputs() const
436 return m_connect_inputs->get_active();
440 NewSessionDialog::limit_inputs_used_for_connection() const
442 return m_limit_input_ports->get_active();
446 NewSessionDialog::input_limit_count() const
448 return m_input_limit_count->get_value_as_int();
452 NewSessionDialog::connect_outputs() const
454 return m_connect_outputs->get_active();
458 NewSessionDialog::limit_outputs_used_for_connection() const
460 return m_limit_output_ports->get_active();
464 NewSessionDialog::output_limit_count() const
466 return m_output_limit_count->get_value_as_int();
470 NewSessionDialog::connect_outs_to_master() const
472 return m_connect_outputs_to_master->get_active();
476 NewSessionDialog::connect_outs_to_physical() const
478 return m_connect_outputs_to_physical->get_active();
482 NewSessionDialog::get_current_page()
484 return m_notebook->get_current_page();
489 NewSessionDialog::reset_name()
491 m_name->set_text("");
492 set_response_sensitive (Gtk::RESPONSE_OK, false);
497 NewSessionDialog::entry_key_release (GdkEventKey* ev)
499 if (m_name->get_text() != "") {
500 set_response_sensitive (Gtk::RESPONSE_OK, true);
501 set_response_sensitive (Gtk::RESPONSE_NONE, true);
503 set_response_sensitive (Gtk::RESPONSE_OK, false);
509 NewSessionDialog::notebook_page_changed (GtkNotebookPage* np, uint pagenum)
512 m_okbutton->set_label(_("Open"));
513 set_response_sensitive (Gtk::RESPONSE_NONE, false);
514 m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::OPEN, Gtk::ICON_SIZE_BUTTON)));
515 if (m_treeview->get_selection()->count_selected_rows() == 0) {
516 set_response_sensitive (Gtk::RESPONSE_OK, false);
518 set_response_sensitive (Gtk::RESPONSE_OK, true);
521 if (m_name->get_text() != "") {
522 set_response_sensitive (Gtk::RESPONSE_NONE, true);
524 m_okbutton->set_label(_("New"));
525 m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::NEW, Gtk::ICON_SIZE_BUTTON)));
526 if (m_name->get_text() == "") {
527 set_response_sensitive (Gtk::RESPONSE_OK, false);
529 set_response_sensitive (Gtk::RESPONSE_OK, true);
535 NewSessionDialog::treeview_selection_changed ()
537 if (m_treeview->get_selection()->count_selected_rows() == 0) {
538 if (!m_open_filechooser->get_filename().empty()) {
539 set_response_sensitive (Gtk::RESPONSE_OK, true);
541 set_response_sensitive (Gtk::RESPONSE_OK, false);
544 set_response_sensitive (Gtk::RESPONSE_OK, true);
549 NewSessionDialog::file_chosen ()
551 m_treeview->get_selection()->unselect_all();
553 if (!m_open_filechooser->get_filename().empty()) {
554 set_response_sensitive (Gtk::RESPONSE_OK, true);
556 set_response_sensitive (Gtk::RESPONSE_OK, false);
561 NewSessionDialog::template_chosen ()
563 if (m_template->get_filename() != "" ) {;
564 set_response_sensitive (Gtk::RESPONSE_NONE, true);
566 set_response_sensitive (Gtk::RESPONSE_NONE, false);
571 NewSessionDialog::recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col)
573 response (Gtk::RESPONSE_YES);
577 NewSessionDialog::connect_inputs_clicked ()
579 m_limit_input_ports->set_sensitive(m_connect_inputs->get_active());
583 NewSessionDialog::connect_outputs_clicked ()
585 m_limit_output_ports->set_sensitive(m_connect_outputs->get_active());
589 NewSessionDialog::limit_inputs_clicked ()
591 m_input_limit_count->set_sensitive(m_limit_input_ports->get_active());
595 NewSessionDialog::limit_outputs_clicked ()
597 m_output_limit_count->set_sensitive(m_limit_output_ports->get_active());
601 NewSessionDialog::master_bus_button_clicked ()
603 m_master_bus_channel_count->set_sensitive(m_create_master_bus->get_active());
607 NewSessionDialog::monitor_bus_button_clicked ()
609 m_control_bus_channel_count->set_sensitive(m_create_control_bus->get_active());
613 NewSessionDialog::reset_template()
615 m_template->set_filename("");
619 NewSessionDialog::reset_recent()
621 /* Shamelessly ripped from ardour_ui.cc */
622 std::vector<string *> *sessions;
623 std::vector<string *>::iterator i;
624 RecentSessionsSorter cmp;
626 recent_model->clear ();
628 ARDOUR::RecentSessions rs;
629 ARDOUR::read_recent_sessions (rs);
631 /* sort them alphabetically */
632 sort (rs.begin(), rs.end(), cmp);
633 sessions = new std::vector<std::string*>;
635 for (ARDOUR::RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) {
636 sessions->push_back (new string ((*i).second));
639 for (i = sessions->begin(); i != sessions->end(); ++i) {
641 std::vector<std::string*>* states;
642 std::vector<const gchar*> item;
643 std::string fullpath = *(*i);
645 /* remove any trailing / */
647 if (fullpath[fullpath.length()-1] == '/') {
648 fullpath = fullpath.substr (0, fullpath.length()-1);
651 /* now get available states for this session */
653 if ((states = ARDOUR::Session::possible_states (fullpath)) == 0) {
658 Gtk::TreeModel::Row row = *(recent_model->append());
660 row[recent_columns.visible_name] = Glib::path_get_basename (fullpath);
661 row[recent_columns.fullpath] = fullpath;
663 if (states->size() > 1) {
665 /* add the children */
667 for (std::vector<std::string*>::iterator i2 = states->begin(); i2 != states->end(); ++i2) {
669 Gtk::TreeModel::Row child_row = *(recent_model->append (row.children()));
671 child_row[recent_columns.visible_name] = **i2;
672 child_row[recent_columns.fullpath] = fullpath;
684 NewSessionDialog::reset()
688 set_response_sensitive (Gtk::RESPONSE_NONE, false);