2 Copyright (C) 2001 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.
21 #include <pbd/whitespace.h>
23 #include <ardour/session.h>
24 #include <ardour/audioengine.h>
25 #include <ardour/configuration.h>
26 #include <ardour/auditioner.h>
27 #include <ardour/crossfade.h>
28 #include <midi++/manager.h>
29 #include <gtkmm2ext/stop_signal.h>
30 #include <gtkmm2ext/utils.h>
32 #include "public_editor.h"
34 #include "ardour_ui.h"
35 #include "io_selector.h"
36 #include "gain_meter.h"
40 #include "option_editor.h"
44 using namespace ARDOUR;
46 using namespace Editing;
47 using namespace Gtkmm2ext;
50 static vector<string> positional_sync_strings;
52 OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui)
53 : Dialog ("option editor"),
61 sfdb_paths(ListStore::create(sfdb_path_columns)),
62 sfdb_path_view(sfdb_paths),
66 short_xfade_adjustment (0, 1.0, 500.0, 5.0, 100.0),
67 short_xfade_slider (short_xfade_adjustment),
68 destructo_xfade_adjustment (1.0, 1.0, 500.0, 1.0, 100.0),
69 destructo_xfade_slider (destructo_xfade_adjustment),
73 smpte_offset_clock (X_("SMPTEOffsetClock"), true, true),
74 smpte_offset_negative_button (_("SMPTE offset is negative")),
81 click_browse_button (_("Browse")),
82 click_emphasis_browse_button (_("Browse")),
86 keyboard_mouse_table (3, 4),
87 delete_button_adjustment (3, 1, 5),
88 delete_button_spin (delete_button_adjustment),
89 edit_button_adjustment (3, 1, 5),
90 edit_button_spin (edit_button_adjustment)
93 using namespace Notebook_Helpers;
95 click_io_selector = 0;
96 auditioner_io_selector = 0;
99 set_default_size (300, 300);
100 set_title (_("ardour: options editor"));
101 set_wmclass (_("ardour_option_editor"), "Ardour");
103 set_name ("OptionsWindow");
104 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
106 VBox *vbox = get_vbox();
107 set_border_width (3);
109 vbox->set_spacing (4);
110 vbox->pack_start(notebook);
112 signal_delete_event().connect (mem_fun(*this, &OptionEditor::wm_close));
114 notebook.set_show_tabs (true);
115 notebook.set_show_border (true);
116 notebook.set_name ("OptionsNotebook");
118 setup_sync_options();
119 setup_path_options();
120 setup_fade_options ();
121 setup_keyboard_options ();
122 setup_auditioner_editor ();
124 notebook.pages().push_back (TabElem (sync_packer, _("Sync")));
125 notebook.pages().push_back (TabElem (path_table, _("Paths/Files")));
126 notebook.pages().push_back (TabElem (keyboard_mouse_table, _("Kbd/Mouse")));
127 notebook.pages().push_back (TabElem (click_packer, _("Click")));
128 notebook.pages().push_back (TabElem (audition_packer, _("Audition")));
129 notebook.pages().push_back (TabElem (fade_packer, _("Layers & Fades")));
131 if (!MIDI::Manager::instance()->get_midi_ports().empty()) {
132 setup_midi_options ();
133 notebook.pages().push_back (TabElem (midi_packer, _("MIDI")));
141 OptionEditor::set_session (Session *s)
143 clear_click_editor ();
144 clear_auditioner_editor ();
146 click_path_entry.set_text ("");
147 click_emphasis_path_entry.set_text ("");
148 session_raid_entry.set_text ("");
150 click_path_entry.set_sensitive (false);
151 click_emphasis_path_entry.set_sensitive (false);
152 session_raid_entry.set_sensitive (false);
154 smpte_fps_combo.set_sensitive (false);
155 short_xfade_slider.set_sensitive (false);
156 smpte_offset_negative_button.set_sensitive (false);
158 smpte_offset_clock.set_session (s);
160 if ((session = s) == 0) {
165 click_path_entry.set_sensitive (true);
166 click_emphasis_path_entry.set_sensitive (true);
167 session_raid_entry.set_sensitive (true);
168 smpte_fps_combo.set_sensitive (true);
169 short_xfade_slider.set_sensitive (true);
170 smpte_offset_negative_button.set_sensitive (true);
172 if (!s->smpte_drop_frames) {
174 if (s->smpte_frames_per_second == 24.0)
175 smpte_fps_combo.set_active_text (_("24 FPS"));
176 else if (s->smpte_frames_per_second == 25.0)
177 smpte_fps_combo.set_active_text (_("25 FPS"));
178 else if (s->smpte_frames_per_second == 30.0)
179 smpte_fps_combo.set_active_text (_("30 FPS"));
181 smpte_fps_combo.set_active_text (_("???"));
184 if (floor(s->smpte_frames_per_second) == 29.0)
185 smpte_fps_combo.set_active_text (_("30 FPS drop"));
187 smpte_fps_combo.set_active_text (_("???"));
190 smpte_offset_clock.set_session (s);
191 smpte_offset_clock.set (s->smpte_offset (), true);
193 smpte_offset_negative_button.set_active (session->smpte_offset_negative());
195 /* set up port assignments */
197 std::map<MIDI::Port*,vector<RadioButton*> >::iterator res;
199 if (session->mtc_port()) {
200 if ((res = port_toggle_buttons.find (session->mtc_port())) != port_toggle_buttons.end()) {
201 (*res).second[MtcIndex]->set_active (true);
205 if (session->mmc_port ()) {
206 if ((res = port_toggle_buttons.find (session->mmc_port())) != port_toggle_buttons.end()) {
207 (*res).second[MmcIndex]->set_active (true);
211 if (session->midi_port()) {
212 if ((res = port_toggle_buttons.find (session->midi_port())) != port_toggle_buttons.end()) {
213 (*res).second[MidiIndex]->set_active (true);
217 setup_click_editor ();
218 connect_audition_editor ();
220 short_xfade_adjustment.set_value ((Crossfade::short_xfade_length() / (float) session->frame_rate()) * 1000.0);
222 add_session_paths ();
225 OptionEditor::~OptionEditor ()
229 static const gchar *native_format_strings[] = {
230 N_("Broadcast WAVE/floating point"),
231 N_("WAVE/floating point"),
236 OptionEditor::setup_path_options()
240 path_table.set_homogeneous (false);
241 path_table.set_border_width (12);
242 path_table.set_row_spacings (5);
244 session_raid_entry.set_name ("OptionsEntry");
246 session_raid_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::raid_path_changed));
248 label = manage(new Label(_("session RAID path")));
249 label->set_name ("OptionsLabel");
250 path_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
251 path_table.attach (session_raid_entry, 1, 3, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
253 label = manage(new Label(_("Native Format")));
254 label->set_name ("OptionsLabel");
255 path_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
256 path_table.attach (native_format_combo, 1, 3, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
258 label = manage(new Label(_("Soundfile Search Paths")));
259 label->set_name("OptionsLabel");
260 path_table.attach(*label, 0, 1, 2, 3, FILL|EXPAND, FILL);
261 path_table.attach(sfdb_path_view, 1, 3, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
263 sfdb_path_view.append_column(_("Paths"), sfdb_path_columns.paths);
264 sfdb_path_view.set_size_request(-1, 100);
266 vector<string> nfstrings = internationalize (native_format_strings);
268 set_popdown_strings (native_format_combo, nfstrings);
269 native_format_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::native_format_chosen));
271 fixup_combo_size (native_format_combo, nfstrings);
273 if (Config->get_native_format_is_bwf()) {
274 native_format_combo.set_active_text (native_format_strings[0]);
276 native_format_combo.set_active_text (native_format_strings[1]);
279 path_table.show_all();
283 OptionEditor::add_session_paths ()
285 click_path_entry.set_sensitive (true);
286 click_emphasis_path_entry.set_sensitive (true);
287 session_raid_entry.set_sensitive (true);
289 if (session->click_sound.length() == 0) {
290 click_path_entry.set_text (_("internal"));
292 click_path_entry.set_text (session->click_sound);
295 if (session->click_emphasis_sound.length() == 0) {
296 click_emphasis_path_entry.set_text (_("internal"));
298 click_emphasis_path_entry.set_text (session->click_emphasis_sound);
301 session_raid_entry.set_text(session->raid_path());
305 OptionEditor::setup_fade_options ()
309 Label* label = manage (new Label (_("Short crossfade length (msecs)")));
310 label->set_name ("OptionsLabel");
312 hbox = manage (new HBox);
313 hbox->set_border_width (5);
314 hbox->set_spacing (10);
315 hbox->pack_start (*label, false, false);
316 hbox->pack_start (short_xfade_slider, true, true);
317 fade_packer.pack_start (*hbox, false, false);
319 short_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::short_xfade_adjustment_changed));
321 label = manage (new Label (_("Destructive crossfade length (msecs)")));
322 label->set_name ("OptionsLabel");
324 hbox = manage (new HBox);
325 hbox->set_border_width (5);
326 hbox->set_spacing (10);
327 hbox->pack_start (*label, false, false);
328 hbox->pack_start (destructo_xfade_slider, true, true);
329 fade_packer.pack_start (*hbox, false, false);
331 destructo_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::destructo_xfade_adjustment_changed));
333 short_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
334 destructo_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
336 destructo_xfade_adjustment.set_value (Config->get_destructive_xfade_msecs());
338 fade_packer.show_all ();
342 OptionEditor::short_xfade_adjustment_changed ()
345 float val = short_xfade_adjustment.get_value();
347 /* val is in msecs */
349 Crossfade::set_short_xfade_length ((jack_nframes_t) floor (session->frame_rate() * (val / 1000.0)));
354 OptionEditor::destructo_xfade_adjustment_changed ()
356 float val = destructo_xfade_adjustment.get_value();
358 /* val is in msecs */
361 Config->set_destructive_xfade_msecs ((uint32_t) floor (val), session->frame_rate());
363 Config->set_destructive_xfade_msecs ((uint32_t) floor (val), 0);
368 OptionEditor::setup_sync_options ()
374 dumb.push_back (X_("24 FPS"));
375 dumb.push_back (X_("25 FPS"));
376 dumb.push_back (X_("30 FPS drop"));
377 dumb.push_back (X_("30 FPS non-drop"));
379 set_popdown_strings (smpte_fps_combo, dumb);
380 smpte_fps_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::smpte_fps_chosen));
382 smpte_offset_clock.set_mode (AudioClock::SMPTE);
383 smpte_offset_clock.ValueChanged.connect (mem_fun(*this, &OptionEditor::smpte_offset_chosen));
385 smpte_offset_negative_button.set_name ("OptionEditorToggleButton");
387 smpte_offset_negative_button.unset_flags (Gtk::CAN_FOCUS);
389 Label *smpte_fps_label = manage (new Label (_("SMPTE Frames/second")));
390 Label *smpte_offset_label = manage (new Label (_("SMPTE Offset")));
391 smpte_fps_label->set_name("OptionsLabel");
392 smpte_offset_label->set_name("OptionsLabel");
394 hbox = manage (new HBox);
395 hbox->set_border_width (5);
396 hbox->set_spacing (10);
397 hbox->pack_start (*smpte_fps_label, false, false);
398 hbox->pack_start (smpte_fps_combo, false, false);
400 sync_packer.pack_start (*hbox, false, false);
402 hbox = manage (new HBox);
403 hbox->set_border_width (5);
404 hbox->set_spacing (10);
405 hbox->pack_start (*smpte_offset_label, false, false);
406 hbox->pack_start (smpte_offset_clock, false, false);
407 hbox->pack_start (smpte_offset_negative_button, false, false);
409 sync_packer.pack_start (*hbox, false, false);
411 smpte_offset_negative_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::smpte_offset_negative_clicked));
415 OptionEditor::smpte_offset_negative_clicked ()
418 session->set_smpte_offset_negative (smpte_offset_negative_button.get_active());
423 OptionEditor::smpte_fps_chosen ()
426 string str = smpte_fps_combo.get_active_text();
428 if (str == X_("24 FPS")) {
429 session->set_smpte_type (24.0, false);
430 } else if (str == X_("25 FPS")) {
431 session->set_smpte_type (25.0, false);
432 } else if (str == X_("30 FPS drop")) {
433 session->set_smpte_type (29.97, true);
434 } else if (str == X_("30 FPS non-drop")) {
435 session->set_smpte_type (30.0, false);
441 OptionEditor::smpte_offset_chosen()
444 jack_nframes_t frames = smpte_offset_clock.current_duration();
445 session->set_smpte_offset (frames);
451 OptionEditor::setup_midi_options ()
454 MIDI::Manager::PortMap::const_iterator i;
455 const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports();
460 Gtk::Table* table = manage (new Table (ports.size() + 4, 9));
462 table->set_row_spacings (6);
463 table->set_col_spacings (10);
465 table->attach (*(manage (new Label (X_("Port")))), 0, 1, 0, 1);
466 table->attach (*(manage (new Label (X_("Offline")))), 1, 2, 0, 1);
467 table->attach (*(manage (new Label (X_("Trace\nInput")))), 2, 3, 0, 1);
468 table->attach (*(manage (new Label (X_("Trace\nOutput")))), 3, 4, 0, 1);
469 table->attach (*(manage (new Label (X_("MTC")))), 4, 5, 0, 1);
470 table->attach (*(manage (new Label (X_("MMC")))), 6, 7, 0, 1);
471 table->attach (*(manage (new Label (X_("MIDI Parameter\nControl")))), 8, 9, 0, 1);
473 table->attach (*(manage (new HSeparator())), 0, 9, 1, 2);
474 table->attach (*(manage (new VSeparator())), 5, 6, 0, 8);
475 table->attach (*(manage (new VSeparator())), 7, 8, 0, 8);
477 for (n = 0, i = ports.begin(); i != ports.end(); ++n, ++i) {
479 pair<MIDI::Port*,vector<RadioButton*> > newpair;
481 newpair.first = i->second;
483 table->attach (*(manage (new Label (i->first))), 0, 1, n+2, n+3,FILL|EXPAND, FILL );
484 tb = manage (new ToggleButton (_("online")));
485 tb->set_name ("OptionEditorToggleButton");
487 /* remember, we have to handle the i18n case where the relative
488 lengths of the strings in language N is different than in english.
491 if (strlen (_("offline")) > strlen (_("online"))) {
492 set_size_request_to_display_given_text (*tb, _("offline"), 15, 12);
494 set_size_request_to_display_given_text (*tb, _("online"), 15, 12);
497 tb->set_active (!(*i).second->input()->offline());
498 tb->signal_button_press_event().connect (bind (mem_fun(*this, &OptionEditor::port_online_toggled), (*i).second, tb));
499 (*i).second->input()->OfflineStatusChanged.connect (bind (mem_fun(*this, &OptionEditor::map_port_online), (*i).second, tb));
500 table->attach (*tb, 1, 2, n+2, n+3, FILL|EXPAND, FILL);
502 tb = manage (new ToggleButton ());
503 tb->set_name ("OptionEditorToggleButton");
504 tb->signal_button_press_event().connect (bind (mem_fun(*this, &OptionEditor::port_trace_in_toggled), (*i).second, tb));
505 tb->set_size_request (10, 10);
506 table->attach (*tb, 2, 3, n+2, n+3, FILL|EXPAND, FILL);
508 tb = manage (new ToggleButton ());
509 tb->set_name ("OptionEditorToggleButton");
510 tb->signal_button_press_event().connect (bind (mem_fun(*this, &OptionEditor::port_trace_out_toggled), (*i).second, tb));
511 tb->set_size_request (10, 10);
512 table->attach (*tb, 3, 4, n+2, n+3, FILL|EXPAND, FILL);
514 rb = manage (new RadioButton ());
515 newpair.second.push_back (rb);
516 rb->set_name ("OptionEditorToggleButton");
518 mtc_button_group = rb->get_group();
520 rb->set_group (mtc_button_group);
523 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 (Config->get_mtc_port_name() == i->first) {
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);
538 table->attach (*rb, 6, 7, n+2, n+3, FILL|EXPAND, FILL);
539 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mmc_port_chosen), (*i).second, rb));
541 if (Config->get_mmc_port_name() == i->first) {
542 rb->set_active (true);
545 rb = manage (new RadioButton ());
546 newpair.second.push_back (rb);
547 rb->set_name ("OptionEditorToggleButton");
549 midi_button_group = rb->get_group();
551 rb->set_group (midi_button_group);
553 table->attach (*rb, 8, 9, n+2, n+3, FILL|EXPAND, FILL);
554 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_port_chosen), (*i).second, rb));
556 if (Config->get_midi_port_name() == i->first) {
557 rb->set_active (true);
560 port_toggle_buttons.insert (newpair);
565 hbox = manage (new HBox);
566 hbox->set_border_width (6);
567 hbox->pack_start (*table, true, false);
568 midi_packer.pack_start (*hbox, false, false);
572 OptionEditor::mtc_port_chosen (MIDI::Port *port, Gtk::RadioButton* rb)
575 if (rb->get_active()) {
576 cerr << "Activating MTC port " << port->name() << endl;
578 session->set_mtc_port (port->name());
579 Config->set_mtc_port_name (port->name());
581 session->set_mtc_port ("");
583 rb->set_active (true);
589 OptionEditor::mmc_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb)
592 if (rb->get_active()) {
593 cerr << "Activating MMC port " << port->name() << endl;
595 session->set_mmc_port (port->name());
596 Config->set_mtc_port_name (port->name());
598 session->set_mmc_port ("");
600 rb->set_active (true);
606 OptionEditor::midi_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb)
609 if (rb->get_active()) {
610 cerr << "Activating MIDI port " << port->name() << endl;
612 session->set_midi_port (port->name());
613 Config->set_midi_port_name (port->name());
615 session->set_midi_port ("");
617 rb->set_active (true);
623 OptionEditor::port_online_toggled (GdkEventButton* ev, MIDI::Port* port, ToggleButton* tb)
625 bool wanted = tb->get_active(); /* it hasn't changed at this point */
627 if (wanted != port->input()->offline()) {
628 port->input()->set_offline (wanted);
630 return stop_signal (*tb, "button_press_event");
634 OptionEditor::map_port_online (MIDI::Port* port, ToggleButton* tb)
636 if (port->input()->offline()) {
637 static_cast<Label*>(tb->get_child())->set_text (_("offline"));
638 tb->set_active (false);
640 static_cast<Label*>(tb->get_child())->set_text (_("online"));
641 tb->set_active (true);
646 OptionEditor::port_trace_in_toggled (GdkEventButton* ev, MIDI::Port* port, ToggleButton* tb)
648 /* XXX not very good MVC style here */
650 port->input()->trace (!tb->get_active(), &cerr, string (port->name()) + string (" input: "));
651 tb->set_active (!tb->get_active());
652 return stop_signal (*tb, "button_press_event");
656 OptionEditor::port_trace_out_toggled (GdkEventButton* ev,MIDI::Port* port, ToggleButton* tb)
658 /* XXX not very good MVC style here */
660 port->output()->trace (!tb->get_active(), &cerr, string (port->name()) + string (" output: "));
661 tb->set_active (!tb->get_active());
662 return stop_signal (*tb, "button_press_event");
666 OptionEditor::save ()
668 /* XXX a bit odd that we save the entire session state here */
674 OptionEditor::wm_close (GdkEventAny *ev)
682 OptionEditor::raid_path_changed ()
685 session->set_raid_path (session_raid_entry.get_text());
690 OptionEditor::click_browse_clicked ()
692 SoundFileChooser sfdb (_("Choose Click"));
694 int result = sfdb.run ();
696 if (result == Gtk::RESPONSE_OK) {
697 click_chosen(sfdb.get_filename());
702 OptionEditor::click_chosen (const string & path)
704 click_path_entry.set_text (path);
705 click_sound_changed ();
709 OptionEditor::click_emphasis_browse_clicked ()
711 SoundFileChooser sfdb (_("Choose Click Emphasis"));
713 int result = sfdb.run ();
715 if (result == Gtk::RESPONSE_OK) {
716 click_emphasis_chosen (sfdb.get_filename());
721 OptionEditor::click_emphasis_chosen (const string & path)
723 click_emphasis_path_entry.set_text (path);
724 click_emphasis_sound_changed ();
728 OptionEditor::click_sound_changed ()
731 string path = click_path_entry.get_text();
733 if (path == session->click_sound) {
737 if (path.length() == 0) {
739 session->set_click_sound ("");
743 strip_whitespace_edges (path);
745 if (path == _("internal")) {
746 session->set_click_sound ("");
748 session->set_click_sound (path);
755 OptionEditor::click_emphasis_sound_changed ()
758 string path = click_emphasis_path_entry.get_text();
760 if (path == session->click_emphasis_sound) {
764 if (path.length() == 0) {
766 session->set_click_emphasis_sound ("");
770 strip_whitespace_edges (path);
772 if (path == _("internal")) {
773 session->set_click_emphasis_sound ("");
775 session->set_click_emphasis_sound (path);
782 OptionEditor::native_format_chosen ()
790 bool use_bwf = (native_format_combo.get_active_text() == native_format_strings[0]);
792 if (use_bwf != Config->get_native_format_is_bwf()) {
793 Config->set_native_format_is_bwf (use_bwf);
794 session->reset_native_file_format ();
799 OptionEditor::clear_click_editor ()
801 if (click_io_selector) {
802 click_packer.remove (*click_io_selector);
803 click_packer.remove (*click_gpm);
804 delete click_io_selector;
806 click_io_selector = 0;
812 OptionEditor::setup_click_editor ()
815 HBox* hpacker = manage (new HBox);
817 click_path_entry.set_sensitive (true);
818 click_emphasis_path_entry.set_sensitive (true);
820 click_path_entry.set_name ("OptionsEntry");
821 click_emphasis_path_entry.set_name ("OptionsEntry");
823 click_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_sound_changed));
824 click_emphasis_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed));
826 click_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_sound_changed));
827 click_emphasis_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_emphasis_sound_changed));
829 click_browse_button.set_name ("EditorGTKButton");
830 click_emphasis_browse_button.set_name ("EditorGTKButton");
831 click_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_browse_clicked));
832 click_emphasis_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_emphasis_browse_clicked));
834 click_packer.set_border_width (12);
835 click_packer.set_spacing (5);
837 click_io_selector = new IOSelector (*session, session->click_io(), false);
838 click_gpm = new GainMeter (session->click_io(), *session);
840 click_table.set_col_spacings (10);
842 label = manage(new Label(_("Click audio file")));
843 label->set_name ("OptionsLabel");
844 click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
845 click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
846 click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL);
848 label = manage(new Label(_("Click emphasis audiofile")));
849 label->set_name ("OptionsLabel");
850 click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
851 click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
852 click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL);
854 hpacker->set_spacing (10);
855 hpacker->pack_start (*click_io_selector, false, false);
856 hpacker->pack_start (*click_gpm, false, false);
858 click_packer.pack_start (click_table, false, false);
859 click_packer.pack_start (*hpacker, false, false);
861 click_packer.show_all ();
865 OptionEditor::clear_auditioner_editor ()
867 if (auditioner_io_selector) {
868 audition_hpacker.remove (*auditioner_io_selector);
869 audition_hpacker.remove (*auditioner_gpm);
870 delete auditioner_io_selector;
871 delete auditioner_gpm;
872 auditioner_io_selector = 0;
878 OptionEditor::setup_auditioner_editor ()
880 audition_packer.set_border_width (12);
881 audition_packer.set_spacing (5);
882 audition_hpacker.set_spacing (10);
884 audition_label.set_name ("OptionEditorAuditionerLabel");
885 audition_label.set_text (_("The auditioner is a dedicated mixer strip used\n"
886 "for listening to specific regions outside the context\n"
887 "of the overall mix. It can be connected just like any\n"
888 "other mixer strip."));
890 audition_packer.pack_start (audition_label, false, false, 10);
891 audition_packer.pack_start (audition_hpacker, false, false);
895 OptionEditor::connect_audition_editor ()
897 auditioner_io_selector = new IOSelector (*session, session->the_auditioner(), false);
898 auditioner_gpm = new GainMeter (session->the_auditioner(), *session);
900 audition_hpacker.pack_start (*auditioner_io_selector, false, false);
901 audition_hpacker.pack_start (*auditioner_gpm, false, false);
903 auditioner_io_selector->show_all ();
904 auditioner_gpm->show_all ();
908 OptionEditor::focus_out_event_handler (GdkEventFocus* ev, void (OptionEditor::*pmf)())
914 static const struct {
918 { "Shift", GDK_SHIFT_MASK },
919 { "Control", GDK_CONTROL_MASK },
920 { "Alt (Mod1)", GDK_MOD1_MASK },
921 { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK },
922 { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK },
923 { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK },
924 { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
925 { "Mod2", GDK_MOD2_MASK },
926 { "Mod3", GDK_MOD3_MASK },
927 { "Mod4", GDK_MOD4_MASK },
928 { "Mod5", GDK_MOD5_MASK },
933 OptionEditor::setup_keyboard_options ()
938 keyboard_mouse_table.set_border_width (12);
939 keyboard_mouse_table.set_row_spacings (5);
940 keyboard_mouse_table.set_col_spacings (5);
942 /* internationalize and prepare for use with combos */
944 for (int i = 0; modifiers[i].name; ++i) {
945 dumb.push_back (_(modifiers[i].name));
948 set_popdown_strings (edit_modifier_combo, dumb);
949 edit_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::edit_modifier_chosen));
951 for (int x = 0; modifiers[x].name; ++x) {
952 if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
953 edit_modifier_combo.set_active_text (_(modifiers[x].name));
958 label = manage (new Label (_("Edit using")));
959 label->set_name ("OptionsLabel");
960 label->set_alignment (1.0, 0.5);
962 keyboard_mouse_table.attach (*label, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
963 keyboard_mouse_table.attach (edit_modifier_combo, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
965 label = manage (new Label (_("+ button")));
966 label->set_name ("OptionsLabel");
968 keyboard_mouse_table.attach (*label, 3, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
969 keyboard_mouse_table.attach (edit_button_spin, 4, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
971 edit_button_spin.set_name ("OptionsEntry");
972 edit_button_adjustment.set_value (Keyboard::edit_button());
973 edit_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::edit_button_changed));
975 set_popdown_strings (delete_modifier_combo, dumb);
976 delete_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::delete_modifier_chosen));
978 for (int x = 0; modifiers[x].name; ++x) {
979 if (modifiers[x].modifier == Keyboard::delete_modifier ()) {
980 delete_modifier_combo.set_active_text (_(modifiers[x].name));
985 label = manage (new Label (_("Delete using")));
986 label->set_name ("OptionsLabel");
987 label->set_alignment (1.0, 0.5);
989 keyboard_mouse_table.attach (*label, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
990 keyboard_mouse_table.attach (delete_modifier_combo, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
992 label = manage (new Label (_("+ button")));
993 label->set_name ("OptionsLabel");
995 keyboard_mouse_table.attach (*label, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
996 keyboard_mouse_table.attach (delete_button_spin, 4, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
998 delete_button_spin.set_name ("OptionsEntry");
999 delete_button_adjustment.set_value (Keyboard::delete_button());
1000 delete_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::delete_button_changed));
1002 set_popdown_strings (snap_modifier_combo, dumb);
1003 snap_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::snap_modifier_chosen));
1005 for (int x = 0; modifiers[x].name; ++x) {
1006 if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) {
1007 snap_modifier_combo.set_active_text (_(modifiers[x].name));
1012 label = manage (new Label (_("Ignore snap using")));
1013 label->set_name ("OptionsLabel");
1014 label->set_alignment (1.0, 0.5);
1016 keyboard_mouse_table.attach (*label, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
1017 keyboard_mouse_table.attach (snap_modifier_combo, 1, 2, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
1021 OptionEditor::edit_modifier_chosen ()
1025 txt = edit_modifier_combo.get_active_text();
1027 for (int i = 0; modifiers[i].name; ++i) {
1028 if (txt == _(modifiers[i].name)) {
1029 Keyboard::set_edit_modifier (modifiers[i].modifier);
1036 OptionEditor::delete_modifier_chosen ()
1040 txt = delete_modifier_combo.get_active_text();
1042 for (int i = 0; modifiers[i].name; ++i) {
1043 if (txt == _(modifiers[i].name)) {
1044 Keyboard::set_delete_modifier (modifiers[i].modifier);
1051 OptionEditor::snap_modifier_chosen ()
1055 txt = snap_modifier_combo.get_active_text();
1057 for (int i = 0; modifiers[i].name; ++i) {
1058 if (txt == _(modifiers[i].name)) {
1059 Keyboard::set_snap_modifier (modifiers[i].modifier);
1066 OptionEditor::delete_button_changed ()
1068 Keyboard::set_delete_button ((guint) delete_button_adjustment.get_value());
1072 OptionEditor::edit_button_changed ()
1074 Keyboard::set_edit_button ((guint) edit_button_adjustment.get_value());
1078 OptionEditor::fixup_combo_size (Gtk::ComboBoxText& combo, vector<string>& strings)
1080 /* find the widest string */
1082 string::size_type maxlen = 0;
1085 for (vector<string>::iterator i = strings.begin(); i != strings.end(); ++i) {
1086 string::size_type l;
1088 if ((l = (*i).length()) > maxlen) {
1094 /* try to include ascenders and descenders */
1096 if (maxstring.length() > 2) {
1101 const guint32 FUDGE = 10; // Combo's are stupid - they steal space from the entry for the button
1103 set_size_request_to_display_given_text (combo, maxstring.c_str(), 10 + FUDGE, 10);