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, 11),
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),
85 add_midi_port_button (_("Add new MIDI port")),
90 click_browse_button (_("Browse")),
91 click_emphasis_browse_button (_("Browse")),
95 keyboard_mouse_table (3, 4),
96 delete_button_adjustment (3, 1, 5),
97 delete_button_spin (delete_button_adjustment),
98 edit_button_adjustment (3, 1, 5),
99 edit_button_spin (edit_button_adjustment)
102 using namespace Notebook_Helpers;
104 click_io_selector = 0;
105 auditioner_io_selector = 0;
108 WindowTitle title(Glib::get_application_name());
109 title += _("Preferences");
110 set_title(title.get_string());
112 set_default_size (300, 300);
113 set_wmclass (X_("ardour_preferences"), "Ardour");
115 set_name ("Preferences");
116 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
118 VBox *vbox = get_vbox();
119 set_border_width (3);
121 vbox->set_spacing (4);
122 vbox->pack_start(notebook);
124 signal_delete_event().connect (mem_fun(*this, &OptionEditor::wm_close));
126 notebook.set_show_tabs (true);
127 notebook.set_show_border (true);
128 notebook.set_name ("OptionsNotebook");
130 setup_sync_options();
131 setup_path_options();
132 setup_fade_options ();
133 setup_keyboard_options ();
134 setup_auditioner_editor ();
136 notebook.pages().push_back (TabElem (sync_packer, _("Sync")));
137 notebook.pages().push_back (TabElem (path_table, _("Paths/Files")));
138 notebook.pages().push_back (TabElem (keyboard_mouse_table, _("Kbd/Mouse")));
139 notebook.pages().push_back (TabElem (click_packer, _("Click")));
140 notebook.pages().push_back (TabElem (audition_packer, _("Audition")));
141 notebook.pages().push_back (TabElem (fade_packer, _("Layers & Fades")));
143 setup_midi_options ();
144 notebook.pages().push_back (TabElem (midi_packer, _("MIDI")));
151 OptionEditor::set_session (Session *s)
153 clear_click_editor ();
154 clear_auditioner_editor ();
156 click_path_entry.set_text ("");
157 click_emphasis_path_entry.set_text ("");
158 session_raid_entry.set_text ("");
160 click_path_entry.set_sensitive (false);
161 click_emphasis_path_entry.set_sensitive (false);
162 session_raid_entry.set_sensitive (false);
164 short_xfade_slider.set_sensitive (false);
165 smpte_offset_negative_button.set_sensitive (false);
167 smpte_offset_clock.set_session (s);
169 if ((session = s) == 0) {
173 click_path_entry.set_sensitive (true);
174 click_emphasis_path_entry.set_sensitive (true);
175 session_raid_entry.set_sensitive (true);
176 short_xfade_slider.set_sensitive (true);
177 smpte_offset_negative_button.set_sensitive (true);
179 smpte_offset_clock.set_session (s);
180 smpte_offset_clock.set (s->smpte_offset (), true);
182 smpte_offset_negative_button.set_active (session->smpte_offset_negative());
184 redisplay_midi_ports ();
186 setup_click_editor ();
187 connect_audition_editor ();
189 short_xfade_adjustment.set_value ((Crossfade::short_xfade_length() / (float) session->frame_rate()) * 1000.0);
191 add_session_paths ();
194 OptionEditor::~OptionEditor ()
199 OptionEditor::setup_path_options()
203 path_table.set_homogeneous (false);
204 path_table.set_border_width (12);
205 path_table.set_row_spacings (5);
207 session_raid_entry.set_name ("OptionsEntry");
209 session_raid_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::raid_path_changed));
211 label = manage(new Label(_("session RAID path")));
212 label->set_name ("OptionsLabel");
213 path_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
214 path_table.attach (session_raid_entry, 1, 3, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
216 path_table.show_all();
220 OptionEditor::add_session_paths ()
222 click_path_entry.set_sensitive (true);
223 click_emphasis_path_entry.set_sensitive (true);
224 session_raid_entry.set_sensitive (true);
226 if (Config->get_click_sound().empty()) {
227 click_path_entry.set_text (_("internal"));
229 click_path_entry.set_text (Config->get_click_sound());
232 if (Config->get_click_emphasis_sound().empty()) {
233 click_emphasis_path_entry.set_text (_("internal"));
235 click_emphasis_path_entry.set_text (Config->get_click_emphasis_sound());
238 session_raid_entry.set_text(session->raid_path());
242 OptionEditor::setup_fade_options ()
246 Label* label = manage (new Label (_("Short crossfade length (msecs)")));
247 label->set_name ("OptionsLabel");
249 hbox = manage (new HBox);
250 hbox->set_border_width (5);
251 hbox->set_spacing (10);
252 hbox->pack_start (*label, false, false);
253 hbox->pack_start (short_xfade_slider, true, true);
254 fade_packer.pack_start (*hbox, false, false);
256 short_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::short_xfade_adjustment_changed));
258 label = manage (new Label (_("Destructive crossfade length (msecs)")));
259 label->set_name ("OptionsLabel");
261 hbox = manage (new HBox);
262 hbox->set_border_width (5);
263 hbox->set_spacing (10);
264 hbox->pack_start (*label, false, false);
265 hbox->pack_start (destructo_xfade_slider, true, true);
266 fade_packer.pack_start (*hbox, false, false);
268 destructo_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::destructo_xfade_adjustment_changed));
270 short_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
271 destructo_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
273 destructo_xfade_adjustment.set_value (Config->get_destructive_xfade_msecs());
275 fade_packer.show_all ();
279 OptionEditor::short_xfade_adjustment_changed ()
282 float val = short_xfade_adjustment.get_value();
284 /* val is in msecs */
286 Crossfade::set_short_xfade_length ((nframes_t) floor (session->frame_rate() * (val / 1000.0)));
291 OptionEditor::destructo_xfade_adjustment_changed ()
293 float val = destructo_xfade_adjustment.get_value();
295 /* val is in msecs */
298 Config->set_destructive_xfade_msecs ((uint32_t) floor (val));
301 SndFileSource::setup_standard_crossfades (session->frame_rate());
306 OptionEditor::setup_sync_options ()
311 smpte_offset_clock.set_mode (AudioClock::SMPTE);
312 smpte_offset_clock.ValueChanged.connect (mem_fun(*this, &OptionEditor::smpte_offset_chosen));
314 smpte_offset_negative_button.set_name ("OptionEditorToggleButton");
316 smpte_offset_negative_button.unset_flags (Gtk::CAN_FOCUS);
318 Label *smpte_offset_label = manage (new Label (_("SMPTE Offset")));
319 smpte_offset_label->set_name("OptionsLabel");
321 hbox = manage (new HBox);
322 hbox->set_border_width (5);
323 hbox->set_spacing (10);
324 hbox->pack_start (*smpte_offset_label, false, false);
325 hbox->pack_start (smpte_offset_clock, false, false);
326 hbox->pack_start (smpte_offset_negative_button, false, false);
328 sync_packer.pack_start (*hbox, false, false);
330 smpte_offset_negative_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::smpte_offset_negative_clicked));
334 OptionEditor::smpte_offset_negative_clicked ()
337 session->set_smpte_offset_negative (smpte_offset_negative_button.get_active());
342 OptionEditor::smpte_offset_chosen()
345 nframes_t frames = smpte_offset_clock.current_duration();
346 session->set_smpte_offset (frames);
352 OptionEditor::setup_midi_options ()
357 midi_port_table.set_row_spacings (6);
358 midi_port_table.set_col_spacings (10);
360 redisplay_midi_ports ();
362 mmc_receive_device_id_adjustment.set_value (Config->get_mmc_receive_device_id());
363 mmc_send_device_id_adjustment.set_value (Config->get_mmc_send_device_id());
365 mmc_receive_device_id_adjustment.signal_value_changed().connect (mem_fun (*this, &OptionEditor::mmc_receive_device_id_adjusted));
366 mmc_send_device_id_adjustment.signal_value_changed().connect (mem_fun (*this, &OptionEditor::mmc_send_device_id_adjusted));
368 hbox = manage (new HBox);
369 hbox->set_border_width (6);
370 hbox->pack_start (midi_port_table, true, false);
372 midi_packer.pack_start (*hbox, false, false);
373 midi_packer.pack_start (add_midi_port_button, false, false);
375 hbox = manage (new HBox);
376 hbox->set_border_width (6);
377 hbox->set_spacing (6);
378 label = (manage (new Label (_("Inbound MMC Device ID"))));
379 hbox->pack_start (mmc_receive_device_id_spinner, false, false);
380 hbox->pack_start (*label, false, false);
381 midi_packer.pack_start (*hbox, false, false);
383 mmc_receive_device_id_spinner.set_value(Config->get_mmc_receive_device_id ());
385 hbox = manage (new HBox);
386 hbox->set_border_width (6);
387 hbox->set_spacing (6);
388 label = (manage (new Label (_("Outbound MMC Device ID"))));
389 hbox->pack_start (mmc_send_device_id_spinner, false, false);
390 hbox->pack_start (*label, false, false);
391 midi_packer.pack_start (*hbox, false, false);
393 mmc_send_device_id_spinner.set_value(Config->get_mmc_send_device_id ());
395 add_midi_port_button.signal_clicked().connect (mem_fun (*this, &OptionEditor::add_midi_port));
399 OptionEditor::redisplay_midi_ports ()
401 MIDI::Manager::PortMap::const_iterator i;
402 const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports();
405 /* remove all existing widgets */
407 // XXX broken in gtkmm 2.10
408 // midi_port_table.clear ();
410 for (vector<Widget*>::iterator w = midi_port_table_widgets.begin(); w != midi_port_table_widgets.end(); ++w) {
411 midi_port_table.remove (**w);
414 midi_port_table_widgets.clear ();
416 midi_port_table.resize (ports.size() + 4, 11);
420 label = (manage (new Label (_("Port"))));
422 midi_port_table_widgets.push_back (label);
423 midi_port_table.attach (*label, 0, 1, 0, 1);
424 label = (manage (new Label (_("Offline"))));
426 midi_port_table_widgets.push_back (label);
427 midi_port_table.attach (*label, 1, 2, 0, 1);
428 label = (manage (new Label (_("Trace\nInput"))));
430 midi_port_table_widgets.push_back (label);
431 midi_port_table.attach (*label, 2, 3, 0, 1);
432 label = (manage (new Label (_("Trace\nOutput"))));
434 midi_port_table_widgets.push_back (label);
435 midi_port_table.attach (*label, 3, 4, 0, 1);
436 label = (manage (new Label (_("MTC"))));
438 midi_port_table_widgets.push_back (label);
439 midi_port_table.attach (*label, 4, 5, 0, 1);
440 label = (manage (new Label (_("MMC"))));
442 midi_port_table_widgets.push_back (label);
443 midi_port_table.attach (*label, 6, 7, 0, 1);
444 label = (manage (new Label (_("MIDI Parameter\nControl"))));
446 midi_port_table_widgets.push_back (label);
447 midi_port_table.attach (*label, 8, 9, 0, 1);
449 Gtk::HSeparator* hsep = (manage (new HSeparator()));
451 midi_port_table_widgets.push_back (hsep);
452 midi_port_table.attach (*hsep, 0, 9, 1, 2);
453 Gtk::VSeparator* vsep = (manage (new VSeparator()));
455 midi_port_table_widgets.push_back (vsep);
456 midi_port_table.attach (*vsep, 5, 6, 0, 8);
457 vsep = (manage (new VSeparator()));
459 midi_port_table_widgets.push_back (vsep);
460 midi_port_table.attach (*vsep, 7, 8, 0, 8);
462 for (n = 0, i = ports.begin(); i != ports.end(); ++n, ++i) {
468 /* the remove button. create early so we can pass it to various callbacks */
470 bb = manage (new Button (Stock::REMOVE));
471 bb->set_name ("OptionEditorToggleButton");
473 midi_port_table_widgets.push_back (bb);
474 midi_port_table.attach (*bb, 9, 10, n+2, n+3, FILL|EXPAND, FILL);
475 bb->signal_clicked().connect (bind (mem_fun(*this, &OptionEditor::remove_midi_port), i->second));
476 bb->set_sensitive (port_removable (i->second));
478 label = (manage (new Label (i->first)));
480 midi_port_table_widgets.push_back (label);
481 midi_port_table.attach (*label, 0, 1, n+2, n+3,FILL|EXPAND, FILL );
483 tb = manage (new ToggleButton (_("online")));
484 tb->set_name ("OptionEditorToggleButton");
486 /* remember, we have to handle the i18n case where the relative
487 lengths of the strings in language N is different than in english.
490 if (strlen (_("offline")) > strlen (_("online"))) {
491 set_size_request_to_display_given_text (*tb, _("offline"), 15, 12);
493 set_size_request_to_display_given_text (*tb, _("online"), 15, 12);
496 if (i->second->input()) {
497 tb->set_active (!i->second->input()->offline());
498 tb->signal_toggled().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));
502 midi_port_table_widgets.push_back (tb);
503 midi_port_table.attach (*tb, 1, 2, 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_in_toggled), (*i).second, tb));
508 tb->set_size_request (10, 10);
510 midi_port_table_widgets.push_back (tb);
511 midi_port_table.attach (*tb, 2, 3, n+2, n+3, FILL|EXPAND, FILL);
513 tb = manage (new ToggleButton ());
514 tb->set_name ("OptionEditorToggleButton");
515 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_out_toggled), (*i).second, tb));
516 tb->set_size_request (10, 10);
518 midi_port_table_widgets.push_back (tb);
519 midi_port_table.attach (*tb, 3, 4, n+2, n+3, FILL|EXPAND, FILL);
521 rb = manage (new RadioButton ());
522 rb->set_name ("OptionEditorToggleButton");
524 mtc_button_group = rb->get_group();
526 rb->set_group (mtc_button_group);
530 midi_port_table_widgets.push_back (rb);
531 midi_port_table.attach (*rb, 4, 5, n+2, n+3, FILL|EXPAND, FILL);
532 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mtc_port_chosen), (*i).second, rb, bb));
534 if (session && i->second == session->mtc_port()) {
535 rb->set_active (true);
538 rb = manage (new RadioButton ());
539 rb->set_name ("OptionEditorToggleButton");
541 mmc_button_group = rb->get_group();
543 rb->set_group (mmc_button_group);
546 midi_port_table_widgets.push_back (rb);
547 midi_port_table.attach (*rb, 6, 7, n+2, n+3, FILL|EXPAND, FILL);
548 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mmc_port_chosen), (*i).second, rb, bb));
550 if (session && i->second == session->mmc_port()) {
551 rb->set_active (true);
554 rb = manage (new RadioButton ());
555 rb->set_name ("OptionEditorToggleButton");
557 midi_button_group = rb->get_group();
559 rb->set_group (midi_button_group);
562 midi_port_table_widgets.push_back (rb);
563 midi_port_table.attach (*rb, 8, 9, n+2, n+3, FILL|EXPAND, FILL);
564 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_port_chosen), (*i).second, rb, bb));
566 if (session && i->second == session->midi_port()) {
567 rb->set_active (true);
572 midi_port_table.show();
576 OptionEditor::remove_midi_port (MIDI::Port* port)
578 MIDI::Manager::instance()->remove_port (port);
579 redisplay_midi_ports ();
583 OptionEditor::add_midi_port ()
585 MidiPortDialog dialog;
587 dialog.set_position (WIN_POS_MOUSE);
588 dialog.set_transient_for (*this);
592 int ret = dialog.run ();
595 case RESPONSE_ACCEPT:
602 Glib::ustring mode = dialog.port_mode_combo.get_active_text();
605 if (mode == _("input")) {
607 } else if (mode == (_("output"))) {
613 MIDI::PortRequest req (X_("ardour"),
614 dialog.port_name.get_text(),
616 MIDI::PortFactory::default_port_type());
618 if (MIDI::Manager::instance()->add_port (req) != 0) {
619 redisplay_midi_ports ();
624 OptionEditor::port_removable (MIDI::Port *port)
630 if (port == session->mtc_port() ||
631 port == session->mmc_port() ||
632 port == session->midi_port()) {
639 OptionEditor::mtc_port_chosen (MIDI::Port *port, Gtk::RadioButton* rb, Gtk::Button* bb)
642 if (rb->get_active()) {
643 session->set_mtc_port (port->name());
644 Config->set_mtc_port_name (port->name());
646 session->set_mtc_port ("");
648 bb->set_sensitive (port_removable (port));
653 OptionEditor::mmc_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb, Gtk::Button* bb)
656 if (rb->get_active()) {
657 session->set_mmc_port (port->name());
658 Config->set_mtc_port_name (port->name());
660 session->set_mmc_port ("");
662 bb->set_sensitive (port_removable (port));
667 OptionEditor::midi_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb, Gtk::Button* bb)
670 if (rb->get_active()) {
671 session->set_midi_port (port->name());
672 Config->set_midi_port_name (port->name());
674 session->set_midi_port ("");
676 bb->set_sensitive (port_removable (port));
681 OptionEditor::port_online_toggled (MIDI::Port* port, ToggleButton* tb)
683 bool wanted = tb->get_active();
686 if (wanted != port->input()->offline()) {
687 port->input()->set_offline (wanted);
693 OptionEditor::map_port_online (MIDI::Port* port, ToggleButton* tb)
695 bool bstate = tb->get_active ();
698 if (bstate != port->input()->offline()) {
699 if (port->input()->offline()) {
700 tb->set_label (_("offline"));
701 tb->set_active (false);
703 tb->set_label (_("online"));
704 tb->set_active (true);
711 OptionEditor::mmc_receive_device_id_adjusted ()
713 uint8_t id = (uint8_t) mmc_receive_device_id_spinner.get_value();
714 Config->set_mmc_receive_device_id (id);
718 OptionEditor::mmc_send_device_id_adjusted ()
720 uint8_t id = (uint8_t) mmc_send_device_id_spinner.get_value();
721 Config->set_mmc_send_device_id (id);
725 OptionEditor::port_trace_in_toggled (MIDI::Port* port, ToggleButton* tb)
727 bool trace = tb->get_active();
730 if (port->input()->tracing() != trace) {
731 port->input()->trace (trace, &cerr, string (port->name()) + string (" input: "));
737 OptionEditor::port_trace_out_toggled (MIDI::Port* port, ToggleButton* tb)
739 bool trace = tb->get_active();
741 if (port->output()) {
742 if (port->output()->tracing() != trace) {
743 port->output()->trace (trace, &cerr, string (port->name()) + string (" output: "));
749 OptionEditor::save ()
751 /* XXX a bit odd that we save the entire session state here */
757 OptionEditor::wm_close (GdkEventAny *ev)
765 OptionEditor::raid_path_changed ()
768 Config->set_raid_path (session_raid_entry.get_text());
773 OptionEditor::click_browse_clicked ()
775 // SoundFileChooser sfdb (_("Choose Click"), session);
777 //int result = sfdb.run ();
779 // if (result == Gtk::RESPONSE_OK) {
780 // click_chosen(sfdb.get_filename());
785 OptionEditor::click_chosen (const string & path)
787 click_path_entry.set_text (path);
788 click_sound_changed ();
792 OptionEditor::click_emphasis_browse_clicked ()
795 SoundFileChooser sfdb (_("Choose Click Emphasis"), session);
797 int result = sfdb.run ();
799 if (result == Gtk::RESPONSE_OK) {
800 click_emphasis_chosen (sfdb.get_filename());
806 OptionEditor::click_emphasis_chosen (const string & path)
808 click_emphasis_path_entry.set_text (path);
809 click_emphasis_sound_changed ();
813 OptionEditor::click_sound_changed ()
816 string path = click_path_entry.get_text();
818 if (path == Config->get_click_sound()) {
822 strip_whitespace_edges (path);
824 if (path == _("internal")) {
825 Config->set_click_sound ("");
827 Config->set_click_sound (path);
833 OptionEditor::click_emphasis_sound_changed ()
836 string path = click_emphasis_path_entry.get_text();
838 if (path == Config->get_click_emphasis_sound()) {
842 strip_whitespace_edges (path);
844 if (path == _("internal")) {
845 Config->set_click_emphasis_sound ("");
847 Config->set_click_emphasis_sound (path);
853 OptionEditor::clear_click_editor ()
855 if (click_io_selector) {
856 click_packer.remove (*click_io_selector);
857 click_packer.remove (*click_gpm);
858 delete click_io_selector;
860 click_io_selector = 0;
866 OptionEditor::setup_click_editor ()
869 HBox* hpacker = manage (new HBox);
871 click_path_entry.set_sensitive (true);
872 click_emphasis_path_entry.set_sensitive (true);
874 click_path_entry.set_name ("OptionsEntry");
875 click_emphasis_path_entry.set_name ("OptionsEntry");
877 click_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_sound_changed));
878 click_emphasis_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed));
880 click_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_sound_changed));
881 click_emphasis_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_emphasis_sound_changed));
883 click_browse_button.set_name ("EditorGTKButton");
884 click_emphasis_browse_button.set_name ("EditorGTKButton");
885 click_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_browse_clicked));
886 click_emphasis_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_emphasis_browse_clicked));
888 click_packer.set_border_width (12);
889 click_packer.set_spacing (5);
891 click_io_selector = new IOSelector (*session, session->click_io(), false);
892 click_gpm = new GainMeter (session->click_io(), *session);
894 click_table.set_col_spacings (10);
896 label = manage(new Label(_("Click audio file")));
897 label->set_name ("OptionsLabel");
898 click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
899 click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
900 click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL);
902 label = manage(new Label(_("Click emphasis audiofile")));
903 label->set_name ("OptionsLabel");
904 click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
905 click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
906 click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL);
908 hpacker->set_spacing (10);
909 hpacker->pack_start (*click_io_selector, false, false);
910 hpacker->pack_start (*click_gpm, false, false);
912 click_packer.pack_start (click_table, false, false);
913 click_packer.pack_start (*hpacker, false, false);
915 click_packer.show_all ();
919 OptionEditor::clear_auditioner_editor ()
921 if (auditioner_io_selector) {
922 audition_hpacker.remove (*auditioner_io_selector);
923 audition_hpacker.remove (*auditioner_gpm);
924 delete auditioner_io_selector;
925 delete auditioner_gpm;
926 auditioner_io_selector = 0;
932 OptionEditor::setup_auditioner_editor ()
934 audition_packer.set_border_width (12);
935 audition_packer.set_spacing (5);
936 audition_hpacker.set_spacing (10);
938 audition_label.set_name ("OptionEditorAuditionerLabel");
939 audition_label.set_text (_("The auditioner is a dedicated mixer strip used\n"
940 "for listening to specific regions outside the context\n"
941 "of the overall mix. It can be connected just like any\n"
942 "other mixer strip."));
944 audition_packer.pack_start (audition_label, false, false, 10);
945 audition_packer.pack_start (audition_hpacker, false, false);
949 OptionEditor::connect_audition_editor ()
951 auditioner_io_selector = new IOSelector (*session, session->the_auditioner(), false);
952 auditioner_gpm = new GainMeter (session->the_auditioner(), *session);
954 audition_hpacker.pack_start (*auditioner_io_selector, false, false);
955 audition_hpacker.pack_start (*auditioner_gpm, false, false);
957 auditioner_io_selector->show_all ();
958 auditioner_gpm->show_all ();
962 OptionEditor::focus_out_event_handler (GdkEventFocus* ev, void (OptionEditor::*pmf)())
968 static const struct {
972 { "Shift", GDK_SHIFT_MASK },
973 { "Control", GDK_CONTROL_MASK },
974 { "Alt (Mod1)", GDK_MOD1_MASK },
975 { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK },
976 { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK },
977 { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK },
978 { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
979 { "Mod2", GDK_MOD2_MASK },
980 { "Mod3", GDK_MOD3_MASK },
981 { "Mod4", GDK_MOD4_MASK },
982 { "Mod5", GDK_MOD5_MASK },
987 OptionEditor::setup_keyboard_options ()
992 keyboard_mouse_table.set_border_width (12);
993 keyboard_mouse_table.set_row_spacings (5);
994 keyboard_mouse_table.set_col_spacings (5);
996 /* internationalize and prepare for use with combos */
998 for (int i = 0; modifiers[i].name; ++i) {
999 dumb.push_back (_(modifiers[i].name));
1002 set_popdown_strings (edit_modifier_combo, dumb);
1003 edit_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::edit_modifier_chosen));
1005 for (int x = 0; modifiers[x].name; ++x) {
1006 if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
1007 edit_modifier_combo.set_active_text (_(modifiers[x].name));
1012 label = manage (new Label (_("Edit using")));
1013 label->set_name ("OptionsLabel");
1014 label->set_alignment (1.0, 0.5);
1016 keyboard_mouse_table.attach (*label, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1017 keyboard_mouse_table.attach (edit_modifier_combo, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1019 label = manage (new Label (_("+ button")));
1020 label->set_name ("OptionsLabel");
1022 keyboard_mouse_table.attach (*label, 3, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1023 keyboard_mouse_table.attach (edit_button_spin, 4, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
1025 edit_button_spin.set_name ("OptionsEntry");
1026 edit_button_adjustment.set_value (Keyboard::edit_button());
1027 edit_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::edit_button_changed));
1029 set_popdown_strings (delete_modifier_combo, dumb);
1030 delete_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::delete_modifier_chosen));
1032 for (int x = 0; modifiers[x].name; ++x) {
1033 if (modifiers[x].modifier == Keyboard::delete_modifier ()) {
1034 delete_modifier_combo.set_active_text (_(modifiers[x].name));
1039 label = manage (new Label (_("Delete using")));
1040 label->set_name ("OptionsLabel");
1041 label->set_alignment (1.0, 0.5);
1043 keyboard_mouse_table.attach (*label, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1044 keyboard_mouse_table.attach (delete_modifier_combo, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1046 label = manage (new Label (_("+ button")));
1047 label->set_name ("OptionsLabel");
1049 keyboard_mouse_table.attach (*label, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1050 keyboard_mouse_table.attach (delete_button_spin, 4, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
1052 delete_button_spin.set_name ("OptionsEntry");
1053 delete_button_adjustment.set_value (Keyboard::delete_button());
1054 delete_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::delete_button_changed));
1056 set_popdown_strings (snap_modifier_combo, dumb);
1057 snap_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::snap_modifier_chosen));
1059 for (int x = 0; modifiers[x].name; ++x) {
1060 if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) {
1061 snap_modifier_combo.set_active_text (_(modifiers[x].name));
1066 label = manage (new Label (_("Ignore snap using")));
1067 label->set_name ("OptionsLabel");
1068 label->set_alignment (1.0, 0.5);
1070 keyboard_mouse_table.attach (*label, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
1071 keyboard_mouse_table.attach (snap_modifier_combo, 1, 2, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
1075 OptionEditor::edit_modifier_chosen ()
1079 txt = edit_modifier_combo.get_active_text();
1081 for (int i = 0; modifiers[i].name; ++i) {
1082 if (txt == _(modifiers[i].name)) {
1083 Keyboard::set_edit_modifier (modifiers[i].modifier);
1090 OptionEditor::delete_modifier_chosen ()
1094 txt = delete_modifier_combo.get_active_text();
1096 for (int i = 0; modifiers[i].name; ++i) {
1097 if (txt == _(modifiers[i].name)) {
1098 Keyboard::set_delete_modifier (modifiers[i].modifier);
1105 OptionEditor::snap_modifier_chosen ()
1109 txt = snap_modifier_combo.get_active_text();
1111 for (int i = 0; modifiers[i].name; ++i) {
1112 if (txt == _(modifiers[i].name)) {
1113 Keyboard::set_snap_modifier (modifiers[i].modifier);
1120 OptionEditor::delete_button_changed ()
1122 Keyboard::set_delete_button ((guint) delete_button_adjustment.get_value());
1126 OptionEditor::edit_button_changed ()
1128 Keyboard::set_edit_button ((guint) edit_button_adjustment.get_value());
1132 OptionEditor::fixup_combo_size (Gtk::ComboBoxText& combo, vector<string>& strings)
1134 /* find the widest string */
1136 string::size_type maxlen = 0;
1139 for (vector<string>::iterator i = strings.begin(); i != strings.end(); ++i) {
1140 string::size_type l;
1142 if ((l = (*i).length()) > maxlen) {
1148 /* try to include ascenders and descenders */
1150 if (maxstring.length() > 2) {
1155 const guint32 FUDGE = 10; // Combo's are stupid - they steal space from the entry for the button
1157 set_size_request_to_display_given_text (combo, maxstring.c_str(), 10 + FUDGE, 10);