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 <gtkmm2ext/stop_signal.h>
31 #include <gtkmm2ext/utils.h>
32 #include <gtkmm2ext/window_title.h>
34 #include "public_editor.h"
37 #include "ardour_ui.h"
38 #include "io_selector.h"
39 #include "gain_meter.h"
43 #include "option_editor.h"
44 #include "midi_port_dialog.h"
48 using namespace ARDOUR;
51 using namespace Editing;
52 using namespace Gtkmm2ext;
55 static vector<string> positional_sync_strings;
57 OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui)
58 : Dialog ("options editor"),
68 short_xfade_adjustment (0, 1.0, 500.0, 5.0, 100.0),
69 short_xfade_slider (short_xfade_adjustment),
70 destructo_xfade_adjustment (1.0, 1.0, 500.0, 1.0, 100.0),
71 destructo_xfade_slider (destructo_xfade_adjustment),
75 smpte_offset_clock (X_("smpteoffset"), false, X_("SMPTEOffsetClock"), true, true),
76 smpte_offset_negative_button (_("SMPTE offset is negative")),
80 midi_port_table (4, 10),
81 mmc_device_id_adjustment (0.0, 0.0, (double) 0x7f, 1.0, 16.0),
82 mmc_device_id_spinner (mmc_device_id_adjustment),
83 add_midi_port_button (_("Add new MIDI port")),
88 click_browse_button (_("Browse")),
89 click_emphasis_browse_button (_("Browse")),
93 keyboard_mouse_table (3, 4),
94 delete_button_adjustment (3, 1, 5),
95 delete_button_spin (delete_button_adjustment),
96 edit_button_adjustment (3, 1, 5),
97 edit_button_spin (edit_button_adjustment)
100 using namespace Notebook_Helpers;
102 click_io_selector = 0;
103 auditioner_io_selector = 0;
106 WindowTitle title(Glib::get_application_name());
107 title += _("Options Editor");
108 set_title(title.get_string());
110 set_default_size (300, 300);
111 set_wmclass (X_("ardour_option_editor"), "Ardour");
113 set_name ("OptionsWindow");
114 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
116 VBox *vbox = get_vbox();
117 set_border_width (3);
119 vbox->set_spacing (4);
120 vbox->pack_start(notebook);
122 signal_delete_event().connect (mem_fun(*this, &OptionEditor::wm_close));
124 notebook.set_show_tabs (true);
125 notebook.set_show_border (true);
126 notebook.set_name ("OptionsNotebook");
128 setup_sync_options();
129 setup_path_options();
130 setup_fade_options ();
131 setup_keyboard_options ();
132 setup_auditioner_editor ();
134 notebook.pages().push_back (TabElem (sync_packer, _("Sync")));
135 notebook.pages().push_back (TabElem (path_table, _("Paths/Files")));
136 notebook.pages().push_back (TabElem (keyboard_mouse_table, _("Kbd/Mouse")));
137 notebook.pages().push_back (TabElem (click_packer, _("Click")));
138 notebook.pages().push_back (TabElem (audition_packer, _("Audition")));
139 notebook.pages().push_back (TabElem (fade_packer, _("Layers & Fades")));
141 setup_midi_options ();
142 notebook.pages().push_back (TabElem (midi_packer, _("MIDI")));
149 OptionEditor::set_session (Session *s)
151 clear_click_editor ();
152 clear_auditioner_editor ();
154 click_path_entry.set_text ("");
155 click_emphasis_path_entry.set_text ("");
156 session_raid_entry.set_text ("");
158 click_path_entry.set_sensitive (false);
159 click_emphasis_path_entry.set_sensitive (false);
160 session_raid_entry.set_sensitive (false);
162 short_xfade_slider.set_sensitive (false);
163 smpte_offset_negative_button.set_sensitive (false);
165 smpte_offset_clock.set_session (s);
167 if ((session = s) == 0) {
171 click_path_entry.set_sensitive (true);
172 click_emphasis_path_entry.set_sensitive (true);
173 session_raid_entry.set_sensitive (true);
174 short_xfade_slider.set_sensitive (true);
175 smpte_offset_negative_button.set_sensitive (true);
177 smpte_offset_clock.set_session (s);
178 smpte_offset_clock.set (s->smpte_offset (), true);
180 smpte_offset_negative_button.set_active (session->smpte_offset_negative());
182 /* set up port assignments */
184 std::map<MIDI::Port*,vector<RadioButton*> >::iterator res;
186 if (session->mtc_port()) {
187 if ((res = port_toggle_buttons.find (session->mtc_port())) != port_toggle_buttons.end()) {
188 (*res).second[MtcIndex]->set_active (true);
192 if (session->mmc_port ()) {
193 if ((res = port_toggle_buttons.find (session->mmc_port())) != port_toggle_buttons.end()) {
194 (*res).second[MmcIndex]->set_active (true);
198 if (session->midi_port()) {
199 if ((res = port_toggle_buttons.find (session->midi_port())) != port_toggle_buttons.end()) {
200 (*res).second[MidiIndex]->set_active (true);
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 OptionEditor::setup_fade_options ()
264 Label* label = manage (new Label (_("Short crossfade length (msecs)")));
265 label->set_name ("OptionsLabel");
267 hbox = manage (new HBox);
268 hbox->set_border_width (5);
269 hbox->set_spacing (10);
270 hbox->pack_start (*label, false, false);
271 hbox->pack_start (short_xfade_slider, true, true);
272 fade_packer.pack_start (*hbox, false, false);
274 short_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::short_xfade_adjustment_changed));
276 label = manage (new Label (_("Destructive crossfade length (msecs)")));
277 label->set_name ("OptionsLabel");
279 hbox = manage (new HBox);
280 hbox->set_border_width (5);
281 hbox->set_spacing (10);
282 hbox->pack_start (*label, false, false);
283 hbox->pack_start (destructo_xfade_slider, true, true);
284 fade_packer.pack_start (*hbox, false, false);
286 destructo_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::destructo_xfade_adjustment_changed));
288 short_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
289 destructo_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
291 destructo_xfade_adjustment.set_value (Config->get_destructive_xfade_msecs());
293 fade_packer.show_all ();
297 OptionEditor::short_xfade_adjustment_changed ()
300 float val = short_xfade_adjustment.get_value();
302 /* val is in msecs */
304 Crossfade::set_short_xfade_length ((nframes_t) floor (session->frame_rate() * (val / 1000.0)));
309 OptionEditor::destructo_xfade_adjustment_changed ()
311 float val = destructo_xfade_adjustment.get_value();
313 /* val is in msecs */
316 Config->set_destructive_xfade_msecs ((uint32_t) floor (val));
319 SndFileSource::setup_standard_crossfades (session->frame_rate());
324 OptionEditor::setup_sync_options ()
329 smpte_offset_clock.set_mode (AudioClock::SMPTE);
330 smpte_offset_clock.ValueChanged.connect (mem_fun(*this, &OptionEditor::smpte_offset_chosen));
332 smpte_offset_negative_button.set_name ("OptionEditorToggleButton");
334 smpte_offset_negative_button.unset_flags (Gtk::CAN_FOCUS);
336 Label *smpte_offset_label = manage (new Label (_("SMPTE Offset")));
337 smpte_offset_label->set_name("OptionsLabel");
339 hbox = manage (new HBox);
340 hbox->set_border_width (5);
341 hbox->set_spacing (10);
342 hbox->pack_start (*smpte_offset_label, false, false);
343 hbox->pack_start (smpte_offset_clock, false, false);
344 hbox->pack_start (smpte_offset_negative_button, false, false);
346 sync_packer.pack_start (*hbox, false, false);
348 smpte_offset_negative_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::smpte_offset_negative_clicked));
352 OptionEditor::smpte_offset_negative_clicked ()
355 session->set_smpte_offset_negative (smpte_offset_negative_button.get_active());
360 OptionEditor::smpte_offset_chosen()
363 nframes_t frames = smpte_offset_clock.current_duration();
364 session->set_smpte_offset (frames);
370 OptionEditor::setup_midi_options ()
374 midi_port_table.set_row_spacings (6);
375 midi_port_table.set_col_spacings (10);
377 redisplay_midi_ports ();
379 mmc_device_id_adjustment.signal_value_changed().connect (mem_fun (*this, &OptionEditor::mmc_device_id_adjusted));
381 hbox = manage (new HBox);
382 hbox->set_border_width (6);
383 hbox->pack_start (midi_port_table, true, false);
385 midi_packer.pack_start (*hbox, false, false);
386 midi_packer.pack_start (add_midi_port_button, false, false);
388 add_midi_port_button.signal_clicked().connect (mem_fun (*this, &OptionEditor::add_midi_port));
392 OptionEditor::redisplay_midi_ports ()
394 MIDI::Manager::PortMap::const_iterator i;
395 const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports();
398 /* remove all existing widgets */
400 // XXX broken in gtkmm 2.10
401 // midi_port_table.clear ();
403 for (vector<Widget*>::iterator w = midi_port_table_widgets.begin(); w != midi_port_table_widgets.end(); ++w) {
404 midi_port_table.remove (**w);
407 midi_port_table_widgets.clear ();
409 midi_port_table.resize (ports.size() + 4, 10);
413 label = (manage (new Label (_("Port"))));
415 midi_port_table_widgets.push_back (label);
416 midi_port_table.attach (*label, 0, 1, 0, 1);
417 label = (manage (new Label (_("Offline"))));
419 midi_port_table_widgets.push_back (label);
420 midi_port_table.attach (*label, 1, 2, 0, 1);
421 label = (manage (new Label (_("Trace\nInput"))));
423 midi_port_table_widgets.push_back (label);
424 midi_port_table.attach (*label, 2, 3, 0, 1);
425 label = (manage (new Label (_("Trace\nOutput"))));
427 midi_port_table_widgets.push_back (label);
428 midi_port_table.attach (*label, 3, 4, 0, 1);
429 label = (manage (new Label (_("MTC"))));
431 midi_port_table_widgets.push_back (label);
432 midi_port_table.attach (*label, 4, 5, 0, 1);
433 label = (manage (new Label (_("MMC"))));
435 midi_port_table_widgets.push_back (label);
436 midi_port_table.attach (*label, 6, 7, 0, 1);
437 label = (manage (new Label (_("MIDI Parameter\nControl"))));
439 midi_port_table_widgets.push_back (label);
440 midi_port_table.attach (*label, 8, 9, 0, 1);
442 Gtk::HSeparator* hsep = (manage (new HSeparator()));
444 midi_port_table_widgets.push_back (hsep);
445 midi_port_table.attach (*hsep, 0, 9, 1, 2);
446 Gtk::VSeparator* vsep = (manage (new VSeparator()));
448 midi_port_table_widgets.push_back (vsep);
449 midi_port_table.attach (*vsep, 5, 6, 0, 8);
450 vsep = (manage (new VSeparator()));
452 midi_port_table_widgets.push_back (vsep);
453 midi_port_table.attach (*vsep, 7, 8, 0, 8);
455 label = (manage (new Label (_("MMC Device ID"))));
457 midi_port_table_widgets.push_back (label);
458 midi_port_table.attach (*label, 9, 10, 0, 1);
459 midi_port_table_widgets.push_back (&mmc_device_id_spinner);
460 midi_port_table.attach (mmc_device_id_spinner, 9, 10, 1, 2);
462 for (n = 0, i = ports.begin(); i != ports.end(); ++n, ++i) {
464 pair<MIDI::Port*,vector<RadioButton*> > newpair;
468 newpair.first = i->second;
470 label = (manage (new Label (i->first)));
472 midi_port_table_widgets.push_back (label);
473 midi_port_table.attach (*label, 0, 1, n+2, n+3,FILL|EXPAND, FILL );
475 tb = manage (new ToggleButton (_("online")));
476 tb->set_name ("OptionEditorToggleButton");
478 /* remember, we have to handle the i18n case where the relative
479 lengths of the strings in language N is different than in english.
482 if (strlen (_("offline")) > strlen (_("online"))) {
483 set_size_request_to_display_given_text (*tb, _("offline"), 15, 12);
485 set_size_request_to_display_given_text (*tb, _("online"), 15, 12);
488 if (i->second->input()) {
489 tb->set_active (!i->second->input()->offline());
490 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_online_toggled), i->second, tb));
491 i->second->input()->OfflineStatusChanged.connect (bind (mem_fun(*this, &OptionEditor::map_port_online), (*i).second, tb));
494 midi_port_table_widgets.push_back (tb);
495 midi_port_table.attach (*tb, 1, 2, n+2, n+3, FILL|EXPAND, FILL);
497 tb = manage (new ToggleButton ());
498 tb->set_name ("OptionEditorToggleButton");
499 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_in_toggled), (*i).second, tb));
500 tb->set_size_request (10, 10);
502 midi_port_table_widgets.push_back (tb);
503 midi_port_table.attach (*tb, 2, 3, n+2, n+3, FILL|EXPAND, FILL);
505 tb = manage (new ToggleButton ());
506 tb->set_name ("OptionEditorToggleButton");
507 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_out_toggled), (*i).second, tb));
508 tb->set_size_request (10, 10);
510 midi_port_table.attach (*tb, 3, 4, n+2, n+3, FILL|EXPAND, FILL);
512 rb = manage (new RadioButton ());
513 newpair.second.push_back (rb);
514 rb->set_name ("OptionEditorToggleButton");
516 mtc_button_group = rb->get_group();
518 rb->set_group (mtc_button_group);
522 midi_port_table_widgets.push_back (rb);
523 midi_port_table.attach (*rb, 4, 5, n+2, n+3, FILL|EXPAND, FILL);
524 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mtc_port_chosen), (*i).second, rb));
526 if (session && i->second == session->mtc_port()) {
527 rb->set_active (true);
530 rb = manage (new RadioButton ());
531 newpair.second.push_back (rb);
532 rb->set_name ("OptionEditorToggleButton");
534 mmc_button_group = rb->get_group();
536 rb->set_group (mmc_button_group);
539 midi_port_table_widgets.push_back (rb);
540 midi_port_table.attach (*rb, 6, 7, n+2, n+3, FILL|EXPAND, FILL);
541 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mmc_port_chosen), (*i).second, rb));
543 if (session && i->second == session->mmc_port()) {
544 rb->set_active (true);
547 rb = manage (new RadioButton ());
548 newpair.second.push_back (rb);
549 rb->set_name ("OptionEditorToggleButton");
551 midi_button_group = rb->get_group();
553 rb->set_group (midi_button_group);
556 midi_port_table_widgets.push_back (rb);
557 midi_port_table.attach (*rb, 8, 9, n+2, n+3, FILL|EXPAND, FILL);
558 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_port_chosen), (*i).second, rb));
560 if (session && i->second == session->midi_port()) {
561 rb->set_active (true);
564 port_toggle_buttons.insert (newpair);
567 midi_port_table.show();
571 OptionEditor::add_midi_port ()
573 MidiPortDialog dialog;
575 dialog.set_position (WIN_POS_MOUSE);
576 dialog.set_transient_for (*this);
580 int ret = dialog.run ();
583 case RESPONSE_ACCEPT:
590 Glib::ustring mode = dialog.port_mode_combo.get_active_text();
593 if (mode == _("input")) {
595 } else if (mode == (_("output"))) {
601 MIDI::PortRequest req (X_("ardour"),
602 dialog.port_name.get_text(),
604 MIDI::PortFactory::default_port_type());
606 if (MIDI::Manager::instance()->add_port (req) != 0) {
607 redisplay_midi_ports ();
612 OptionEditor::mtc_port_chosen (MIDI::Port *port, Gtk::RadioButton* rb)
615 if (rb->get_active()) {
617 session->set_mtc_port (port->name());
618 Config->set_mtc_port_name (port->name());
620 session->set_mtc_port ("");
622 rb->set_active (true);
628 OptionEditor::mmc_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb)
631 if (rb->get_active()) {
633 session->set_mmc_port (port->name());
634 Config->set_mtc_port_name (port->name());
636 session->set_mmc_port ("");
638 rb->set_active (true);
644 OptionEditor::midi_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb)
647 if (rb->get_active()) {
649 session->set_midi_port (port->name());
650 Config->set_midi_port_name (port->name());
652 session->set_midi_port ("");
654 rb->set_active (true);
660 OptionEditor::port_online_toggled (MIDI::Port* port, ToggleButton* tb)
662 bool wanted = tb->get_active();
665 if (wanted != port->input()->offline()) {
666 port->input()->set_offline (wanted);
672 OptionEditor::map_port_online (MIDI::Port* port, ToggleButton* tb)
674 bool bstate = tb->get_active ();
677 if (bstate != port->input()->offline()) {
678 if (port->input()->offline()) {
679 tb->set_label (_("offline"));
680 tb->set_active (false);
682 tb->set_label (_("online"));
683 tb->set_active (true);
690 OptionEditor::mmc_device_id_adjusted ()
692 uint8_t id = (uint8_t) mmc_device_id_spinner.get_value();
694 if (id != Config->get_mmc_device_id()) {
695 Config->set_mmc_device_id (id);
700 OptionEditor::port_trace_in_toggled (MIDI::Port* port, ToggleButton* tb)
702 bool trace = tb->get_active();
705 if (port->input()->tracing() != trace) {
706 port->input()->trace (trace, &cerr, string (port->name()) + string (" input: "));
712 OptionEditor::port_trace_out_toggled (MIDI::Port* port, ToggleButton* tb)
714 bool trace = tb->get_active();
716 if (port->output()) {
717 if (port->output()->tracing() != trace) {
718 port->output()->trace (trace, &cerr, string (port->name()) + string (" output: "));
724 OptionEditor::save ()
726 /* XXX a bit odd that we save the entire session state here */
732 OptionEditor::wm_close (GdkEventAny *ev)
740 OptionEditor::raid_path_changed ()
743 Config->set_raid_path (session_raid_entry.get_text());
748 OptionEditor::click_browse_clicked ()
750 SoundFileChooser sfdb (_("Choose Click"), session);
752 int result = sfdb.run ();
754 if (result == Gtk::RESPONSE_OK) {
755 click_chosen(sfdb.get_filename());
760 OptionEditor::click_chosen (const string & path)
762 click_path_entry.set_text (path);
763 click_sound_changed ();
767 OptionEditor::click_emphasis_browse_clicked ()
769 SoundFileChooser sfdb (_("Choose Click Emphasis"), session);
771 int result = sfdb.run ();
773 if (result == Gtk::RESPONSE_OK) {
774 click_emphasis_chosen (sfdb.get_filename());
779 OptionEditor::click_emphasis_chosen (const string & path)
781 click_emphasis_path_entry.set_text (path);
782 click_emphasis_sound_changed ();
786 OptionEditor::click_sound_changed ()
789 string path = click_path_entry.get_text();
791 if (path == Config->get_click_sound()) {
795 strip_whitespace_edges (path);
797 if (path == _("internal")) {
798 Config->set_click_sound ("");
800 Config->set_click_sound (path);
806 OptionEditor::click_emphasis_sound_changed ()
809 string path = click_emphasis_path_entry.get_text();
811 if (path == Config->get_click_emphasis_sound()) {
815 strip_whitespace_edges (path);
817 if (path == _("internal")) {
818 Config->set_click_emphasis_sound ("");
820 Config->set_click_emphasis_sound (path);
826 OptionEditor::clear_click_editor ()
828 if (click_io_selector) {
829 click_packer.remove (*click_io_selector);
830 click_packer.remove (*click_gpm);
831 delete click_io_selector;
833 click_io_selector = 0;
839 OptionEditor::setup_click_editor ()
842 HBox* hpacker = manage (new HBox);
844 click_path_entry.set_sensitive (true);
845 click_emphasis_path_entry.set_sensitive (true);
847 click_path_entry.set_name ("OptionsEntry");
848 click_emphasis_path_entry.set_name ("OptionsEntry");
850 click_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_sound_changed));
851 click_emphasis_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed));
853 click_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_sound_changed));
854 click_emphasis_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_emphasis_sound_changed));
856 click_browse_button.set_name ("EditorGTKButton");
857 click_emphasis_browse_button.set_name ("EditorGTKButton");
858 click_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_browse_clicked));
859 click_emphasis_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_emphasis_browse_clicked));
861 click_packer.set_border_width (12);
862 click_packer.set_spacing (5);
864 click_io_selector = new IOSelector (*session, session->click_io(), false);
865 click_gpm = new GainMeter (session->click_io(), *session);
867 click_table.set_col_spacings (10);
869 label = manage(new Label(_("Click audio file")));
870 label->set_name ("OptionsLabel");
871 click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
872 click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
873 click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL);
875 label = manage(new Label(_("Click emphasis audiofile")));
876 label->set_name ("OptionsLabel");
877 click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
878 click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
879 click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL);
881 hpacker->set_spacing (10);
882 hpacker->pack_start (*click_io_selector, false, false);
883 hpacker->pack_start (*click_gpm, false, false);
885 click_packer.pack_start (click_table, false, false);
886 click_packer.pack_start (*hpacker, false, false);
888 click_packer.show_all ();
892 OptionEditor::clear_auditioner_editor ()
894 if (auditioner_io_selector) {
895 audition_hpacker.remove (*auditioner_io_selector);
896 audition_hpacker.remove (*auditioner_gpm);
897 delete auditioner_io_selector;
898 delete auditioner_gpm;
899 auditioner_io_selector = 0;
905 OptionEditor::setup_auditioner_editor ()
907 audition_packer.set_border_width (12);
908 audition_packer.set_spacing (5);
909 audition_hpacker.set_spacing (10);
911 audition_label.set_name ("OptionEditorAuditionerLabel");
912 audition_label.set_text (_("The auditioner is a dedicated mixer strip used\n"
913 "for listening to specific regions outside the context\n"
914 "of the overall mix. It can be connected just like any\n"
915 "other mixer strip."));
917 audition_packer.pack_start (audition_label, false, false, 10);
918 audition_packer.pack_start (audition_hpacker, false, false);
922 OptionEditor::connect_audition_editor ()
924 auditioner_io_selector = new IOSelector (*session, session->the_auditioner(), false);
925 auditioner_gpm = new GainMeter (session->the_auditioner(), *session);
927 audition_hpacker.pack_start (*auditioner_io_selector, false, false);
928 audition_hpacker.pack_start (*auditioner_gpm, false, false);
930 auditioner_io_selector->show_all ();
931 auditioner_gpm->show_all ();
935 OptionEditor::focus_out_event_handler (GdkEventFocus* ev, void (OptionEditor::*pmf)())
941 static const struct {
945 { "Shift", GDK_SHIFT_MASK },
946 { "Control", GDK_CONTROL_MASK },
947 { "Alt (Mod1)", GDK_MOD1_MASK },
948 { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK },
949 { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK },
950 { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK },
951 { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
952 { "Mod2", GDK_MOD2_MASK },
953 { "Mod3", GDK_MOD3_MASK },
954 { "Mod4", GDK_MOD4_MASK },
955 { "Mod5", GDK_MOD5_MASK },
960 OptionEditor::setup_keyboard_options ()
965 keyboard_mouse_table.set_border_width (12);
966 keyboard_mouse_table.set_row_spacings (5);
967 keyboard_mouse_table.set_col_spacings (5);
969 /* internationalize and prepare for use with combos */
971 for (int i = 0; modifiers[i].name; ++i) {
972 dumb.push_back (_(modifiers[i].name));
975 set_popdown_strings (edit_modifier_combo, dumb);
976 edit_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::edit_modifier_chosen));
978 for (int x = 0; modifiers[x].name; ++x) {
979 if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
980 edit_modifier_combo.set_active_text (_(modifiers[x].name));
985 label = manage (new Label (_("Edit using")));
986 label->set_name ("OptionsLabel");
987 label->set_alignment (1.0, 0.5);
989 keyboard_mouse_table.attach (*label, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
990 keyboard_mouse_table.attach (edit_modifier_combo, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
992 label = manage (new Label (_("+ button")));
993 label->set_name ("OptionsLabel");
995 keyboard_mouse_table.attach (*label, 3, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
996 keyboard_mouse_table.attach (edit_button_spin, 4, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
998 edit_button_spin.set_name ("OptionsEntry");
999 edit_button_adjustment.set_value (Keyboard::edit_button());
1000 edit_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::edit_button_changed));
1002 set_popdown_strings (delete_modifier_combo, dumb);
1003 delete_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::delete_modifier_chosen));
1005 for (int x = 0; modifiers[x].name; ++x) {
1006 if (modifiers[x].modifier == Keyboard::delete_modifier ()) {
1007 delete_modifier_combo.set_active_text (_(modifiers[x].name));
1012 label = manage (new Label (_("Delete using")));
1013 label->set_name ("OptionsLabel");
1014 label->set_alignment (1.0, 0.5);
1016 keyboard_mouse_table.attach (*label, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1017 keyboard_mouse_table.attach (delete_modifier_combo, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1019 label = manage (new Label (_("+ button")));
1020 label->set_name ("OptionsLabel");
1022 keyboard_mouse_table.attach (*label, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1023 keyboard_mouse_table.attach (delete_button_spin, 4, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1025 delete_button_spin.set_name ("OptionsEntry");
1026 delete_button_adjustment.set_value (Keyboard::delete_button());
1027 delete_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::delete_button_changed));
1029 set_popdown_strings (snap_modifier_combo, dumb);
1030 snap_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::snap_modifier_chosen));
1032 for (int x = 0; modifiers[x].name; ++x) {
1033 if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) {
1034 snap_modifier_combo.set_active_text (_(modifiers[x].name));
1039 label = manage (new Label (_("Ignore snap using")));
1040 label->set_name ("OptionsLabel");
1041 label->set_alignment (1.0, 0.5);
1043 keyboard_mouse_table.attach (*label, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
1044 keyboard_mouse_table.attach (snap_modifier_combo, 1, 2, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
1048 OptionEditor::edit_modifier_chosen ()
1052 txt = edit_modifier_combo.get_active_text();
1054 for (int i = 0; modifiers[i].name; ++i) {
1055 if (txt == _(modifiers[i].name)) {
1056 Keyboard::set_edit_modifier (modifiers[i].modifier);
1063 OptionEditor::delete_modifier_chosen ()
1067 txt = delete_modifier_combo.get_active_text();
1069 for (int i = 0; modifiers[i].name; ++i) {
1070 if (txt == _(modifiers[i].name)) {
1071 Keyboard::set_delete_modifier (modifiers[i].modifier);
1078 OptionEditor::snap_modifier_chosen ()
1082 txt = snap_modifier_combo.get_active_text();
1084 for (int i = 0; modifiers[i].name; ++i) {
1085 if (txt == _(modifiers[i].name)) {
1086 Keyboard::set_snap_modifier (modifiers[i].modifier);
1093 OptionEditor::delete_button_changed ()
1095 Keyboard::set_delete_button ((guint) delete_button_adjustment.get_value());
1099 OptionEditor::edit_button_changed ()
1101 Keyboard::set_edit_button ((guint) edit_button_adjustment.get_value());
1105 OptionEditor::fixup_combo_size (Gtk::ComboBoxText& combo, vector<string>& strings)
1107 /* find the widest string */
1109 string::size_type maxlen = 0;
1112 for (vector<string>::iterator i = strings.begin(); i != strings.end(); ++i) {
1113 string::size_type l;
1115 if ((l = (*i).length()) > maxlen) {
1121 /* try to include ascenders and descenders */
1123 if (maxstring.length() > 2) {
1128 const guint32 FUDGE = 10; // Combo's are stupid - they steal space from the entry for the button
1130 set_size_request_to_display_given_text (combo, maxstring.c_str(), 10 + FUDGE, 10);