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.
21 #include <pbd/whitespace.h>
23 #include <ardour/audio_library.h>
24 #include <ardour/session.h>
25 #include <ardour/audioengine.h>
26 #include <ardour/configuration.h>
27 #include <ardour/auditioner.h>
28 #include <ardour/destructive_filesource.h>
29 #include <ardour/crossfade.h>
30 #include <midi++/manager.h>
31 #include <gtkmm2ext/stop_signal.h>
32 #include <gtkmm2ext/utils.h>
34 #include "public_editor.h"
36 #include "ardour_ui.h"
37 #include "io_selector.h"
38 #include "gain_meter.h"
42 #include "option_editor.h"
46 using namespace ARDOUR;
49 using namespace Editing;
50 using namespace Gtkmm2ext;
53 static vector<string> positional_sync_strings;
55 OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui)
56 : Dialog ("option editor"),
67 short_xfade_adjustment (0, 1.0, 500.0, 5.0, 100.0),
68 short_xfade_slider (short_xfade_adjustment),
69 destructo_xfade_adjustment (1.0, 1.0, 500.0, 1.0, 100.0),
70 destructo_xfade_slider (destructo_xfade_adjustment),
74 smpte_offset_clock (X_("SMPTEOffsetClock"), true, true),
75 smpte_offset_negative_button (_("SMPTE offset is negative")),
82 click_browse_button (_("Browse")),
83 click_emphasis_browse_button (_("Browse")),
87 keyboard_mouse_table (3, 4),
88 delete_button_adjustment (3, 1, 5),
89 delete_button_spin (delete_button_adjustment),
90 edit_button_adjustment (3, 1, 5),
91 edit_button_spin (edit_button_adjustment)
94 using namespace Notebook_Helpers;
96 click_io_selector = 0;
97 auditioner_io_selector = 0;
100 set_default_size (300, 300);
101 set_title (_("ardour: options editor"));
102 set_wmclass (_("ardour_option_editor"), "Ardour");
104 set_name ("OptionsWindow");
105 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
107 VBox *vbox = get_vbox();
108 set_border_width (3);
110 vbox->set_spacing (4);
111 vbox->pack_start(notebook);
113 signal_delete_event().connect (mem_fun(*this, &OptionEditor::wm_close));
115 notebook.set_show_tabs (true);
116 notebook.set_show_border (true);
117 notebook.set_name ("OptionsNotebook");
119 setup_sync_options();
120 setup_path_options();
121 setup_fade_options ();
122 setup_keyboard_options ();
123 setup_auditioner_editor ();
125 notebook.pages().push_back (TabElem (sync_packer, _("Sync")));
126 notebook.pages().push_back (TabElem (path_table, _("Paths/Files")));
127 notebook.pages().push_back (TabElem (keyboard_mouse_table, _("Kbd/Mouse")));
128 notebook.pages().push_back (TabElem (click_packer, _("Click")));
129 notebook.pages().push_back (TabElem (audition_packer, _("Audition")));
130 notebook.pages().push_back (TabElem (fade_packer, _("Layers & Fades")));
132 if (!MIDI::Manager::instance()->get_midi_ports().empty()) {
133 setup_midi_options ();
134 notebook.pages().push_back (TabElem (midi_packer, _("MIDI")));
142 OptionEditor::set_session (Session *s)
144 clear_click_editor ();
145 clear_auditioner_editor ();
147 click_path_entry.set_text ("");
148 click_emphasis_path_entry.set_text ("");
149 session_raid_entry.set_text ("");
151 click_path_entry.set_sensitive (false);
152 click_emphasis_path_entry.set_sensitive (false);
153 session_raid_entry.set_sensitive (false);
155 smpte_fps_combo.set_sensitive (false);
156 short_xfade_slider.set_sensitive (false);
157 smpte_offset_negative_button.set_sensitive (false);
159 smpte_offset_clock.set_session (s);
161 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 ()
230 OptionEditor::setup_path_options()
234 path_table.set_homogeneous (false);
235 path_table.set_border_width (12);
236 path_table.set_row_spacings (5);
238 session_raid_entry.set_name ("OptionsEntry");
240 session_raid_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::raid_path_changed));
242 label = manage(new Label(_("session RAID path")));
243 label->set_name ("OptionsLabel");
244 path_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
245 path_table.attach (session_raid_entry, 1, 3, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
247 label = manage(new Label(_("Soundfile Search Paths")));
248 label->set_name("OptionsLabel");
249 path_table.attach(*label, 0, 1, 2, 3, FILL|EXPAND, FILL);
250 path_table.attach(sfdb_path_view, 1, 3, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
252 sfdb_path_view.set_paths(Library->get_paths());
253 sfdb_path_view.PathsUpdated.connect (mem_fun(*this, &OptionEditor::sfdb_paths_changed));
255 path_table.show_all();
259 OptionEditor::sfdb_paths_changed ()
261 Library->set_paths (sfdb_path_view.get_paths());
265 OptionEditor::add_session_paths ()
267 click_path_entry.set_sensitive (true);
268 click_emphasis_path_entry.set_sensitive (true);
269 session_raid_entry.set_sensitive (true);
271 if (session->click_sound.length() == 0) {
272 click_path_entry.set_text (_("internal"));
274 click_path_entry.set_text (session->click_sound);
277 if (session->click_emphasis_sound.length() == 0) {
278 click_emphasis_path_entry.set_text (_("internal"));
280 click_emphasis_path_entry.set_text (session->click_emphasis_sound);
283 session_raid_entry.set_text(session->raid_path());
287 OptionEditor::setup_fade_options ()
291 Label* label = manage (new Label (_("Short crossfade length (msecs)")));
292 label->set_name ("OptionsLabel");
294 hbox = manage (new HBox);
295 hbox->set_border_width (5);
296 hbox->set_spacing (10);
297 hbox->pack_start (*label, false, false);
298 hbox->pack_start (short_xfade_slider, true, true);
299 fade_packer.pack_start (*hbox, false, false);
301 short_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::short_xfade_adjustment_changed));
303 label = manage (new Label (_("Destructive crossfade length (msecs)")));
304 label->set_name ("OptionsLabel");
306 hbox = manage (new HBox);
307 hbox->set_border_width (5);
308 hbox->set_spacing (10);
309 hbox->pack_start (*label, false, false);
310 hbox->pack_start (destructo_xfade_slider, true, true);
311 fade_packer.pack_start (*hbox, false, false);
313 destructo_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::destructo_xfade_adjustment_changed));
315 short_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
316 destructo_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
318 destructo_xfade_adjustment.set_value (Config->get_destructive_xfade_msecs());
320 fade_packer.show_all ();
324 OptionEditor::short_xfade_adjustment_changed ()
327 float val = short_xfade_adjustment.get_value();
329 /* val is in msecs */
331 Crossfade::set_short_xfade_length ((jack_nframes_t) floor (session->frame_rate() * (val / 1000.0)));
336 OptionEditor::destructo_xfade_adjustment_changed ()
338 float val = destructo_xfade_adjustment.get_value();
340 /* val is in msecs */
342 Config->set_destructive_xfade_msecs ((uint32_t) floor (val));
345 DestructiveFileSource::setup_standard_crossfades (session->frame_rate());
350 OptionEditor::setup_sync_options ()
356 dumb.push_back (X_("24 FPS"));
357 dumb.push_back (X_("25 FPS"));
358 dumb.push_back (X_("30 FPS drop"));
359 dumb.push_back (X_("30 FPS non-drop"));
361 set_popdown_strings (smpte_fps_combo, dumb);
362 smpte_fps_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::smpte_fps_chosen));
364 smpte_offset_clock.set_mode (AudioClock::SMPTE);
365 smpte_offset_clock.ValueChanged.connect (mem_fun(*this, &OptionEditor::smpte_offset_chosen));
367 smpte_offset_negative_button.set_name ("OptionEditorToggleButton");
369 smpte_offset_negative_button.unset_flags (Gtk::CAN_FOCUS);
371 Label *smpte_fps_label = manage (new Label (_("SMPTE Frames/second")));
372 Label *smpte_offset_label = manage (new Label (_("SMPTE Offset")));
373 smpte_fps_label->set_name("OptionsLabel");
374 smpte_offset_label->set_name("OptionsLabel");
376 hbox = manage (new HBox);
377 hbox->set_border_width (5);
378 hbox->set_spacing (10);
379 hbox->pack_start (*smpte_fps_label, false, false);
380 hbox->pack_start (smpte_fps_combo, false, false);
382 sync_packer.pack_start (*hbox, false, false);
384 hbox = manage (new HBox);
385 hbox->set_border_width (5);
386 hbox->set_spacing (10);
387 hbox->pack_start (*smpte_offset_label, false, false);
388 hbox->pack_start (smpte_offset_clock, false, false);
389 hbox->pack_start (smpte_offset_negative_button, false, false);
391 sync_packer.pack_start (*hbox, false, false);
393 smpte_offset_negative_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::smpte_offset_negative_clicked));
397 OptionEditor::smpte_offset_negative_clicked ()
400 session->set_smpte_offset_negative (smpte_offset_negative_button.get_active());
405 OptionEditor::smpte_fps_chosen ()
408 string str = smpte_fps_combo.get_active_text();
410 if (str == X_("24 FPS")) {
411 session->set_smpte_type (24.0, false);
412 } else if (str == X_("25 FPS")) {
413 session->set_smpte_type (25.0, false);
414 } else if (str == X_("30 FPS drop")) {
415 session->set_smpte_type (29.97, true);
416 } else if (str == X_("30 FPS non-drop")) {
417 session->set_smpte_type (30.0, false);
423 OptionEditor::smpte_offset_chosen()
426 jack_nframes_t frames = smpte_offset_clock.current_duration();
427 session->set_smpte_offset (frames);
433 OptionEditor::setup_midi_options ()
436 MIDI::Manager::PortMap::const_iterator i;
437 const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports();
442 Gtk::Table* table = manage (new Table (ports.size() + 4, 9));
444 table->set_row_spacings (6);
445 table->set_col_spacings (10);
447 table->attach (*(manage (new Label (X_("Port")))), 0, 1, 0, 1);
448 table->attach (*(manage (new Label (X_("Offline")))), 1, 2, 0, 1);
449 table->attach (*(manage (new Label (X_("Trace\nInput")))), 2, 3, 0, 1);
450 table->attach (*(manage (new Label (X_("Trace\nOutput")))), 3, 4, 0, 1);
451 table->attach (*(manage (new Label (X_("MTC")))), 4, 5, 0, 1);
452 table->attach (*(manage (new Label (X_("MMC")))), 6, 7, 0, 1);
453 table->attach (*(manage (new Label (X_("MIDI Parameter\nControl")))), 8, 9, 0, 1);
455 table->attach (*(manage (new HSeparator())), 0, 9, 1, 2);
456 table->attach (*(manage (new VSeparator())), 5, 6, 0, 8);
457 table->attach (*(manage (new VSeparator())), 7, 8, 0, 8);
459 for (n = 0, i = ports.begin(); i != ports.end(); ++n, ++i) {
461 pair<MIDI::Port*,vector<RadioButton*> > newpair;
463 newpair.first = i->second;
465 table->attach (*(manage (new Label (i->first))), 0, 1, n+2, n+3,FILL|EXPAND, FILL );
466 tb = manage (new ToggleButton (_("online")));
467 tb->set_name ("OptionEditorToggleButton");
469 /* remember, we have to handle the i18n case where the relative
470 lengths of the strings in language N is different than in english.
473 if (strlen (_("offline")) > strlen (_("online"))) {
474 set_size_request_to_display_given_text (*tb, _("offline"), 15, 12);
476 set_size_request_to_display_given_text (*tb, _("online"), 15, 12);
479 tb->set_active (!(*i).second->input()->offline());
480 tb->signal_button_press_event().connect (bind (mem_fun(*this, &OptionEditor::port_online_toggled), (*i).second, tb));
481 (*i).second->input()->OfflineStatusChanged.connect (bind (mem_fun(*this, &OptionEditor::map_port_online), (*i).second, tb));
482 table->attach (*tb, 1, 2, n+2, n+3, FILL|EXPAND, FILL);
484 tb = manage (new ToggleButton ());
485 tb->set_name ("OptionEditorToggleButton");
486 tb->signal_button_press_event().connect (bind (mem_fun(*this, &OptionEditor::port_trace_in_toggled), (*i).second, tb));
487 tb->set_size_request (10, 10);
488 table->attach (*tb, 2, 3, n+2, n+3, FILL|EXPAND, FILL);
490 tb = manage (new ToggleButton ());
491 tb->set_name ("OptionEditorToggleButton");
492 tb->signal_button_press_event().connect (bind (mem_fun(*this, &OptionEditor::port_trace_out_toggled), (*i).second, tb));
493 tb->set_size_request (10, 10);
494 table->attach (*tb, 3, 4, n+2, n+3, FILL|EXPAND, FILL);
496 rb = manage (new RadioButton ());
497 newpair.second.push_back (rb);
498 rb->set_name ("OptionEditorToggleButton");
500 mtc_button_group = rb->get_group();
502 rb->set_group (mtc_button_group);
505 table->attach (*rb, 4, 5, n+2, n+3, FILL|EXPAND, FILL);
506 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mtc_port_chosen), (*i).second, rb));
508 if (Config->get_mtc_port_name() == i->first) {
509 rb->set_active (true);
512 rb = manage (new RadioButton ());
513 newpair.second.push_back (rb);
514 rb->set_name ("OptionEditorToggleButton");
516 mmc_button_group = rb->get_group();
518 rb->set_group (mmc_button_group);
520 table->attach (*rb, 6, 7, n+2, n+3, FILL|EXPAND, FILL);
521 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mmc_port_chosen), (*i).second, rb));
523 if (Config->get_mmc_port_name() == i->first) {
524 rb->set_active (true);
527 rb = manage (new RadioButton ());
528 newpair.second.push_back (rb);
529 rb->set_name ("OptionEditorToggleButton");
531 midi_button_group = rb->get_group();
533 rb->set_group (midi_button_group);
535 table->attach (*rb, 8, 9, n+2, n+3, FILL|EXPAND, FILL);
536 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_port_chosen), (*i).second, rb));
538 if (Config->get_midi_port_name() == i->first) {
539 rb->set_active (true);
542 port_toggle_buttons.insert (newpair);
547 hbox = manage (new HBox);
548 hbox->set_border_width (6);
549 hbox->pack_start (*table, true, false);
550 midi_packer.pack_start (*hbox, false, false);
554 OptionEditor::mtc_port_chosen (MIDI::Port *port, Gtk::RadioButton* rb)
557 if (rb->get_active()) {
558 cerr << "Activating MTC port " << port->name() << endl;
560 session->set_mtc_port (port->name());
561 Config->set_mtc_port_name (port->name());
563 session->set_mtc_port ("");
565 rb->set_active (true);
571 OptionEditor::mmc_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb)
574 if (rb->get_active()) {
575 cerr << "Activating MMC port " << port->name() << endl;
577 session->set_mmc_port (port->name());
578 Config->set_mtc_port_name (port->name());
580 session->set_mmc_port ("");
582 rb->set_active (true);
588 OptionEditor::midi_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb)
591 if (rb->get_active()) {
592 cerr << "Activating MIDI port " << port->name() << endl;
594 session->set_midi_port (port->name());
595 Config->set_midi_port_name (port->name());
597 session->set_midi_port ("");
599 rb->set_active (true);
605 OptionEditor::port_online_toggled (GdkEventButton* ev, MIDI::Port* port, ToggleButton* tb)
607 bool wanted = tb->get_active(); /* it hasn't changed at this point */
609 if (wanted != port->input()->offline()) {
610 port->input()->set_offline (wanted);
612 return stop_signal (*tb, "button_press_event");
616 OptionEditor::map_port_online (MIDI::Port* port, ToggleButton* tb)
618 if (port->input()->offline()) {
619 tb->set_label (_("offline"));
620 tb->set_active (false);
622 tb->set_label (_("online"));
623 tb->set_active (true);
628 OptionEditor::port_trace_in_toggled (GdkEventButton* ev, MIDI::Port* port, ToggleButton* tb)
630 /* XXX not very good MVC style here */
632 port->input()->trace (!tb->get_active(), &cerr, string (port->name()) + string (" input: "));
633 tb->set_active (!tb->get_active());
634 return stop_signal (*tb, "button_press_event");
638 OptionEditor::port_trace_out_toggled (GdkEventButton* ev,MIDI::Port* port, ToggleButton* tb)
640 /* XXX not very good MVC style here */
642 port->output()->trace (!tb->get_active(), &cerr, string (port->name()) + string (" output: "));
643 tb->set_active (!tb->get_active());
644 return stop_signal (*tb, "button_press_event");
648 OptionEditor::save ()
650 /* XXX a bit odd that we save the entire session state here */
656 OptionEditor::wm_close (GdkEventAny *ev)
664 OptionEditor::raid_path_changed ()
667 session->set_raid_path (session_raid_entry.get_text());
672 OptionEditor::click_browse_clicked ()
674 SoundFileChooser sfdb (_("Choose Click"), session);
676 int result = sfdb.run ();
678 if (result == Gtk::RESPONSE_OK) {
679 click_chosen(sfdb.get_filename());
684 OptionEditor::click_chosen (const string & path)
686 click_path_entry.set_text (path);
687 click_sound_changed ();
691 OptionEditor::click_emphasis_browse_clicked ()
693 SoundFileChooser sfdb (_("Choose Click Emphasis"), session);
695 int result = sfdb.run ();
697 if (result == Gtk::RESPONSE_OK) {
698 click_emphasis_chosen (sfdb.get_filename());
703 OptionEditor::click_emphasis_chosen (const string & path)
705 click_emphasis_path_entry.set_text (path);
706 click_emphasis_sound_changed ();
710 OptionEditor::click_sound_changed ()
713 string path = click_path_entry.get_text();
715 if (path == session->click_sound) {
719 if (path.length() == 0) {
721 session->set_click_sound ("");
725 strip_whitespace_edges (path);
727 if (path == _("internal")) {
728 session->set_click_sound ("");
730 session->set_click_sound (path);
737 OptionEditor::click_emphasis_sound_changed ()
740 string path = click_emphasis_path_entry.get_text();
742 if (path == session->click_emphasis_sound) {
746 if (path.length() == 0) {
748 session->set_click_emphasis_sound ("");
752 strip_whitespace_edges (path);
754 if (path == _("internal")) {
755 session->set_click_emphasis_sound ("");
757 session->set_click_emphasis_sound (path);
764 OptionEditor::clear_click_editor ()
766 if (click_io_selector) {
767 click_packer.remove (*click_io_selector);
768 click_packer.remove (*click_gpm);
769 delete click_io_selector;
771 click_io_selector = 0;
777 OptionEditor::setup_click_editor ()
780 HBox* hpacker = manage (new HBox);
782 click_path_entry.set_sensitive (true);
783 click_emphasis_path_entry.set_sensitive (true);
785 click_path_entry.set_name ("OptionsEntry");
786 click_emphasis_path_entry.set_name ("OptionsEntry");
788 click_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_sound_changed));
789 click_emphasis_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed));
791 click_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_sound_changed));
792 click_emphasis_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_emphasis_sound_changed));
794 click_browse_button.set_name ("EditorGTKButton");
795 click_emphasis_browse_button.set_name ("EditorGTKButton");
796 click_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_browse_clicked));
797 click_emphasis_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_emphasis_browse_clicked));
799 click_packer.set_border_width (12);
800 click_packer.set_spacing (5);
802 click_io_selector = new IOSelector (*session, session->click_io(), false);
803 click_gpm = new GainMeter (session->click_io(), *session);
805 click_table.set_col_spacings (10);
807 label = manage(new Label(_("Click audio file")));
808 label->set_name ("OptionsLabel");
809 click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
810 click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
811 click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL);
813 label = manage(new Label(_("Click emphasis audiofile")));
814 label->set_name ("OptionsLabel");
815 click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
816 click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
817 click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL);
819 hpacker->set_spacing (10);
820 hpacker->pack_start (*click_io_selector, false, false);
821 hpacker->pack_start (*click_gpm, false, false);
823 click_packer.pack_start (click_table, false, false);
824 click_packer.pack_start (*hpacker, false, false);
826 click_packer.show_all ();
830 OptionEditor::clear_auditioner_editor ()
832 if (auditioner_io_selector) {
833 audition_hpacker.remove (*auditioner_io_selector);
834 audition_hpacker.remove (*auditioner_gpm);
835 delete auditioner_io_selector;
836 delete auditioner_gpm;
837 auditioner_io_selector = 0;
843 OptionEditor::setup_auditioner_editor ()
845 audition_packer.set_border_width (12);
846 audition_packer.set_spacing (5);
847 audition_hpacker.set_spacing (10);
849 audition_label.set_name ("OptionEditorAuditionerLabel");
850 audition_label.set_text (_("The auditioner is a dedicated mixer strip used\n"
851 "for listening to specific regions outside the context\n"
852 "of the overall mix. It can be connected just like any\n"
853 "other mixer strip."));
855 audition_packer.pack_start (audition_label, false, false, 10);
856 audition_packer.pack_start (audition_hpacker, false, false);
860 OptionEditor::connect_audition_editor ()
862 auditioner_io_selector = new IOSelector (*session, session->the_auditioner(), false);
863 auditioner_gpm = new GainMeter (session->the_auditioner(), *session);
865 audition_hpacker.pack_start (*auditioner_io_selector, false, false);
866 audition_hpacker.pack_start (*auditioner_gpm, false, false);
868 auditioner_io_selector->show_all ();
869 auditioner_gpm->show_all ();
873 OptionEditor::focus_out_event_handler (GdkEventFocus* ev, void (OptionEditor::*pmf)())
879 static const struct {
883 { "Shift", GDK_SHIFT_MASK },
884 { "Control", GDK_CONTROL_MASK },
885 { "Alt (Mod1)", GDK_MOD1_MASK },
886 { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK },
887 { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK },
888 { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK },
889 { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
890 { "Mod2", GDK_MOD2_MASK },
891 { "Mod3", GDK_MOD3_MASK },
892 { "Mod4", GDK_MOD4_MASK },
893 { "Mod5", GDK_MOD5_MASK },
898 OptionEditor::setup_keyboard_options ()
903 keyboard_mouse_table.set_border_width (12);
904 keyboard_mouse_table.set_row_spacings (5);
905 keyboard_mouse_table.set_col_spacings (5);
907 /* internationalize and prepare for use with combos */
909 for (int i = 0; modifiers[i].name; ++i) {
910 dumb.push_back (_(modifiers[i].name));
913 set_popdown_strings (edit_modifier_combo, dumb);
914 edit_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::edit_modifier_chosen));
916 for (int x = 0; modifiers[x].name; ++x) {
917 if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
918 edit_modifier_combo.set_active_text (_(modifiers[x].name));
923 label = manage (new Label (_("Edit using")));
924 label->set_name ("OptionsLabel");
925 label->set_alignment (1.0, 0.5);
927 keyboard_mouse_table.attach (*label, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
928 keyboard_mouse_table.attach (edit_modifier_combo, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
930 label = manage (new Label (_("+ button")));
931 label->set_name ("OptionsLabel");
933 keyboard_mouse_table.attach (*label, 3, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
934 keyboard_mouse_table.attach (edit_button_spin, 4, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
936 edit_button_spin.set_name ("OptionsEntry");
937 edit_button_adjustment.set_value (Keyboard::edit_button());
938 edit_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::edit_button_changed));
940 set_popdown_strings (delete_modifier_combo, dumb);
941 delete_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::delete_modifier_chosen));
943 for (int x = 0; modifiers[x].name; ++x) {
944 if (modifiers[x].modifier == Keyboard::delete_modifier ()) {
945 delete_modifier_combo.set_active_text (_(modifiers[x].name));
950 label = manage (new Label (_("Delete using")));
951 label->set_name ("OptionsLabel");
952 label->set_alignment (1.0, 0.5);
954 keyboard_mouse_table.attach (*label, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
955 keyboard_mouse_table.attach (delete_modifier_combo, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
957 label = manage (new Label (_("+ button")));
958 label->set_name ("OptionsLabel");
960 keyboard_mouse_table.attach (*label, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
961 keyboard_mouse_table.attach (delete_button_spin, 4, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
963 delete_button_spin.set_name ("OptionsEntry");
964 delete_button_adjustment.set_value (Keyboard::delete_button());
965 delete_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::delete_button_changed));
967 set_popdown_strings (snap_modifier_combo, dumb);
968 snap_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::snap_modifier_chosen));
970 for (int x = 0; modifiers[x].name; ++x) {
971 if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) {
972 snap_modifier_combo.set_active_text (_(modifiers[x].name));
977 label = manage (new Label (_("Ignore snap using")));
978 label->set_name ("OptionsLabel");
979 label->set_alignment (1.0, 0.5);
981 keyboard_mouse_table.attach (*label, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
982 keyboard_mouse_table.attach (snap_modifier_combo, 1, 2, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
986 OptionEditor::edit_modifier_chosen ()
990 txt = edit_modifier_combo.get_active_text();
992 for (int i = 0; modifiers[i].name; ++i) {
993 if (txt == _(modifiers[i].name)) {
994 Keyboard::set_edit_modifier (modifiers[i].modifier);
1001 OptionEditor::delete_modifier_chosen ()
1005 txt = delete_modifier_combo.get_active_text();
1007 for (int i = 0; modifiers[i].name; ++i) {
1008 if (txt == _(modifiers[i].name)) {
1009 Keyboard::set_delete_modifier (modifiers[i].modifier);
1016 OptionEditor::snap_modifier_chosen ()
1020 txt = snap_modifier_combo.get_active_text();
1022 for (int i = 0; modifiers[i].name; ++i) {
1023 if (txt == _(modifiers[i].name)) {
1024 Keyboard::set_snap_modifier (modifiers[i].modifier);
1031 OptionEditor::delete_button_changed ()
1033 Keyboard::set_delete_button ((guint) delete_button_adjustment.get_value());
1037 OptionEditor::edit_button_changed ()
1039 Keyboard::set_edit_button ((guint) edit_button_adjustment.get_value());
1043 OptionEditor::fixup_combo_size (Gtk::ComboBoxText& combo, vector<string>& strings)
1045 /* find the widest string */
1047 string::size_type maxlen = 0;
1050 for (vector<string>::iterator i = strings.begin(); i != strings.end(); ++i) {
1051 string::size_type l;
1053 if ((l = (*i).length()) > maxlen) {
1059 /* try to include ascenders and descenders */
1061 if (maxstring.length() > 2) {
1066 const guint32 FUDGE = 10; // Combo's are stupid - they steal space from the entry for the button
1068 set_size_request_to_display_given_text (combo, maxstring.c_str(), 10 + FUDGE, 10);