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(_("Session Name")));
42 m_name = Gtk::manage(new class Gtk::Entry());
43 session_location_label = Gtk::manage(new class Gtk::Label(_("Session Location")));
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 Control 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.5,0.5);
102 session_name_label->set_padding(0,0);
103 session_name_label->set_justify(Gtk::JUSTIFY_LEFT);
104 session_name_label->set_line_wrap(false);
105 session_name_label->set_use_markup(false);
106 session_name_label->set_selectable(false);
107 m_name->set_visibility(true);
108 m_name->set_editable(true);
109 m_name->set_max_length(0);
110 m_name->set_text("");
111 m_name->set_has_frame(true);
112 m_name->set_activates_default(false);
113 session_location_label->set_alignment(0.5,0.5);
114 session_location_label->set_padding(0,0);
115 session_location_label->set_justify(Gtk::JUSTIFY_LEFT);
116 session_location_label->set_line_wrap(false);
117 session_location_label->set_use_markup(false);
118 session_location_label->set_selectable(false);
119 session_template_label->set_alignment(0.5,0.5);
120 session_template_label->set_padding(0,0);
121 session_template_label->set_justify(Gtk::JUSTIFY_LEFT);
122 session_template_label->set_line_wrap(false);
123 session_template_label->set_use_markup(false);
124 session_template_label->set_selectable(false);
125 m_create_control_bus->set_flags(Gtk::CAN_FOCUS);
126 m_create_control_bus->set_relief(Gtk::RELIEF_NORMAL);
127 m_create_control_bus->set_mode(true);
128 m_create_control_bus->set_active(false);
129 m_control_bus_channel_count->set_flags(Gtk::CAN_FOCUS);
130 m_control_bus_channel_count->set_update_policy(Gtk::UPDATE_ALWAYS);
131 m_control_bus_channel_count->set_numeric(true);
132 m_control_bus_channel_count->set_digits(0);
133 m_control_bus_channel_count->set_wrap(false);
134 m_master_bus_channel_count->set_flags(Gtk::CAN_FOCUS);
135 m_master_bus_channel_count->set_update_policy(Gtk::UPDATE_ALWAYS);
136 m_master_bus_channel_count->set_numeric(true);
137 m_master_bus_channel_count->set_digits(0);
138 m_master_bus_channel_count->set_wrap(false);
139 m_create_master_bus->set_flags(Gtk::CAN_FOCUS);
140 m_create_master_bus->set_relief(Gtk::RELIEF_NORMAL);
141 m_create_master_bus->set_mode(true);
142 m_create_master_bus->set_active(true);
143 advanced_table->set_row_spacings(0);
144 advanced_table->set_col_spacings(0);
145 advanced_table->attach(*chan_count_label, 1, 2, 0, 1, Gtk::AttachOptions(), Gtk::AttachOptions(), 0, 0);
146 advanced_table->attach(*m_create_control_bus, 0, 1, 2, 3, Gtk::FILL, Gtk::AttachOptions(), 0, 0);
147 advanced_table->attach(*m_control_bus_channel_count, 1, 2, 2, 3, Gtk::AttachOptions(), Gtk::AttachOptions(), 0, 0);
148 advanced_table->attach(*m_master_bus_channel_count, 1, 2, 1, 2, Gtk::AttachOptions(), Gtk::AttachOptions(), 0, 0);
149 advanced_table->attach(*m_create_master_bus, 0, 1, 1, 2, Gtk::FILL, Gtk::AttachOptions(), 0, 0);
150 options_label->set_alignment(0.5,0.5);
151 options_label->set_padding(0,0);
152 options_label->set_justify(Gtk::JUSTIFY_LEFT);
153 options_label->set_line_wrap(false);
154 options_label->set_use_markup(false);
155 options_label->set_selectable(false);
156 m_connect_inputs->set_flags(Gtk::CAN_FOCUS);
157 m_connect_inputs->set_relief(Gtk::RELIEF_NORMAL);
158 m_connect_inputs->set_mode(true);
159 m_connect_inputs->set_active(false);
160 m_limit_input_ports->set_flags(Gtk::CAN_FOCUS);
161 m_limit_input_ports->set_relief(Gtk::RELIEF_NORMAL);
162 m_limit_input_ports->set_mode(true);
163 m_limit_input_ports->set_active(false);
164 m_input_limit_count->set_flags(Gtk::CAN_FOCUS);
165 m_input_limit_count->set_update_policy(Gtk::UPDATE_ALWAYS);
166 m_input_limit_count->set_numeric(true);
167 m_input_limit_count->set_digits(0);
168 m_input_limit_count->set_wrap(false);
169 input_port_limit_hbox->pack_start(*m_limit_input_ports, Gtk::PACK_SHRINK, 0);
170 input_port_limit_hbox->pack_start(*m_input_limit_count);
171 input_port_hbox->pack_start(*m_connect_inputs, Gtk::PACK_SHRINK, 0);
172 input_port_hbox->pack_start(*input_port_limit_hbox, Gtk::PACK_EXPAND_PADDING, 0);
173 input_table->set_row_spacings(0);
174 input_table->set_col_spacings(0);
175 input_table->attach(*input_port_hbox, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
176 input_port_alignment->add(*input_table);
177 input_label->set_alignment(0.5,0.5);
178 input_label->set_padding(0,0);
179 input_label->set_justify(Gtk::JUSTIFY_LEFT);
180 input_label->set_line_wrap(false);
181 input_label->set_use_markup(true);
182 input_label->set_selectable(false);
183 input_frame->set_shadow_type(Gtk::SHADOW_NONE);
184 input_frame->set_label_align(0,0.5);
185 input_frame->add(*input_port_alignment);
186 input_frame->set_label_widget(*input_label);
187 m_connect_outputs->set_flags(Gtk::CAN_FOCUS);
188 m_connect_outputs->set_relief(Gtk::RELIEF_NORMAL);
189 m_connect_outputs->set_mode(true);
190 m_connect_outputs->set_active(false);
191 m_limit_output_ports->set_flags(Gtk::CAN_FOCUS);
192 m_limit_output_ports->set_relief(Gtk::RELIEF_NORMAL);
193 m_limit_output_ports->set_mode(true);
194 m_limit_output_ports->set_active(false);
195 m_output_limit_count->set_flags(Gtk::CAN_FOCUS);
196 m_output_limit_count->set_update_policy(Gtk::UPDATE_ALWAYS);
197 m_output_limit_count->set_numeric(false);
198 m_output_limit_count->set_digits(0);
199 m_output_limit_count->set_wrap(false);
200 output_port_limit_hbox->pack_start(*m_limit_output_ports, Gtk::PACK_SHRINK, 0);
201 output_port_limit_hbox->pack_start(*m_output_limit_count);
202 output_port_hbox->pack_start(*m_connect_outputs, Gtk::PACK_SHRINK, 0);
203 output_port_hbox->pack_start(*output_port_limit_hbox, Gtk::PACK_EXPAND_PADDING, 0);
204 m_connect_outputs_to_master->set_flags(Gtk::CAN_FOCUS);
205 m_connect_outputs_to_master->set_relief(Gtk::RELIEF_NORMAL);
206 m_connect_outputs_to_master->set_mode(true);
207 m_connect_outputs_to_master->set_active(false);
208 m_connect_outputs_to_physical->set_flags(Gtk::CAN_FOCUS);
209 m_connect_outputs_to_physical->set_relief(Gtk::RELIEF_NORMAL);
210 m_connect_outputs_to_physical->set_mode(true);
211 m_connect_outputs_to_physical->set_active(false);
212 output_conn_vbox->pack_start(*m_connect_outputs_to_master, Gtk::PACK_SHRINK, 0);
213 output_conn_vbox->pack_start(*m_connect_outputs_to_physical, Gtk::PACK_SHRINK, 0);
214 output_vbox->pack_start(*output_port_hbox);
215 output_vbox->pack_start(*output_conn_vbox);
216 output_port_alignment->add(*output_vbox);
217 output_label->set_alignment(0.5,0.5);
218 output_label->set_padding(0,0);
219 output_label->set_justify(Gtk::JUSTIFY_LEFT);
220 output_label->set_line_wrap(false);
221 output_label->set_use_markup(true);
222 output_label->set_selectable(false);
223 output_frame->set_shadow_type(Gtk::SHADOW_NONE);
224 output_frame->set_label_align(0,0.5);
225 output_frame->add(*output_port_alignment);
226 output_frame->set_label_widget(*output_label);
227 advanced_vbox->pack_start(*advanced_table, Gtk::PACK_SHRINK, 0);
228 advanced_vbox->pack_start(*options_label, Gtk::PACK_SHRINK, 14);
229 advanced_vbox->pack_start(*input_frame);
230 advanced_vbox->pack_start(*output_frame);
231 advanced_label->set_alignment(0.5,0.5);
232 advanced_label->set_padding(0,0);
233 advanced_label->set_justify(Gtk::JUSTIFY_LEFT);
234 advanced_label->set_line_wrap(false);
235 advanced_label->set_use_markup(true);
236 advanced_label->set_selectable(false);
237 advanced_expander->set_flags(Gtk::CAN_FOCUS);
238 advanced_expander->set_border_width(10);
239 advanced_expander->set_expanded(true);
240 advanced_expander->set_spacing(0);
241 advanced_expander->add(*advanced_vbox);
242 advanced_expander->set_label_widget(*advanced_label);
243 new_session_table->set_border_width(5);
244 new_session_table->set_row_spacings(1);
245 new_session_table->set_col_spacings(1);
246 new_session_table->attach(*session_name_label, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
247 new_session_table->attach(*m_name, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
248 new_session_table->attach(*session_location_label, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
249 new_session_table->attach(*m_folder, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
250 new_session_table->attach(*session_template_label, 0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
251 new_session_table->attach(*m_template, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
252 new_session_table->attach(*advanced_expander, 0, 2, 3, 4, Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
253 chan_count_label->set_alignment(0.5,0.5);
254 chan_count_label->set_padding(0,0);
255 chan_count_label->set_justify(Gtk::JUSTIFY_LEFT);
256 chan_count_label->set_line_wrap(false);
257 chan_count_label->set_use_markup(false);
258 chan_count_label->set_selectable(false);
259 open_session_hbox->pack_start(*m_open_filechooser);
260 open_session_alignment->add(*open_session_hbox);
261 open_sesion_label->set_alignment(0.5,0.5);
262 open_sesion_label->set_padding(0,0);
263 open_sesion_label->set_justify(Gtk::JUSTIFY_LEFT);
264 open_sesion_label->set_line_wrap(false);
265 open_sesion_label->set_use_markup(false);
266 open_sesion_label->set_selectable(false);
267 open_session_frame->set_border_width(10);
268 open_session_frame->set_shadow_type(Gtk::SHADOW_IN);
269 open_session_frame->set_label_align(0,0.5);
270 open_session_frame->add(*open_session_alignment);
271 open_session_frame->set_label_widget(*open_sesion_label);
272 m_treeview->set_flags(Gtk::CAN_FOCUS);
273 m_treeview->set_headers_visible(true);
274 m_treeview->set_rules_hint(false);
275 m_treeview->set_reorderable(false);
276 m_treeview->set_enable_search(true);
277 m_treeview->set_fixed_height_mode(false);
278 m_treeview->set_hover_selection(false);
279 m_treeview->set_hover_expand(true);
280 recent_scrolledwindow->set_flags(Gtk::CAN_FOCUS);
281 recent_scrolledwindow->set_border_width(10);
282 recent_scrolledwindow->set_shadow_type(Gtk::SHADOW_IN);
283 recent_scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
284 recent_scrolledwindow->property_window_placement().set_value(Gtk::CORNER_TOP_LEFT);
285 recent_scrolledwindow->add(*m_treeview);
286 recent_alignment->add(*recent_scrolledwindow);
287 recent_sesion_label->set_alignment(0.5,0.5);
288 recent_sesion_label->set_padding(0,0);
289 recent_sesion_label->set_justify(Gtk::JUSTIFY_LEFT);
290 recent_sesion_label->set_line_wrap(false);
291 recent_sesion_label->set_use_markup(false);
292 recent_sesion_label->set_selectable(false);
293 recent_frame->set_border_width(10);
294 recent_frame->set_shadow_type(Gtk::SHADOW_IN);
295 recent_frame->set_label_align(0,0.5);
296 recent_frame->add(*recent_alignment);
297 recent_frame->set_label_widget(*recent_sesion_label);
298 open_session_vbox->pack_start(*open_session_frame, Gtk::PACK_SHRINK, 0);
299 open_session_vbox->pack_start(*recent_frame, Gtk::PACK_EXPAND_WIDGET, 5);
300 m_notebook->set_flags(Gtk::CAN_FOCUS);
301 m_notebook->set_show_tabs(true);
302 m_notebook->set_show_border(true);
303 m_notebook->set_tab_pos(Gtk::POS_TOP);
304 m_notebook->set_scrollable(false);
305 m_notebook->append_page(*new_session_table, _("New Session"));
306 m_notebook->pages().back().set_tab_label_packing(false, true, Gtk::PACK_START);
307 m_notebook->append_page(*open_session_vbox, _("Open Session"));
308 m_notebook->pages().back().set_tab_label_packing(false, true, Gtk::PACK_START);
309 get_vbox()->set_homogeneous(false);
310 get_vbox()->set_spacing(0);
311 get_vbox()->pack_start(*m_notebook, Gtk::PACK_SHRINK, 0);
312 set_title(_("Create New Session"));
314 //property_window_position().set_value(Gtk::WIN_POS_NONE);
315 set_resizable(false);
316 //property_destroy_with_parent().set_value(false);
317 set_has_separator(true);
318 // add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP);
319 add_button(Gtk::Stock::QUIT, Gtk::RESPONSE_CANCEL);
320 add_button(Gtk::Stock::CLEAR, Gtk::RESPONSE_NONE);
321 m_okbutton = add_button(Gtk::Stock::NEW, Gtk::RESPONSE_OK);
325 recent_model = Gtk::TreeStore::create (recent_columns);
326 m_treeview->set_model (recent_model);
327 m_treeview->append_column (_("Recent Sessions"), recent_columns.visible_name);
328 m_treeview->set_headers_visible (false);
329 m_treeview->get_selection()->set_mode (Gtk::SELECTION_SINGLE);
333 std::string path = ARDOUR::get_user_ardour_path();
335 path = ARDOUR::get_system_data_path();
338 m_template->set_current_folder (path + X_("templates/"));
340 m_template->set_show_hidden (true);
341 set_default_response (Gtk::RESPONSE_OK);
342 set_response_sensitive (Gtk::RESPONSE_OK, false);
343 set_response_sensitive (Gtk::RESPONSE_NONE, false);
344 m_notebook->show_all_children();
345 m_notebook->set_current_page(0);
347 Gtk::FileFilter* filter = manage (new (Gtk::FileFilter));
349 filter->add_pattern(X_("*.ardour"));
350 filter->add_pattern(X_("*.ardour.bak"));
351 m_open_filechooser->set_filter (*filter);
353 ///@ todo connect some signals
355 m_name->signal_key_release_event().connect(mem_fun (*this, &NewSessionDialog::entry_key_release));
356 m_notebook->signal_switch_page().connect (mem_fun (*this, &NewSessionDialog::notebook_page_changed));
357 m_treeview->get_selection()->signal_changed().connect (mem_fun (*this, &NewSessionDialog::treeview_selection_changed));
358 m_treeview->signal_row_activated().connect (mem_fun (*this, &NewSessionDialog::recent_row_activated));
359 m_open_filechooser->signal_selection_changed ().connect (mem_fun (*this, &NewSessionDialog::file_chosen));
360 m_template->signal_selection_changed ().connect (mem_fun (*this, &NewSessionDialog::template_chosen));
361 m_name->grab_focus();
365 NewSessionDialog::set_session_name(const Glib::ustring& name)
367 m_name->set_text(name);
371 NewSessionDialog::session_name() const
373 std::string str = Glib::filename_from_utf8(m_open_filechooser->get_filename());
374 std::string::size_type position = str.find_last_of ('/');
375 str = str.substr (position+1);
376 position = str.find_last_of ('.');
377 str = str.substr (0, position);
380 XXX what to do if it's a .bak file?
381 load_session doesn't allow it!
383 if ((position = str.rfind(".bak")) != string::npos) {
384 str = str.substr (0, position);
388 if (m_notebook->get_current_page() == 0) {
389 return Glib::filename_from_utf8(m_name->get_text());
391 if (m_treeview->get_selection()->count_selected_rows() == 0) {
392 return Glib::filename_from_utf8(str);
394 Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected();
395 return (*i)[recent_columns.visible_name];
400 NewSessionDialog::session_folder() const
402 if (m_notebook->get_current_page() == 0) {
403 return Glib::filename_from_utf8(m_folder->get_current_folder());
406 if (m_treeview->get_selection()->count_selected_rows() == 0) {
407 return Glib::filename_from_utf8(m_open_filechooser->get_current_folder());
409 Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected();
410 return (*i)[recent_columns.fullpath];
415 NewSessionDialog::use_session_template() const
417 if(m_template->get_filename().empty() && (m_notebook->get_current_page() == 0)) return false;
422 NewSessionDialog::session_template_name() const
424 return Glib::filename_from_utf8(m_template->get_filename());
428 NewSessionDialog::create_master_bus() const
430 return m_create_master_bus->get_active();
434 NewSessionDialog::master_channel_count() const
436 return m_master_bus_channel_count->get_value_as_int();
440 NewSessionDialog::create_control_bus() const
442 return m_create_control_bus->get_active();
446 NewSessionDialog::control_channel_count() const
448 return m_control_bus_channel_count->get_value_as_int();
452 NewSessionDialog::connect_inputs() const
454 return m_connect_inputs->get_active();
458 NewSessionDialog::limit_inputs_used_for_connection() const
460 return m_limit_input_ports->get_active();
464 NewSessionDialog::input_limit_count() const
466 return m_input_limit_count->get_value_as_int();
470 NewSessionDialog::connect_outputs() const
472 return m_connect_outputs->get_active();
476 NewSessionDialog::limit_outputs_used_for_connection() const
478 return m_limit_output_ports->get_active();
482 NewSessionDialog::output_limit_count() const
484 return m_output_limit_count->get_value_as_int();
488 NewSessionDialog::connect_outs_to_master() const
490 return m_connect_outputs_to_master->get_active();
494 NewSessionDialog::connect_outs_to_physical() const
496 return m_connect_outputs_to_physical->get_active();
500 NewSessionDialog::get_current_page()
502 return m_notebook->get_current_page();
507 NewSessionDialog::reset_name()
509 m_name->set_text("");
510 set_response_sensitive (Gtk::RESPONSE_OK, false);
515 NewSessionDialog::entry_key_release (GdkEventKey* ev)
517 if (m_name->get_text() != "") {
518 set_response_sensitive (Gtk::RESPONSE_OK, true);
519 set_response_sensitive (Gtk::RESPONSE_NONE, true);
521 set_response_sensitive (Gtk::RESPONSE_OK, false);
527 NewSessionDialog::notebook_page_changed (GtkNotebookPage* np, uint pagenum)
530 m_okbutton->set_label(_("Open"));
531 set_response_sensitive (Gtk::RESPONSE_NONE, false);
532 m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::OPEN, Gtk::ICON_SIZE_BUTTON)));
533 if (m_treeview->get_selection()->count_selected_rows() == 0) {
534 set_response_sensitive (Gtk::RESPONSE_OK, false);
536 set_response_sensitive (Gtk::RESPONSE_OK, true);
539 if (m_name->get_text() != "") {
540 set_response_sensitive (Gtk::RESPONSE_NONE, true);
542 m_okbutton->set_label(_("New"));
543 m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::NEW, Gtk::ICON_SIZE_BUTTON)));
544 if (m_name->get_text() == "") {
545 set_response_sensitive (Gtk::RESPONSE_OK, false);
547 set_response_sensitive (Gtk::RESPONSE_OK, true);
553 NewSessionDialog::treeview_selection_changed ()
555 if (m_treeview->get_selection()->count_selected_rows() == 0) {
556 if (!m_open_filechooser->get_filename().empty()) {
557 set_response_sensitive (Gtk::RESPONSE_OK, true);
559 set_response_sensitive (Gtk::RESPONSE_OK, false);
562 set_response_sensitive (Gtk::RESPONSE_OK, true);
567 NewSessionDialog::file_chosen ()
569 m_treeview->get_selection()->unselect_all();
571 if (m_treeview->get_selection()->count_selected_rows() == 0) {
572 set_response_sensitive (Gtk::RESPONSE_OK, true);
577 NewSessionDialog::template_chosen ()
579 if (m_template->get_filename() != "" ) {;
580 set_response_sensitive (Gtk::RESPONSE_NONE, true);
582 set_response_sensitive (Gtk::RESPONSE_NONE, false);
588 NewSessionDialog::recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col)
590 response (Gtk::RESPONSE_YES);
594 NewSessionDialog::reset_template()
596 m_template->set_filename("");
600 NewSessionDialog::reset_recent()
602 /* Shamelessly ripped from ardour_ui.cc */
603 std::vector<string *> *sessions;
604 std::vector<string *>::iterator i;
605 RecentSessionsSorter cmp;
607 recent_model->clear ();
609 ARDOUR::RecentSessions rs;
610 ARDOUR::read_recent_sessions (rs);
612 /* sort them alphabetically */
613 sort (rs.begin(), rs.end(), cmp);
614 sessions = new std::vector<std::string*>;
616 for (ARDOUR::RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) {
617 sessions->push_back (new string ((*i).second));
620 for (i = sessions->begin(); i != sessions->end(); ++i) {
622 std::vector<std::string*>* states;
623 std::vector<const gchar*> item;
624 std::string fullpath = *(*i);
626 /* remove any trailing / */
628 if (fullpath[fullpath.length()-1] == '/') {
629 fullpath = fullpath.substr (0, fullpath.length()-1);
632 /* now get available states for this session */
634 if ((states = ARDOUR::Session::possible_states (fullpath)) == 0) {
639 Gtk::TreeModel::Row row = *(recent_model->append());
641 row[recent_columns.visible_name] = PBD::basename (fullpath);
642 row[recent_columns.fullpath] = fullpath;
644 if (states->size() > 1) {
646 /* add the children */
648 for (std::vector<std::string*>::iterator i2 = states->begin(); i2 != states->end(); ++i2) {
650 Gtk::TreeModel::Row child_row = *(recent_model->append (row.children()));
652 child_row[recent_columns.visible_name] = **i2;
653 child_row[recent_columns.fullpath] = fullpath;
665 NewSessionDialog::reset()
669 set_response_sensitive (Gtk::RESPONSE_NONE, false);