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.
19 #include <pango/pangoft2.h> // for fontmap resolution control for GnomeCanvas
20 #include <pango/pangocairo.h> // for fontmap resolution control for GnomeCanvas
22 #include <pbd/whitespace.h>
24 #include <ardour/ardour.h>
25 #include <ardour/session.h>
26 #include <ardour/audioengine.h>
27 #include <ardour/configuration.h>
28 #include <ardour/auditioner.h>
29 #include <ardour/sndfilesource.h>
30 #include <ardour/crossfade.h>
31 #include <ardour/profile.h>
32 #include <midi++/manager.h>
33 #include <midi++/factory.h>
34 #include <gtkmm2ext/stop_signal.h>
35 #include <gtkmm2ext/utils.h>
36 #include <gtkmm2ext/window_title.h>
38 #include "public_editor.h"
41 #include "ardour_ui.h"
42 #include "io_selector.h"
43 #include "gain_meter.h"
47 #include "option_editor.h"
48 #include "midi_port_dialog.h"
49 #include "gui_thread.h"
54 using namespace ARDOUR
;
57 using namespace Editing
;
58 using namespace Gtkmm2ext
;
61 static vector
<string
> positional_sync_strings
;
63 OptionEditor::OptionEditor (ARDOUR_UI
& uip
, PublicEditor
& ed
, Mixer_UI
& mixui
)
64 : ArdourDialog ("options editor", false),
74 short_xfade_adjustment (0, 1.0, 500.0, 5.0, 100.0),
75 short_xfade_slider (short_xfade_adjustment
),
76 destructo_xfade_adjustment (1.0, 1.0, 500.0, 1.0, 100.0),
77 destructo_xfade_slider (destructo_xfade_adjustment
),
78 history_depth (20, -1, 100, 1.0, 10.0),
79 saved_history_depth (20, 0, 100, 1.0, 10.0),
80 history_depth_spinner (history_depth
),
81 saved_history_depth_spinner (saved_history_depth
),
82 limit_history_button (_("Limit undo history")),
83 save_history_button (_("Save undo history")),
87 smpte_offset_clock (X_("smpteoffset"), false, X_("SMPTEOffsetClock"), true, true),
88 smpte_offset_negative_button (_("SMPTE offset is negative")),
89 synced_timecode_button (_("Timecode source is sample-clock synced")),
93 midi_port_table (4, 11),
94 mmc_receive_device_id_adjustment (0.0, 0.0, (double) 0x7f, 1.0, 16.0),
95 mmc_receive_device_id_spinner (mmc_receive_device_id_adjustment
),
96 mmc_send_device_id_adjustment (0.0, 0.0, (double) 0x7f, 1.0, 16.0),
97 mmc_send_device_id_spinner (mmc_send_device_id_adjustment
),
98 add_midi_port_button (_("Add new MIDI port")),
99 initial_program_change_adjustment (0.0, -1.0, (double) 0x7f, 1.0, 16.0),
100 initial_program_change_spinner (initial_program_change_adjustment
),
105 click_browse_button (_("Browse")),
106 click_emphasis_browse_button (_("Browse")),
110 keyboard_mouse_table (4, 4),
111 delete_button_adjustment (3, 1, 5),
112 delete_button_spin (delete_button_adjustment
),
113 edit_button_adjustment (3, 1, 5),
114 edit_button_spin (edit_button_adjustment
)
117 using namespace Notebook_Helpers
;
119 first_click_setup
= true;
120 click_io_selector
= 0;
121 auditioner_io_selector
= 0;
124 set_title(_("Preferences"));
126 set_default_size (300, 300);
127 set_wmclass (X_("ardour_preferences"), PROGRAM_NAME
);
129 set_name ("Preferences");
130 add_events (Gdk::KEY_PRESS_MASK
|Gdk::KEY_RELEASE_MASK
);
132 VBox
*vbox
= get_vbox();
133 set_border_width (3);
135 vbox
->set_spacing (4);
136 vbox
->pack_start(notebook
);
138 signal_delete_event().connect (mem_fun(*this, &OptionEditor::wm_close
));
140 notebook
.set_show_tabs (true);
141 notebook
.set_show_border (true);
142 notebook
.set_name ("OptionsNotebook");
144 setup_sync_options();
145 setup_path_options();
146 setup_misc_options ();
147 setup_keyboard_options ();
148 setup_auditioner_editor ();
150 if (!Profile
->get_sae()) {
151 notebook
.pages().push_back (TabElem (sync_packer
, _("Sync")));
152 notebook
.pages().push_back (TabElem (path_table
, _("Paths/Files")));
153 notebook
.pages().push_back (TabElem (keyboard_mouse_table
, _("Kbd/Mouse")));
155 notebook
.pages().push_back (TabElem (click_packer
, _("Click")));
156 notebook
.pages().push_back (TabElem (audition_packer
, _("Audition")));
157 notebook
.pages().push_back (TabElem (misc_packer
, _("Misc")));
159 setup_midi_options ();
160 notebook
.pages().push_back (TabElem (midi_packer
, _("MIDI")));
165 Config
->map_parameters (mem_fun (*this, &OptionEditor::parameter_changed
));
166 Config
->ParameterChanged
.connect (mem_fun (*this, &OptionEditor::parameter_changed
));
170 OptionEditor::set_session (Session
*s
)
172 clear_click_editor ();
173 clear_auditioner_editor ();
175 click_path_entry
.set_text ("");
176 click_emphasis_path_entry
.set_text ("");
177 session_raid_entry
.set_text ("");
179 click_path_entry
.set_sensitive (false);
180 click_emphasis_path_entry
.set_sensitive (false);
181 session_raid_entry
.set_sensitive (false);
183 short_xfade_slider
.set_sensitive (false);
184 smpte_offset_negative_button
.set_sensitive (false);
186 smpte_offset_clock
.set_session (s
);
188 if ((session
= s
) == 0) {
192 click_path_entry
.set_sensitive (true);
193 click_emphasis_path_entry
.set_sensitive (true);
194 session_raid_entry
.set_sensitive (true);
195 short_xfade_slider
.set_sensitive (true);
196 smpte_offset_negative_button
.set_sensitive (true);
198 smpte_offset_clock
.set_session (s
);
199 smpte_offset_clock
.set (s
->smpte_offset (), true);
201 smpte_offset_negative_button
.set_active (session
->smpte_offset_negative());
203 redisplay_midi_ports ();
205 setup_click_editor ();
206 connect_audition_editor ();
208 short_xfade_adjustment
.set_value ((Crossfade::short_xfade_length() / (float) session
->frame_rate()) * 1000.0);
210 add_session_paths ();
213 OptionEditor::~OptionEditor ()
218 OptionEditor::setup_path_options()
222 path_table
.set_homogeneous (false);
223 path_table
.set_border_width (12);
224 path_table
.set_row_spacings (5);
226 session_raid_entry
.set_name ("OptionsEntry");
228 session_raid_entry
.signal_activate().connect (mem_fun(*this, &OptionEditor::raid_path_changed
));
230 label
= manage(new Label(_("session RAID path")));
231 label
->set_name ("OptionsLabel");
232 path_table
.attach (*label
, 0, 1, 0, 1, FILL
|EXPAND
, FILL
);
233 path_table
.attach (session_raid_entry
, 1, 3, 0, 1, Gtk::FILL
|Gtk::EXPAND
, FILL
);
235 path_table
.show_all();
239 OptionEditor::add_session_paths ()
241 click_path_entry
.set_sensitive (true);
242 click_emphasis_path_entry
.set_sensitive (true);
243 session_raid_entry
.set_sensitive (true);
245 if (Config
->get_click_sound().empty()) {
246 click_path_entry
.set_text (_("internal"));
248 click_path_entry
.set_text (Config
->get_click_sound());
251 if (Config
->get_click_emphasis_sound().empty()) {
252 click_emphasis_path_entry
.set_text (_("internal"));
254 click_emphasis_path_entry
.set_text (Config
->get_click_emphasis_sound());
257 session_raid_entry
.set_text(session
->raid_path());
262 font_scale_changed (Gtk::Adjustment
* adj
)
264 Config
->set_font_scale((long)floor (adj
->get_value() * 1024));
270 OptionEditor::setup_misc_options ()
276 /* font scaling does nothing with GDK/Quartz */
278 Gtk::Adjustment
* dpi_adj
= new Gtk::Adjustment ((double)Config
->get_font_scale() / 1024, 50, 250, 1, 10);
279 Gtk::HScale
* dpi_range
= new Gtk::HScale (*dpi_adj
);
281 label
= manage (new Label (_("Font Scaling")));
282 label
->set_name ("OptionsLabel");
284 dpi_range
->set_update_policy (Gtk::UPDATE_DISCONTINUOUS
);
285 dpi_adj
->signal_value_changed().connect (bind (sigc::ptr_fun (font_scale_changed
), dpi_adj
));
287 hbox
= manage (new HBox
);
288 hbox
->set_border_width (5);
289 hbox
->set_spacing (10);
290 hbox
->pack_start (*label
, false, false);
291 hbox
->pack_start (*dpi_range
, true, true);
292 misc_packer
.pack_start (*hbox
, false, false);
295 label
= manage (new Label (_("Short crossfade length (msecs)")));
296 label
->set_name ("OptionsLabel");
298 hbox
= manage (new HBox
);
299 hbox
->set_border_width (5);
300 hbox
->set_spacing (10);
301 hbox
->pack_start (*label
, false, false);
302 hbox
->pack_start (short_xfade_slider
, true, true);
303 misc_packer
.pack_start (*hbox
, false, false);
305 short_xfade_adjustment
.signal_value_changed().connect (mem_fun(*this, &OptionEditor::short_xfade_adjustment_changed
));
307 label
= manage (new Label (_("Destructive crossfade length (msecs)")));
308 label
->set_name ("OptionsLabel");
310 hbox
= manage (new HBox
);
311 hbox
->set_border_width (5);
312 hbox
->set_spacing (10);
313 hbox
->pack_start (*label
, false, false);
314 hbox
->pack_start (destructo_xfade_slider
, true, true);
315 misc_packer
.pack_start (*hbox
, false, false);
318 destructo_xfade_adjustment
.signal_value_changed().connect (mem_fun(*this, &OptionEditor::destructo_xfade_adjustment_changed
));
320 hbox
= manage (new HBox
);
321 hbox
->set_border_width (5);
322 hbox
->set_spacing (10);
323 hbox
->pack_start (limit_history_button
, false, false);
324 misc_packer
.pack_start (*hbox
, false, false);
326 label
= manage (new Label (_("History depth (commands)")));
327 label
->set_name ("OptionsLabel");
329 hbox
= manage (new HBox
);
330 hbox
->set_border_width (5);
331 hbox
->set_spacing (10);
332 hbox
->pack_start (*label
, false, false);
333 hbox
->pack_start (history_depth_spinner
, false, false);
334 misc_packer
.pack_start (*hbox
, false, false);
336 history_depth
.signal_value_changed().connect (mem_fun (*this, &OptionEditor::history_depth_changed
));
337 saved_history_depth
.signal_value_changed().connect (mem_fun (*this, &OptionEditor::saved_history_depth_changed
));
338 save_history_button
.signal_toggled().connect (mem_fun (*this, &OptionEditor::save_history_toggled
));
339 limit_history_button
.signal_toggled().connect (mem_fun (*this, &OptionEditor::limit_history_toggled
));
341 hbox
= manage (new HBox
);
342 hbox
->set_border_width (5);
343 hbox
->set_spacing (10);
344 hbox
->pack_start (save_history_button
, false, false);
345 misc_packer
.pack_start (*hbox
, false, false);
347 label
= manage (new Label (_("Saved history depth (commands)")));
348 label
->set_name ("OptionsLabel");
350 hbox
= manage (new HBox
);
351 hbox
->set_border_width (5);
352 hbox
->set_spacing (10);
353 hbox
->pack_start (*label
, false, false);
354 hbox
->pack_start (saved_history_depth_spinner
, false, false);
355 misc_packer
.pack_start (*hbox
, false, false);
357 short_xfade_slider
.set_update_policy (UPDATE_DISCONTINUOUS
);
358 destructo_xfade_slider
.set_update_policy (UPDATE_DISCONTINUOUS
);
360 destructo_xfade_adjustment
.set_value (Config
->get_destructive_xfade_msecs());
362 misc_packer
.show_all ();
366 OptionEditor::limit_history_toggled ()
368 bool x
= limit_history_button
.get_active();
371 Config
->set_history_depth (0);
372 history_depth_spinner
.set_sensitive (false);
374 if (Config
->get_history_depth() == 0) {
375 /* get back to a sane default */
376 Config
->set_history_depth (20);
378 history_depth_spinner
.set_sensitive (true);
383 OptionEditor::save_history_toggled ()
385 bool x
= save_history_button
.get_active();
387 if (x
!= Config
->get_save_history()) {
388 Config
->set_save_history (x
);
389 saved_history_depth_spinner
.set_sensitive (x
);
394 OptionEditor::history_depth_changed()
396 Config
->set_history_depth ((int32_t) floor (history_depth
.get_value()));
400 OptionEditor::saved_history_depth_changed()
402 Config
->set_saved_history_depth ((int32_t) floor (saved_history_depth
.get_value()));
406 OptionEditor::short_xfade_adjustment_changed ()
409 float val
= short_xfade_adjustment
.get_value();
411 /* val is in msecs */
413 Crossfade::set_short_xfade_length ((nframes_t
) floor (session
->frame_rate() * (val
/ 1000.0)));
418 OptionEditor::destructo_xfade_adjustment_changed ()
420 float val
= destructo_xfade_adjustment
.get_value();
422 /* val is in msecs */
425 Config
->set_destructive_xfade_msecs ((uint32_t) floor (val
));
428 SndFileSource::setup_standard_crossfades (session
->frame_rate());
433 OptionEditor::setup_sync_options ()
438 smpte_offset_clock
.set_mode (AudioClock::SMPTE
);
439 smpte_offset_clock
.ValueChanged
.connect (mem_fun(*this, &OptionEditor::smpte_offset_chosen
));
441 smpte_offset_negative_button
.set_name ("OptionEditorToggleButton");
443 smpte_offset_negative_button
.unset_flags (Gtk::CAN_FOCUS
);
445 Label
*smpte_offset_label
= manage (new Label (_("SMPTE Offset")));
446 smpte_offset_label
->set_name("OptionsLabel");
448 hbox
= manage (new HBox
);
449 hbox
->set_border_width (5);
450 hbox
->set_spacing (10);
451 hbox
->pack_start (*smpte_offset_label
, false, false);
452 hbox
->pack_start (smpte_offset_clock
, false, false);
453 hbox
->pack_start (smpte_offset_negative_button
, false, false);
455 sync_packer
.pack_start (*hbox
, false, false);
456 sync_packer
.pack_start (synced_timecode_button
, false, false);
458 smpte_offset_negative_button
.signal_clicked().connect (mem_fun(*this, &OptionEditor::smpte_offset_negative_clicked
));
459 synced_timecode_button
.signal_toggled().connect (mem_fun(*this, &OptionEditor::synced_timecode_toggled
));
463 OptionEditor::smpte_offset_negative_clicked ()
466 session
->set_smpte_offset_negative (smpte_offset_negative_button
.get_active());
471 OptionEditor::synced_timecode_toggled ()
475 if ((x
= synced_timecode_button
.get_active()) != Config
->get_timecode_source_is_synced()) {
476 Config
->set_timecode_source_is_synced (x
);
477 Config
->save_state();
482 OptionEditor::smpte_offset_chosen()
485 nframes_t frames
= smpte_offset_clock
.current_duration();
486 session
->set_smpte_offset (frames
);
492 OptionEditor::setup_midi_options ()
497 midi_port_table
.set_row_spacings (6);
498 midi_port_table
.set_col_spacings (10);
500 redisplay_midi_ports ();
502 mmc_receive_device_id_adjustment
.set_value (Config
->get_mmc_receive_device_id());
503 mmc_send_device_id_adjustment
.set_value (Config
->get_mmc_send_device_id());
505 mmc_receive_device_id_adjustment
.signal_value_changed().connect (mem_fun (*this, &OptionEditor::mmc_receive_device_id_adjusted
));
506 mmc_send_device_id_adjustment
.signal_value_changed().connect (mem_fun (*this, &OptionEditor::mmc_send_device_id_adjusted
));
508 hbox
= manage (new HBox
);
509 hbox
->set_border_width (6);
510 hbox
->pack_start (midi_port_table
, true, false);
512 midi_packer
.pack_start (*hbox
, false, false);
513 midi_packer
.pack_start (add_midi_port_button
, false, false);
515 hbox
= manage (new HBox
);
516 hbox
->set_border_width (6);
517 hbox
->set_spacing (6);
518 label
= (manage (new Label (_("Inbound MMC Device ID"))));
519 hbox
->pack_start (mmc_receive_device_id_spinner
, false, false);
520 hbox
->pack_start (*label
, false, false);
521 midi_packer
.pack_start (*hbox
, false, false);
523 mmc_receive_device_id_spinner
.set_value(Config
->get_mmc_receive_device_id ());
525 hbox
= manage (new HBox
);
526 hbox
->set_border_width (6);
527 hbox
->set_spacing (6);
528 label
= (manage (new Label (_("Outbound MMC Device ID"))));
529 hbox
->pack_start (mmc_send_device_id_spinner
, false, false);
530 hbox
->pack_start (*label
, false, false);
531 midi_packer
.pack_start (*hbox
, false, false);
533 mmc_send_device_id_spinner
.set_value(Config
->get_mmc_send_device_id ());
535 hbox
= manage (new HBox
);
536 hbox
->set_border_width (6);
537 hbox
->set_spacing (6);
538 label
= (manage (new Label (_("Startup program change"))));
539 hbox
->pack_start (initial_program_change_spinner
, false, false);
540 hbox
->pack_start (*label
, false, false);
541 midi_packer
.pack_start (*hbox
, false, false);
543 initial_program_change_spinner
.set_value (Config
->get_initial_program_change());
544 initial_program_change_adjustment
.signal_value_changed().connect (mem_fun (*this, &OptionEditor::initial_program_change_adjusted
));
546 add_midi_port_button
.signal_clicked().connect (mem_fun (*this, &OptionEditor::add_midi_port
));
550 OptionEditor::initial_program_change_adjusted ()
552 Config
->set_initial_program_change (((int32_t) floor (initial_program_change_adjustment
.get_value())) & 0x7f);
556 OptionEditor::redisplay_midi_ports ()
558 MIDI::Manager::PortMap::const_iterator i
;
559 const MIDI::Manager::PortMap
& ports
= MIDI::Manager::instance()->get_midi_ports();
562 /* remove all existing widgets */
564 // XXX broken in gtkmm 2.10
565 // midi_port_table.clear ();
567 for (vector
<Widget
*>::iterator w
= midi_port_table_widgets
.begin(); w
!= midi_port_table_widgets
.end(); ++w
) {
568 midi_port_table
.remove (**w
);
571 midi_port_table_widgets
.clear ();
573 midi_port_table
.resize (ports
.size() + 4, 11);
577 label
= (manage (new Label (_("Port"))));
579 midi_port_table_widgets
.push_back (label
);
580 midi_port_table
.attach (*label
, 0, 1, 0, 1);
581 label
= (manage (new Label (_("Offline"))));
583 midi_port_table_widgets
.push_back (label
);
584 midi_port_table
.attach (*label
, 1, 2, 0, 1);
585 label
= (manage (new Label (_("Trace\nInput"))));
587 midi_port_table_widgets
.push_back (label
);
588 midi_port_table
.attach (*label
, 2, 3, 0, 1);
589 label
= (manage (new Label (_("Trace\nOutput"))));
591 midi_port_table_widgets
.push_back (label
);
592 midi_port_table
.attach (*label
, 3, 4, 0, 1);
593 label
= (manage (new Label (_("MTC"))));
595 midi_port_table_widgets
.push_back (label
);
596 midi_port_table
.attach (*label
, 4, 5, 0, 1);
597 label
= (manage (new Label (_("MMC"))));
599 midi_port_table_widgets
.push_back (label
);
600 midi_port_table
.attach (*label
, 6, 7, 0, 1);
601 label
= (manage (new Label (_("MIDI Parameter\nControl"))));
603 midi_port_table_widgets
.push_back (label
);
604 midi_port_table
.attach (*label
, 8, 9, 0, 1);
606 Gtk::HSeparator
* hsep
= (manage (new HSeparator()));
608 midi_port_table_widgets
.push_back (hsep
);
609 midi_port_table
.attach (*hsep
, 0, 9, 1, 2);
610 Gtk::VSeparator
* vsep
= (manage (new VSeparator()));
612 midi_port_table_widgets
.push_back (vsep
);
613 midi_port_table
.attach (*vsep
, 5, 6, 0, 8);
614 vsep
= (manage (new VSeparator()));
616 midi_port_table_widgets
.push_back (vsep
);
617 midi_port_table
.attach (*vsep
, 7, 8, 0, 8);
619 for (n
= 0, i
= ports
.begin(); i
!= ports
.end(); ++n
, ++i
) {
625 /* the remove button. create early so we can pass it to various callbacks */
627 bb
= manage (new Button (Stock::REMOVE
));
628 bb
->set_name ("OptionEditorToggleButton");
630 midi_port_table_widgets
.push_back (bb
);
631 midi_port_table
.attach (*bb
, 9, 10, n
+2, n
+3, FILL
|EXPAND
, FILL
);
632 bb
->signal_clicked().connect (bind (mem_fun(*this, &OptionEditor::remove_midi_port
), i
->second
));
633 bb
->set_sensitive (port_removable (i
->second
));
635 label
= (manage (new Label (i
->first
)));
637 midi_port_table_widgets
.push_back (label
);
638 midi_port_table
.attach (*label
, 0, 1, n
+2, n
+3,FILL
|EXPAND
, FILL
);
640 tb
= manage (new ToggleButton (_("online")));
641 tb
->set_name ("OptionEditorToggleButton");
643 /* remember, we have to handle the i18n case where the relative
644 lengths of the strings in language N is different than in english.
647 if (strlen (_("offline")) > strlen (_("online"))) {
648 set_size_request_to_display_given_text (*tb
, _("offline"), 15, 12);
650 set_size_request_to_display_given_text (*tb
, _("online"), 15, 12);
653 if (i
->second
->input()) {
654 tb
->set_active (!i
->second
->input()->offline());
655 tb
->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_online_toggled
), i
->second
, tb
));
656 i
->second
->input()->OfflineStatusChanged
.connect (bind (mem_fun(*this, &OptionEditor::map_port_online
), (*i
).second
, tb
));
659 midi_port_table_widgets
.push_back (tb
);
660 midi_port_table
.attach (*tb
, 1, 2, n
+2, n
+3, FILL
|EXPAND
, FILL
);
662 tb
= manage (new ToggleButton ());
663 tb
->set_name ("OptionEditorToggleButton");
664 tb
->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_in_toggled
), (*i
).second
, tb
));
665 tb
->set_size_request (10, 10);
667 midi_port_table_widgets
.push_back (tb
);
668 midi_port_table
.attach (*tb
, 2, 3, n
+2, n
+3, FILL
|EXPAND
, FILL
);
670 tb
= manage (new ToggleButton ());
671 tb
->set_name ("OptionEditorToggleButton");
672 tb
->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_out_toggled
), (*i
).second
, tb
));
673 tb
->set_size_request (10, 10);
675 midi_port_table_widgets
.push_back (tb
);
676 midi_port_table
.attach (*tb
, 3, 4, n
+2, n
+3, FILL
|EXPAND
, FILL
);
678 rb
= manage (new RadioButton ());
679 rb
->set_name ("OptionEditorToggleButton");
681 mtc_button_group
= rb
->get_group();
683 rb
->set_group (mtc_button_group
);
687 midi_port_table_widgets
.push_back (rb
);
688 midi_port_table
.attach (*rb
, 4, 5, n
+2, n
+3, FILL
|EXPAND
, FILL
);
689 rb
->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mtc_port_chosen
), (*i
).second
, rb
, bb
));
691 if (session
&& i
->second
== session
->mtc_port()) {
692 rb
->set_active (true);
695 rb
= manage (new RadioButton ());
696 rb
->set_name ("OptionEditorToggleButton");
698 mmc_button_group
= rb
->get_group();
700 rb
->set_group (mmc_button_group
);
703 midi_port_table_widgets
.push_back (rb
);
704 midi_port_table
.attach (*rb
, 6, 7, n
+2, n
+3, FILL
|EXPAND
, FILL
);
705 rb
->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mmc_port_chosen
), (*i
).second
, rb
, bb
));
707 if (session
&& i
->second
== session
->mmc_port()) {
708 rb
->set_active (true);
711 rb
= manage (new RadioButton ());
712 rb
->set_name ("OptionEditorToggleButton");
714 midi_button_group
= rb
->get_group();
716 rb
->set_group (midi_button_group
);
719 midi_port_table_widgets
.push_back (rb
);
720 midi_port_table
.attach (*rb
, 8, 9, n
+2, n
+3, FILL
|EXPAND
, FILL
);
721 rb
->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_port_chosen
), (*i
).second
, rb
, bb
));
723 if (session
&& i
->second
== session
->midi_port()) {
724 rb
->set_active (true);
729 midi_port_table
.show();
733 OptionEditor::remove_midi_port (MIDI::Port
* port
)
735 MIDI::Manager::instance()->remove_port (port
);
736 redisplay_midi_ports ();
740 OptionEditor::add_midi_port ()
742 MidiPortDialog dialog
;
744 dialog
.set_position (WIN_POS_MOUSE
);
745 dialog
.set_transient_for (*this);
749 int ret
= dialog
.run ();
752 case RESPONSE_ACCEPT
:
759 Glib::ustring mode
= dialog
.port_mode_combo
.get_active_text();
762 if (mode
== _("input")) {
764 } else if (mode
== (_("output"))) {
771 XMLNode
node (X_("MIDI-port"));
773 node
.add_property ("tag", dialog
.port_name
.get_text());
774 node
.add_property ("device", X_("ardour")); // XXX this can't be right for all types
775 node
.add_property ("type", MIDI::PortFactory::default_port_type());
776 node
.add_property ("mode", smod
);
778 if (MIDI::Manager::instance()->add_port (node
) != 0) {
779 redisplay_midi_ports ();
784 OptionEditor::port_removable (MIDI::Port
*port
)
790 if (port
== session
->mtc_port() ||
791 port
== session
->mmc_port() ||
792 port
== session
->midi_port()) {
799 OptionEditor::mtc_port_chosen (MIDI::Port
*port
, Gtk::RadioButton
* rb
, Gtk::Button
* bb
)
802 if (rb
->get_active()) {
803 session
->set_mtc_port (port
->name());
804 Config
->set_mtc_port_name (port
->name());
806 session
->set_mtc_port ("");
808 bb
->set_sensitive (port_removable (port
));
813 OptionEditor::mmc_port_chosen (MIDI::Port
* port
, Gtk::RadioButton
* rb
, Gtk::Button
* bb
)
816 if (rb
->get_active()) {
817 session
->set_mmc_port (port
->name());
818 Config
->set_mtc_port_name (port
->name());
820 session
->set_mmc_port ("");
822 bb
->set_sensitive (port_removable (port
));
827 OptionEditor::midi_port_chosen (MIDI::Port
* port
, Gtk::RadioButton
* rb
, Gtk::Button
* bb
)
830 if (rb
->get_active()) {
831 session
->set_midi_port (port
->name());
832 Config
->set_midi_port_name (port
->name());
834 session
->set_midi_port ("");
836 bb
->set_sensitive (port_removable (port
));
841 OptionEditor::port_online_toggled (MIDI::Port
* port
, ToggleButton
* tb
)
843 bool wanted
= tb
->get_active();
846 if (wanted
!= port
->input()->offline()) {
847 port
->input()->set_offline (wanted
);
853 OptionEditor::map_port_online (MIDI::Port
* port
, ToggleButton
* tb
)
855 bool bstate
= tb
->get_active ();
858 if (bstate
!= port
->input()->offline()) {
859 if (port
->input()->offline()) {
860 tb
->set_label (_("offline"));
861 tb
->set_active (false);
863 tb
->set_label (_("online"));
864 tb
->set_active (true);
871 OptionEditor::mmc_receive_device_id_adjusted ()
873 uint8_t id
= (uint8_t) mmc_receive_device_id_spinner
.get_value();
874 Config
->set_mmc_receive_device_id (id
);
878 OptionEditor::mmc_send_device_id_adjusted ()
880 uint8_t id
= (uint8_t) mmc_send_device_id_spinner
.get_value();
881 Config
->set_mmc_send_device_id (id
);
885 OptionEditor::port_trace_in_toggled (MIDI::Port
* port
, ToggleButton
* tb
)
887 bool trace
= tb
->get_active();
890 if (port
->input()->tracing() != trace
) {
891 port
->input()->trace (trace
, &cerr
, string (port
->name()) + string (" input: "));
897 OptionEditor::port_trace_out_toggled (MIDI::Port
* port
, ToggleButton
* tb
)
899 bool trace
= tb
->get_active();
901 if (port
->output()) {
902 if (port
->output()->tracing() != trace
) {
903 port
->output()->trace (trace
, &cerr
, string (port
->name()) + string (" output: "));
909 OptionEditor::save ()
911 /* XXX a bit odd that we save the entire session state here */
917 OptionEditor::wm_close (GdkEventAny
*ev
)
925 OptionEditor::raid_path_changed ()
928 Config
->set_raid_path (session_raid_entry
.get_text());
933 OptionEditor::click_browse_clicked ()
935 SoundFileChooser
sfdb (*this, _("Choose Click"), session
);
940 int result
= sfdb
.run ();
942 if (result
== Gtk::RESPONSE_OK
) {
943 click_chosen(sfdb
.get_filename());
948 OptionEditor::click_chosen (const string
& path
)
950 click_path_entry
.set_text (path
);
951 click_sound_changed ();
955 OptionEditor::click_emphasis_browse_clicked ()
957 SoundFileChooser
sfdb (*this, _("Choose Click Emphasis"), session
);
962 int result
= sfdb
.run ();
964 if (result
== Gtk::RESPONSE_OK
) {
965 click_emphasis_chosen (sfdb
.get_filename());
970 OptionEditor::click_emphasis_chosen (const string
& path
)
972 click_emphasis_path_entry
.set_text (path
);
973 click_emphasis_sound_changed ();
977 OptionEditor::click_sound_changed ()
980 string path
= click_path_entry
.get_text();
982 if (path
== Config
->get_click_sound()) {
986 strip_whitespace_edges (path
);
988 if (path
== _("internal")) {
989 Config
->set_click_sound ("");
991 Config
->set_click_sound (path
);
997 OptionEditor::click_emphasis_sound_changed ()
1000 string path
= click_emphasis_path_entry
.get_text();
1002 if (path
== Config
->get_click_emphasis_sound()) {
1006 strip_whitespace_edges (path
);
1008 if (path
== _("internal")) {
1009 Config
->set_click_emphasis_sound ("");
1011 Config
->set_click_emphasis_sound (path
);
1017 OptionEditor::clear_click_editor ()
1019 if (click_io_selector
) {
1020 click_hpacker
.remove (*click_io_selector
);
1021 click_hpacker
.remove (*click_gpm
);
1022 delete click_io_selector
;
1024 click_io_selector
= 0;
1030 OptionEditor::setup_click_editor ()
1034 if (first_click_setup
) {
1036 click_path_entry
.set_name ("OptionsEntry");
1037 click_emphasis_path_entry
.set_name ("OptionsEntry");
1039 click_path_entry
.signal_activate().connect (mem_fun(*this, &OptionEditor::click_sound_changed
));
1040 click_emphasis_path_entry
.signal_activate().connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed
));
1042 click_path_entry
.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler
), &OptionEditor::click_sound_changed
));
1043 click_emphasis_path_entry
.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler
), &OptionEditor::click_emphasis_sound_changed
));
1045 click_browse_button
.set_name ("EditorGTKButton");
1046 click_emphasis_browse_button
.set_name ("EditorGTKButton");
1048 click_browse_button
.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_browse_clicked
));
1049 click_emphasis_browse_button
.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_emphasis_browse_clicked
));
1051 click_packer
.set_border_width (12);
1052 click_packer
.set_spacing (5);
1054 click_table
.set_col_spacings (10);
1056 label
= manage(new Label(_("Click audio file")));
1057 label
->set_name ("OptionsLabel");
1058 click_table
.attach (*label
, 0, 1, 0, 1, FILL
|EXPAND
, FILL
);
1059 click_table
.attach (click_path_entry
, 1, 2, 0, 1, Gtk::FILL
|Gtk::EXPAND
, FILL
);
1060 click_table
.attach (click_browse_button
, 2, 3, 0, 1, FILL
|EXPAND
, FILL
);
1062 label
= manage(new Label(_("Click emphasis audiofile")));
1063 label
->set_name ("OptionsLabel");
1064 click_table
.attach (*label
, 0, 1, 1, 2, FILL
|EXPAND
, FILL
);
1065 click_table
.attach (click_emphasis_path_entry
, 1, 2, 1, 2, Gtk::FILL
|Gtk::EXPAND
, FILL
);
1066 click_table
.attach (click_emphasis_browse_button
, 2, 3, 1, 2, FILL
|EXPAND
, FILL
);
1068 click_packer
.pack_start (click_table
, false, false);
1069 click_packer
.pack_start (click_hpacker
, false, false);
1072 click_hpacker
.set_spacing (10);
1074 first_click_setup
= false;
1077 click_path_entry
.set_sensitive (true);
1078 click_emphasis_path_entry
.set_sensitive (true);
1080 click_io_selector
= new IOSelector (*session
, session
->click_io(), false);
1081 click_gpm
= new GainMeter (*session
);
1082 click_gpm
->set_io (session
->click_io());
1084 click_hpacker
.pack_start (*click_io_selector
, false, false);
1085 click_hpacker
.pack_start (*click_gpm
, false, false);
1087 click_packer
.show_all ();
1091 OptionEditor::clear_auditioner_editor ()
1093 if (auditioner_io_selector
) {
1094 audition_hpacker
.remove (*auditioner_io_selector
);
1095 audition_hpacker
.remove (*auditioner_gpm
);
1096 delete auditioner_io_selector
;
1097 delete auditioner_gpm
;
1098 auditioner_io_selector
= 0;
1104 OptionEditor::setup_auditioner_editor ()
1106 audition_packer
.set_border_width (12);
1107 audition_packer
.set_spacing (5);
1108 audition_hpacker
.set_spacing (10);
1110 audition_label
.set_name ("OptionEditorAuditionerLabel");
1111 audition_label
.set_text (_("The auditioner is a dedicated mixer strip used\n"
1112 "for listening to specific regions outside the context\n"
1113 "of the overall mix. It can be connected just like any\n"
1114 "other mixer strip."));
1116 audition_packer
.pack_start (audition_label
, false, false, 10);
1117 audition_packer
.pack_start (audition_hpacker
, false, false);
1121 OptionEditor::connect_audition_editor ()
1123 auditioner_io_selector
= new IOSelector (*session
, session
->the_auditioner(), false);
1124 auditioner_gpm
= new GainMeter (*session
);
1125 auditioner_gpm
->set_io (session
->the_auditioner());
1127 audition_hpacker
.pack_start (*auditioner_io_selector
, false, false);
1128 audition_hpacker
.pack_start (*auditioner_gpm
, false, false);
1130 auditioner_io_selector
->show_all ();
1131 auditioner_gpm
->show_all ();
1135 OptionEditor::focus_out_event_handler (GdkEventFocus
* ev
, void (OptionEditor::*pmf
)())
1141 static const struct {
1152 { "Shift", GDK_SHIFT_MASK
},
1153 { "Command", GDK_META_MASK
},
1154 { "Control", GDK_CONTROL_MASK
},
1155 { "Option", GDK_MOD1_MASK
},
1156 { "Command-Shift", GDK_MOD1_MASK
|GDK_SHIFT_MASK
},
1157 { "Command-Option", GDK_MOD1_MASK
|GDK_MOD5_MASK
},
1158 { "Shift-Option", GDK_SHIFT_MASK
|GDK_MOD5_MASK
},
1159 { "Shift-Command-Option", GDK_MOD5_MASK
|GDK_SHIFT_MASK
|GDK_MOD1_MASK
},
1162 { "Shift", GDK_SHIFT_MASK
},
1163 { "Control", GDK_CONTROL_MASK
},
1164 { "Alt (Mod1)", GDK_MOD1_MASK
},
1165 { "Control-Shift", GDK_CONTROL_MASK
|GDK_SHIFT_MASK
},
1166 { "Control-Alt", GDK_CONTROL_MASK
|GDK_MOD1_MASK
},
1167 { "Shift-Alt", GDK_SHIFT_MASK
|GDK_MOD1_MASK
},
1168 { "Control-Shift-Alt", GDK_CONTROL_MASK
|GDK_SHIFT_MASK
|GDK_MOD1_MASK
},
1169 { "Mod2", GDK_MOD2_MASK
},
1170 { "Mod3", GDK_MOD3_MASK
},
1171 { "Mod4", GDK_MOD4_MASK
},
1172 { "Mod5", GDK_MOD5_MASK
},
1178 OptionEditor::setup_keyboard_options ()
1180 vector
<string
> dumb
;
1183 keyboard_mouse_table
.set_border_width (12);
1184 keyboard_mouse_table
.set_row_spacings (5);
1185 keyboard_mouse_table
.set_col_spacings (5);
1187 /* internationalize and prepare for use with combos */
1189 for (int i
= 0; modifiers
[i
].name
; ++i
) {
1190 dumb
.push_back (_(modifiers
[i
].name
));
1193 set_popdown_strings (edit_modifier_combo
, dumb
);
1194 edit_modifier_combo
.signal_changed().connect (mem_fun(*this, &OptionEditor::edit_modifier_chosen
));
1196 for (int x
= 0; modifiers
[x
].name
; ++x
) {
1197 if (modifiers
[x
].modifier
== Keyboard::edit_modifier ()) {
1198 edit_modifier_combo
.set_active_text (_(modifiers
[x
].name
));
1203 label
= manage (new Label (_("Edit using")));
1204 label
->set_name ("OptionsLabel");
1205 label
->set_alignment (1.0, 0.5);
1207 keyboard_mouse_table
.attach (*label
, 0, 1, 0, 1, Gtk::FILL
|Gtk::EXPAND
, FILL
);
1208 keyboard_mouse_table
.attach (edit_modifier_combo
, 1, 2, 0, 1, Gtk::FILL
|Gtk::EXPAND
, FILL
);
1210 label
= manage (new Label (_("+ button")));
1211 label
->set_name ("OptionsLabel");
1213 keyboard_mouse_table
.attach (*label
, 3, 4, 0, 1, Gtk::FILL
|Gtk::EXPAND
, FILL
);
1214 keyboard_mouse_table
.attach (edit_button_spin
, 4, 5, 0, 1, Gtk::FILL
|Gtk::EXPAND
, FILL
);
1216 edit_button_spin
.set_name ("OptionsEntry");
1217 edit_button_adjustment
.set_value (Keyboard::edit_button());
1218 edit_button_adjustment
.signal_value_changed().connect (mem_fun(*this, &OptionEditor::edit_button_changed
));
1220 set_popdown_strings (delete_modifier_combo
, dumb
);
1221 delete_modifier_combo
.signal_changed().connect (mem_fun(*this, &OptionEditor::delete_modifier_chosen
));
1223 for (int x
= 0; modifiers
[x
].name
; ++x
) {
1224 if (modifiers
[x
].modifier
== Keyboard::delete_modifier ()) {
1225 delete_modifier_combo
.set_active_text (_(modifiers
[x
].name
));
1230 label
= manage (new Label (_("Delete using")));
1231 label
->set_name ("OptionsLabel");
1232 label
->set_alignment (1.0, 0.5);
1234 keyboard_mouse_table
.attach (*label
, 0, 1, 1, 2, Gtk::FILL
|Gtk::EXPAND
, FILL
);
1235 keyboard_mouse_table
.attach (delete_modifier_combo
, 1, 2, 1, 2, Gtk::FILL
|Gtk::EXPAND
, FILL
);
1237 label
= manage (new Label (_("+ button")));
1238 label
->set_name ("OptionsLabel");
1240 keyboard_mouse_table
.attach (*label
, 3, 4, 1, 2, Gtk::FILL
|Gtk::EXPAND
, FILL
);
1241 keyboard_mouse_table
.attach (delete_button_spin
, 4, 5, 1, 2, Gtk::FILL
|Gtk::EXPAND
, FILL
);
1243 delete_button_spin
.set_name ("OptionsEntry");
1244 delete_button_adjustment
.set_value (Keyboard::delete_button());
1245 delete_button_adjustment
.signal_value_changed().connect (mem_fun(*this, &OptionEditor::delete_button_changed
));
1247 set_popdown_strings (snap_modifier_combo
, dumb
);
1248 snap_modifier_combo
.signal_changed().connect (mem_fun(*this, &OptionEditor::snap_modifier_chosen
));
1250 for (int x
= 0; modifiers
[x
].name
; ++x
) {
1251 if (modifiers
[x
].modifier
== (guint
) Keyboard::snap_modifier ()) {
1252 snap_modifier_combo
.set_active_text (_(modifiers
[x
].name
));
1257 label
= manage (new Label (_("Ignore snap using")));
1258 label
->set_name ("OptionsLabel");
1259 label
->set_alignment (1.0, 0.5);
1261 keyboard_mouse_table
.attach (*label
, 0, 1, 2, 3, Gtk::FILL
|Gtk::EXPAND
, FILL
);
1262 keyboard_mouse_table
.attach (snap_modifier_combo
, 1, 2, 2, 3, Gtk::FILL
|Gtk::EXPAND
, FILL
);
1264 vector
<string
> strs
;
1266 for (std::map
<std::string
,std::string
>::iterator bf
= Keyboard::binding_files
.begin(); bf
!= Keyboard::binding_files
.end(); ++bf
) {
1267 strs
.push_back (bf
->first
);
1270 set_popdown_strings (keyboard_layout_selector
, strs
);
1271 keyboard_layout_selector
.set_active_text (Keyboard::current_binding_name());
1272 keyboard_layout_selector
.signal_changed().connect (mem_fun (*this, &OptionEditor::bindings_changed
));
1274 label
= manage (new Label (_("Keyboard layout")));
1275 label
->set_name ("OptionsLabel");
1276 label
->set_alignment (1.0, 0.5);
1278 keyboard_mouse_table
.attach (*label
, 0, 1, 3, 4, Gtk::FILL
|Gtk::EXPAND
, FILL
);
1279 keyboard_mouse_table
.attach (keyboard_layout_selector
, 1, 2, 3, 4, Gtk::FILL
|Gtk::EXPAND
, FILL
);
1283 OptionEditor::bindings_changed ()
1287 txt
= keyboard_layout_selector
.get_active_text();
1289 for (std::map
<string
,string
>::iterator i
= Keyboard::binding_files
.begin(); i
!= Keyboard::binding_files
.end(); ++i
) {
1290 if (txt
== i
->first
) {
1291 if (Keyboard::load_keybindings (i
->second
)) {
1292 Keyboard::save_keybindings ();
1299 OptionEditor::edit_modifier_chosen ()
1303 txt
= edit_modifier_combo
.get_active_text();
1305 for (int i
= 0; modifiers
[i
].name
; ++i
) {
1306 if (txt
== _(modifiers
[i
].name
)) {
1307 Keyboard::set_edit_modifier (modifiers
[i
].modifier
);
1314 OptionEditor::delete_modifier_chosen ()
1318 txt
= delete_modifier_combo
.get_active_text();
1320 for (int i
= 0; modifiers
[i
].name
; ++i
) {
1321 if (txt
== _(modifiers
[i
].name
)) {
1322 Keyboard::set_delete_modifier (modifiers
[i
].modifier
);
1329 OptionEditor::snap_modifier_chosen ()
1333 txt
= snap_modifier_combo
.get_active_text();
1335 for (int i
= 0; modifiers
[i
].name
; ++i
) {
1336 if (txt
== _(modifiers
[i
].name
)) {
1337 Keyboard::set_snap_modifier (modifiers
[i
].modifier
);
1344 OptionEditor::delete_button_changed ()
1346 Keyboard::set_delete_button ((guint
) delete_button_adjustment
.get_value());
1350 OptionEditor::edit_button_changed ()
1352 Keyboard::set_edit_button ((guint
) edit_button_adjustment
.get_value());
1356 OptionEditor::parameter_changed (const char* parameter_name
)
1358 ENSURE_GUI_THREAD (bind (mem_fun (*this, &OptionEditor::parameter_changed
), parameter_name
));
1360 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
1362 if (PARAM_IS ("timecode-source-is-synced")) {
1363 synced_timecode_button
.set_active (Config
->get_timecode_source_is_synced());
1364 } else if (PARAM_IS ("history-depth")) {
1365 int32_t depth
= Config
->get_history_depth();
1367 history_depth
.set_value (depth
);
1368 history_depth_spinner
.set_sensitive (depth
!= 0);
1369 limit_history_button
.set_active (depth
!= 0);
1371 } else if (PARAM_IS ("saved-history-depth")) {
1373 saved_history_depth
.set_value (Config
->get_saved_history_depth());
1375 } else if (PARAM_IS ("save-history")) {
1377 bool x
= Config
->get_save_history();
1379 save_history_button
.set_active (x
);
1380 saved_history_depth_spinner
.set_sensitive (x
);
1381 } else if (PARAM_IS ("font-scale")) {