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 <midi++/manager.h>
32 #include <midi++/factory.h>
33 #include <gtkmm2ext/stop_signal.h>
34 #include <gtkmm2ext/utils.h>
35 #include <gtkmm2ext/window_title.h>
37 #include "public_editor.h"
40 #include "ardour_ui.h"
41 #include "io_selector.h"
42 #include "gain_meter.h"
46 #include "option_editor.h"
47 #include "midi_port_dialog.h"
48 #include "gui_thread.h"
53 using namespace ARDOUR;
56 using namespace Editing;
57 using namespace Gtkmm2ext;
60 static vector<string> positional_sync_strings;
62 OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui)
63 : ArdourDialog ("options editor", false),
73 short_xfade_adjustment (0, 1.0, 500.0, 5.0, 100.0),
74 short_xfade_slider (short_xfade_adjustment),
75 destructo_xfade_adjustment (1.0, 1.0, 500.0, 1.0, 100.0),
76 destructo_xfade_slider (destructo_xfade_adjustment),
77 history_depth (20, -1, 100, 1.0, 10.0),
78 saved_history_depth (20, 0, 100, 1.0, 10.0),
79 history_depth_spinner (history_depth),
80 saved_history_depth_spinner (saved_history_depth),
81 limit_history_button (_("Limit undo history")),
82 save_history_button (_("Save undo history")),
86 smpte_offset_clock (X_("smpteoffset"), false, X_("SMPTEOffsetClock"), true, true),
87 smpte_offset_negative_button (_("SMPTE offset is negative")),
88 synced_timecode_button (_("Timecode source is sample-clock synced")),
92 midi_port_table (4, 12),
93 mmc_receive_device_id_adjustment (0.0, 0.0, (double) 0x7f, 1.0, 16.0),
94 mmc_receive_device_id_spinner (mmc_receive_device_id_adjustment),
95 mmc_send_device_id_adjustment (0.0, 0.0, (double) 0x7f, 1.0, 16.0),
96 mmc_send_device_id_spinner (mmc_send_device_id_adjustment),
97 add_midi_port_button (_("Add new MIDI port")),
102 click_browse_button (_("Browse")),
103 click_emphasis_browse_button (_("Browse")),
107 keyboard_mouse_table (4, 4),
108 delete_button_adjustment (3, 1, 5),
109 delete_button_spin (delete_button_adjustment),
110 edit_button_adjustment (3, 1, 5),
111 edit_button_spin (edit_button_adjustment)
114 using namespace Notebook_Helpers;
116 click_io_selector = 0;
117 auditioner_io_selector = 0;
120 WindowTitle title(Glib::get_application_name());
121 title += _("Preferences");
122 set_title(title.get_string());
124 set_default_size (300, 300);
125 set_wmclass (X_("ardour_preferences"), "Ardour");
127 set_name ("Preferences");
128 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
130 VBox *vbox = get_vbox();
131 set_border_width (3);
133 vbox->set_spacing (4);
134 vbox->pack_start(notebook);
136 signal_delete_event().connect (mem_fun(*this, &OptionEditor::wm_close));
138 notebook.set_show_tabs (true);
139 notebook.set_show_border (true);
140 notebook.set_name ("OptionsNotebook");
142 setup_sync_options();
143 setup_path_options();
144 setup_misc_options ();
145 setup_keyboard_options ();
146 setup_auditioner_editor ();
148 notebook.pages().push_back (TabElem (sync_packer, _("Sync")));
149 notebook.pages().push_back (TabElem (path_table, _("Paths/Files")));
150 notebook.pages().push_back (TabElem (keyboard_mouse_table, _("Kbd/Mouse")));
151 notebook.pages().push_back (TabElem (click_packer, _("Click")));
152 notebook.pages().push_back (TabElem (audition_packer, _("Audition")));
153 notebook.pages().push_back (TabElem (misc_packer, _("Misc")));
155 setup_midi_options ();
156 notebook.pages().push_back (TabElem (midi_packer, _("MIDI")));
161 Config->map_parameters (mem_fun (*this, &OptionEditor::parameter_changed));
162 Config->ParameterChanged.connect (mem_fun (*this, &OptionEditor::parameter_changed));
166 OptionEditor::set_session (Session *s)
168 clear_click_editor ();
169 clear_auditioner_editor ();
171 click_path_entry.set_text ("");
172 click_emphasis_path_entry.set_text ("");
173 session_raid_entry.set_text ("");
175 click_path_entry.set_sensitive (false);
176 click_emphasis_path_entry.set_sensitive (false);
177 session_raid_entry.set_sensitive (false);
179 short_xfade_slider.set_sensitive (false);
180 smpte_offset_negative_button.set_sensitive (false);
182 smpte_offset_clock.set_session (s);
184 if ((session = s) == 0) {
188 click_path_entry.set_sensitive (true);
189 click_emphasis_path_entry.set_sensitive (true);
190 session_raid_entry.set_sensitive (true);
191 short_xfade_slider.set_sensitive (true);
192 smpte_offset_negative_button.set_sensitive (true);
194 smpte_offset_clock.set_session (s);
195 smpte_offset_clock.set (s->smpte_offset (), true);
197 smpte_offset_negative_button.set_active (session->smpte_offset_negative());
199 redisplay_midi_ports ();
201 setup_click_editor ();
202 connect_audition_editor ();
204 short_xfade_adjustment.set_value ((Crossfade::short_xfade_length() / (float) session->frame_rate()) * 1000.0);
206 add_session_paths ();
209 OptionEditor::~OptionEditor ()
214 OptionEditor::setup_path_options()
218 path_table.set_homogeneous (false);
219 path_table.set_border_width (12);
220 path_table.set_row_spacings (5);
222 session_raid_entry.set_name ("OptionsEntry");
224 session_raid_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::raid_path_changed));
226 label = manage(new Label(_("session RAID path")));
227 label->set_name ("OptionsLabel");
228 path_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
229 path_table.attach (session_raid_entry, 1, 3, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
231 path_table.show_all();
235 OptionEditor::add_session_paths ()
237 click_path_entry.set_sensitive (true);
238 click_emphasis_path_entry.set_sensitive (true);
239 session_raid_entry.set_sensitive (true);
241 if (Config->get_click_sound().empty()) {
242 click_path_entry.set_text (_("internal"));
244 click_path_entry.set_text (Config->get_click_sound());
247 if (Config->get_click_emphasis_sound().empty()) {
248 click_emphasis_path_entry.set_text (_("internal"));
250 click_emphasis_path_entry.set_text (Config->get_click_emphasis_sound());
253 session_raid_entry.set_text(session->raid_path());
257 font_scale_changed (Gtk::Adjustment* adj)
259 Config->set_font_scale((long)floor (adj->get_value() * 1024));
264 OptionEditor::setup_misc_options ()
270 /* font scaling does nothing with GDK/Quartz */
272 Gtk::Adjustment* dpi_adj = new Gtk::Adjustment ((double)Config->get_font_scale() / 1024, 50, 250, 1, 10);
273 Gtk::HScale * dpi_range = new Gtk::HScale (*dpi_adj);
275 label = manage (new Label (_("Font Scaling")));
276 label->set_name ("OptionsLabel");
278 dpi_range->set_update_policy (Gtk::UPDATE_DISCONTINUOUS);
279 dpi_adj->signal_value_changed().connect (bind (sigc::ptr_fun (font_scale_changed), dpi_adj));
281 hbox = manage (new HBox);
282 hbox->set_border_width (5);
283 hbox->set_spacing (10);
284 hbox->pack_start (*label, false, false);
285 hbox->pack_start (*dpi_range, true, true);
286 misc_packer.pack_start (*hbox, false, false);
289 label = manage (new Label (_("Short crossfade length (msecs)")));
290 label->set_name ("OptionsLabel");
292 hbox = manage (new HBox);
293 hbox->set_border_width (5);
294 hbox->set_spacing (10);
295 hbox->pack_start (*label, false, false);
296 hbox->pack_start (short_xfade_slider, true, true);
297 misc_packer.pack_start (*hbox, false, false);
299 short_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::short_xfade_adjustment_changed));
301 label = manage (new Label (_("Destructive crossfade length (msecs)")));
302 label->set_name ("OptionsLabel");
304 hbox = manage (new HBox);
305 hbox->set_border_width (5);
306 hbox->set_spacing (10);
307 hbox->pack_start (*label, false, false);
308 hbox->pack_start (destructo_xfade_slider, true, true);
309 misc_packer.pack_start (*hbox, false, false);
312 destructo_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::destructo_xfade_adjustment_changed));
314 hbox = manage (new HBox);
315 hbox->set_border_width (5);
316 hbox->set_spacing (10);
317 hbox->pack_start (limit_history_button, false, false);
318 misc_packer.pack_start (*hbox, false, false);
320 label = manage (new Label (_("History depth (commands)")));
321 label->set_name ("OptionsLabel");
323 hbox = manage (new HBox);
324 hbox->set_border_width (5);
325 hbox->set_spacing (10);
326 hbox->pack_start (*label, false, false);
327 hbox->pack_start (history_depth_spinner, false, false);
328 misc_packer.pack_start (*hbox, false, false);
330 history_depth.signal_value_changed().connect (mem_fun (*this, &OptionEditor::history_depth_changed));
331 saved_history_depth.signal_value_changed().connect (mem_fun (*this, &OptionEditor::saved_history_depth_changed));
332 save_history_button.signal_toggled().connect (mem_fun (*this, &OptionEditor::save_history_toggled));
333 limit_history_button.signal_toggled().connect (mem_fun (*this, &OptionEditor::limit_history_toggled));
335 hbox = manage (new HBox);
336 hbox->set_border_width (5);
337 hbox->set_spacing (10);
338 hbox->pack_start (save_history_button, false, false);
339 misc_packer.pack_start (*hbox, false, false);
341 label = manage (new Label (_("Saved history depth (commands)")));
342 label->set_name ("OptionsLabel");
344 hbox = manage (new HBox);
345 hbox->set_border_width (5);
346 hbox->set_spacing (10);
347 hbox->pack_start (*label, false, false);
348 hbox->pack_start (saved_history_depth_spinner, false, false);
349 misc_packer.pack_start (*hbox, false, false);
351 short_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
352 destructo_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
354 destructo_xfade_adjustment.set_value (Config->get_destructive_xfade_msecs());
356 misc_packer.show_all ();
360 OptionEditor::limit_history_toggled ()
362 bool x = limit_history_button.get_active();
365 Config->set_history_depth (0);
366 history_depth_spinner.set_sensitive (false);
368 if (Config->get_history_depth() == 0) {
369 /* get back to a sane default */
370 Config->set_history_depth (20);
372 history_depth_spinner.set_sensitive (true);
377 OptionEditor::save_history_toggled ()
379 bool x = save_history_button.get_active();
381 if (x != Config->get_save_history()) {
382 Config->set_save_history (x);
383 saved_history_depth_spinner.set_sensitive (x);
388 OptionEditor::history_depth_changed()
390 Config->set_history_depth ((int32_t) floor (history_depth.get_value()));
394 OptionEditor::saved_history_depth_changed()
396 Config->set_saved_history_depth ((int32_t) floor (saved_history_depth.get_value()));
400 OptionEditor::short_xfade_adjustment_changed ()
403 float val = short_xfade_adjustment.get_value();
405 /* val is in msecs */
407 Crossfade::set_short_xfade_length ((nframes_t) floor (session->frame_rate() * (val / 1000.0)));
412 OptionEditor::destructo_xfade_adjustment_changed ()
414 float val = destructo_xfade_adjustment.get_value();
416 /* val is in msecs */
419 Config->set_destructive_xfade_msecs ((uint32_t) floor (val));
422 SndFileSource::setup_standard_crossfades (session->frame_rate());
427 OptionEditor::setup_sync_options ()
432 smpte_offset_clock.set_mode (AudioClock::SMPTE);
433 smpte_offset_clock.ValueChanged.connect (mem_fun(*this, &OptionEditor::smpte_offset_chosen));
435 smpte_offset_negative_button.set_name ("OptionEditorToggleButton");
437 smpte_offset_negative_button.unset_flags (Gtk::CAN_FOCUS);
439 Label *smpte_offset_label = manage (new Label (_("SMPTE Offset")));
440 smpte_offset_label->set_name("OptionsLabel");
442 hbox = manage (new HBox);
443 hbox->set_border_width (5);
444 hbox->set_spacing (10);
445 hbox->pack_start (*smpte_offset_label, false, false);
446 hbox->pack_start (smpte_offset_clock, false, false);
447 hbox->pack_start (smpte_offset_negative_button, false, false);
449 sync_packer.pack_start (*hbox, false, false);
450 sync_packer.pack_start (synced_timecode_button, false, false);
452 smpte_offset_negative_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::smpte_offset_negative_clicked));
453 synced_timecode_button.signal_toggled().connect (mem_fun(*this, &OptionEditor::synced_timecode_toggled));
457 OptionEditor::smpte_offset_negative_clicked ()
460 session->set_smpte_offset_negative (smpte_offset_negative_button.get_active());
465 OptionEditor::synced_timecode_toggled ()
469 if ((x = synced_timecode_button.get_active()) != Config->get_timecode_source_is_synced()) {
470 Config->set_timecode_source_is_synced (x);
471 Config->save_state();
476 OptionEditor::smpte_offset_chosen()
479 nframes_t frames = smpte_offset_clock.current_duration();
480 session->set_smpte_offset (frames);
486 OptionEditor::setup_midi_options ()
491 midi_port_table.set_row_spacings (6);
492 midi_port_table.set_col_spacings (10);
494 redisplay_midi_ports ();
496 mmc_receive_device_id_adjustment.set_value (Config->get_mmc_receive_device_id());
497 mmc_send_device_id_adjustment.set_value (Config->get_mmc_send_device_id());
499 mmc_receive_device_id_adjustment.signal_value_changed().connect (mem_fun (*this, &OptionEditor::mmc_receive_device_id_adjusted));
500 mmc_send_device_id_adjustment.signal_value_changed().connect (mem_fun (*this, &OptionEditor::mmc_send_device_id_adjusted));
502 hbox = manage (new HBox);
503 hbox->set_border_width (6);
504 hbox->pack_start (midi_port_table, true, false);
506 midi_packer.pack_start (*hbox, false, false);
507 add_midi_port_button.set_label ("Add MIDI port");
508 midi_packer.pack_start (add_midi_port_button, false, false);
510 hbox = manage (new HBox);
511 hbox->set_border_width (6);
512 hbox->set_spacing (6);
513 label = (manage (new Label (_("Inbound MMC Device ID"))));
514 hbox->pack_start (mmc_receive_device_id_spinner, false, false);
515 hbox->pack_start (*label, false, false);
516 midi_packer.pack_start (*hbox, false, false);
518 mmc_receive_device_id_spinner.set_value(Config->get_mmc_receive_device_id ());
520 hbox = manage (new HBox);
521 hbox->set_border_width (6);
522 hbox->set_spacing (6);
523 label = (manage (new Label (_("Outbound MMC Device ID"))));
524 hbox->pack_start (mmc_send_device_id_spinner, false, false);
525 hbox->pack_start (*label, false, false);
526 midi_packer.pack_start (*hbox, false, false);
528 mmc_send_device_id_spinner.set_value(Config->get_mmc_send_device_id ());
530 add_midi_port_button.signal_clicked().connect (mem_fun (*this, &OptionEditor::add_midi_port));
534 OptionEditor::redisplay_midi_ports ()
536 MIDI::Manager::PortMap::const_iterator i;
537 const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports();
540 /* remove all existing widgets */
542 // XXX broken in gtkmm 2.10
543 // midi_port_table.clear ();
545 for (vector<Widget*>::iterator w = midi_port_table_widgets.begin(); w != midi_port_table_widgets.end(); ++w) {
546 midi_port_table.remove (**w);
549 midi_port_table_widgets.clear ();
551 midi_port_table.resize (ports.size() + 4, 12);
555 label = (manage (new Label (_("Port"))));
557 midi_port_table_widgets.push_back (label);
558 midi_port_table.attach (*label, 0, 1, 0, 1);
559 label = (manage (new Label (_("Offline"))));
561 midi_port_table_widgets.push_back (label);
562 midi_port_table.attach (*label, 1, 2, 0, 1);
563 label = (manage (new Label (_("Trace\nInput"))));
565 midi_port_table_widgets.push_back (label);
566 midi_port_table.attach (*label, 2, 3, 0, 1);
567 label = (manage (new Label (_("Trace\nOutput"))));
569 midi_port_table_widgets.push_back (label);
570 midi_port_table.attach (*label, 3, 4, 0, 1);
571 label = (manage (new Label (_("MTC"))));
573 midi_port_table_widgets.push_back (label);
574 midi_port_table.attach (*label, 4, 5, 0, 1);
575 label = (manage (new Label (_("MIDI\nClock"))));
577 midi_port_table_widgets.push_back (label);
578 midi_port_table.attach (*label, 6, 7, 0, 1);
579 label = (manage (new Label (_("MMC"))));
581 midi_port_table_widgets.push_back (label);
582 midi_port_table.attach (*label, 8, 9, 0, 1);
583 label = (manage (new Label (_("MIDI Parameter\nControl"))));
585 midi_port_table_widgets.push_back (label);
586 midi_port_table.attach (*label, 10, 11, 0, 1);
588 Gtk::HSeparator* hsep = (manage (new HSeparator()));
590 midi_port_table_widgets.push_back (hsep);
591 midi_port_table.attach (*hsep, 0, 11, 1, 2);
592 Gtk::VSeparator* vsep = (manage (new VSeparator()));
594 midi_port_table_widgets.push_back (vsep);
595 midi_port_table.attach (*vsep, 5, 6, 0, 8);
596 vsep = (manage (new VSeparator()));
598 midi_port_table_widgets.push_back (vsep);
599 midi_port_table.attach (*vsep, 7, 8, 0, 8);
600 vsep = (manage (new VSeparator()));
602 midi_port_table_widgets.push_back (vsep);
603 midi_port_table.attach (*vsep, 9, 10, 0, 8);
605 for (n = 0, i = ports.begin(); i != ports.end(); ++n, ++i) {
611 /* the remove button. create early so we can pass it to various callbacks */
613 bb = manage (new Button (Stock::REMOVE));
614 bb->set_name ("OptionEditorToggleButton");
616 midi_port_table_widgets.push_back (bb);
617 midi_port_table.attach (*bb, 11, 12, n+2, n+3, FILL|EXPAND, FILL);
618 bb->signal_clicked().connect (bind (mem_fun(*this, &OptionEditor::remove_midi_port), i->second));
619 bb->set_sensitive (port_removable (i->second));
621 label = (manage (new Label (i->first)));
623 midi_port_table_widgets.push_back (label);
624 midi_port_table.attach (*label, 0, 1, n+2, n+3,FILL|EXPAND, FILL );
626 tb = manage (new ToggleButton (_("online")));
627 tb->set_name ("OptionEditorToggleButton");
629 /* remember, we have to handle the i18n case where the relative
630 lengths of the strings in language N is different than in english.
633 if (strlen (_("offline")) > strlen (_("online"))) {
634 set_size_request_to_display_given_text (*tb, _("offline"), 15, 12);
636 set_size_request_to_display_given_text (*tb, _("online"), 15, 12);
639 if (i->second->input()) {
640 tb->set_active (!i->second->input()->offline());
641 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_online_toggled), i->second, tb));
642 i->second->input()->OfflineStatusChanged.connect (bind (mem_fun(*this, &OptionEditor::map_port_online), (*i).second, tb));
645 midi_port_table_widgets.push_back (tb);
646 midi_port_table.attach (*tb, 1, 2, n+2, n+3, FILL|EXPAND, FILL);
649 tb = manage (new ToggleButton ());
650 tb->set_name ("OptionEditorToggleButton");
651 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_in_toggled), (*i).second, tb));
652 tb->set_size_request (10, 10);
654 midi_port_table_widgets.push_back (tb);
655 midi_port_table.attach (*tb, 2, 3, n+2, n+3, FILL|EXPAND, FILL);
658 tb = manage (new ToggleButton ());
659 tb->set_name ("OptionEditorToggleButton");
660 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_out_toggled), (*i).second, tb));
661 tb->set_size_request (10, 10);
663 midi_port_table_widgets.push_back (tb);
664 midi_port_table.attach (*tb, 3, 4, n+2, n+3, FILL|EXPAND, FILL);
667 rb = manage (new RadioButton ());
668 rb->set_name ("OptionEditorToggleButton");
670 mtc_button_group = rb->get_group();
672 rb->set_group (mtc_button_group);
675 midi_port_table_widgets.push_back (rb);
676 midi_port_table.attach (*rb, 4, 5, n+2, n+3, FILL|EXPAND, FILL);
677 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mtc_port_chosen), (*i).second, rb, bb));
679 if (session && i->second == session->mtc_port()) {
680 rb->set_active (true);
683 // MIDI Clock Radio Button
684 rb = manage (new RadioButton ());
685 rb->set_name ("OptionEditorToggleButton");
687 midi_clock_button_group = rb->get_group();
689 rb->set_group (midi_clock_button_group);
692 midi_port_table_widgets.push_back (rb);
693 midi_port_table.attach (*rb, 6, 7, n+2, n+3, FILL|EXPAND, FILL);
694 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_clock_port_chosen), (*i).second, rb, bb));
696 if (session && i->second == session->midi_clock_port()) {
697 rb->set_active (true);
700 rb = manage (new RadioButton ());
701 rb->set_name ("OptionEditorToggleButton");
703 mmc_button_group = rb->get_group();
705 rb->set_group (mmc_button_group);
708 midi_port_table_widgets.push_back (rb);
709 midi_port_table.attach (*rb, 8, 9, n+2, n+3, FILL|EXPAND, FILL);
710 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mmc_port_chosen), (*i).second, rb, bb));
712 if (session && i->second == session->mmc_port()) {
713 rb->set_active (true);
716 rb = manage (new RadioButton ());
717 rb->set_name ("OptionEditorToggleButton");
719 midi_button_group = rb->get_group();
721 rb->set_group (midi_button_group);
724 midi_port_table_widgets.push_back (rb);
725 midi_port_table.attach (*rb, 10, 11, n+2, n+3, FILL|EXPAND, FILL);
726 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_port_chosen), (*i).second, rb, bb));
728 if (session && i->second == session->midi_port()) {
729 rb->set_active (true);
734 midi_port_table.show();
738 OptionEditor::remove_midi_port (MIDI::Port* port)
740 MIDI::Manager::instance()->remove_port (port);
741 redisplay_midi_ports ();
745 OptionEditor::add_midi_port ()
747 MidiPortDialog dialog;
749 dialog.set_position (WIN_POS_MOUSE);
750 dialog.set_transient_for (*this);
754 int ret = dialog.run ();
757 case RESPONSE_ACCEPT:
764 Glib::ustring mode = dialog.port_mode_combo.get_active_text();
767 if (mode == _("input")) {
769 } else if (mode == (_("output"))) {
776 XMLNode node (X_("MIDI-port"));
778 node.add_property ("tag", dialog.port_name.get_text());
779 node.add_property ("device", X_("ardour")); // XXX this can't be right for all types
780 node.add_property ("type", MIDI::PortFactory::default_port_type());
781 node.add_property ("mode", smod);
783 if (MIDI::Manager::instance()->add_port (node) != 0) {
784 redisplay_midi_ports ();
789 OptionEditor::port_removable (MIDI::Port *port)
795 if (port == session->mtc_port() ||
796 port == session->mmc_port() ||
797 port == session->midi_port()) {
804 OptionEditor::mtc_port_chosen (MIDI::Port *port, Gtk::RadioButton* rb, Gtk::Button* bb)
807 if (rb->get_active()) {
808 session->set_mtc_port (port->name());
809 Config->set_mtc_port_name (port->name());
811 session->set_mtc_port ("");
813 bb->set_sensitive (port_removable (port));
818 OptionEditor::mmc_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb, Gtk::Button* bb)
821 if (rb->get_active()) {
822 session->set_mmc_port (port->name());
823 Config->set_mtc_port_name (port->name());
825 session->set_mmc_port ("");
827 bb->set_sensitive (port_removable (port));
832 OptionEditor::midi_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb, Gtk::Button* bb)
835 if (rb->get_active()) {
836 session->set_midi_port (port->name());
837 Config->set_midi_port_name (port->name());
839 session->set_midi_port ("");
841 bb->set_sensitive (port_removable (port));
846 OptionEditor::midi_clock_port_chosen (MIDI::Port *port, Gtk::RadioButton* rb, Gtk::Button* bb)
849 if (rb->get_active()) {
850 session->set_midi_clock_port (port->name());
851 Config->set_midi_clock_port_name (port->name());
853 session->set_midi_clock_port ("");
855 bb->set_sensitive (port_removable (port));
860 OptionEditor::port_online_toggled (MIDI::Port* port, ToggleButton* tb)
862 bool wanted = tb->get_active();
865 if (wanted != port->input()->offline()) {
866 port->input()->set_offline (wanted);
872 OptionEditor::map_port_online (MIDI::Port* port, ToggleButton* tb)
874 bool bstate = tb->get_active ();
877 if (bstate != port->input()->offline()) {
878 if (port->input()->offline()) {
879 tb->set_label (_("offline"));
880 tb->set_active (false);
882 tb->set_label (_("online"));
883 tb->set_active (true);
890 OptionEditor::mmc_receive_device_id_adjusted ()
892 uint8_t id = (uint8_t) mmc_receive_device_id_spinner.get_value();
893 Config->set_mmc_receive_device_id (id);
897 OptionEditor::mmc_send_device_id_adjusted ()
899 uint8_t id = (uint8_t) mmc_send_device_id_spinner.get_value();
900 Config->set_mmc_send_device_id (id);
904 OptionEditor::port_trace_in_toggled (MIDI::Port* port, ToggleButton* tb)
906 bool trace = tb->get_active();
909 if (port->input()->tracing() != trace) {
910 port->input()->trace (trace, &cerr, string (port->name()) + string (" input: "));
916 OptionEditor::port_trace_out_toggled (MIDI::Port* port, ToggleButton* tb)
918 bool trace = tb->get_active();
920 if (port->output()) {
921 if (port->output()->tracing() != trace) {
922 port->output()->trace (trace, &cerr, string (port->name()) + string (" output: "));
928 OptionEditor::save ()
930 /* XXX a bit odd that we save the entire session state here */
936 OptionEditor::wm_close (GdkEventAny *ev)
944 OptionEditor::raid_path_changed ()
947 Config->set_raid_path (session_raid_entry.get_text());
952 OptionEditor::click_browse_clicked ()
954 SoundFileChooser sfdb (*this, _("Choose Click"), session);
959 int result = sfdb.run ();
961 if (result == Gtk::RESPONSE_OK) {
962 click_chosen(sfdb.get_filename());
967 OptionEditor::click_chosen (const string & path)
969 click_path_entry.set_text (path);
970 click_sound_changed ();
974 OptionEditor::click_emphasis_browse_clicked ()
976 SoundFileChooser sfdb (*this, _("Choose Click Emphasis"), session);
981 int result = sfdb.run ();
983 if (result == Gtk::RESPONSE_OK) {
984 click_emphasis_chosen (sfdb.get_filename());
989 OptionEditor::click_emphasis_chosen (const string & path)
991 click_emphasis_path_entry.set_text (path);
992 click_emphasis_sound_changed ();
996 OptionEditor::click_sound_changed ()
999 string path = click_path_entry.get_text();
1001 if (path == Config->get_click_sound()) {
1005 strip_whitespace_edges (path);
1007 if (path == _("internal")) {
1008 Config->set_click_sound ("");
1010 Config->set_click_sound (path);
1016 OptionEditor::click_emphasis_sound_changed ()
1019 string path = click_emphasis_path_entry.get_text();
1021 if (path == Config->get_click_emphasis_sound()) {
1025 strip_whitespace_edges (path);
1027 if (path == _("internal")) {
1028 Config->set_click_emphasis_sound ("");
1030 Config->set_click_emphasis_sound (path);
1036 OptionEditor::clear_click_editor ()
1038 if (click_io_selector) {
1039 click_packer.remove (*click_io_selector);
1040 click_packer.remove (*click_gpm);
1041 delete click_io_selector;
1043 click_io_selector = 0;
1049 OptionEditor::setup_click_editor ()
1052 HBox* hpacker = manage (new HBox);
1054 click_path_entry.set_sensitive (true);
1055 click_emphasis_path_entry.set_sensitive (true);
1057 click_path_entry.set_name ("OptionsEntry");
1058 click_emphasis_path_entry.set_name ("OptionsEntry");
1060 click_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_sound_changed));
1061 click_emphasis_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed));
1063 click_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_sound_changed));
1064 click_emphasis_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_emphasis_sound_changed));
1066 click_browse_button.set_name ("EditorGTKButton");
1067 click_emphasis_browse_button.set_name ("EditorGTKButton");
1068 click_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_browse_clicked));
1069 click_emphasis_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_emphasis_browse_clicked));
1071 click_packer.set_border_width (12);
1072 click_packer.set_spacing (5);
1074 click_io_selector = new IOSelector (*session, session->click_io(), false);
1075 click_gpm = new GainMeter (session->click_io(), *session);
1077 click_table.set_col_spacings (10);
1079 label = manage(new Label(_("Click audio file")));
1080 label->set_name ("OptionsLabel");
1081 click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
1082 click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1083 click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL);
1085 label = manage(new Label(_("Click emphasis audiofile")));
1086 label->set_name ("OptionsLabel");
1087 click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
1088 click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1089 click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL);
1091 hpacker->set_spacing (10);
1092 hpacker->pack_start (*click_io_selector, false, false);
1093 hpacker->pack_start (*click_gpm, false, false);
1095 click_packer.pack_start (click_table, false, false);
1096 click_packer.pack_start (*hpacker, false, false);
1098 click_packer.show_all ();
1102 OptionEditor::clear_auditioner_editor ()
1104 if (auditioner_io_selector) {
1105 audition_hpacker.remove (*auditioner_io_selector);
1106 audition_hpacker.remove (*auditioner_gpm);
1107 delete auditioner_io_selector;
1108 delete auditioner_gpm;
1109 auditioner_io_selector = 0;
1115 OptionEditor::setup_auditioner_editor ()
1117 audition_packer.set_border_width (12);
1118 audition_packer.set_spacing (5);
1119 audition_hpacker.set_spacing (10);
1121 audition_label.set_name ("OptionEditorAuditionerLabel");
1122 audition_label.set_text (_("The auditioner is a dedicated mixer strip used\n"
1123 "for listening to specific regions outside the context\n"
1124 "of the overall mix. It can be connected just like any\n"
1125 "other mixer strip."));
1127 audition_packer.pack_start (audition_label, false, false, 10);
1128 audition_packer.pack_start (audition_hpacker, false, false);
1132 OptionEditor::connect_audition_editor ()
1134 auditioner_io_selector = new IOSelector (*session, session->the_auditioner(), false);
1135 auditioner_gpm = new GainMeter (session->the_auditioner(), *session);
1137 audition_hpacker.pack_start (*auditioner_io_selector, false, false);
1138 audition_hpacker.pack_start (*auditioner_gpm, false, false);
1140 auditioner_io_selector->show_all ();
1141 auditioner_gpm->show_all ();
1145 OptionEditor::focus_out_event_handler (GdkEventFocus* ev, void (OptionEditor::*pmf)())
1151 static const struct {
1162 { "Shift", GDK_SHIFT_MASK },
1163 { "Command", GDK_META_MASK },
1164 { "Control", GDK_CONTROL_MASK },
1165 { "Option", GDK_MOD1_MASK },
1166 { "Command-Shift", GDK_MOD1_MASK|GDK_SHIFT_MASK },
1167 { "Command-Option", GDK_MOD1_MASK|GDK_MOD5_MASK },
1168 { "Shift-Option", GDK_SHIFT_MASK|GDK_MOD5_MASK },
1169 { "Shift-Command-Option", GDK_MOD5_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
1172 { "Shift", GDK_SHIFT_MASK },
1173 { "Control", GDK_CONTROL_MASK },
1174 { "Alt (Mod1)", GDK_MOD1_MASK },
1175 { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK },
1176 { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK },
1177 { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK },
1178 { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
1179 { "Mod2", GDK_MOD2_MASK },
1180 { "Mod3", GDK_MOD3_MASK },
1181 { "Mod4", GDK_MOD4_MASK },
1182 { "Mod5", GDK_MOD5_MASK },
1188 OptionEditor::setup_keyboard_options ()
1190 vector<string> dumb;
1193 keyboard_mouse_table.set_border_width (12);
1194 keyboard_mouse_table.set_row_spacings (5);
1195 keyboard_mouse_table.set_col_spacings (5);
1197 /* internationalize and prepare for use with combos */
1199 for (int i = 0; modifiers[i].name; ++i) {
1200 dumb.push_back (_(modifiers[i].name));
1203 set_popdown_strings (edit_modifier_combo, dumb);
1204 edit_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::edit_modifier_chosen));
1206 for (int x = 0; modifiers[x].name; ++x) {
1207 if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
1208 edit_modifier_combo.set_active_text (_(modifiers[x].name));
1213 label = manage (new Label (_("Edit using")));
1214 label->set_name ("OptionsLabel");
1215 label->set_alignment (1.0, 0.5);
1217 keyboard_mouse_table.attach (*label, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1218 keyboard_mouse_table.attach (edit_modifier_combo, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1220 label = manage (new Label (_("+ button")));
1221 label->set_name ("OptionsLabel");
1223 keyboard_mouse_table.attach (*label, 3, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1224 keyboard_mouse_table.attach (edit_button_spin, 4, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1226 edit_button_spin.set_name ("OptionsEntry");
1227 edit_button_adjustment.set_value (Keyboard::edit_button());
1228 edit_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::edit_button_changed));
1230 set_popdown_strings (delete_modifier_combo, dumb);
1231 delete_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::delete_modifier_chosen));
1233 for (int x = 0; modifiers[x].name; ++x) {
1234 if (modifiers[x].modifier == Keyboard::delete_modifier ()) {
1235 delete_modifier_combo.set_active_text (_(modifiers[x].name));
1240 label = manage (new Label (_("Delete using")));
1241 label->set_name ("OptionsLabel");
1242 label->set_alignment (1.0, 0.5);
1244 keyboard_mouse_table.attach (*label, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1245 keyboard_mouse_table.attach (delete_modifier_combo, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1247 label = manage (new Label (_("+ button")));
1248 label->set_name ("OptionsLabel");
1250 keyboard_mouse_table.attach (*label, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1251 keyboard_mouse_table.attach (delete_button_spin, 4, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1253 delete_button_spin.set_name ("OptionsEntry");
1254 delete_button_adjustment.set_value (Keyboard::delete_button());
1255 delete_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::delete_button_changed));
1257 set_popdown_strings (snap_modifier_combo, dumb);
1258 snap_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::snap_modifier_chosen));
1260 for (int x = 0; modifiers[x].name; ++x) {
1261 if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) {
1262 snap_modifier_combo.set_active_text (_(modifiers[x].name));
1267 label = manage (new Label (_("Ignore snap using")));
1268 label->set_name ("OptionsLabel");
1269 label->set_alignment (1.0, 0.5);
1271 keyboard_mouse_table.attach (*label, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
1272 keyboard_mouse_table.attach (snap_modifier_combo, 1, 2, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
1274 vector<string> strs;
1276 for (std::map<std::string,std::string>::iterator bf = Keyboard::binding_files.begin(); bf != Keyboard::binding_files.end(); ++bf) {
1277 strs.push_back (bf->first);
1280 set_popdown_strings (keyboard_layout_selector, strs);
1281 keyboard_layout_selector.set_active_text (Keyboard::current_binding_name());
1282 keyboard_layout_selector.signal_changed().connect (mem_fun (*this, &OptionEditor::bindings_changed));
1284 label = manage (new Label (_("Keyboard layout")));
1285 label->set_name ("OptionsLabel");
1286 label->set_alignment (1.0, 0.5);
1288 keyboard_mouse_table.attach (*label, 0, 1, 3, 4, Gtk::FILL|Gtk::EXPAND, FILL);
1289 keyboard_mouse_table.attach (keyboard_layout_selector, 1, 2, 3, 4, Gtk::FILL|Gtk::EXPAND, FILL);
1293 OptionEditor::bindings_changed ()
1297 txt = keyboard_layout_selector.get_active_text();
1299 for (std::map<string,string>::iterator i = Keyboard::binding_files.begin(); i != Keyboard::binding_files.end(); ++i) {
1300 if (txt == i->first) {
1301 if (Keyboard::load_keybindings (i->second)) {
1302 Keyboard::save_keybindings ();
1309 OptionEditor::edit_modifier_chosen ()
1313 txt = edit_modifier_combo.get_active_text();
1315 for (int i = 0; modifiers[i].name; ++i) {
1316 if (txt == _(modifiers[i].name)) {
1317 Keyboard::set_edit_modifier (modifiers[i].modifier);
1324 OptionEditor::delete_modifier_chosen ()
1328 txt = delete_modifier_combo.get_active_text();
1330 for (int i = 0; modifiers[i].name; ++i) {
1331 if (txt == _(modifiers[i].name)) {
1332 Keyboard::set_delete_modifier (modifiers[i].modifier);
1339 OptionEditor::snap_modifier_chosen ()
1343 txt = snap_modifier_combo.get_active_text();
1345 for (int i = 0; modifiers[i].name; ++i) {
1346 if (txt == _(modifiers[i].name)) {
1347 Keyboard::set_snap_modifier (modifiers[i].modifier);
1354 OptionEditor::delete_button_changed ()
1356 Keyboard::set_delete_button ((guint) delete_button_adjustment.get_value());
1360 OptionEditor::edit_button_changed ()
1362 Keyboard::set_edit_button ((guint) edit_button_adjustment.get_value());
1366 OptionEditor::fixup_combo_size (Gtk::ComboBoxText& combo, vector<string>& strings)
1368 /* find the widest string */
1370 string::size_type maxlen = 0;
1373 for (vector<string>::iterator i = strings.begin(); i != strings.end(); ++i) {
1374 string::size_type l;
1376 if ((l = (*i).length()) > maxlen) {
1382 /* try to include ascenders and descenders */
1384 if (maxstring.length() > 2) {
1389 const guint32 FUDGE = 10; // Combo's are stupid - they steal space from the entry for the button
1391 set_size_request_to_display_given_text (combo, maxstring.c_str(), 10 + FUDGE, 10);
1395 OptionEditor::parameter_changed (const char* parameter_name)
1397 ENSURE_GUI_THREAD (bind (mem_fun (*this, &OptionEditor::parameter_changed), parameter_name));
1399 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
1401 if (PARAM_IS ("timecode-source-is-synced")) {
1402 synced_timecode_button.set_active (Config->get_timecode_source_is_synced());
1403 } else if (PARAM_IS ("history-depth")) {
1404 int32_t depth = Config->get_history_depth();
1406 history_depth.set_value (depth);
1407 history_depth_spinner.set_sensitive (depth != 0);
1408 limit_history_button.set_active (depth != 0);
1410 } else if (PARAM_IS ("saved-history-depth")) {
1412 saved_history_depth.set_value (Config->get_saved_history_depth());
1414 } else if (PARAM_IS ("save-history")) {
1416 bool x = Config->get_save_history();
1418 save_history_button.set_active (x);
1419 saved_history_depth_spinner.set_sensitive (x);
1420 } else if (PARAM_IS ("font-scale")) {