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")),
98 initial_program_change_adjustment (0.0, -1.0, (double) 0x7f, 1.0, 16.0),
99 initial_program_change_spinner (initial_program_change_adjustment),
104 click_browse_button (_("Browse")),
105 click_emphasis_browse_button (_("Browse")),
109 keyboard_mouse_table (4, 4),
110 delete_button_adjustment (3, 1, 5),
111 delete_button_spin (delete_button_adjustment),
112 edit_button_adjustment (3, 1, 5),
113 edit_button_spin (edit_button_adjustment)
116 using namespace Notebook_Helpers;
118 first_click_setup = true;
119 click_io_selector = 0;
120 auditioner_io_selector = 0;
123 WindowTitle title(Glib::get_application_name());
124 title += _("Preferences");
125 set_title(title.get_string());
127 set_default_size (300, 300);
128 set_wmclass (X_("ardour_preferences"), "Ardour");
130 set_name ("Preferences");
131 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
133 VBox *vbox = get_vbox();
134 set_border_width (3);
136 vbox->set_spacing (4);
137 vbox->pack_start(notebook);
139 signal_delete_event().connect (mem_fun(*this, &OptionEditor::wm_close));
141 notebook.set_show_tabs (true);
142 notebook.set_show_border (true);
143 notebook.set_name ("OptionsNotebook");
145 setup_sync_options();
146 setup_path_options();
147 setup_misc_options ();
148 setup_keyboard_options ();
149 setup_auditioner_editor ();
151 notebook.pages().push_back (TabElem (sync_packer, _("Sync")));
152 notebook.pages().push_back (TabElem (path_table, _("Paths/Files")));
153 notebook.pages().push_back (TabElem (keyboard_mouse_table, _("Kbd/Mouse")));
154 notebook.pages().push_back (TabElem (click_packer, _("Click")));
155 notebook.pages().push_back (TabElem (audition_packer, _("Audition")));
156 notebook.pages().push_back (TabElem (misc_packer, _("Misc")));
158 setup_midi_options ();
159 notebook.pages().push_back (TabElem (midi_packer, _("MIDI")));
164 Config->map_parameters (mem_fun (*this, &OptionEditor::parameter_changed));
165 Config->ParameterChanged.connect (mem_fun (*this, &OptionEditor::parameter_changed));
169 OptionEditor::set_session (Session *s)
171 clear_click_editor ();
172 clear_auditioner_editor ();
174 click_path_entry.set_text ("");
175 click_emphasis_path_entry.set_text ("");
176 session_raid_entry.set_text ("");
178 click_path_entry.set_sensitive (false);
179 click_emphasis_path_entry.set_sensitive (false);
180 session_raid_entry.set_sensitive (false);
182 short_xfade_slider.set_sensitive (false);
183 smpte_offset_negative_button.set_sensitive (false);
185 smpte_offset_clock.set_session (s);
187 if ((session = s) == 0) {
191 click_path_entry.set_sensitive (true);
192 click_emphasis_path_entry.set_sensitive (true);
193 session_raid_entry.set_sensitive (true);
194 short_xfade_slider.set_sensitive (true);
195 smpte_offset_negative_button.set_sensitive (true);
197 smpte_offset_clock.set_session (s);
198 smpte_offset_clock.set (s->smpte_offset (), true);
200 smpte_offset_negative_button.set_active (session->smpte_offset_negative());
202 redisplay_midi_ports ();
204 setup_click_editor ();
205 connect_audition_editor ();
207 short_xfade_adjustment.set_value ((Crossfade::short_xfade_length() / (float) session->frame_rate()) * 1000.0);
209 add_session_paths ();
212 OptionEditor::~OptionEditor ()
217 OptionEditor::setup_path_options()
221 path_table.set_homogeneous (false);
222 path_table.set_border_width (12);
223 path_table.set_row_spacings (5);
225 session_raid_entry.set_name ("OptionsEntry");
227 session_raid_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::raid_path_changed));
229 label = manage(new Label(_("session RAID path")));
230 label->set_name ("OptionsLabel");
231 path_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
232 path_table.attach (session_raid_entry, 1, 3, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
234 path_table.show_all();
238 OptionEditor::add_session_paths ()
240 click_path_entry.set_sensitive (true);
241 click_emphasis_path_entry.set_sensitive (true);
242 session_raid_entry.set_sensitive (true);
244 if (Config->get_click_sound().empty()) {
245 click_path_entry.set_text (_("internal"));
247 click_path_entry.set_text (Config->get_click_sound());
250 if (Config->get_click_emphasis_sound().empty()) {
251 click_emphasis_path_entry.set_text (_("internal"));
253 click_emphasis_path_entry.set_text (Config->get_click_emphasis_sound());
256 session_raid_entry.set_text(session->raid_path());
260 font_scale_changed (Gtk::Adjustment* adj)
262 Config->set_font_scale((long)floor (adj->get_value() * 1024));
267 OptionEditor::setup_misc_options ()
273 /* font scaling does nothing with GDK/Quartz */
275 Gtk::Adjustment* dpi_adj = new Gtk::Adjustment ((double)Config->get_font_scale() / 1024, 50, 250, 1, 10);
276 Gtk::HScale * dpi_range = new Gtk::HScale (*dpi_adj);
278 label = manage (new Label (_("Font Scaling")));
279 label->set_name ("OptionsLabel");
281 dpi_range->set_update_policy (Gtk::UPDATE_DISCONTINUOUS);
282 dpi_adj->signal_value_changed().connect (bind (sigc::ptr_fun (font_scale_changed), dpi_adj));
284 hbox = manage (new HBox);
285 hbox->set_border_width (5);
286 hbox->set_spacing (10);
287 hbox->pack_start (*label, false, false);
288 hbox->pack_start (*dpi_range, true, true);
289 misc_packer.pack_start (*hbox, false, false);
292 label = manage (new Label (_("Short crossfade length (msecs)")));
293 label->set_name ("OptionsLabel");
295 hbox = manage (new HBox);
296 hbox->set_border_width (5);
297 hbox->set_spacing (10);
298 hbox->pack_start (*label, false, false);
299 hbox->pack_start (short_xfade_slider, true, true);
300 misc_packer.pack_start (*hbox, false, false);
302 short_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::short_xfade_adjustment_changed));
304 label = manage (new Label (_("Destructive crossfade length (msecs)")));
305 label->set_name ("OptionsLabel");
307 hbox = manage (new HBox);
308 hbox->set_border_width (5);
309 hbox->set_spacing (10);
310 hbox->pack_start (*label, false, false);
311 hbox->pack_start (destructo_xfade_slider, true, true);
312 misc_packer.pack_start (*hbox, false, false);
315 destructo_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::destructo_xfade_adjustment_changed));
317 hbox = manage (new HBox);
318 hbox->set_border_width (5);
319 hbox->set_spacing (10);
320 hbox->pack_start (limit_history_button, false, false);
321 misc_packer.pack_start (*hbox, false, false);
323 label = manage (new Label (_("History depth (commands)")));
324 label->set_name ("OptionsLabel");
326 hbox = manage (new HBox);
327 hbox->set_border_width (5);
328 hbox->set_spacing (10);
329 hbox->pack_start (*label, false, false);
330 hbox->pack_start (history_depth_spinner, false, false);
331 misc_packer.pack_start (*hbox, false, false);
333 history_depth.signal_value_changed().connect (mem_fun (*this, &OptionEditor::history_depth_changed));
334 saved_history_depth.signal_value_changed().connect (mem_fun (*this, &OptionEditor::saved_history_depth_changed));
335 save_history_button.signal_toggled().connect (mem_fun (*this, &OptionEditor::save_history_toggled));
336 limit_history_button.signal_toggled().connect (mem_fun (*this, &OptionEditor::limit_history_toggled));
338 hbox = manage (new HBox);
339 hbox->set_border_width (5);
340 hbox->set_spacing (10);
341 hbox->pack_start (save_history_button, false, false);
342 misc_packer.pack_start (*hbox, false, false);
344 label = manage (new Label (_("Saved history depth (commands)")));
345 label->set_name ("OptionsLabel");
347 hbox = manage (new HBox);
348 hbox->set_border_width (5);
349 hbox->set_spacing (10);
350 hbox->pack_start (*label, false, false);
351 hbox->pack_start (saved_history_depth_spinner, false, false);
352 misc_packer.pack_start (*hbox, false, false);
354 short_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
355 destructo_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
357 destructo_xfade_adjustment.set_value (Config->get_destructive_xfade_msecs());
359 misc_packer.show_all ();
363 OptionEditor::limit_history_toggled ()
365 bool x = limit_history_button.get_active();
368 Config->set_history_depth (0);
369 history_depth_spinner.set_sensitive (false);
371 if (Config->get_history_depth() == 0) {
372 /* get back to a sane default */
373 Config->set_history_depth (20);
375 history_depth_spinner.set_sensitive (true);
380 OptionEditor::save_history_toggled ()
382 bool x = save_history_button.get_active();
384 if (x != Config->get_save_history()) {
385 Config->set_save_history (x);
386 saved_history_depth_spinner.set_sensitive (x);
391 OptionEditor::history_depth_changed()
393 Config->set_history_depth ((int32_t) floor (history_depth.get_value()));
397 OptionEditor::saved_history_depth_changed()
399 Config->set_saved_history_depth ((int32_t) floor (saved_history_depth.get_value()));
403 OptionEditor::short_xfade_adjustment_changed ()
406 float val = short_xfade_adjustment.get_value();
408 /* val is in msecs */
410 Crossfade::set_short_xfade_length ((nframes_t) floor (session->frame_rate() * (val / 1000.0)));
415 OptionEditor::destructo_xfade_adjustment_changed ()
417 float val = destructo_xfade_adjustment.get_value();
419 /* val is in msecs */
422 Config->set_destructive_xfade_msecs ((uint32_t) floor (val));
425 SndFileSource::setup_standard_crossfades (session->frame_rate());
430 OptionEditor::setup_sync_options ()
435 smpte_offset_clock.set_mode (AudioClock::SMPTE);
436 smpte_offset_clock.ValueChanged.connect (mem_fun(*this, &OptionEditor::smpte_offset_chosen));
438 smpte_offset_negative_button.set_name ("OptionEditorToggleButton");
440 smpte_offset_negative_button.unset_flags (Gtk::CAN_FOCUS);
442 Label *smpte_offset_label = manage (new Label (_("SMPTE Offset")));
443 smpte_offset_label->set_name("OptionsLabel");
445 hbox = manage (new HBox);
446 hbox->set_border_width (5);
447 hbox->set_spacing (10);
448 hbox->pack_start (*smpte_offset_label, false, false);
449 hbox->pack_start (smpte_offset_clock, false, false);
450 hbox->pack_start (smpte_offset_negative_button, false, false);
452 sync_packer.pack_start (*hbox, false, false);
453 sync_packer.pack_start (synced_timecode_button, false, false);
455 smpte_offset_negative_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::smpte_offset_negative_clicked));
456 synced_timecode_button.signal_toggled().connect (mem_fun(*this, &OptionEditor::synced_timecode_toggled));
460 OptionEditor::smpte_offset_negative_clicked ()
463 session->set_smpte_offset_negative (smpte_offset_negative_button.get_active());
468 OptionEditor::synced_timecode_toggled ()
472 if ((x = synced_timecode_button.get_active()) != Config->get_timecode_source_is_synced()) {
473 Config->set_timecode_source_is_synced (x);
474 Config->save_state();
479 OptionEditor::smpte_offset_chosen()
482 nframes_t frames = smpte_offset_clock.current_duration();
483 session->set_smpte_offset (frames);
489 OptionEditor::setup_midi_options ()
494 midi_port_table.set_row_spacings (6);
495 midi_port_table.set_col_spacings (10);
497 redisplay_midi_ports ();
499 mmc_receive_device_id_adjustment.set_value (Config->get_mmc_receive_device_id());
500 mmc_send_device_id_adjustment.set_value (Config->get_mmc_send_device_id());
502 mmc_receive_device_id_adjustment.signal_value_changed().connect (mem_fun (*this, &OptionEditor::mmc_receive_device_id_adjusted));
503 mmc_send_device_id_adjustment.signal_value_changed().connect (mem_fun (*this, &OptionEditor::mmc_send_device_id_adjusted));
505 hbox = manage (new HBox);
506 hbox->set_border_width (6);
507 hbox->pack_start (midi_port_table, true, false);
509 midi_packer.pack_start (*hbox, false, false);
510 add_midi_port_button.set_label ("Add MIDI port");
511 midi_packer.pack_start (add_midi_port_button, false, false);
513 hbox = manage (new HBox);
514 hbox->set_border_width (6);
515 hbox->set_spacing (6);
516 label = (manage (new Label (_("Inbound MMC Device ID"))));
517 hbox->pack_start (mmc_receive_device_id_spinner, false, false);
518 hbox->pack_start (*label, false, false);
519 midi_packer.pack_start (*hbox, false, false);
521 mmc_receive_device_id_spinner.set_value(Config->get_mmc_receive_device_id ());
523 hbox = manage (new HBox);
524 hbox->set_border_width (6);
525 hbox->set_spacing (6);
526 label = (manage (new Label (_("Outbound MMC Device ID"))));
527 hbox->pack_start (mmc_send_device_id_spinner, false, false);
528 hbox->pack_start (*label, false, false);
529 midi_packer.pack_start (*hbox, false, false);
531 mmc_send_device_id_spinner.set_value(Config->get_mmc_send_device_id ());
533 hbox = manage (new HBox);
534 hbox->set_border_width (6);
535 hbox->set_spacing (6);
536 label = (manage (new Label (_("Startup program change"))));
537 hbox->pack_start (initial_program_change_spinner, false, false);
538 hbox->pack_start (*label, false, false);
539 midi_packer.pack_start (*hbox, false, false);
541 initial_program_change_spinner.set_value (Config->get_initial_program_change());
542 initial_program_change_adjustment.signal_value_changed().connect (mem_fun (*this, &OptionEditor::initial_program_change_adjusted));
544 add_midi_port_button.signal_clicked().connect (mem_fun (*this, &OptionEditor::add_midi_port));
548 OptionEditor::initial_program_change_adjusted ()
550 Config->set_initial_program_change (((int32_t) floor (initial_program_change_adjustment.get_value())) & 0x7f);
554 OptionEditor::redisplay_midi_ports ()
556 MIDI::Manager::PortMap::const_iterator i;
557 const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports();
560 /* remove all existing widgets */
562 // XXX broken in gtkmm 2.10
563 // midi_port_table.clear ();
565 for (vector<Widget*>::iterator w = midi_port_table_widgets.begin(); w != midi_port_table_widgets.end(); ++w) {
566 midi_port_table.remove (**w);
569 midi_port_table_widgets.clear ();
571 midi_port_table.resize (ports.size() + 4, 12);
575 label = (manage (new Label (_("Port"))));
577 midi_port_table_widgets.push_back (label);
578 midi_port_table.attach (*label, 0, 1, 0, 1);
579 label = (manage (new Label (_("Offline"))));
581 midi_port_table_widgets.push_back (label);
582 midi_port_table.attach (*label, 1, 2, 0, 1);
583 label = (manage (new Label (_("Trace\nInput"))));
585 midi_port_table_widgets.push_back (label);
586 midi_port_table.attach (*label, 2, 3, 0, 1);
587 label = (manage (new Label (_("Trace\nOutput"))));
589 midi_port_table_widgets.push_back (label);
590 midi_port_table.attach (*label, 3, 4, 0, 1);
591 label = (manage (new Label (_("MTC"))));
593 midi_port_table_widgets.push_back (label);
594 midi_port_table.attach (*label, 4, 5, 0, 1);
595 label = (manage (new Label (_("MIDI\nClock"))));
597 midi_port_table_widgets.push_back (label);
598 midi_port_table.attach (*label, 6, 7, 0, 1);
599 label = (manage (new Label (_("MMC"))));
601 midi_port_table_widgets.push_back (label);
602 midi_port_table.attach (*label, 8, 9, 0, 1);
603 label = (manage (new Label (_("MIDI Parameter\nControl"))));
605 midi_port_table_widgets.push_back (label);
606 midi_port_table.attach (*label, 10, 11, 0, 1);
608 Gtk::HSeparator* hsep = (manage (new HSeparator()));
610 midi_port_table_widgets.push_back (hsep);
611 midi_port_table.attach (*hsep, 0, 11, 1, 2);
612 Gtk::VSeparator* vsep = (manage (new VSeparator()));
614 midi_port_table_widgets.push_back (vsep);
615 midi_port_table.attach (*vsep, 5, 6, 0, 8);
616 vsep = (manage (new VSeparator()));
618 midi_port_table_widgets.push_back (vsep);
619 midi_port_table.attach (*vsep, 7, 8, 0, 8);
620 vsep = (manage (new VSeparator()));
622 midi_port_table_widgets.push_back (vsep);
623 midi_port_table.attach (*vsep, 9, 10, 0, 8);
625 for (n = 0, i = ports.begin(); i != ports.end(); ++n, ++i) {
631 /* the remove button. create early so we can pass it to various callbacks */
633 bb = manage (new Button (Stock::REMOVE));
634 bb->set_name ("OptionEditorToggleButton");
636 midi_port_table_widgets.push_back (bb);
637 midi_port_table.attach (*bb, 11, 12, n+2, n+3, FILL|EXPAND, FILL);
638 bb->signal_clicked().connect (bind (mem_fun(*this, &OptionEditor::remove_midi_port), i->second));
639 bb->set_sensitive (port_removable (i->second));
641 label = (manage (new Label (i->first)));
643 midi_port_table_widgets.push_back (label);
644 midi_port_table.attach (*label, 0, 1, n+2, n+3,FILL|EXPAND, FILL );
646 tb = manage (new ToggleButton (_("online")));
647 tb->set_name ("OptionEditorToggleButton");
649 /* remember, we have to handle the i18n case where the relative
650 lengths of the strings in language N is different than in english.
653 if (strlen (_("offline")) > strlen (_("online"))) {
654 set_size_request_to_display_given_text (*tb, _("offline"), 15, 12);
656 set_size_request_to_display_given_text (*tb, _("online"), 15, 12);
659 if (i->second->input()) {
660 tb->set_active (!i->second->input()->offline());
661 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_online_toggled), i->second, tb));
662 i->second->input()->OfflineStatusChanged.connect (bind (mem_fun(*this, &OptionEditor::map_port_online), (*i).second, tb));
665 midi_port_table_widgets.push_back (tb);
666 midi_port_table.attach (*tb, 1, 2, n+2, n+3, FILL|EXPAND, FILL);
669 tb = manage (new ToggleButton ());
670 tb->set_name ("OptionEditorToggleButton");
671 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_in_toggled), (*i).second, tb));
672 tb->set_size_request (10, 10);
674 midi_port_table_widgets.push_back (tb);
675 midi_port_table.attach (*tb, 2, 3, n+2, n+3, FILL|EXPAND, FILL);
678 tb = manage (new ToggleButton ());
679 tb->set_name ("OptionEditorToggleButton");
680 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_out_toggled), (*i).second, tb));
681 tb->set_size_request (10, 10);
683 midi_port_table_widgets.push_back (tb);
684 midi_port_table.attach (*tb, 3, 4, n+2, n+3, FILL|EXPAND, FILL);
687 rb = manage (new RadioButton ());
688 rb->set_name ("OptionEditorToggleButton");
690 mtc_button_group = rb->get_group();
692 rb->set_group (mtc_button_group);
695 midi_port_table_widgets.push_back (rb);
696 midi_port_table.attach (*rb, 4, 5, n+2, n+3, FILL|EXPAND, FILL);
697 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mtc_port_chosen), (*i).second, rb, bb));
699 if (session && i->second == session->mtc_port()) {
700 rb->set_active (true);
703 // MIDI Clock Radio Button
704 rb = manage (new RadioButton ());
705 rb->set_name ("OptionEditorToggleButton");
707 midi_clock_button_group = rb->get_group();
709 rb->set_group (midi_clock_button_group);
712 midi_port_table_widgets.push_back (rb);
713 midi_port_table.attach (*rb, 6, 7, n+2, n+3, FILL|EXPAND, FILL);
714 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_clock_port_chosen), (*i).second, rb, bb));
716 if (session && i->second == session->midi_clock_port()) {
717 rb->set_active (true);
720 rb = manage (new RadioButton ());
721 rb->set_name ("OptionEditorToggleButton");
723 mmc_button_group = rb->get_group();
725 rb->set_group (mmc_button_group);
728 midi_port_table_widgets.push_back (rb);
729 midi_port_table.attach (*rb, 8, 9, n+2, n+3, FILL|EXPAND, FILL);
730 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mmc_port_chosen), (*i).second, rb, bb));
732 if (session && i->second == session->mmc_port()) {
733 rb->set_active (true);
736 rb = manage (new RadioButton ());
737 rb->set_name ("OptionEditorToggleButton");
739 midi_button_group = rb->get_group();
741 rb->set_group (midi_button_group);
744 midi_port_table_widgets.push_back (rb);
745 midi_port_table.attach (*rb, 10, 11, n+2, n+3, FILL|EXPAND, FILL);
746 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_port_chosen), (*i).second, rb, bb));
748 if (session && i->second == session->midi_port()) {
749 rb->set_active (true);
754 midi_port_table.show();
758 OptionEditor::remove_midi_port (MIDI::Port* port)
760 MIDI::Manager::instance()->remove_port (port);
761 redisplay_midi_ports ();
765 OptionEditor::add_midi_port ()
767 MidiPortDialog dialog;
769 dialog.set_position (WIN_POS_MOUSE);
770 dialog.set_transient_for (*this);
774 int ret = dialog.run ();
777 case RESPONSE_ACCEPT:
784 Glib::ustring mode = dialog.port_mode_combo.get_active_text();
787 if (mode == _("input")) {
789 } else if (mode == (_("output"))) {
796 XMLNode node (X_("MIDI-port"));
798 node.add_property ("tag", dialog.port_name.get_text());
799 node.add_property ("device", X_("ardour")); // XXX this can't be right for all types
800 node.add_property ("type", MIDI::PortFactory::default_port_type());
801 node.add_property ("mode", smod);
803 if (MIDI::Manager::instance()->add_port (node) != 0) {
804 redisplay_midi_ports ();
809 OptionEditor::port_removable (MIDI::Port *port)
815 if (port == session->mtc_port() ||
816 port == session->mmc_port() ||
817 port == session->midi_port()) {
824 OptionEditor::mtc_port_chosen (MIDI::Port *port, Gtk::RadioButton* rb, Gtk::Button* bb)
827 if (rb->get_active()) {
828 session->set_mtc_port (port->name());
829 Config->set_mtc_port_name (port->name());
831 session->set_mtc_port ("");
833 bb->set_sensitive (port_removable (port));
838 OptionEditor::mmc_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb, Gtk::Button* bb)
841 if (rb->get_active()) {
842 session->set_mmc_port (port->name());
843 Config->set_mtc_port_name (port->name());
845 session->set_mmc_port ("");
847 bb->set_sensitive (port_removable (port));
852 OptionEditor::midi_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb, Gtk::Button* bb)
855 if (rb->get_active()) {
856 session->set_midi_port (port->name());
857 Config->set_midi_port_name (port->name());
859 session->set_midi_port ("");
861 bb->set_sensitive (port_removable (port));
866 OptionEditor::midi_clock_port_chosen (MIDI::Port *port, Gtk::RadioButton* rb, Gtk::Button* bb)
869 if (rb->get_active()) {
870 session->set_midi_clock_port (port->name());
871 Config->set_midi_clock_port_name (port->name());
873 session->set_midi_clock_port ("");
875 bb->set_sensitive (port_removable (port));
880 OptionEditor::port_online_toggled (MIDI::Port* port, ToggleButton* tb)
882 bool wanted = tb->get_active();
885 if (wanted != port->input()->offline()) {
886 port->input()->set_offline (wanted);
892 OptionEditor::map_port_online (MIDI::Port* port, ToggleButton* tb)
894 bool bstate = tb->get_active ();
897 if (bstate != port->input()->offline()) {
898 if (port->input()->offline()) {
899 tb->set_label (_("offline"));
900 tb->set_active (false);
902 tb->set_label (_("online"));
903 tb->set_active (true);
910 OptionEditor::mmc_receive_device_id_adjusted ()
912 uint8_t id = (uint8_t) mmc_receive_device_id_spinner.get_value();
913 Config->set_mmc_receive_device_id (id);
917 OptionEditor::mmc_send_device_id_adjusted ()
919 uint8_t id = (uint8_t) mmc_send_device_id_spinner.get_value();
920 Config->set_mmc_send_device_id (id);
924 OptionEditor::port_trace_in_toggled (MIDI::Port* port, ToggleButton* tb)
926 bool trace = tb->get_active();
929 if (port->input()->tracing() != trace) {
930 port->input()->trace (trace, &cerr, string (port->name()) + string (" input: "));
936 OptionEditor::port_trace_out_toggled (MIDI::Port* port, ToggleButton* tb)
938 bool trace = tb->get_active();
940 if (port->output()) {
941 if (port->output()->tracing() != trace) {
942 port->output()->trace (trace, &cerr, string (port->name()) + string (" output: "));
948 OptionEditor::save ()
950 /* XXX a bit odd that we save the entire session state here */
956 OptionEditor::wm_close (GdkEventAny *ev)
964 OptionEditor::raid_path_changed ()
967 Config->set_raid_path (session_raid_entry.get_text());
972 OptionEditor::click_browse_clicked ()
974 SoundFileChooser sfdb (*this, _("Choose Click"), session);
979 int result = sfdb.run ();
981 if (result == Gtk::RESPONSE_OK) {
982 click_chosen(sfdb.get_filename());
987 OptionEditor::click_chosen (const string & path)
989 click_path_entry.set_text (path);
990 click_sound_changed ();
994 OptionEditor::click_emphasis_browse_clicked ()
996 SoundFileChooser sfdb (*this, _("Choose Click Emphasis"), session);
1001 int result = sfdb.run ();
1003 if (result == Gtk::RESPONSE_OK) {
1004 click_emphasis_chosen (sfdb.get_filename());
1009 OptionEditor::click_emphasis_chosen (const string & path)
1011 click_emphasis_path_entry.set_text (path);
1012 click_emphasis_sound_changed ();
1016 OptionEditor::click_sound_changed ()
1019 string path = click_path_entry.get_text();
1021 if (path == Config->get_click_sound()) {
1025 strip_whitespace_edges (path);
1027 if (path == _("internal")) {
1028 Config->set_click_sound ("");
1030 Config->set_click_sound (path);
1036 OptionEditor::click_emphasis_sound_changed ()
1039 string path = click_emphasis_path_entry.get_text();
1041 if (path == Config->get_click_emphasis_sound()) {
1045 strip_whitespace_edges (path);
1047 if (path == _("internal")) {
1048 Config->set_click_emphasis_sound ("");
1050 Config->set_click_emphasis_sound (path);
1056 OptionEditor::clear_click_editor ()
1058 if (click_io_selector) {
1059 click_hpacker.remove (*click_io_selector);
1060 click_hpacker.remove (*click_gpm);
1061 delete click_io_selector;
1063 click_io_selector = 0;
1069 OptionEditor::setup_click_editor ()
1073 if (first_click_setup) {
1075 click_path_entry.set_name ("OptionsEntry");
1076 click_emphasis_path_entry.set_name ("OptionsEntry");
1078 click_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_sound_changed));
1079 click_emphasis_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed));
1081 click_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_sound_changed));
1082 click_emphasis_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_emphasis_sound_changed));
1084 click_browse_button.set_name ("EditorGTKButton");
1085 click_emphasis_browse_button.set_name ("EditorGTKButton");
1087 click_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_browse_clicked));
1088 click_emphasis_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_emphasis_browse_clicked));
1090 click_packer.set_border_width (12);
1091 click_packer.set_spacing (5);
1093 click_table.set_col_spacings (10);
1095 label = manage(new Label(_("Click audio file")));
1096 label->set_name ("OptionsLabel");
1097 click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
1098 click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1099 click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL);
1101 label = manage(new Label(_("Click emphasis audiofile")));
1102 label->set_name ("OptionsLabel");
1103 click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
1104 click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1105 click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL);
1107 click_packer.pack_start (click_table, false, false);
1108 click_packer.pack_start (click_hpacker, false, false);
1111 click_hpacker.set_spacing (10);
1113 first_click_setup = false;
1116 click_path_entry.set_sensitive (true);
1117 click_emphasis_path_entry.set_sensitive (true);
1119 click_io_selector = new IOSelector (*session, session->click_io(), false);
1120 click_gpm = new GainMeter (session->click_io(), *session);
1122 click_hpacker.pack_start (*click_io_selector, false, false);
1123 click_hpacker.pack_start (*click_gpm, false, false);
1125 click_table.set_col_spacings (10);
1127 label = manage(new Label(_("Click audio file")));
1128 label->set_name ("OptionsLabel");
1129 click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
1130 click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1131 click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL);
1133 label = manage(new Label(_("Click emphasis audiofile")));
1134 label->set_name ("OptionsLabel");
1135 click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
1136 click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1137 click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL);
1139 click_packer.show_all ();
1143 OptionEditor::clear_auditioner_editor ()
1145 if (auditioner_io_selector) {
1146 audition_hpacker.remove (*auditioner_io_selector);
1147 audition_hpacker.remove (*auditioner_gpm);
1148 delete auditioner_io_selector;
1149 delete auditioner_gpm;
1150 auditioner_io_selector = 0;
1156 OptionEditor::setup_auditioner_editor ()
1158 audition_packer.set_border_width (12);
1159 audition_packer.set_spacing (5);
1160 audition_hpacker.set_spacing (10);
1162 audition_label.set_name ("OptionEditorAuditionerLabel");
1163 audition_label.set_text (_("The auditioner is a dedicated mixer strip used\n"
1164 "for listening to specific regions outside the context\n"
1165 "of the overall mix. It can be connected just like any\n"
1166 "other mixer strip."));
1168 audition_packer.pack_start (audition_label, false, false, 10);
1169 audition_packer.pack_start (audition_hpacker, false, false);
1173 OptionEditor::connect_audition_editor ()
1175 auditioner_io_selector = new IOSelector (*session, session->the_auditioner(), false);
1176 auditioner_gpm = new GainMeter (session->the_auditioner(), *session);
1178 audition_hpacker.pack_start (*auditioner_io_selector, false, false);
1179 audition_hpacker.pack_start (*auditioner_gpm, false, false);
1181 auditioner_io_selector->show_all ();
1182 auditioner_gpm->show_all ();
1186 OptionEditor::focus_out_event_handler (GdkEventFocus* ev, void (OptionEditor::*pmf)())
1192 static const struct {
1203 { "Shift", GDK_SHIFT_MASK },
1204 { "Command", GDK_META_MASK },
1205 { "Control", GDK_CONTROL_MASK },
1206 { "Option", GDK_MOD1_MASK },
1207 { "Command-Shift", GDK_MOD1_MASK|GDK_SHIFT_MASK },
1208 { "Command-Option", GDK_MOD1_MASK|GDK_MOD5_MASK },
1209 { "Shift-Option", GDK_SHIFT_MASK|GDK_MOD5_MASK },
1210 { "Shift-Command-Option", GDK_MOD5_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
1213 { "Shift", GDK_SHIFT_MASK },
1214 { "Control", GDK_CONTROL_MASK },
1215 { "Alt (Mod1)", GDK_MOD1_MASK },
1216 { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK },
1217 { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK },
1218 { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK },
1219 { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
1220 { "Mod2", GDK_MOD2_MASK },
1221 { "Mod3", GDK_MOD3_MASK },
1222 { "Mod4", GDK_MOD4_MASK },
1223 { "Mod5", GDK_MOD5_MASK },
1229 OptionEditor::setup_keyboard_options ()
1231 vector<string> dumb;
1234 keyboard_mouse_table.set_border_width (12);
1235 keyboard_mouse_table.set_row_spacings (5);
1236 keyboard_mouse_table.set_col_spacings (5);
1238 /* internationalize and prepare for use with combos */
1240 for (int i = 0; modifiers[i].name; ++i) {
1241 dumb.push_back (_(modifiers[i].name));
1244 set_popdown_strings (edit_modifier_combo, dumb);
1245 edit_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::edit_modifier_chosen));
1247 for (int x = 0; modifiers[x].name; ++x) {
1248 if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
1249 edit_modifier_combo.set_active_text (_(modifiers[x].name));
1254 label = manage (new Label (_("Edit using")));
1255 label->set_name ("OptionsLabel");
1256 label->set_alignment (1.0, 0.5);
1258 keyboard_mouse_table.attach (*label, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1259 keyboard_mouse_table.attach (edit_modifier_combo, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1261 label = manage (new Label (_("+ button")));
1262 label->set_name ("OptionsLabel");
1264 keyboard_mouse_table.attach (*label, 3, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1265 keyboard_mouse_table.attach (edit_button_spin, 4, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1267 edit_button_spin.set_name ("OptionsEntry");
1268 edit_button_adjustment.set_value (Keyboard::edit_button());
1269 edit_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::edit_button_changed));
1271 set_popdown_strings (delete_modifier_combo, dumb);
1272 delete_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::delete_modifier_chosen));
1274 for (int x = 0; modifiers[x].name; ++x) {
1275 if (modifiers[x].modifier == Keyboard::delete_modifier ()) {
1276 delete_modifier_combo.set_active_text (_(modifiers[x].name));
1281 label = manage (new Label (_("Delete using")));
1282 label->set_name ("OptionsLabel");
1283 label->set_alignment (1.0, 0.5);
1285 keyboard_mouse_table.attach (*label, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1286 keyboard_mouse_table.attach (delete_modifier_combo, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1288 label = manage (new Label (_("+ button")));
1289 label->set_name ("OptionsLabel");
1291 keyboard_mouse_table.attach (*label, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1292 keyboard_mouse_table.attach (delete_button_spin, 4, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1294 delete_button_spin.set_name ("OptionsEntry");
1295 delete_button_adjustment.set_value (Keyboard::delete_button());
1296 delete_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::delete_button_changed));
1298 set_popdown_strings (snap_modifier_combo, dumb);
1299 snap_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::snap_modifier_chosen));
1301 for (int x = 0; modifiers[x].name; ++x) {
1302 if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) {
1303 snap_modifier_combo.set_active_text (_(modifiers[x].name));
1308 label = manage (new Label (_("Ignore snap using")));
1309 label->set_name ("OptionsLabel");
1310 label->set_alignment (1.0, 0.5);
1312 keyboard_mouse_table.attach (*label, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
1313 keyboard_mouse_table.attach (snap_modifier_combo, 1, 2, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
1315 vector<string> strs;
1317 for (std::map<std::string,std::string>::iterator bf = Keyboard::binding_files.begin(); bf != Keyboard::binding_files.end(); ++bf) {
1318 strs.push_back (bf->first);
1321 set_popdown_strings (keyboard_layout_selector, strs);
1322 keyboard_layout_selector.set_active_text (Keyboard::current_binding_name());
1323 keyboard_layout_selector.signal_changed().connect (mem_fun (*this, &OptionEditor::bindings_changed));
1325 label = manage (new Label (_("Keyboard layout")));
1326 label->set_name ("OptionsLabel");
1327 label->set_alignment (1.0, 0.5);
1329 keyboard_mouse_table.attach (*label, 0, 1, 3, 4, Gtk::FILL|Gtk::EXPAND, FILL);
1330 keyboard_mouse_table.attach (keyboard_layout_selector, 1, 2, 3, 4, Gtk::FILL|Gtk::EXPAND, FILL);
1334 OptionEditor::bindings_changed ()
1338 txt = keyboard_layout_selector.get_active_text();
1340 for (std::map<string,string>::iterator i = Keyboard::binding_files.begin(); i != Keyboard::binding_files.end(); ++i) {
1341 if (txt == i->first) {
1342 if (Keyboard::load_keybindings (i->second)) {
1343 Keyboard::save_keybindings ();
1350 OptionEditor::edit_modifier_chosen ()
1354 txt = edit_modifier_combo.get_active_text();
1356 for (int i = 0; modifiers[i].name; ++i) {
1357 if (txt == _(modifiers[i].name)) {
1358 Keyboard::set_edit_modifier (modifiers[i].modifier);
1365 OptionEditor::delete_modifier_chosen ()
1369 txt = delete_modifier_combo.get_active_text();
1371 for (int i = 0; modifiers[i].name; ++i) {
1372 if (txt == _(modifiers[i].name)) {
1373 Keyboard::set_delete_modifier (modifiers[i].modifier);
1380 OptionEditor::snap_modifier_chosen ()
1384 txt = snap_modifier_combo.get_active_text();
1386 for (int i = 0; modifiers[i].name; ++i) {
1387 if (txt == _(modifiers[i].name)) {
1388 Keyboard::set_snap_modifier (modifiers[i].modifier);
1395 OptionEditor::delete_button_changed ()
1397 Keyboard::set_delete_button ((guint) delete_button_adjustment.get_value());
1401 OptionEditor::edit_button_changed ()
1403 Keyboard::set_edit_button ((guint) edit_button_adjustment.get_value());
1407 OptionEditor::fixup_combo_size (Gtk::ComboBoxText& combo, vector<string>& strings)
1409 /* find the widest string */
1411 string::size_type maxlen = 0;
1414 for (vector<string>::iterator i = strings.begin(); i != strings.end(); ++i) {
1415 string::size_type l;
1417 if ((l = (*i).length()) > maxlen) {
1423 /* try to include ascenders and descenders */
1425 if (maxstring.length() > 2) {
1430 const guint32 FUDGE = 10; // Combo's are stupid - they steal space from the entry for the button
1432 set_size_request_to_display_given_text (combo, maxstring.c_str(), 10 + FUDGE, 10);
1436 OptionEditor::parameter_changed (const char* parameter_name)
1438 ENSURE_GUI_THREAD (bind (mem_fun (*this, &OptionEditor::parameter_changed), parameter_name));
1440 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
1442 if (PARAM_IS ("timecode-source-is-synced")) {
1443 synced_timecode_button.set_active (Config->get_timecode_source_is_synced());
1444 } else if (PARAM_IS ("history-depth")) {
1445 int32_t depth = Config->get_history_depth();
1447 history_depth.set_value (depth);
1448 history_depth_spinner.set_sensitive (depth != 0);
1449 limit_history_button.set_active (depth != 0);
1451 } else if (PARAM_IS ("saved-history-depth")) {
1453 saved_history_depth.set_value (Config->get_saved_history_depth());
1455 } else if (PARAM_IS ("save-history")) {
1457 bool x = Config->get_save_history();
1459 save_history_button.set_active (x);
1460 saved_history_depth_spinner.set_sensitive (x);
1461 } else if (PARAM_IS ("font-scale")) {