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 add_midi_port_button.set_label ("Add MIDI port");
391 midi_packer.pack_start (add_midi_port_button, false, false);
393 hbox = manage (new HBox);
394 hbox->set_border_width (6);
395 hbox->set_spacing (6);
396 label = (manage (new Label (_("Inbound MMC Device ID"))));
397 hbox->pack_start (mmc_receive_device_id_spinner, false, false);
398 hbox->pack_start (*label, false, false);
399 midi_packer.pack_start (*hbox, false, false);
401 hbox = manage (new HBox);
402 hbox->set_border_width (6);
403 hbox->set_spacing (6);
404 label = (manage (new Label (_("Outbound MMC Device ID"))));
405 hbox->pack_start (mmc_send_device_id_spinner, false, false);
406 hbox->pack_start (*label, false, false);
407 midi_packer.pack_start (*hbox, false, false);
409 add_midi_port_button.signal_clicked().connect (mem_fun (*this, &OptionEditor::add_midi_port));
413 OptionEditor::redisplay_midi_ports ()
415 MIDI::Manager::PortMap::const_iterator i;
416 const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports();
419 /* remove all existing widgets */
421 // XXX broken in gtkmm 2.10
422 // midi_port_table.clear ();
424 for (vector<Widget*>::iterator w = midi_port_table_widgets.begin(); w != midi_port_table_widgets.end(); ++w) {
425 midi_port_table.remove (**w);
428 midi_port_table_widgets.clear ();
430 midi_port_table.resize (ports.size() + 4, 11);
434 label = (manage (new Label (_("Port"))));
436 midi_port_table_widgets.push_back (label);
437 midi_port_table.attach (*label, 0, 1, 0, 1);
438 label = (manage (new Label (_("Offline"))));
440 midi_port_table_widgets.push_back (label);
441 midi_port_table.attach (*label, 1, 2, 0, 1);
442 label = (manage (new Label (_("Trace\nInput"))));
444 midi_port_table_widgets.push_back (label);
445 midi_port_table.attach (*label, 2, 3, 0, 1);
446 label = (manage (new Label (_("Trace\nOutput"))));
448 midi_port_table_widgets.push_back (label);
449 midi_port_table.attach (*label, 3, 4, 0, 1);
450 label = (manage (new Label (_("MTC"))));
452 midi_port_table_widgets.push_back (label);
453 midi_port_table.attach (*label, 4, 5, 0, 1);
454 label = (manage (new Label (_("MMC"))));
456 midi_port_table_widgets.push_back (label);
457 midi_port_table.attach (*label, 6, 7, 0, 1);
458 label = (manage (new Label (_("MIDI Parameter\nControl"))));
460 midi_port_table_widgets.push_back (label);
461 midi_port_table.attach (*label, 8, 9, 0, 1);
463 Gtk::HSeparator* hsep = (manage (new HSeparator()));
465 midi_port_table_widgets.push_back (hsep);
466 midi_port_table.attach (*hsep, 0, 9, 1, 2);
467 Gtk::VSeparator* vsep = (manage (new VSeparator()));
469 midi_port_table_widgets.push_back (vsep);
470 midi_port_table.attach (*vsep, 5, 6, 0, 8);
471 vsep = (manage (new VSeparator()));
473 midi_port_table_widgets.push_back (vsep);
474 midi_port_table.attach (*vsep, 7, 8, 0, 8);
476 for (n = 0, i = ports.begin(); i != ports.end(); ++n, ++i) {
482 /* the remove button. create early so we can pass it to various callbacks */
484 bb = manage (new Button (Stock::REMOVE));
485 bb->set_name ("OptionEditorToggleButton");
487 midi_port_table_widgets.push_back (bb);
488 midi_port_table.attach (*bb, 9, 10, n+2, n+3, FILL|EXPAND, FILL);
489 bb->signal_clicked().connect (bind (mem_fun(*this, &OptionEditor::remove_midi_port), i->second));
490 bb->set_sensitive (port_removable (i->second));
492 label = (manage (new Label (i->first)));
494 midi_port_table_widgets.push_back (label);
495 midi_port_table.attach (*label, 0, 1, n+2, n+3,FILL|EXPAND, FILL );
497 tb = manage (new ToggleButton (_("online")));
498 tb->set_name ("OptionEditorToggleButton");
500 /* remember, we have to handle the i18n case where the relative
501 lengths of the strings in language N is different than in english.
504 if (strlen (_("offline")) > strlen (_("online"))) {
505 set_size_request_to_display_given_text (*tb, _("offline"), 15, 12);
507 set_size_request_to_display_given_text (*tb, _("online"), 15, 12);
510 if (i->second->input()) {
511 tb->set_active (!i->second->input()->offline());
512 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_online_toggled), i->second, tb));
513 i->second->input()->OfflineStatusChanged.connect (bind (mem_fun(*this, &OptionEditor::map_port_online), (*i).second, tb));
516 midi_port_table_widgets.push_back (tb);
517 midi_port_table.attach (*tb, 1, 2, n+2, n+3, FILL|EXPAND, FILL);
519 tb = manage (new ToggleButton ());
520 tb->set_name ("OptionEditorToggleButton");
521 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_in_toggled), (*i).second, tb));
522 tb->set_size_request (10, 10);
524 midi_port_table_widgets.push_back (tb);
525 midi_port_table.attach (*tb, 2, 3, n+2, n+3, FILL|EXPAND, FILL);
527 tb = manage (new ToggleButton ());
528 tb->set_name ("OptionEditorToggleButton");
529 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_out_toggled), (*i).second, tb));
530 tb->set_size_request (10, 10);
532 midi_port_table_widgets.push_back (tb);
533 midi_port_table.attach (*tb, 3, 4, n+2, n+3, FILL|EXPAND, FILL);
535 rb = manage (new RadioButton ());
536 rb->set_name ("OptionEditorToggleButton");
538 mtc_button_group = rb->get_group();
540 rb->set_group (mtc_button_group);
544 midi_port_table_widgets.push_back (rb);
545 midi_port_table.attach (*rb, 4, 5, n+2, n+3, FILL|EXPAND, FILL);
546 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mtc_port_chosen), (*i).second, rb, bb));
548 if (session && i->second == session->mtc_port()) {
549 rb->set_active (true);
552 rb = manage (new RadioButton ());
553 rb->set_name ("OptionEditorToggleButton");
555 mmc_button_group = rb->get_group();
557 rb->set_group (mmc_button_group);
560 midi_port_table_widgets.push_back (rb);
561 midi_port_table.attach (*rb, 6, 7, n+2, n+3, FILL|EXPAND, FILL);
562 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mmc_port_chosen), (*i).second, rb, bb));
564 if (session && i->second == session->mmc_port()) {
565 rb->set_active (true);
568 rb = manage (new RadioButton ());
569 rb->set_name ("OptionEditorToggleButton");
571 midi_button_group = rb->get_group();
573 rb->set_group (midi_button_group);
576 midi_port_table_widgets.push_back (rb);
577 midi_port_table.attach (*rb, 8, 9, n+2, n+3, FILL|EXPAND, FILL);
578 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_port_chosen), (*i).second, rb, bb));
580 if (session && i->second == session->midi_port()) {
581 rb->set_active (true);
586 midi_port_table.show();
590 OptionEditor::remove_midi_port (MIDI::Port* port)
592 MIDI::Manager::instance()->remove_port (port);
593 redisplay_midi_ports ();
597 OptionEditor::add_midi_port ()
599 MidiPortDialog dialog;
601 dialog.set_position (WIN_POS_MOUSE);
602 dialog.set_transient_for (*this);
606 int ret = dialog.run ();
609 case RESPONSE_ACCEPT:
616 Glib::ustring mode = dialog.port_mode_combo.get_active_text();
619 if (mode == _("input")) {
621 } else if (mode == (_("output"))) {
627 MIDI::PortRequest req (X_("ardour"),
628 dialog.port_name.get_text(),
630 MIDI::PortFactory::default_port_type());
632 if (MIDI::Manager::instance()->add_port (req) != 0) {
633 redisplay_midi_ports ();
638 OptionEditor::port_removable (MIDI::Port *port)
644 if (port == session->mtc_port() ||
645 port == session->mmc_port() ||
646 port == session->midi_port()) {
653 OptionEditor::mtc_port_chosen (MIDI::Port *port, Gtk::RadioButton* rb, Gtk::Button* bb)
656 if (rb->get_active()) {
657 session->set_mtc_port (port->name());
658 Config->set_mtc_port_name (port->name());
660 session->set_mtc_port ("");
662 bb->set_sensitive (port_removable (port));
667 OptionEditor::mmc_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb, Gtk::Button* bb)
670 if (rb->get_active()) {
671 session->set_mmc_port (port->name());
672 Config->set_mtc_port_name (port->name());
674 session->set_mmc_port ("");
676 bb->set_sensitive (port_removable (port));
681 OptionEditor::midi_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb, Gtk::Button* bb)
684 if (rb->get_active()) {
685 session->set_midi_port (port->name());
686 Config->set_midi_port_name (port->name());
688 session->set_midi_port ("");
690 bb->set_sensitive (port_removable (port));
695 OptionEditor::port_online_toggled (MIDI::Port* port, ToggleButton* tb)
697 bool wanted = tb->get_active();
699 if (wanted != port->input()->offline()) {
700 port->input()->set_offline (wanted);
705 OptionEditor::map_port_online (MIDI::Port* port, ToggleButton* tb)
707 bool bstate = tb->get_active ();
709 if (bstate != port->input()->offline()) {
710 if (port->input()->offline()) {
711 tb->set_label (_("offline"));
712 tb->set_active (false);
714 tb->set_label (_("online"));
715 tb->set_active (true);
721 OptionEditor::mmc_receive_device_id_adjusted ()
723 uint8_t id = (uint8_t) mmc_receive_device_id_spinner.get_value();
725 if (id != Config->get_mmc_receive_device_id()) {
726 Config->set_mmc_receive_device_id (id);
731 OptionEditor::mmc_send_device_id_adjusted ()
733 uint8_t id = (uint8_t) mmc_send_device_id_spinner.get_value();
735 if (id != Config->get_mmc_send_device_id()) {
736 Config->set_mmc_send_device_id (id);
741 OptionEditor::port_trace_in_toggled (MIDI::Port* port, ToggleButton* tb)
743 bool trace = tb->get_active();
745 if (port->input()->tracing() != trace) {
746 port->input()->trace (trace, &cerr, string (port->name()) + string (" input: "));
751 OptionEditor::port_trace_out_toggled (MIDI::Port* port, ToggleButton* tb)
753 bool trace = tb->get_active();
755 if (port->output()->tracing() != trace) {
756 port->output()->trace (trace, &cerr, string (port->name()) + string (" output: "));
761 OptionEditor::save ()
763 /* XXX a bit odd that we save the entire session state here */
769 OptionEditor::wm_close (GdkEventAny *ev)
777 OptionEditor::raid_path_changed ()
780 Config->set_raid_path (session_raid_entry.get_text());
785 OptionEditor::click_browse_clicked ()
787 SoundFileChooser sfdb (_("Choose Click"), session);
789 int result = sfdb.run ();
791 if (result == Gtk::RESPONSE_OK) {
792 click_chosen(sfdb.get_filename());
797 OptionEditor::click_chosen (const string & path)
799 click_path_entry.set_text (path);
800 click_sound_changed ();
804 OptionEditor::click_emphasis_browse_clicked ()
806 SoundFileChooser sfdb (_("Choose Click Emphasis"), session);
808 int result = sfdb.run ();
810 if (result == Gtk::RESPONSE_OK) {
811 click_emphasis_chosen (sfdb.get_filename());
816 OptionEditor::click_emphasis_chosen (const string & path)
818 click_emphasis_path_entry.set_text (path);
819 click_emphasis_sound_changed ();
823 OptionEditor::click_sound_changed ()
826 string path = click_path_entry.get_text();
828 if (path == Config->get_click_sound()) {
832 strip_whitespace_edges (path);
834 if (path == _("internal")) {
835 Config->set_click_sound ("");
837 Config->set_click_sound (path);
843 OptionEditor::click_emphasis_sound_changed ()
846 string path = click_emphasis_path_entry.get_text();
848 if (path == Config->get_click_emphasis_sound()) {
852 strip_whitespace_edges (path);
854 if (path == _("internal")) {
855 Config->set_click_emphasis_sound ("");
857 Config->set_click_emphasis_sound (path);
863 OptionEditor::clear_click_editor ()
865 if (click_io_selector) {
866 click_packer.remove (*click_io_selector);
867 click_packer.remove (*click_gpm);
868 delete click_io_selector;
870 click_io_selector = 0;
876 OptionEditor::setup_click_editor ()
879 HBox* hpacker = manage (new HBox);
881 click_path_entry.set_sensitive (true);
882 click_emphasis_path_entry.set_sensitive (true);
884 click_path_entry.set_name ("OptionsEntry");
885 click_emphasis_path_entry.set_name ("OptionsEntry");
887 click_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_sound_changed));
888 click_emphasis_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed));
890 click_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_sound_changed));
891 click_emphasis_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_emphasis_sound_changed));
893 click_browse_button.set_name ("EditorGTKButton");
894 click_emphasis_browse_button.set_name ("EditorGTKButton");
895 click_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_browse_clicked));
896 click_emphasis_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_emphasis_browse_clicked));
898 click_packer.set_border_width (12);
899 click_packer.set_spacing (5);
901 click_io_selector = new IOSelector (*session, session->click_io(), false);
902 click_gpm = new GainMeter (session->click_io(), *session);
904 click_table.set_col_spacings (10);
906 label = manage(new Label(_("Click audio file")));
907 label->set_name ("OptionsLabel");
908 click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
909 click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
910 click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL);
912 label = manage(new Label(_("Click emphasis audiofile")));
913 label->set_name ("OptionsLabel");
914 click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
915 click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
916 click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL);
918 hpacker->set_spacing (10);
919 hpacker->pack_start (*click_io_selector, false, false);
920 hpacker->pack_start (*click_gpm, false, false);
922 click_packer.pack_start (click_table, false, false);
923 click_packer.pack_start (*hpacker, false, false);
925 click_packer.show_all ();
929 OptionEditor::clear_auditioner_editor ()
931 if (auditioner_io_selector) {
932 audition_hpacker.remove (*auditioner_io_selector);
933 audition_hpacker.remove (*auditioner_gpm);
934 delete auditioner_io_selector;
935 delete auditioner_gpm;
936 auditioner_io_selector = 0;
942 OptionEditor::setup_auditioner_editor ()
944 audition_packer.set_border_width (12);
945 audition_packer.set_spacing (5);
946 audition_hpacker.set_spacing (10);
948 audition_label.set_name ("OptionEditorAuditionerLabel");
949 audition_label.set_text (_("The auditioner is a dedicated mixer strip used\n"
950 "for listening to specific regions outside the context\n"
951 "of the overall mix. It can be connected just like any\n"
952 "other mixer strip."));
954 audition_packer.pack_start (audition_label, false, false, 10);
955 audition_packer.pack_start (audition_hpacker, false, false);
959 OptionEditor::connect_audition_editor ()
961 auditioner_io_selector = new IOSelector (*session, session->the_auditioner(), false);
962 auditioner_gpm = new GainMeter (session->the_auditioner(), *session);
964 audition_hpacker.pack_start (*auditioner_io_selector, false, false);
965 audition_hpacker.pack_start (*auditioner_gpm, false, false);
967 auditioner_io_selector->show_all ();
968 auditioner_gpm->show_all ();
972 OptionEditor::focus_out_event_handler (GdkEventFocus* ev, void (OptionEditor::*pmf)())
978 static const struct {
982 { "Shift", GDK_SHIFT_MASK },
983 { "Control", GDK_CONTROL_MASK },
984 { "Alt (Mod1)", GDK_MOD1_MASK },
985 { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK },
986 { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK },
987 { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK },
988 { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
989 { "Mod2", GDK_MOD2_MASK },
990 { "Mod3", GDK_MOD3_MASK },
991 { "Mod4", GDK_MOD4_MASK },
992 { "Mod5", GDK_MOD5_MASK },
997 OptionEditor::setup_keyboard_options ()
1002 keyboard_mouse_table.set_border_width (12);
1003 keyboard_mouse_table.set_row_spacings (5);
1004 keyboard_mouse_table.set_col_spacings (5);
1006 /* internationalize and prepare for use with combos */
1008 for (int i = 0; modifiers[i].name; ++i) {
1009 dumb.push_back (_(modifiers[i].name));
1012 set_popdown_strings (edit_modifier_combo, dumb);
1013 edit_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::edit_modifier_chosen));
1015 for (int x = 0; modifiers[x].name; ++x) {
1016 if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
1017 edit_modifier_combo.set_active_text (_(modifiers[x].name));
1022 label = manage (new Label (_("Edit using")));
1023 label->set_name ("OptionsLabel");
1024 label->set_alignment (1.0, 0.5);
1026 keyboard_mouse_table.attach (*label, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1027 keyboard_mouse_table.attach (edit_modifier_combo, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1029 label = manage (new Label (_("+ button")));
1030 label->set_name ("OptionsLabel");
1032 keyboard_mouse_table.attach (*label, 3, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1033 keyboard_mouse_table.attach (edit_button_spin, 4, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1035 edit_button_spin.set_name ("OptionsEntry");
1036 edit_button_adjustment.set_value (Keyboard::edit_button());
1037 edit_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::edit_button_changed));
1039 set_popdown_strings (delete_modifier_combo, dumb);
1040 delete_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::delete_modifier_chosen));
1042 for (int x = 0; modifiers[x].name; ++x) {
1043 if (modifiers[x].modifier == Keyboard::delete_modifier ()) {
1044 delete_modifier_combo.set_active_text (_(modifiers[x].name));
1049 label = manage (new Label (_("Delete using")));
1050 label->set_name ("OptionsLabel");
1051 label->set_alignment (1.0, 0.5);
1053 keyboard_mouse_table.attach (*label, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1054 keyboard_mouse_table.attach (delete_modifier_combo, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1056 label = manage (new Label (_("+ button")));
1057 label->set_name ("OptionsLabel");
1059 keyboard_mouse_table.attach (*label, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1060 keyboard_mouse_table.attach (delete_button_spin, 4, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1062 delete_button_spin.set_name ("OptionsEntry");
1063 delete_button_adjustment.set_value (Keyboard::delete_button());
1064 delete_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::delete_button_changed));
1066 set_popdown_strings (snap_modifier_combo, dumb);
1067 snap_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::snap_modifier_chosen));
1069 for (int x = 0; modifiers[x].name; ++x) {
1070 if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) {
1071 snap_modifier_combo.set_active_text (_(modifiers[x].name));
1076 label = manage (new Label (_("Ignore snap using")));
1077 label->set_name ("OptionsLabel");
1078 label->set_alignment (1.0, 0.5);
1080 keyboard_mouse_table.attach (*label, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
1081 keyboard_mouse_table.attach (snap_modifier_combo, 1, 2, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
1085 OptionEditor::edit_modifier_chosen ()
1089 txt = edit_modifier_combo.get_active_text();
1091 for (int i = 0; modifiers[i].name; ++i) {
1092 if (txt == _(modifiers[i].name)) {
1093 Keyboard::set_edit_modifier (modifiers[i].modifier);
1100 OptionEditor::delete_modifier_chosen ()
1104 txt = delete_modifier_combo.get_active_text();
1106 for (int i = 0; modifiers[i].name; ++i) {
1107 if (txt == _(modifiers[i].name)) {
1108 Keyboard::set_delete_modifier (modifiers[i].modifier);
1115 OptionEditor::snap_modifier_chosen ()
1119 txt = snap_modifier_combo.get_active_text();
1121 for (int i = 0; modifiers[i].name; ++i) {
1122 if (txt == _(modifiers[i].name)) {
1123 Keyboard::set_snap_modifier (modifiers[i].modifier);
1130 OptionEditor::delete_button_changed ()
1132 Keyboard::set_delete_button ((guint) delete_button_adjustment.get_value());
1136 OptionEditor::edit_button_changed ()
1138 Keyboard::set_edit_button ((guint) edit_button_adjustment.get_value());
1142 OptionEditor::fixup_combo_size (Gtk::ComboBoxText& combo, vector<string>& strings)
1144 /* find the widest string */
1146 string::size_type maxlen = 0;
1149 for (vector<string>::iterator i = strings.begin(); i != strings.end(); ++i) {
1150 string::size_type l;
1152 if ((l = (*i).length()) > maxlen) {
1158 /* try to include ascenders and descenders */
1160 if (maxstring.length() > 2) {
1165 const guint32 FUDGE = 10; // Combo's are stupid - they steal space from the entry for the button
1167 set_size_request_to_display_given_text (combo, maxstring.c_str(), 10 + FUDGE, 10);