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.
20 #include <pbd/whitespace.h>
22 #include <ardour/session.h>
23 #include <ardour/audioengine.h>
24 #include <ardour/configuration.h>
25 #include <ardour/auditioner.h>
26 #include <ardour/sndfilesource.h>
27 #include <ardour/crossfade.h>
28 #include <midi++/manager.h>
29 #include <midi++/factory.h>
30 #include <midi++/port_request.h>
31 #include <gtkmm2ext/stop_signal.h>
32 #include <gtkmm2ext/utils.h>
33 #include <gtkmm2ext/window_title.h>
35 #include "public_editor.h"
38 #include "ardour_ui.h"
39 #include "io_selector.h"
40 #include "gain_meter.h"
44 #include "option_editor.h"
45 #include "midi_port_dialog.h"
49 using namespace ARDOUR;
52 using namespace Editing;
53 using namespace Gtkmm2ext;
56 static vector<string> positional_sync_strings;
58 OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui)
59 : Dialog ("options editor"),
69 short_xfade_adjustment (0, 1.0, 500.0, 5.0, 100.0),
70 short_xfade_slider (short_xfade_adjustment),
71 destructo_xfade_adjustment (1.0, 1.0, 500.0, 1.0, 100.0),
72 destructo_xfade_slider (destructo_xfade_adjustment),
76 smpte_offset_clock (X_("smpteoffset"), false, X_("SMPTEOffsetClock"), true, true),
77 smpte_offset_negative_button (_("SMPTE offset is negative")),
81 mmc_receive_device_id_adjustment (0.0, 0.0, (double) 0x7f, 1.0, 16.0),
82 mmc_receive_device_id_spinner (mmc_receive_device_id_adjustment),
83 mmc_send_device_id_adjustment (0.0, 0.0, (double) 0x7f, 1.0, 16.0),
84 mmc_send_device_id_spinner (mmc_send_device_id_adjustment),
89 click_browse_button (_("Browse")),
90 click_emphasis_browse_button (_("Browse")),
94 keyboard_mouse_table (3, 4),
95 delete_button_adjustment (3, 1, 5),
96 delete_button_spin (delete_button_adjustment),
97 edit_button_adjustment (3, 1, 5),
98 edit_button_spin (edit_button_adjustment)
101 using namespace Notebook_Helpers;
103 click_io_selector = 0;
104 auditioner_io_selector = 0;
107 WindowTitle title(Glib::get_application_name());
108 title += _("Options Editor");
109 set_title(title.get_string());
111 set_default_size (300, 300);
112 set_wmclass (X_("ardour_option_editor"), "Ardour");
114 set_name ("OptionsWindow");
115 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
117 VBox *vbox = get_vbox();
118 set_border_width (3);
120 vbox->set_spacing (4);
121 vbox->pack_start(notebook);
123 signal_delete_event().connect (mem_fun(*this, &OptionEditor::wm_close));
125 notebook.set_show_tabs (true);
126 notebook.set_show_border (true);
127 notebook.set_name ("OptionsNotebook");
129 setup_sync_options();
130 setup_path_options();
131 setup_fade_options ();
132 setup_keyboard_options ();
133 setup_auditioner_editor ();
135 notebook.pages().push_back (TabElem (sync_packer, _("Sync")));
136 notebook.pages().push_back (TabElem (path_table, _("Paths/Files")));
137 notebook.pages().push_back (TabElem (keyboard_mouse_table, _("Kbd/Mouse")));
138 notebook.pages().push_back (TabElem (click_packer, _("Click")));
139 notebook.pages().push_back (TabElem (audition_packer, _("Audition")));
140 notebook.pages().push_back (TabElem (fade_packer, _("Layers & Fades")));
142 if (!MIDI::Manager::instance()->get_midi_ports().empty()) {
143 setup_midi_options ();
144 notebook.pages().push_back (TabElem (midi_packer, _("MIDI")));
152 OptionEditor::set_session (Session *s)
154 clear_click_editor ();
155 clear_auditioner_editor ();
157 click_path_entry.set_text ("");
158 click_emphasis_path_entry.set_text ("");
159 session_raid_entry.set_text ("");
161 click_path_entry.set_sensitive (false);
162 click_emphasis_path_entry.set_sensitive (false);
163 session_raid_entry.set_sensitive (false);
165 short_xfade_slider.set_sensitive (false);
166 smpte_offset_negative_button.set_sensitive (false);
168 smpte_offset_clock.set_session (s);
170 if ((session = s) == 0) {
174 click_path_entry.set_sensitive (true);
175 click_emphasis_path_entry.set_sensitive (true);
176 session_raid_entry.set_sensitive (true);
177 short_xfade_slider.set_sensitive (true);
178 smpte_offset_negative_button.set_sensitive (true);
180 smpte_offset_clock.set_session (s);
181 smpte_offset_clock.set (s->smpte_offset (), true);
183 smpte_offset_negative_button.set_active (session->smpte_offset_negative());
185 /* set up port assignments */
187 std::map<MIDI::Port*,vector<RadioButton*> >::iterator res;
189 if (session->mtc_port()) {
190 if ((res = port_toggle_buttons.find (session->mtc_port())) != port_toggle_buttons.end()) {
191 (*res).second[MtcIndex]->set_active (true);
195 if (session->mmc_port ()) {
196 if ((res = port_toggle_buttons.find (session->mmc_port())) != port_toggle_buttons.end()) {
197 (*res).second[MmcIndex]->set_active (true);
201 if (session->midi_port()) {
202 if ((res = port_toggle_buttons.find (session->midi_port())) != port_toggle_buttons.end()) {
203 (*res).second[MidiIndex]->set_active (true);
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 OptionEditor::setup_fade_options ()
267 Label* label = manage (new Label (_("Short crossfade length (msecs)")));
268 label->set_name ("OptionsLabel");
270 hbox = manage (new HBox);
271 hbox->set_border_width (5);
272 hbox->set_spacing (10);
273 hbox->pack_start (*label, false, false);
274 hbox->pack_start (short_xfade_slider, true, true);
275 fade_packer.pack_start (*hbox, false, false);
277 short_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::short_xfade_adjustment_changed));
279 label = manage (new Label (_("Destructive crossfade length (msecs)")));
280 label->set_name ("OptionsLabel");
282 hbox = manage (new HBox);
283 hbox->set_border_width (5);
284 hbox->set_spacing (10);
285 hbox->pack_start (*label, false, false);
286 hbox->pack_start (destructo_xfade_slider, true, true);
287 fade_packer.pack_start (*hbox, false, false);
289 destructo_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::destructo_xfade_adjustment_changed));
291 short_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
292 destructo_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
294 destructo_xfade_adjustment.set_value (Config->get_destructive_xfade_msecs());
296 fade_packer.show_all ();
300 OptionEditor::short_xfade_adjustment_changed ()
303 float val = short_xfade_adjustment.get_value();
305 /* val is in msecs */
307 Crossfade::set_short_xfade_length ((nframes_t) floor (session->frame_rate() * (val / 1000.0)));
312 OptionEditor::destructo_xfade_adjustment_changed ()
314 float val = destructo_xfade_adjustment.get_value();
316 /* val is in msecs */
319 Config->set_destructive_xfade_msecs ((uint32_t) floor (val));
322 SndFileSource::setup_standard_crossfades (session->frame_rate());
327 OptionEditor::setup_sync_options ()
332 smpte_offset_clock.set_mode (AudioClock::SMPTE);
333 smpte_offset_clock.ValueChanged.connect (mem_fun(*this, &OptionEditor::smpte_offset_chosen));
335 smpte_offset_negative_button.set_name ("OptionEditorToggleButton");
337 smpte_offset_negative_button.unset_flags (Gtk::CAN_FOCUS);
339 Label *smpte_offset_label = manage (new Label (_("SMPTE Offset")));
340 smpte_offset_label->set_name("OptionsLabel");
342 hbox = manage (new HBox);
343 hbox->set_border_width (5);
344 hbox->set_spacing (10);
345 hbox->pack_start (*smpte_offset_label, false, false);
346 hbox->pack_start (smpte_offset_clock, false, false);
347 hbox->pack_start (smpte_offset_negative_button, false, false);
349 sync_packer.pack_start (*hbox, false, false);
351 smpte_offset_negative_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::smpte_offset_negative_clicked));
355 OptionEditor::smpte_offset_negative_clicked ()
358 session->set_smpte_offset_negative (smpte_offset_negative_button.get_active());
363 OptionEditor::smpte_offset_chosen()
366 nframes_t frames = smpte_offset_clock.current_duration();
367 session->set_smpte_offset (frames);
372 OptionEditor::setup_midi_options ()
377 midi_port_table.set_row_spacings (6);
378 midi_port_table.set_col_spacings (10);
380 redisplay_midi_ports ();
382 mmc_receive_device_id_adjustment.signal_value_changed().connect (mem_fun (*this, &OptionEditor::mmc_receive_device_id_adjusted));
383 mmc_send_device_id_adjustment.signal_value_changed().connect (mem_fun (*this, &OptionEditor::mmc_send_device_id_adjusted));
385 hbox = manage (new HBox);
386 hbox->set_border_width (6);
387 hbox->pack_start (midi_port_table, true, false);
389 midi_packer.pack_start (*hbox, false, false);
390 midi_packer.pack_start (add_midi_port_button, false, false);
392 hbox = manage (new HBox);
393 hbox->set_border_width (6);
394 hbox->set_spacing (6);
395 label = (manage (new Label (_("Inbound MMC Device ID"))));
396 hbox->pack_start (mmc_receive_device_id_spinner, false, false);
397 hbox->pack_start (*label, false, false);
398 midi_packer.pack_start (*hbox, false, false);
400 hbox = manage (new HBox);
401 hbox->set_border_width (6);
402 hbox->set_spacing (6);
403 label = (manage (new Label (_("Outbound MMC Device ID"))));
404 hbox->pack_start (mmc_send_device_id_spinner, false, false);
405 hbox->pack_start (*label, false, false);
406 midi_packer.pack_start (*hbox, false, false);
408 add_midi_port_button.signal_clicked().connect (mem_fun (*this, &OptionEditor::add_midi_port));
412 OptionEditor::redisplay_midi_ports ()
414 MIDI::Manager::PortMap::const_iterator i;
415 const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports();
418 /* remove all existing widgets */
420 // XXX broken in gtkmm 2.10
421 // midi_port_table.clear ();
423 for (vector<Widget*>::iterator w = midi_port_table_widgets.begin(); w != midi_port_table_widgets.end(); ++w) {
424 midi_port_table.remove (**w);
427 midi_port_table_widgets.clear ();
429 midi_port_table.resize (ports.size() + 4, 11);
433 label = (manage (new Label (_("Port"))));
435 midi_port_table_widgets.push_back (label);
436 midi_port_table.attach (*label, 0, 1, 0, 1);
437 label = (manage (new Label (_("Offline"))));
439 midi_port_table_widgets.push_back (label);
440 midi_port_table.attach (*label, 1, 2, 0, 1);
441 label = (manage (new Label (_("Trace\nInput"))));
443 midi_port_table_widgets.push_back (label);
444 midi_port_table.attach (*label, 2, 3, 0, 1);
445 label = (manage (new Label (_("Trace\nOutput"))));
447 midi_port_table_widgets.push_back (label);
448 midi_port_table.attach (*label, 3, 4, 0, 1);
449 label = (manage (new Label (_("MTC"))));
451 midi_port_table_widgets.push_back (label);
452 midi_port_table.attach (*label, 4, 5, 0, 1);
453 label = (manage (new Label (_("MMC"))));
455 midi_port_table_widgets.push_back (label);
456 midi_port_table.attach (*label, 6, 7, 0, 1);
457 label = (manage (new Label (_("MIDI Parameter\nControl"))));
459 midi_port_table_widgets.push_back (label);
460 midi_port_table.attach (*label, 8, 9, 0, 1);
462 Gtk::HSeparator* hsep = (manage (new HSeparator()));
464 midi_port_table_widgets.push_back (hsep);
465 midi_port_table.attach (*hsep, 0, 9, 1, 2);
466 Gtk::VSeparator* vsep = (manage (new VSeparator()));
468 midi_port_table_widgets.push_back (vsep);
469 midi_port_table.attach (*vsep, 5, 6, 0, 8);
470 vsep = (manage (new VSeparator()));
472 midi_port_table_widgets.push_back (vsep);
473 midi_port_table.attach (*vsep, 7, 8, 0, 8);
475 for (n = 0, i = ports.begin(); i != ports.end(); ++n, ++i) {
481 /* the remove button. create early so we can pass it to various callbacks */
483 bb = manage (new Button (Stock::REMOVE));
484 bb->set_name ("OptionEditorToggleButton");
486 midi_port_table_widgets.push_back (bb);
487 midi_port_table.attach (*bb, 9, 10, n+2, n+3, FILL|EXPAND, FILL);
488 bb->signal_clicked().connect (bind (mem_fun(*this, &OptionEditor::remove_midi_port), i->second));
489 bb->set_sensitive (port_removable (i->second));
491 label = (manage (new Label (i->first)));
493 midi_port_table_widgets.push_back (label);
494 midi_port_table.attach (*label, 0, 1, n+2, n+3,FILL|EXPAND, FILL );
496 tb = manage (new ToggleButton (_("online")));
497 tb->set_name ("OptionEditorToggleButton");
499 /* remember, we have to handle the i18n case where the relative
500 lengths of the strings in language N is different than in english.
503 if (strlen (_("offline")) > strlen (_("online"))) {
504 set_size_request_to_display_given_text (*tb, _("offline"), 15, 12);
506 set_size_request_to_display_given_text (*tb, _("online"), 15, 12);
509 if (i->second->input()) {
510 tb->set_active (!i->second->input()->offline());
511 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_online_toggled), i->second, tb));
512 i->second->input()->OfflineStatusChanged.connect (bind (mem_fun(*this, &OptionEditor::map_port_online), (*i).second, tb));
515 midi_port_table_widgets.push_back (tb);
516 midi_port_table.attach (*tb, 1, 2, n+2, n+3, FILL|EXPAND, FILL);
518 tb = manage (new ToggleButton ());
519 tb->set_name ("OptionEditorToggleButton");
520 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_in_toggled), (*i).second, tb));
521 tb->set_size_request (10, 10);
523 midi_port_table_widgets.push_back (tb);
524 midi_port_table.attach (*tb, 2, 3, n+2, n+3, FILL|EXPAND, FILL);
526 tb = manage (new ToggleButton ());
527 tb->set_name ("OptionEditorToggleButton");
528 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_out_toggled), (*i).second, tb));
529 tb->set_size_request (10, 10);
531 midi_port_table_widgets.push_back (tb);
532 midi_port_table.attach (*tb, 3, 4, n+2, n+3, FILL|EXPAND, FILL);
534 rb = manage (new RadioButton ());
535 rb->set_name ("OptionEditorToggleButton");
537 mtc_button_group = rb->get_group();
539 rb->set_group (mtc_button_group);
543 midi_port_table_widgets.push_back (rb);
544 midi_port_table.attach (*rb, 4, 5, n+2, n+3, FILL|EXPAND, FILL);
545 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mtc_port_chosen), (*i).second, rb, bb));
547 if (session && i->second == session->mtc_port()) {
548 rb->set_active (true);
551 rb = manage (new RadioButton ());
552 rb->set_name ("OptionEditorToggleButton");
554 mmc_button_group = rb->get_group();
556 rb->set_group (mmc_button_group);
559 midi_port_table_widgets.push_back (rb);
560 midi_port_table.attach (*rb, 6, 7, n+2, n+3, FILL|EXPAND, FILL);
561 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mmc_port_chosen), (*i).second, rb, bb));
563 if (session && i->second == session->mmc_port()) {
564 rb->set_active (true);
567 rb = manage (new RadioButton ());
568 rb->set_name ("OptionEditorToggleButton");
570 midi_button_group = rb->get_group();
572 rb->set_group (midi_button_group);
575 midi_port_table_widgets.push_back (rb);
576 midi_port_table.attach (*rb, 8, 9, n+2, n+3, FILL|EXPAND, FILL);
577 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_port_chosen), (*i).second, rb, bb));
579 if (session && i->second == session->midi_port()) {
580 rb->set_active (true);
585 midi_port_table.show();
589 OptionEditor::remove_midi_port (MIDI::Port* port)
591 MIDI::Manager::instance()->remove_port (port);
592 redisplay_midi_ports ();
596 OptionEditor::add_midi_port ()
598 MidiPortDialog dialog;
600 dialog.set_position (WIN_POS_MOUSE);
601 dialog.set_transient_for (*this);
605 int ret = dialog.run ();
608 case RESPONSE_ACCEPT:
615 Glib::ustring mode = dialog.port_mode_combo.get_active_text();
618 if (mode == _("input")) {
620 } else if (mode == (_("output"))) {
626 MIDI::PortRequest req (X_("ardour"),
627 dialog.port_name.get_text(),
629 MIDI::PortFactory::default_port_type());
631 if (MIDI::Manager::instance()->add_port (req) != 0) {
632 redisplay_midi_ports ();
637 OptionEditor::port_removable (MIDI::Port *port)
643 if (port == session->mtc_port() ||
644 port == session->mmc_port() ||
645 port == session->midi_port()) {
652 OptionEditor::mtc_port_chosen (MIDI::Port *port, Gtk::RadioButton* rb, Gtk::Button* bb)
655 if (rb->get_active()) {
656 session->set_mtc_port (port->name());
657 Config->set_mtc_port_name (port->name());
659 session->set_mtc_port ("");
661 bb->set_sensitive (port_removable (port));
666 OptionEditor::mmc_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb, Gtk::Button* bb)
669 if (rb->get_active()) {
670 session->set_mmc_port (port->name());
671 Config->set_mtc_port_name (port->name());
673 session->set_mmc_port ("");
675 bb->set_sensitive (port_removable (port));
680 OptionEditor::midi_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb, Gtk::Button* bb)
683 if (rb->get_active()) {
684 session->set_midi_port (port->name());
685 Config->set_midi_port_name (port->name());
687 session->set_midi_port ("");
689 bb->set_sensitive (port_removable (port));
694 OptionEditor::port_online_toggled (MIDI::Port* port, ToggleButton* tb)
696 bool wanted = tb->get_active();
698 if (wanted != port->input()->offline()) {
699 port->input()->set_offline (wanted);
704 OptionEditor::map_port_online (MIDI::Port* port, ToggleButton* tb)
706 bool bstate = tb->get_active ();
708 if (bstate != port->input()->offline()) {
709 if (port->input()->offline()) {
710 tb->set_label (_("offline"));
711 tb->set_active (false);
713 tb->set_label (_("online"));
714 tb->set_active (true);
720 OptionEditor::mmc_receive_device_id_adjusted ()
722 uint8_t id = (uint8_t) mmc_receive_device_id_spinner.get_value();
724 if (id != Config->get_mmc_receive_device_id()) {
725 Config->set_mmc_receive_device_id (id);
730 OptionEditor::mmc_send_device_id_adjusted ()
732 uint8_t id = (uint8_t) mmc_send_device_id_spinner.get_value();
734 if (id != Config->get_mmc_send_device_id()) {
735 Config->set_mmc_send_device_id (id);
740 OptionEditor::port_trace_in_toggled (MIDI::Port* port, ToggleButton* tb)
742 bool trace = tb->get_active();
744 if (port->input()->tracing() != trace) {
745 port->input()->trace (trace, &cerr, string (port->name()) + string (" input: "));
750 OptionEditor::port_trace_out_toggled (MIDI::Port* port, ToggleButton* tb)
752 bool trace = tb->get_active();
754 if (port->output()->tracing() != trace) {
755 port->output()->trace (trace, &cerr, string (port->name()) + string (" output: "));
760 OptionEditor::save ()
762 /* XXX a bit odd that we save the entire session state here */
768 OptionEditor::wm_close (GdkEventAny *ev)
776 OptionEditor::raid_path_changed ()
779 Config->set_raid_path (session_raid_entry.get_text());
784 OptionEditor::click_browse_clicked ()
786 SoundFileChooser sfdb (_("Choose Click"), session);
788 int result = sfdb.run ();
790 if (result == Gtk::RESPONSE_OK) {
791 click_chosen(sfdb.get_filename());
796 OptionEditor::click_chosen (const string & path)
798 click_path_entry.set_text (path);
799 click_sound_changed ();
803 OptionEditor::click_emphasis_browse_clicked ()
805 SoundFileChooser sfdb (_("Choose Click Emphasis"), session);
807 int result = sfdb.run ();
809 if (result == Gtk::RESPONSE_OK) {
810 click_emphasis_chosen (sfdb.get_filename());
815 OptionEditor::click_emphasis_chosen (const string & path)
817 click_emphasis_path_entry.set_text (path);
818 click_emphasis_sound_changed ();
822 OptionEditor::click_sound_changed ()
825 string path = click_path_entry.get_text();
827 if (path == Config->get_click_sound()) {
831 strip_whitespace_edges (path);
833 if (path == _("internal")) {
834 Config->set_click_sound ("");
836 Config->set_click_sound (path);
842 OptionEditor::click_emphasis_sound_changed ()
845 string path = click_emphasis_path_entry.get_text();
847 if (path == Config->get_click_emphasis_sound()) {
851 strip_whitespace_edges (path);
853 if (path == _("internal")) {
854 Config->set_click_emphasis_sound ("");
856 Config->set_click_emphasis_sound (path);
862 OptionEditor::clear_click_editor ()
864 if (click_io_selector) {
865 click_packer.remove (*click_io_selector);
866 click_packer.remove (*click_gpm);
867 delete click_io_selector;
869 click_io_selector = 0;
875 OptionEditor::setup_click_editor ()
878 HBox* hpacker = manage (new HBox);
880 click_path_entry.set_sensitive (true);
881 click_emphasis_path_entry.set_sensitive (true);
883 click_path_entry.set_name ("OptionsEntry");
884 click_emphasis_path_entry.set_name ("OptionsEntry");
886 click_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_sound_changed));
887 click_emphasis_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed));
889 click_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_sound_changed));
890 click_emphasis_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_emphasis_sound_changed));
892 click_browse_button.set_name ("EditorGTKButton");
893 click_emphasis_browse_button.set_name ("EditorGTKButton");
894 click_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_browse_clicked));
895 click_emphasis_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_emphasis_browse_clicked));
897 click_packer.set_border_width (12);
898 click_packer.set_spacing (5);
900 click_io_selector = new IOSelector (*session, session->click_io(), false);
901 click_gpm = new GainMeter (session->click_io(), *session);
903 click_table.set_col_spacings (10);
905 label = manage(new Label(_("Click audio file")));
906 label->set_name ("OptionsLabel");
907 click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
908 click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
909 click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL);
911 label = manage(new Label(_("Click emphasis audiofile")));
912 label->set_name ("OptionsLabel");
913 click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
914 click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
915 click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL);
917 hpacker->set_spacing (10);
918 hpacker->pack_start (*click_io_selector, false, false);
919 hpacker->pack_start (*click_gpm, false, false);
921 click_packer.pack_start (click_table, false, false);
922 click_packer.pack_start (*hpacker, false, false);
924 click_packer.show_all ();
928 OptionEditor::clear_auditioner_editor ()
930 if (auditioner_io_selector) {
931 audition_hpacker.remove (*auditioner_io_selector);
932 audition_hpacker.remove (*auditioner_gpm);
933 delete auditioner_io_selector;
934 delete auditioner_gpm;
935 auditioner_io_selector = 0;
941 OptionEditor::setup_auditioner_editor ()
943 audition_packer.set_border_width (12);
944 audition_packer.set_spacing (5);
945 audition_hpacker.set_spacing (10);
947 audition_label.set_name ("OptionEditorAuditionerLabel");
948 audition_label.set_text (_("The auditioner is a dedicated mixer strip used\n"
949 "for listening to specific regions outside the context\n"
950 "of the overall mix. It can be connected just like any\n"
951 "other mixer strip."));
953 audition_packer.pack_start (audition_label, false, false, 10);
954 audition_packer.pack_start (audition_hpacker, false, false);
958 OptionEditor::connect_audition_editor ()
960 auditioner_io_selector = new IOSelector (*session, session->the_auditioner(), false);
961 auditioner_gpm = new GainMeter (session->the_auditioner(), *session);
963 audition_hpacker.pack_start (*auditioner_io_selector, false, false);
964 audition_hpacker.pack_start (*auditioner_gpm, false, false);
966 auditioner_io_selector->show_all ();
967 auditioner_gpm->show_all ();
971 OptionEditor::focus_out_event_handler (GdkEventFocus* ev, void (OptionEditor::*pmf)())
977 static const struct {
981 { "Shift", GDK_SHIFT_MASK },
982 { "Control", GDK_CONTROL_MASK },
983 { "Alt (Mod1)", GDK_MOD1_MASK },
984 { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK },
985 { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK },
986 { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK },
987 { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
988 { "Mod2", GDK_MOD2_MASK },
989 { "Mod3", GDK_MOD3_MASK },
990 { "Mod4", GDK_MOD4_MASK },
991 { "Mod5", GDK_MOD5_MASK },
996 OptionEditor::setup_keyboard_options ()
1001 keyboard_mouse_table.set_border_width (12);
1002 keyboard_mouse_table.set_row_spacings (5);
1003 keyboard_mouse_table.set_col_spacings (5);
1005 /* internationalize and prepare for use with combos */
1007 for (int i = 0; modifiers[i].name; ++i) {
1008 dumb.push_back (_(modifiers[i].name));
1011 set_popdown_strings (edit_modifier_combo, dumb);
1012 edit_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::edit_modifier_chosen));
1014 for (int x = 0; modifiers[x].name; ++x) {
1015 if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
1016 edit_modifier_combo.set_active_text (_(modifiers[x].name));
1021 label = manage (new Label (_("Edit using")));
1022 label->set_name ("OptionsLabel");
1023 label->set_alignment (1.0, 0.5);
1025 keyboard_mouse_table.attach (*label, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1026 keyboard_mouse_table.attach (edit_modifier_combo, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1028 label = manage (new Label (_("+ button")));
1029 label->set_name ("OptionsLabel");
1031 keyboard_mouse_table.attach (*label, 3, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1032 keyboard_mouse_table.attach (edit_button_spin, 4, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1034 edit_button_spin.set_name ("OptionsEntry");
1035 edit_button_adjustment.set_value (Keyboard::edit_button());
1036 edit_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::edit_button_changed));
1038 set_popdown_strings (delete_modifier_combo, dumb);
1039 delete_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::delete_modifier_chosen));
1041 for (int x = 0; modifiers[x].name; ++x) {
1042 if (modifiers[x].modifier == Keyboard::delete_modifier ()) {
1043 delete_modifier_combo.set_active_text (_(modifiers[x].name));
1048 label = manage (new Label (_("Delete using")));
1049 label->set_name ("OptionsLabel");
1050 label->set_alignment (1.0, 0.5);
1052 keyboard_mouse_table.attach (*label, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1053 keyboard_mouse_table.attach (delete_modifier_combo, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1055 label = manage (new Label (_("+ button")));
1056 label->set_name ("OptionsLabel");
1058 keyboard_mouse_table.attach (*label, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1059 keyboard_mouse_table.attach (delete_button_spin, 4, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1061 delete_button_spin.set_name ("OptionsEntry");
1062 delete_button_adjustment.set_value (Keyboard::delete_button());
1063 delete_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::delete_button_changed));
1065 set_popdown_strings (snap_modifier_combo, dumb);
1066 snap_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::snap_modifier_chosen));
1068 for (int x = 0; modifiers[x].name; ++x) {
1069 if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) {
1070 snap_modifier_combo.set_active_text (_(modifiers[x].name));
1075 label = manage (new Label (_("Ignore snap using")));
1076 label->set_name ("OptionsLabel");
1077 label->set_alignment (1.0, 0.5);
1079 keyboard_mouse_table.attach (*label, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
1080 keyboard_mouse_table.attach (snap_modifier_combo, 1, 2, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
1084 OptionEditor::edit_modifier_chosen ()
1088 txt = edit_modifier_combo.get_active_text();
1090 for (int i = 0; modifiers[i].name; ++i) {
1091 if (txt == _(modifiers[i].name)) {
1092 Keyboard::set_edit_modifier (modifiers[i].modifier);
1099 OptionEditor::delete_modifier_chosen ()
1103 txt = delete_modifier_combo.get_active_text();
1105 for (int i = 0; modifiers[i].name; ++i) {
1106 if (txt == _(modifiers[i].name)) {
1107 Keyboard::set_delete_modifier (modifiers[i].modifier);
1114 OptionEditor::snap_modifier_chosen ()
1118 txt = snap_modifier_combo.get_active_text();
1120 for (int i = 0; modifiers[i].name; ++i) {
1121 if (txt == _(modifiers[i].name)) {
1122 Keyboard::set_snap_modifier (modifiers[i].modifier);
1129 OptionEditor::delete_button_changed ()
1131 Keyboard::set_delete_button ((guint) delete_button_adjustment.get_value());
1135 OptionEditor::edit_button_changed ()
1137 Keyboard::set_edit_button ((guint) edit_button_adjustment.get_value());
1141 OptionEditor::fixup_combo_size (Gtk::ComboBoxText& combo, vector<string>& strings)
1143 /* find the widest string */
1145 string::size_type maxlen = 0;
1148 for (vector<string>::iterator i = strings.begin(); i != strings.end(); ++i) {
1149 string::size_type l;
1151 if ((l = (*i).length()) > maxlen) {
1157 /* try to include ascenders and descenders */
1159 if (maxstring.length() > 2) {
1164 const guint32 FUDGE = 10; // Combo's are stupid - they steal space from the entry for the button
1166 set_size_request_to_display_given_text (combo, maxstring.c_str(), 10 + FUDGE, 10);