2 Copyright (C) 2001-2006 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.
19 #include <pango/pangoft2.h> // for fontmap resolution control for GnomeCanvas
20 #include <pango/pangocairo.h> // for fontmap resolution control for GnomeCanvas
22 #include <pbd/whitespace.h>
24 #include <ardour/ardour.h>
25 #include <ardour/session.h>
26 #include <ardour/audioengine.h>
27 #include <ardour/configuration.h>
28 #include <ardour/auditioner.h>
29 #include <ardour/sndfilesource.h>
30 #include <ardour/crossfade.h>
31 #include <ardour/profile.h>
32 #include <midi++/manager.h>
33 #include <midi++/factory.h>
34 #include <gtkmm2ext/stop_signal.h>
35 #include <gtkmm2ext/utils.h>
36 #include <gtkmm2ext/window_title.h>
38 #include "public_editor.h"
41 #include "ardour_ui.h"
42 #include "io_selector.h"
43 #include "gain_meter.h"
47 #include "option_editor.h"
48 #include "midi_port_dialog.h"
49 #include "gui_thread.h"
54 using namespace ARDOUR;
57 using namespace Editing;
58 using namespace Gtkmm2ext;
61 static vector<string> positional_sync_strings;
63 OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui)
64 : ArdourDialog ("options editor", false),
74 short_xfade_adjustment (0, 1.0, 500.0, 5.0, 100.0),
75 short_xfade_slider (short_xfade_adjustment),
76 destructo_xfade_adjustment (1.0, 1.0, 500.0, 1.0, 100.0),
77 destructo_xfade_slider (destructo_xfade_adjustment),
78 history_depth (20, -1, 100, 1.0, 10.0),
79 saved_history_depth (20, 0, 100, 1.0, 10.0),
80 history_depth_spinner (history_depth),
81 saved_history_depth_spinner (saved_history_depth),
82 limit_history_button (_("Limit undo history")),
83 save_history_button (_("Save undo history")),
87 smpte_offset_clock (X_("smpteoffset"), false, X_("SMPTEOffsetClock"), true, true),
88 smpte_offset_negative_button (_("SMPTE offset is negative")),
89 synced_timecode_button (_("Timecode source is sample-clock synced")),
93 midi_port_table (4, 12),
94 mmc_receive_device_id_adjustment (0.0, 0.0, (double) 0x7f, 1.0, 16.0),
95 mmc_receive_device_id_spinner (mmc_receive_device_id_adjustment),
96 mmc_send_device_id_adjustment (0.0, 0.0, (double) 0x7f, 1.0, 16.0),
97 mmc_send_device_id_spinner (mmc_send_device_id_adjustment),
98 add_midi_port_button (_("Add new MIDI port")),
99 initial_program_change_adjustment (0.0, -1.0, (double) 0x7f, 1.0, 16.0),
100 initial_program_change_spinner (initial_program_change_adjustment),
105 click_browse_button (_("Browse")),
106 click_emphasis_browse_button (_("Browse")),
110 keyboard_mouse_table (4, 4),
111 delete_button_adjustment (3, 1, 5),
112 delete_button_spin (delete_button_adjustment),
113 edit_button_adjustment (3, 1, 5),
114 edit_button_spin (edit_button_adjustment)
117 using namespace Notebook_Helpers;
119 first_click_setup = true;
120 click_io_selector = 0;
121 auditioner_io_selector = 0;
124 WindowTitle title(Glib::get_application_name());
125 title += _("Preferences");
126 set_title(title.get_string());
128 set_default_size (300, 300);
129 set_wmclass (X_("ardour_preferences"), "Ardour");
131 set_name ("Preferences");
132 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
134 VBox *vbox = get_vbox();
135 set_border_width (3);
137 vbox->set_spacing (4);
138 vbox->pack_start(notebook);
140 signal_delete_event().connect (mem_fun(*this, &OptionEditor::wm_close));
142 notebook.set_show_tabs (true);
143 notebook.set_show_border (true);
144 notebook.set_name ("OptionsNotebook");
146 setup_sync_options();
147 setup_path_options();
148 setup_misc_options ();
149 setup_keyboard_options ();
150 setup_auditioner_editor ();
152 if (!Profile->get_sae()) {
153 notebook.pages().push_back (TabElem (sync_packer, _("Sync")));
154 notebook.pages().push_back (TabElem (path_table, _("Paths/Files")));
155 notebook.pages().push_back (TabElem (keyboard_mouse_table, _("Kbd/Mouse")));
157 notebook.pages().push_back (TabElem (click_packer, _("Click")));
158 notebook.pages().push_back (TabElem (audition_packer, _("Audition")));
159 notebook.pages().push_back (TabElem (misc_packer, _("Misc")));
161 setup_midi_options ();
162 notebook.pages().push_back (TabElem (midi_packer, _("MIDI")));
167 Config->map_parameters (mem_fun (*this, &OptionEditor::parameter_changed));
168 Config->ParameterChanged.connect (mem_fun (*this, &OptionEditor::parameter_changed));
172 OptionEditor::set_session (Session *s)
174 clear_click_editor ();
175 clear_auditioner_editor ();
177 click_path_entry.set_text ("");
178 click_emphasis_path_entry.set_text ("");
179 session_raid_entry.set_text ("");
181 click_path_entry.set_sensitive (false);
182 click_emphasis_path_entry.set_sensitive (false);
183 session_raid_entry.set_sensitive (false);
185 short_xfade_slider.set_sensitive (false);
186 smpte_offset_negative_button.set_sensitive (false);
188 smpte_offset_clock.set_session (s);
190 if ((session = s) == 0) {
194 click_path_entry.set_sensitive (true);
195 click_emphasis_path_entry.set_sensitive (true);
196 session_raid_entry.set_sensitive (true);
197 short_xfade_slider.set_sensitive (true);
198 smpte_offset_negative_button.set_sensitive (true);
200 smpte_offset_clock.set_session (s);
201 smpte_offset_clock.set (s->smpte_offset (), true);
203 smpte_offset_negative_button.set_active (session->smpte_offset_negative());
205 redisplay_midi_ports ();
207 setup_click_editor ();
208 connect_audition_editor ();
210 short_xfade_adjustment.set_value ((Crossfade::short_xfade_length() / (float) session->frame_rate()) * 1000.0);
212 add_session_paths ();
215 OptionEditor::~OptionEditor ()
220 OptionEditor::setup_path_options()
224 path_table.set_homogeneous (false);
225 path_table.set_border_width (12);
226 path_table.set_row_spacings (5);
228 session_raid_entry.set_name ("OptionsEntry");
230 session_raid_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::raid_path_changed));
232 label = manage (new Label (_("Session RAID path")));
233 label->set_name ("OptionsLabel");
234 path_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
235 path_table.attach (session_raid_entry, 1, 3, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
237 path_table.show_all();
241 OptionEditor::add_session_paths ()
243 click_path_entry.set_sensitive (true);
244 click_emphasis_path_entry.set_sensitive (true);
245 session_raid_entry.set_sensitive (true);
247 if (Config->get_click_sound().empty()) {
248 click_path_entry.set_text (_("internal"));
250 click_path_entry.set_text (Config->get_click_sound());
253 if (Config->get_click_emphasis_sound().empty()) {
254 click_emphasis_path_entry.set_text (_("internal"));
256 click_emphasis_path_entry.set_text (Config->get_click_emphasis_sound());
259 session_raid_entry.set_text(session->raid_path());
263 font_scale_changed (Gtk::Adjustment* adj)
265 Config->set_font_scale((long)floor (adj->get_value() * 1024));
270 OptionEditor::setup_misc_options ()
276 /* font scaling does nothing with GDK/Quartz */
278 Gtk::Adjustment* dpi_adj = new Gtk::Adjustment ((double)Config->get_font_scale() / 1024, 50, 250, 1, 10);
279 Gtk::HScale * dpi_range = new Gtk::HScale (*dpi_adj);
281 label = manage (new Label (_("Font scaling")));
282 label->set_name ("OptionsLabel");
284 dpi_range->set_update_policy (Gtk::UPDATE_DISCONTINUOUS);
285 dpi_adj->signal_value_changed().connect (bind (sigc::ptr_fun (font_scale_changed), dpi_adj));
287 hbox = manage (new HBox);
288 hbox->set_border_width (5);
289 hbox->set_spacing (10);
290 hbox->pack_start (*label, false, false);
291 hbox->pack_start (*dpi_range, true, true);
292 misc_packer.pack_start (*hbox, false, false);
295 label = manage (new Label (_("Short crossfade length (msecs)")));
296 label->set_name ("OptionsLabel");
298 hbox = manage (new HBox);
299 hbox->set_border_width (5);
300 hbox->set_spacing (10);
301 hbox->pack_start (*label, false, false);
302 hbox->pack_start (short_xfade_slider, true, true);
303 misc_packer.pack_start (*hbox, false, false);
305 short_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::short_xfade_adjustment_changed));
307 label = manage (new Label (_("Destructive crossfade length (msecs)")));
308 label->set_name ("OptionsLabel");
310 hbox = manage (new HBox);
311 hbox->set_border_width (5);
312 hbox->set_spacing (10);
313 hbox->pack_start (*label, false, false);
314 hbox->pack_start (destructo_xfade_slider, true, true);
315 misc_packer.pack_start (*hbox, false, false);
318 destructo_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::destructo_xfade_adjustment_changed));
320 hbox = manage (new HBox);
321 hbox->set_border_width (5);
322 hbox->set_spacing (10);
323 hbox->pack_start (limit_history_button, false, false);
324 misc_packer.pack_start (*hbox, false, false);
326 label = manage (new Label (_("History depth (commands)")));
327 label->set_name ("OptionsLabel");
329 hbox = manage (new HBox);
330 hbox->set_border_width (5);
331 hbox->set_spacing (10);
332 hbox->pack_start (*label, false, false);
333 hbox->pack_start (history_depth_spinner, false, false);
334 misc_packer.pack_start (*hbox, false, false);
336 history_depth.signal_value_changed().connect (mem_fun (*this, &OptionEditor::history_depth_changed));
337 saved_history_depth.signal_value_changed().connect (mem_fun (*this, &OptionEditor::saved_history_depth_changed));
338 save_history_button.signal_toggled().connect (mem_fun (*this, &OptionEditor::save_history_toggled));
339 limit_history_button.signal_toggled().connect (mem_fun (*this, &OptionEditor::limit_history_toggled));
341 hbox = manage (new HBox);
342 hbox->set_border_width (5);
343 hbox->set_spacing (10);
344 hbox->pack_start (save_history_button, false, false);
345 misc_packer.pack_start (*hbox, false, false);
347 label = manage (new Label (_("Saved history depth (commands)")));
348 label->set_name ("OptionsLabel");
350 hbox = manage (new HBox);
351 hbox->set_border_width (5);
352 hbox->set_spacing (10);
353 hbox->pack_start (*label, false, false);
354 hbox->pack_start (saved_history_depth_spinner, false, false);
355 misc_packer.pack_start (*hbox, false, false);
357 short_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
358 destructo_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
360 destructo_xfade_adjustment.set_value (Config->get_destructive_xfade_msecs());
362 misc_packer.show_all ();
366 OptionEditor::limit_history_toggled ()
368 bool x = limit_history_button.get_active();
371 Config->set_history_depth (0);
372 history_depth_spinner.set_sensitive (false);
374 if (Config->get_history_depth() == 0) {
375 /* get back to a sane default */
376 Config->set_history_depth (20);
378 history_depth_spinner.set_sensitive (true);
383 OptionEditor::save_history_toggled ()
385 bool x = save_history_button.get_active();
387 if (x != Config->get_save_history()) {
388 Config->set_save_history (x);
389 saved_history_depth_spinner.set_sensitive (x);
394 OptionEditor::history_depth_changed()
396 Config->set_history_depth ((int32_t) floor (history_depth.get_value()));
400 OptionEditor::saved_history_depth_changed()
402 Config->set_saved_history_depth ((int32_t) floor (saved_history_depth.get_value()));
406 OptionEditor::short_xfade_adjustment_changed ()
409 float val = short_xfade_adjustment.get_value();
411 /* val is in msecs */
413 Crossfade::set_short_xfade_length ((nframes_t) floor (session->frame_rate() * (val / 1000.0)));
418 OptionEditor::destructo_xfade_adjustment_changed ()
420 float val = destructo_xfade_adjustment.get_value();
422 /* val is in msecs */
425 Config->set_destructive_xfade_msecs ((uint32_t) floor (val));
428 SndFileSource::setup_standard_crossfades (session->frame_rate());
433 OptionEditor::setup_sync_options ()
438 smpte_offset_clock.set_mode (AudioClock::SMPTE);
439 smpte_offset_clock.ValueChanged.connect (mem_fun(*this, &OptionEditor::smpte_offset_chosen));
441 smpte_offset_negative_button.set_name ("OptionEditorToggleButton");
443 smpte_offset_negative_button.unset_flags (Gtk::CAN_FOCUS);
445 Label *smpte_offset_label = manage (new Label (_("SMPTE Offset")));
446 smpte_offset_label->set_name("OptionsLabel");
448 hbox = manage (new HBox);
449 hbox->set_border_width (5);
450 hbox->set_spacing (10);
451 hbox->pack_start (*smpte_offset_label, false, false);
452 hbox->pack_start (smpte_offset_clock, false, false);
453 hbox->pack_start (smpte_offset_negative_button, false, false);
455 sync_packer.pack_start (*hbox, false, false);
456 sync_packer.pack_start (synced_timecode_button, false, false);
458 smpte_offset_negative_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::smpte_offset_negative_clicked));
459 synced_timecode_button.signal_toggled().connect (mem_fun(*this, &OptionEditor::synced_timecode_toggled));
463 OptionEditor::smpte_offset_negative_clicked ()
466 session->set_smpte_offset_negative (smpte_offset_negative_button.get_active());
471 OptionEditor::synced_timecode_toggled ()
475 if ((x = synced_timecode_button.get_active()) != Config->get_timecode_source_is_synced()) {
476 Config->set_timecode_source_is_synced (x);
477 Config->save_state();
482 OptionEditor::smpte_offset_chosen()
485 nframes_t frames = smpte_offset_clock.current_duration();
486 session->set_smpte_offset (frames);
492 OptionEditor::setup_midi_options ()
497 midi_port_table.set_row_spacings (6);
498 midi_port_table.set_col_spacings (10);
500 redisplay_midi_ports ();
502 mmc_receive_device_id_adjustment.set_value (Config->get_mmc_receive_device_id());
503 mmc_send_device_id_adjustment.set_value (Config->get_mmc_send_device_id());
505 mmc_receive_device_id_adjustment.signal_value_changed().connect (mem_fun (*this, &OptionEditor::mmc_receive_device_id_adjusted));
506 mmc_send_device_id_adjustment.signal_value_changed().connect (mem_fun (*this, &OptionEditor::mmc_send_device_id_adjusted));
508 hbox = manage (new HBox);
509 hbox->set_border_width (6);
510 hbox->pack_start (midi_port_table, true, false);
512 midi_packer.pack_start (*hbox, false, false);
513 add_midi_port_button.set_label ("Add MIDI Port");
514 midi_packer.pack_start (add_midi_port_button, false, false);
516 hbox = manage (new HBox);
517 hbox->set_border_width (6);
518 hbox->set_spacing (6);
519 label = (manage (new Label (_("Inbound MMC Device ID"))));
520 hbox->pack_start (mmc_receive_device_id_spinner, false, false);
521 hbox->pack_start (*label, false, false);
522 midi_packer.pack_start (*hbox, false, false);
524 mmc_receive_device_id_spinner.set_value(Config->get_mmc_receive_device_id ());
526 hbox = manage (new HBox);
527 hbox->set_border_width (6);
528 hbox->set_spacing (6);
529 label = (manage (new Label (_("Outbound MMC Device ID"))));
530 hbox->pack_start (mmc_send_device_id_spinner, false, false);
531 hbox->pack_start (*label, false, false);
532 midi_packer.pack_start (*hbox, false, false);
534 mmc_send_device_id_spinner.set_value(Config->get_mmc_send_device_id ());
536 hbox = manage (new HBox);
537 hbox->set_border_width (6);
538 hbox->set_spacing (6);
539 label = (manage (new Label (_("Startup program change"))));
540 hbox->pack_start (initial_program_change_spinner, false, false);
541 hbox->pack_start (*label, false, false);
542 midi_packer.pack_start (*hbox, false, false);
544 initial_program_change_spinner.set_value (Config->get_initial_program_change());
545 initial_program_change_adjustment.signal_value_changed().connect (mem_fun (*this, &OptionEditor::initial_program_change_adjusted));
547 add_midi_port_button.signal_clicked().connect (mem_fun (*this, &OptionEditor::add_midi_port));
551 OptionEditor::initial_program_change_adjusted ()
553 Config->set_initial_program_change (((int32_t) floor (initial_program_change_adjustment.get_value())) & 0x7f);
557 OptionEditor::redisplay_midi_ports ()
559 MIDI::Manager::PortMap::const_iterator i;
560 const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports();
563 /* remove all existing widgets */
565 // XXX broken in gtkmm 2.10
566 // midi_port_table.clear ();
568 for (vector<Widget*>::iterator w = midi_port_table_widgets.begin(); w != midi_port_table_widgets.end(); ++w) {
569 midi_port_table.remove (**w);
572 midi_port_table_widgets.clear ();
574 midi_port_table.resize (ports.size() + 4, 12);
578 label = (manage (new Label (_("Port"))));
580 midi_port_table_widgets.push_back (label);
581 midi_port_table.attach (*label, 0, 1, 0, 1);
582 label = (manage (new Label (_("Offline"))));
584 midi_port_table_widgets.push_back (label);
585 midi_port_table.attach (*label, 1, 2, 0, 1);
586 label = (manage (new Label (_("Trace\ninput"))));
588 midi_port_table_widgets.push_back (label);
589 midi_port_table.attach (*label, 2, 3, 0, 1);
590 label = (manage (new Label (_("Trace\noutput"))));
592 midi_port_table_widgets.push_back (label);
593 midi_port_table.attach (*label, 3, 4, 0, 1);
594 label = (manage (new Label (_("MTC"))));
596 midi_port_table_widgets.push_back (label);
597 midi_port_table.attach (*label, 4, 5, 0, 1);
598 label = (manage (new Label (_("MIDI\nclock"))));
600 midi_port_table_widgets.push_back (label);
601 midi_port_table.attach (*label, 6, 7, 0, 1);
602 label = (manage (new Label (_("MMC"))));
604 midi_port_table_widgets.push_back (label);
605 midi_port_table.attach (*label, 8, 9, 0, 1);
606 label = (manage (new Label (_("MIDI parameter\ncontrol"))));
608 midi_port_table_widgets.push_back (label);
609 midi_port_table.attach (*label, 10, 11, 0, 1);
611 Gtk::HSeparator* hsep = (manage (new HSeparator()));
613 midi_port_table_widgets.push_back (hsep);
614 midi_port_table.attach (*hsep, 0, 11, 1, 2);
615 Gtk::VSeparator* vsep = (manage (new VSeparator()));
617 midi_port_table_widgets.push_back (vsep);
618 midi_port_table.attach (*vsep, 5, 6, 0, 8);
619 vsep = (manage (new VSeparator()));
621 midi_port_table_widgets.push_back (vsep);
622 midi_port_table.attach (*vsep, 7, 8, 0, 8);
623 vsep = (manage (new VSeparator()));
625 midi_port_table_widgets.push_back (vsep);
626 midi_port_table.attach (*vsep, 9, 10, 0, 8);
628 for (n = 0, i = ports.begin(); i != ports.end(); ++n, ++i) {
634 /* the remove button. create early so we can pass it to various callbacks */
636 bb = manage (new Button (Stock::REMOVE));
637 bb->set_name ("OptionEditorToggleButton");
639 midi_port_table_widgets.push_back (bb);
640 midi_port_table.attach (*bb, 11, 12, n+2, n+3, FILL|EXPAND, FILL);
641 bb->signal_clicked().connect (bind (mem_fun(*this, &OptionEditor::remove_midi_port), i->second));
642 bb->set_sensitive (port_removable (i->second));
644 label = (manage (new Label (i->first)));
646 midi_port_table_widgets.push_back (label);
647 midi_port_table.attach (*label, 0, 1, n+2, n+3,FILL|EXPAND, FILL );
649 tb = manage (new ToggleButton (_("online")));
650 tb->set_name ("OptionEditorToggleButton");
652 /* remember, we have to handle the i18n case where the relative
653 lengths of the strings in language N is different than in english.
656 if (strlen (_("offline")) > strlen (_("online"))) {
657 set_size_request_to_display_given_text (*tb, _("offline"), 15, 12);
659 set_size_request_to_display_given_text (*tb, _("online"), 15, 12);
662 if (i->second->input()) {
663 tb->set_active (!i->second->input()->offline());
664 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_online_toggled), i->second, tb));
665 i->second->input()->OfflineStatusChanged.connect (bind (mem_fun(*this, &OptionEditor::map_port_online), (*i).second, tb));
668 midi_port_table_widgets.push_back (tb);
669 midi_port_table.attach (*tb, 1, 2, n+2, n+3, FILL|EXPAND, FILL);
672 tb = manage (new ToggleButton ());
673 tb->set_name ("OptionEditorToggleButton");
674 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_in_toggled), (*i).second, tb));
675 tb->set_size_request (10, 10);
677 midi_port_table_widgets.push_back (tb);
678 midi_port_table.attach (*tb, 2, 3, n+2, n+3, FILL|EXPAND, FILL);
681 tb = manage (new ToggleButton ());
682 tb->set_name ("OptionEditorToggleButton");
683 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_out_toggled), (*i).second, tb));
684 tb->set_size_request (10, 10);
686 midi_port_table_widgets.push_back (tb);
687 midi_port_table.attach (*tb, 3, 4, n+2, n+3, FILL|EXPAND, FILL);
690 rb = manage (new RadioButton ());
691 rb->set_name ("OptionEditorToggleButton");
693 mtc_button_group = rb->get_group();
695 rb->set_group (mtc_button_group);
698 midi_port_table_widgets.push_back (rb);
699 midi_port_table.attach (*rb, 4, 5, n+2, n+3, FILL|EXPAND, FILL);
700 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mtc_port_chosen), (*i).second, rb, bb));
702 if (session && i->second == session->mtc_port()) {
703 rb->set_active (true);
706 // MIDI Clock Radio Button
707 rb = manage (new RadioButton ());
708 rb->set_name ("OptionEditorToggleButton");
710 midi_clock_button_group = rb->get_group();
712 rb->set_group (midi_clock_button_group);
715 midi_port_table_widgets.push_back (rb);
716 midi_port_table.attach (*rb, 6, 7, n+2, n+3, FILL|EXPAND, FILL);
717 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_clock_port_chosen), (*i).second, rb, bb));
719 if (session && i->second == session->midi_clock_port()) {
720 rb->set_active (true);
723 rb = manage (new RadioButton ());
724 rb->set_name ("OptionEditorToggleButton");
726 mmc_button_group = rb->get_group();
728 rb->set_group (mmc_button_group);
731 midi_port_table_widgets.push_back (rb);
732 midi_port_table.attach (*rb, 8, 9, n+2, n+3, FILL|EXPAND, FILL);
733 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mmc_port_chosen), (*i).second, rb, bb));
735 if (session && i->second == session->mmc_port()) {
736 rb->set_active (true);
739 rb = manage (new RadioButton ());
740 rb->set_name ("OptionEditorToggleButton");
742 midi_button_group = rb->get_group();
744 rb->set_group (midi_button_group);
747 midi_port_table_widgets.push_back (rb);
748 midi_port_table.attach (*rb, 10, 11, n+2, n+3, FILL|EXPAND, FILL);
749 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_port_chosen), (*i).second, rb, bb));
751 if (session && i->second == session->midi_port()) {
752 rb->set_active (true);
757 midi_port_table.show();
761 OptionEditor::remove_midi_port (MIDI::Port* port)
763 MIDI::Manager::instance()->remove_port (port);
764 redisplay_midi_ports ();
768 OptionEditor::add_midi_port ()
770 MidiPortDialog dialog;
772 dialog.set_position (WIN_POS_MOUSE);
773 dialog.set_transient_for (*this);
777 int ret = dialog.run ();
780 case RESPONSE_ACCEPT:
787 Glib::ustring mode = dialog.port_mode_combo.get_active_text();
790 if (mode == _("input")) {
792 } else if (mode == (_("output"))) {
799 XMLNode node (X_("MIDI-port"));
801 node.add_property ("tag", dialog.port_name.get_text());
802 node.add_property ("device", X_("ardour")); // XXX this can't be right for all types
803 node.add_property ("type", MIDI::PortFactory::default_port_type());
804 node.add_property ("mode", smod);
806 if (MIDI::Manager::instance()->add_port (node) != 0) {
807 redisplay_midi_ports ();
812 OptionEditor::port_removable (MIDI::Port *port)
818 if (port == session->mtc_port() ||
819 port == session->mmc_port() ||
820 port == session->midi_port()) {
827 OptionEditor::mtc_port_chosen (MIDI::Port *port, Gtk::RadioButton* rb, Gtk::Button* bb)
830 if (rb->get_active()) {
831 session->set_mtc_port (port->name());
832 Config->set_mtc_port_name (port->name());
834 session->set_mtc_port ("");
836 bb->set_sensitive (port_removable (port));
841 OptionEditor::mmc_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb, Gtk::Button* bb)
844 if (rb->get_active()) {
845 session->set_mmc_port (port->name());
846 Config->set_mtc_port_name (port->name());
848 session->set_mmc_port ("");
850 bb->set_sensitive (port_removable (port));
855 OptionEditor::midi_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb, Gtk::Button* bb)
858 if (rb->get_active()) {
859 session->set_midi_port (port->name());
860 Config->set_midi_port_name (port->name());
862 session->set_midi_port ("");
864 bb->set_sensitive (port_removable (port));
869 OptionEditor::midi_clock_port_chosen (MIDI::Port *port, Gtk::RadioButton* rb, Gtk::Button* bb)
872 if (rb->get_active()) {
873 session->set_midi_clock_port (port->name());
874 Config->set_midi_clock_port_name (port->name());
876 session->set_midi_clock_port ("");
878 bb->set_sensitive (port_removable (port));
883 OptionEditor::port_online_toggled (MIDI::Port* port, ToggleButton* tb)
885 bool wanted = tb->get_active();
888 if (wanted != port->input()->offline()) {
889 port->input()->set_offline (wanted);
895 OptionEditor::map_port_online (MIDI::Port* port, ToggleButton* tb)
897 bool bstate = tb->get_active ();
900 if (bstate != port->input()->offline()) {
901 if (port->input()->offline()) {
902 tb->set_label (_("offline"));
903 tb->set_active (false);
905 tb->set_label (_("online"));
906 tb->set_active (true);
913 OptionEditor::mmc_receive_device_id_adjusted ()
915 uint8_t id = (uint8_t) mmc_receive_device_id_spinner.get_value();
916 Config->set_mmc_receive_device_id (id);
920 OptionEditor::mmc_send_device_id_adjusted ()
922 uint8_t id = (uint8_t) mmc_send_device_id_spinner.get_value();
923 Config->set_mmc_send_device_id (id);
927 OptionEditor::port_trace_in_toggled (MIDI::Port* port, ToggleButton* tb)
929 bool trace = tb->get_active();
932 if (port->input()->tracing() != trace) {
933 port->input()->trace (trace, &cerr, string (port->name()) + string (" input: "));
939 OptionEditor::port_trace_out_toggled (MIDI::Port* port, ToggleButton* tb)
941 bool trace = tb->get_active();
943 if (port->output()) {
944 if (port->output()->tracing() != trace) {
945 port->output()->trace (trace, &cerr, string (port->name()) + string (" output: "));
951 OptionEditor::save ()
953 /* XXX a bit odd that we save the entire session state here */
959 OptionEditor::wm_close (GdkEventAny *ev)
967 OptionEditor::raid_path_changed ()
970 Config->set_raid_path (session_raid_entry.get_text());
975 OptionEditor::click_browse_clicked ()
977 SoundFileChooser sfdb (*this, _("Choose Click"), session);
982 int result = sfdb.run ();
984 if (result == Gtk::RESPONSE_OK) {
985 click_chosen(sfdb.get_filename());
990 OptionEditor::click_chosen (const string & path)
992 click_path_entry.set_text (path);
993 click_sound_changed ();
997 OptionEditor::click_emphasis_browse_clicked ()
999 SoundFileChooser sfdb (*this, _("Choose Click Emphasis"), session);
1004 int result = sfdb.run ();
1006 if (result == Gtk::RESPONSE_OK) {
1007 click_emphasis_chosen (sfdb.get_filename());
1012 OptionEditor::click_emphasis_chosen (const string & path)
1014 click_emphasis_path_entry.set_text (path);
1015 click_emphasis_sound_changed ();
1019 OptionEditor::click_sound_changed ()
1022 string path = click_path_entry.get_text();
1024 if (path == Config->get_click_sound()) {
1028 strip_whitespace_edges (path);
1030 if (path == _("internal")) {
1031 Config->set_click_sound ("");
1033 Config->set_click_sound (path);
1039 OptionEditor::click_emphasis_sound_changed ()
1042 string path = click_emphasis_path_entry.get_text();
1044 if (path == Config->get_click_emphasis_sound()) {
1048 strip_whitespace_edges (path);
1050 if (path == _("internal")) {
1051 Config->set_click_emphasis_sound ("");
1053 Config->set_click_emphasis_sound (path);
1059 OptionEditor::clear_click_editor ()
1061 if (click_io_selector) {
1062 click_hpacker.remove (*click_io_selector);
1063 click_hpacker.remove (*click_gpm);
1064 delete click_io_selector;
1066 click_io_selector = 0;
1072 OptionEditor::setup_click_editor ()
1076 if (first_click_setup) {
1078 click_path_entry.set_name ("OptionsEntry");
1079 click_emphasis_path_entry.set_name ("OptionsEntry");
1081 click_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_sound_changed));
1082 click_emphasis_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed));
1084 click_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_sound_changed));
1085 click_emphasis_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_emphasis_sound_changed));
1087 click_browse_button.set_name ("EditorGTKButton");
1088 click_emphasis_browse_button.set_name ("EditorGTKButton");
1090 click_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_browse_clicked));
1091 click_emphasis_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_emphasis_browse_clicked));
1093 click_packer.set_border_width (12);
1094 click_packer.set_spacing (5);
1096 click_table.set_col_spacings (10);
1098 label = manage(new Label(_("Click audio file:")));
1099 label->set_name ("OptionsLabel");
1100 label->set_alignment (0, 0.5);
1101 click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
1102 click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1103 click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL);
1105 label = manage(new Label(_("Click emphasis audiofile:")));
1106 label->set_name ("OptionsLabel");
1107 label->set_alignment (0, 0.5);
1108 click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
1109 click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1110 click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL);
1112 click_packer.pack_start (click_table, false, false);
1113 click_packer.pack_start (click_hpacker, false, false);
1115 click_hpacker.set_spacing (10);
1117 first_click_setup = false;
1120 click_path_entry.set_sensitive (true);
1121 click_emphasis_path_entry.set_sensitive (true);
1123 click_io_selector = new IOSelector (*session, session->click_io(), true);
1124 click_gpm = new GainMeter (*session);
1125 click_gpm->set_io (session->click_io());
1127 click_hpacker.pack_start (*click_io_selector, true, true);
1128 click_hpacker.pack_start (*click_gpm, false, false);
1130 click_packer.show_all ();
1134 OptionEditor::clear_auditioner_editor ()
1136 if (auditioner_io_selector) {
1137 audition_hpacker.remove (*auditioner_io_selector);
1138 audition_hpacker.remove (*auditioner_gpm);
1139 delete auditioner_io_selector;
1140 delete auditioner_gpm;
1141 auditioner_io_selector = 0;
1147 OptionEditor::setup_auditioner_editor ()
1149 audition_packer.set_border_width (12);
1150 audition_packer.set_spacing (5);
1151 audition_hpacker.set_spacing (10);
1153 audition_label.set_name ("OptionEditorAuditionerLabel");
1154 audition_label.set_text (_("The auditioner is a dedicated mixer strip used\n"
1155 "for listening to specific regions outside the context\n"
1156 "of the overall mix. It can be connected just like any\n"
1157 "other mixer strip."));
1159 audition_packer.pack_start (audition_label, false, false, 10);
1160 audition_packer.pack_start (audition_hpacker, false, false);
1164 OptionEditor::connect_audition_editor ()
1166 auditioner_io_selector = new IOSelector (*session, session->the_auditioner(), true);
1167 auditioner_gpm = new GainMeter (*session);
1168 auditioner_gpm->set_io (session->the_auditioner());
1170 audition_hpacker.pack_start (*auditioner_io_selector, true, true);
1171 audition_hpacker.pack_start (*auditioner_gpm, false, false);
1173 auditioner_io_selector->show_all ();
1174 auditioner_gpm->show_all ();
1178 OptionEditor::focus_out_event_handler (GdkEventFocus* ev, void (OptionEditor::*pmf)())
1184 static const struct {
1195 { "Shift", GDK_SHIFT_MASK },
1196 { "Command", GDK_META_MASK },
1197 { "Control", GDK_CONTROL_MASK },
1198 { "Option", GDK_MOD1_MASK },
1199 { "Command-Shift", GDK_MOD1_MASK|GDK_SHIFT_MASK },
1200 { "Command-Option", GDK_MOD1_MASK|GDK_MOD5_MASK },
1201 { "Shift-Option", GDK_SHIFT_MASK|GDK_MOD5_MASK },
1202 { "Shift-Command-Option", GDK_MOD5_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
1205 { "Shift", GDK_SHIFT_MASK },
1206 { "Control", GDK_CONTROL_MASK },
1207 { "Alt (Mod1)", GDK_MOD1_MASK },
1208 { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK },
1209 { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK },
1210 { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK },
1211 { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
1212 { "Mod2", GDK_MOD2_MASK },
1213 { "Mod3", GDK_MOD3_MASK },
1214 { "Mod4", GDK_MOD4_MASK },
1215 { "Mod5", GDK_MOD5_MASK },
1221 OptionEditor::setup_keyboard_options ()
1223 vector<string> dumb;
1226 keyboard_mouse_table.set_border_width (12);
1227 keyboard_mouse_table.set_row_spacings (5);
1228 keyboard_mouse_table.set_col_spacings (5);
1230 /* internationalize and prepare for use with combos */
1232 for (int i = 0; modifiers[i].name; ++i) {
1233 dumb.push_back (_(modifiers[i].name));
1236 set_popdown_strings (edit_modifier_combo, dumb);
1237 edit_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::edit_modifier_chosen));
1239 for (int x = 0; modifiers[x].name; ++x) {
1240 if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
1241 edit_modifier_combo.set_active_text (_(modifiers[x].name));
1246 label = manage (new Label (_("Edit using:")));
1247 label->set_name ("OptionsLabel");
1248 label->set_alignment (1.0, 0.5);
1250 keyboard_mouse_table.attach (*label, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1251 keyboard_mouse_table.attach (edit_modifier_combo, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1253 label = manage (new Label (_("+ button")));
1254 label->set_name ("OptionsLabel");
1256 keyboard_mouse_table.attach (*label, 3, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1257 keyboard_mouse_table.attach (edit_button_spin, 4, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1259 edit_button_spin.set_name ("OptionsEntry");
1260 edit_button_adjustment.set_value (Keyboard::edit_button());
1261 edit_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::edit_button_changed));
1263 set_popdown_strings (delete_modifier_combo, dumb);
1264 delete_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::delete_modifier_chosen));
1266 for (int x = 0; modifiers[x].name; ++x) {
1267 if (modifiers[x].modifier == Keyboard::delete_modifier ()) {
1268 delete_modifier_combo.set_active_text (_(modifiers[x].name));
1273 label = manage (new Label (_("Delete using:")));
1274 label->set_name ("OptionsLabel");
1275 label->set_alignment (1.0, 0.5);
1277 keyboard_mouse_table.attach (*label, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1278 keyboard_mouse_table.attach (delete_modifier_combo, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1280 label = manage (new Label (_("+ button")));
1281 label->set_name ("OptionsLabel");
1283 keyboard_mouse_table.attach (*label, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1284 keyboard_mouse_table.attach (delete_button_spin, 4, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1286 delete_button_spin.set_name ("OptionsEntry");
1287 delete_button_adjustment.set_value (Keyboard::delete_button());
1288 delete_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::delete_button_changed));
1290 set_popdown_strings (snap_modifier_combo, dumb);
1291 snap_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::snap_modifier_chosen));
1293 for (int x = 0; modifiers[x].name; ++x) {
1294 if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) {
1295 snap_modifier_combo.set_active_text (_(modifiers[x].name));
1300 label = manage (new Label (_("Ignore snap using:")));
1301 label->set_name ("OptionsLabel");
1302 label->set_alignment (1.0, 0.5);
1304 keyboard_mouse_table.attach (*label, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
1305 keyboard_mouse_table.attach (snap_modifier_combo, 1, 2, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
1307 vector<string> strs;
1309 for (std::map<std::string,std::string>::iterator bf = Keyboard::binding_files.begin(); bf != Keyboard::binding_files.end(); ++bf) {
1310 strs.push_back (bf->first);
1313 set_popdown_strings (keyboard_layout_selector, strs);
1314 keyboard_layout_selector.set_active_text (Keyboard::current_binding_name());
1315 keyboard_layout_selector.signal_changed().connect (mem_fun (*this, &OptionEditor::bindings_changed));
1317 label = manage (new Label (_("Keyboard layout:")));
1318 label->set_name ("OptionsLabel");
1319 label->set_alignment (1.0, 0.5);
1321 keyboard_mouse_table.attach (*label, 0, 1, 3, 4, Gtk::FILL|Gtk::EXPAND, FILL);
1322 keyboard_mouse_table.attach (keyboard_layout_selector, 1, 2, 3, 4, Gtk::FILL|Gtk::EXPAND, FILL);
1326 OptionEditor::bindings_changed ()
1330 txt = keyboard_layout_selector.get_active_text();
1332 for (std::map<string,string>::iterator i = Keyboard::binding_files.begin(); i != Keyboard::binding_files.end(); ++i) {
1333 if (txt == i->first) {
1334 if (Keyboard::load_keybindings (i->second)) {
1335 Keyboard::save_keybindings ();
1342 OptionEditor::edit_modifier_chosen ()
1346 txt = edit_modifier_combo.get_active_text();
1348 for (int i = 0; modifiers[i].name; ++i) {
1349 if (txt == _(modifiers[i].name)) {
1350 Keyboard::set_edit_modifier (modifiers[i].modifier);
1357 OptionEditor::delete_modifier_chosen ()
1361 txt = delete_modifier_combo.get_active_text();
1363 for (int i = 0; modifiers[i].name; ++i) {
1364 if (txt == _(modifiers[i].name)) {
1365 Keyboard::set_delete_modifier (modifiers[i].modifier);
1372 OptionEditor::snap_modifier_chosen ()
1376 txt = snap_modifier_combo.get_active_text();
1378 for (int i = 0; modifiers[i].name; ++i) {
1379 if (txt == _(modifiers[i].name)) {
1380 Keyboard::set_snap_modifier (modifiers[i].modifier);
1387 OptionEditor::delete_button_changed ()
1389 Keyboard::set_delete_button ((guint) delete_button_adjustment.get_value());
1393 OptionEditor::edit_button_changed ()
1395 Keyboard::set_edit_button ((guint) edit_button_adjustment.get_value());
1399 OptionEditor::fixup_combo_size (Gtk::ComboBoxText& combo, vector<string>& strings)
1401 /* find the widest string */
1403 string::size_type maxlen = 0;
1406 for (vector<string>::iterator i = strings.begin(); i != strings.end(); ++i) {
1407 string::size_type l;
1409 if ((l = (*i).length()) > maxlen) {
1415 /* try to include ascenders and descenders */
1417 if (maxstring.length() > 2) {
1422 const guint32 FUDGE = 10; // Combo's are stupid - they steal space from the entry for the button
1424 set_size_request_to_display_given_text (combo, maxstring.c_str(), 10 + FUDGE, 10);
1428 OptionEditor::parameter_changed (const char* parameter_name)
1430 ENSURE_GUI_THREAD (bind (mem_fun (*this, &OptionEditor::parameter_changed), parameter_name));
1432 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
1434 if (PARAM_IS ("timecode-source-is-synced")) {
1435 synced_timecode_button.set_active (Config->get_timecode_source_is_synced());
1436 } else if (PARAM_IS ("history-depth")) {
1437 int32_t depth = Config->get_history_depth();
1439 history_depth.set_value (depth);
1440 history_depth_spinner.set_sensitive (depth != 0);
1441 limit_history_button.set_active (depth != 0);
1443 } else if (PARAM_IS ("saved-history-depth")) {
1445 saved_history_depth.set_value (Config->get_saved_history_depth());
1447 } else if (PARAM_IS ("save-history")) {
1449 bool x = Config->get_save_history();
1451 save_history_button.set_active (x);
1452 saved_history_depth_spinner.set_sensitive (x);
1453 } else if (PARAM_IS ("font-scale")) {