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 <gtkmm2ext/stop_signal.h>
30 #include <gtkmm2ext/utils.h>
31 #include <gtkmm2ext/window_title.h>
33 #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 ("options editor"),
66 short_xfade_adjustment (0, 1.0, 500.0, 5.0, 100.0),
67 short_xfade_slider (short_xfade_adjustment),
68 destructo_xfade_adjustment (1.0, 1.0, 500.0, 1.0, 100.0),
69 destructo_xfade_slider (destructo_xfade_adjustment),
73 smpte_offset_clock (X_("smpteoffset"), false, X_("SMPTEOffsetClock"), true, true),
74 smpte_offset_negative_button (_("SMPTE offset is negative")),
78 mmc_device_id_adjustment (0.0, 0.0, (double) 0x7f, 1.0, 16.0),
79 mmc_device_id_spinner (mmc_device_id_adjustment),
84 click_browse_button (_("Browse")),
85 click_emphasis_browse_button (_("Browse")),
89 keyboard_mouse_table (3, 4),
90 delete_button_adjustment (3, 1, 5),
91 delete_button_spin (delete_button_adjustment),
92 edit_button_adjustment (3, 1, 5),
93 edit_button_spin (edit_button_adjustment)
96 using namespace Notebook_Helpers;
98 click_io_selector = 0;
99 auditioner_io_selector = 0;
102 WindowTitle title(Glib::get_application_name());
103 title += _("Options Editor");
104 set_title(title.get_string());
106 set_default_size (300, 300);
107 set_wmclass (X_("ardour_option_editor"), "Ardour");
109 set_name ("OptionsWindow");
110 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
112 VBox *vbox = get_vbox();
113 set_border_width (3);
115 vbox->set_spacing (4);
116 vbox->pack_start(notebook);
118 signal_delete_event().connect (mem_fun(*this, &OptionEditor::wm_close));
120 notebook.set_show_tabs (true);
121 notebook.set_show_border (true);
122 notebook.set_name ("OptionsNotebook");
124 setup_sync_options();
125 setup_path_options();
126 setup_fade_options ();
127 setup_keyboard_options ();
128 setup_auditioner_editor ();
130 notebook.pages().push_back (TabElem (sync_packer, _("Sync")));
131 notebook.pages().push_back (TabElem (path_table, _("Paths/Files")));
132 notebook.pages().push_back (TabElem (keyboard_mouse_table, _("Kbd/Mouse")));
133 notebook.pages().push_back (TabElem (click_packer, _("Click")));
134 notebook.pages().push_back (TabElem (audition_packer, _("Audition")));
135 notebook.pages().push_back (TabElem (fade_packer, _("Layers & Fades")));
137 if (!MIDI::Manager::instance()->get_midi_ports().empty()) {
138 setup_midi_options ();
139 notebook.pages().push_back (TabElem (midi_packer, _("MIDI")));
147 OptionEditor::set_session (Session *s)
149 clear_click_editor ();
150 clear_auditioner_editor ();
152 click_path_entry.set_text ("");
153 click_emphasis_path_entry.set_text ("");
154 session_raid_entry.set_text ("");
156 click_path_entry.set_sensitive (false);
157 click_emphasis_path_entry.set_sensitive (false);
158 session_raid_entry.set_sensitive (false);
160 short_xfade_slider.set_sensitive (false);
161 smpte_offset_negative_button.set_sensitive (false);
163 smpte_offset_clock.set_session (s);
165 if ((session = s) == 0) {
169 click_path_entry.set_sensitive (true);
170 click_emphasis_path_entry.set_sensitive (true);
171 session_raid_entry.set_sensitive (true);
172 short_xfade_slider.set_sensitive (true);
173 smpte_offset_negative_button.set_sensitive (true);
175 smpte_offset_clock.set_session (s);
176 smpte_offset_clock.set (s->smpte_offset (), true);
178 smpte_offset_negative_button.set_active (session->smpte_offset_negative());
180 /* set up port assignments */
182 std::map<MIDI::Port*,vector<RadioButton*> >::iterator res;
184 if (session->mtc_port()) {
185 if ((res = port_toggle_buttons.find (session->mtc_port())) != port_toggle_buttons.end()) {
186 (*res).second[MtcIndex]->set_active (true);
190 if (session->mmc_port ()) {
191 if ((res = port_toggle_buttons.find (session->mmc_port())) != port_toggle_buttons.end()) {
192 (*res).second[MmcIndex]->set_active (true);
196 if (session->midi_port()) {
197 if ((res = port_toggle_buttons.find (session->midi_port())) != port_toggle_buttons.end()) {
198 (*res).second[MidiIndex]->set_active (true);
202 setup_click_editor ();
203 connect_audition_editor ();
205 short_xfade_adjustment.set_value ((Crossfade::short_xfade_length() / (float) session->frame_rate()) * 1000.0);
207 add_session_paths ();
210 OptionEditor::~OptionEditor ()
215 OptionEditor::setup_path_options()
219 path_table.set_homogeneous (false);
220 path_table.set_border_width (12);
221 path_table.set_row_spacings (5);
223 session_raid_entry.set_name ("OptionsEntry");
225 session_raid_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::raid_path_changed));
227 label = manage(new Label(_("session RAID path")));
228 label->set_name ("OptionsLabel");
229 path_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
230 path_table.attach (session_raid_entry, 1, 3, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
232 path_table.show_all();
236 OptionEditor::add_session_paths ()
238 click_path_entry.set_sensitive (true);
239 click_emphasis_path_entry.set_sensitive (true);
240 session_raid_entry.set_sensitive (true);
242 if (Config->get_click_sound().empty()) {
243 click_path_entry.set_text (_("internal"));
245 click_path_entry.set_text (Config->get_click_sound());
248 if (Config->get_click_emphasis_sound().empty()) {
249 click_emphasis_path_entry.set_text (_("internal"));
251 click_emphasis_path_entry.set_text (Config->get_click_emphasis_sound());
254 session_raid_entry.set_text(session->raid_path());
258 OptionEditor::setup_fade_options ()
262 Label* label = manage (new Label (_("Short crossfade length (msecs)")));
263 label->set_name ("OptionsLabel");
265 hbox = manage (new HBox);
266 hbox->set_border_width (5);
267 hbox->set_spacing (10);
268 hbox->pack_start (*label, false, false);
269 hbox->pack_start (short_xfade_slider, true, true);
270 fade_packer.pack_start (*hbox, false, false);
272 short_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::short_xfade_adjustment_changed));
274 label = manage (new Label (_("Destructive crossfade length (msecs)")));
275 label->set_name ("OptionsLabel");
277 hbox = manage (new HBox);
278 hbox->set_border_width (5);
279 hbox->set_spacing (10);
280 hbox->pack_start (*label, false, false);
281 hbox->pack_start (destructo_xfade_slider, true, true);
282 fade_packer.pack_start (*hbox, false, false);
284 destructo_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::destructo_xfade_adjustment_changed));
286 short_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
287 destructo_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
289 destructo_xfade_adjustment.set_value (Config->get_destructive_xfade_msecs());
291 fade_packer.show_all ();
295 OptionEditor::short_xfade_adjustment_changed ()
298 float val = short_xfade_adjustment.get_value();
300 /* val is in msecs */
302 Crossfade::set_short_xfade_length ((nframes_t) floor (session->frame_rate() * (val / 1000.0)));
307 OptionEditor::destructo_xfade_adjustment_changed ()
309 float val = destructo_xfade_adjustment.get_value();
311 /* val is in msecs */
314 Config->set_destructive_xfade_msecs ((uint32_t) floor (val));
317 SndFileSource::setup_standard_crossfades (session->frame_rate());
322 OptionEditor::setup_sync_options ()
327 smpte_offset_clock.set_mode (AudioClock::SMPTE);
328 smpte_offset_clock.ValueChanged.connect (mem_fun(*this, &OptionEditor::smpte_offset_chosen));
330 smpte_offset_negative_button.set_name ("OptionEditorToggleButton");
332 smpte_offset_negative_button.unset_flags (Gtk::CAN_FOCUS);
334 Label *smpte_offset_label = manage (new Label (_("SMPTE Offset")));
335 smpte_offset_label->set_name("OptionsLabel");
337 hbox = manage (new HBox);
338 hbox->set_border_width (5);
339 hbox->set_spacing (10);
340 hbox->pack_start (*smpte_offset_label, false, false);
341 hbox->pack_start (smpte_offset_clock, false, false);
342 hbox->pack_start (smpte_offset_negative_button, false, false);
344 sync_packer.pack_start (*hbox, false, false);
346 smpte_offset_negative_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::smpte_offset_negative_clicked));
350 OptionEditor::smpte_offset_negative_clicked ()
353 session->set_smpte_offset_negative (smpte_offset_negative_button.get_active());
358 OptionEditor::smpte_offset_chosen()
361 nframes_t frames = smpte_offset_clock.current_duration();
362 session->set_smpte_offset (frames);
368 OptionEditor::setup_midi_options ()
371 MIDI::Manager::PortMap::const_iterator i;
372 const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports();
377 Gtk::Table* table = manage (new Table (ports.size() + 4, 10));
379 table->set_row_spacings (6);
380 table->set_col_spacings (10);
382 table->attach (*(manage (new Label (_("Port")))), 0, 1, 0, 1);
383 table->attach (*(manage (new Label (_("Offline")))), 1, 2, 0, 1);
384 table->attach (*(manage (new Label (_("Trace\nInput")))), 2, 3, 0, 1);
385 table->attach (*(manage (new Label (_("Trace\nOutput")))), 3, 4, 0, 1);
386 table->attach (*(manage (new Label (_("MTC")))), 4, 5, 0, 1);
387 table->attach (*(manage (new Label (_("MMC")))), 6, 7, 0, 1);
388 table->attach (*(manage (new Label (_("MIDI Parameter\nControl")))), 8, 9, 0, 1);
390 table->attach (*(manage (new HSeparator())), 0, 9, 1, 2);
391 table->attach (*(manage (new VSeparator())), 5, 6, 0, 8);
392 table->attach (*(manage (new VSeparator())), 7, 8, 0, 8);
394 table->attach (*(manage (new Label (_("MMC Device ID")))), 9, 10, 0, 1);
395 table->attach (mmc_device_id_spinner, 9, 10, 1, 2);
397 mmc_device_id_adjustment.signal_value_changed().connect (mem_fun (*this, &OptionEditor::mmc_device_id_adjusted));
399 for (n = 0, i = ports.begin(); i != ports.end(); ++n, ++i) {
401 pair<MIDI::Port*,vector<RadioButton*> > newpair;
403 newpair.first = i->second;
405 table->attach (*(manage (new Label (i->first))), 0, 1, n+2, n+3,FILL|EXPAND, FILL );
406 tb = manage (new ToggleButton (_("online")));
407 tb->set_name ("OptionEditorToggleButton");
409 /* remember, we have to handle the i18n case where the relative
410 lengths of the strings in language N is different than in english.
413 if (strlen (_("offline")) > strlen (_("online"))) {
414 set_size_request_to_display_given_text (*tb, _("offline"), 15, 12);
416 set_size_request_to_display_given_text (*tb, _("online"), 15, 12);
419 tb->set_active (!(*i).second->input()->offline());
420 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_online_toggled), (*i).second, tb));
421 (*i).second->input()->OfflineStatusChanged.connect (bind (mem_fun(*this, &OptionEditor::map_port_online), (*i).second, tb));
422 table->attach (*tb, 1, 2, n+2, n+3, FILL|EXPAND, FILL);
424 tb = manage (new ToggleButton ());
425 tb->set_name ("OptionEditorToggleButton");
426 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_in_toggled), (*i).second, tb));
427 tb->set_size_request (10, 10);
428 table->attach (*tb, 2, 3, n+2, n+3, FILL|EXPAND, FILL);
430 tb = manage (new ToggleButton ());
431 tb->set_name ("OptionEditorToggleButton");
432 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_out_toggled), (*i).second, tb));
433 tb->set_size_request (10, 10);
434 table->attach (*tb, 3, 4, n+2, n+3, FILL|EXPAND, FILL);
436 rb = manage (new RadioButton ());
437 newpair.second.push_back (rb);
438 rb->set_name ("OptionEditorToggleButton");
440 mtc_button_group = rb->get_group();
442 rb->set_group (mtc_button_group);
445 table->attach (*rb, 4, 5, n+2, n+3, FILL|EXPAND, FILL);
446 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mtc_port_chosen), (*i).second, rb));
448 if (Config->get_mtc_port_name() == i->first) {
449 rb->set_active (true);
452 rb = manage (new RadioButton ());
453 newpair.second.push_back (rb);
454 rb->set_name ("OptionEditorToggleButton");
456 mmc_button_group = rb->get_group();
458 rb->set_group (mmc_button_group);
460 table->attach (*rb, 6, 7, n+2, n+3, FILL|EXPAND, FILL);
461 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mmc_port_chosen), (*i).second, rb));
463 if (Config->get_mmc_port_name() == i->first) {
464 rb->set_active (true);
467 rb = manage (new RadioButton ());
468 newpair.second.push_back (rb);
469 rb->set_name ("OptionEditorToggleButton");
471 midi_button_group = rb->get_group();
473 rb->set_group (midi_button_group);
475 table->attach (*rb, 8, 9, n+2, n+3, FILL|EXPAND, FILL);
476 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_port_chosen), (*i).second, rb));
478 if (Config->get_midi_port_name() == i->first) {
479 rb->set_active (true);
482 port_toggle_buttons.insert (newpair);
487 hbox = manage (new HBox);
488 hbox->set_border_width (6);
489 hbox->pack_start (*table, true, false);
490 midi_packer.pack_start (*hbox, false, false);
494 OptionEditor::mtc_port_chosen (MIDI::Port *port, Gtk::RadioButton* rb)
497 if (rb->get_active()) {
499 session->set_mtc_port (port->name());
500 Config->set_mtc_port_name (port->name());
502 session->set_mtc_port ("");
504 rb->set_active (true);
510 OptionEditor::mmc_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb)
513 if (rb->get_active()) {
515 session->set_mmc_port (port->name());
516 Config->set_mtc_port_name (port->name());
518 session->set_mmc_port ("");
520 rb->set_active (true);
526 OptionEditor::midi_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb)
529 if (rb->get_active()) {
531 session->set_midi_port (port->name());
532 Config->set_midi_port_name (port->name());
534 session->set_midi_port ("");
536 rb->set_active (true);
542 OptionEditor::port_online_toggled (MIDI::Port* port, ToggleButton* tb)
544 bool wanted = tb->get_active();
546 if (wanted != port->input()->offline()) {
547 port->input()->set_offline (wanted);
552 OptionEditor::map_port_online (MIDI::Port* port, ToggleButton* tb)
554 bool bstate = tb->get_active ();
556 if (bstate != port->input()->offline()) {
557 if (port->input()->offline()) {
558 tb->set_label (_("offline"));
559 tb->set_active (false);
561 tb->set_label (_("online"));
562 tb->set_active (true);
568 OptionEditor::mmc_device_id_adjusted ()
570 uint8_t id = (uint8_t) mmc_device_id_spinner.get_value();
572 if (id != Config->get_mmc_device_id()) {
573 Config->set_mmc_device_id (id);
578 OptionEditor::port_trace_in_toggled (MIDI::Port* port, ToggleButton* tb)
580 bool trace = tb->get_active();
582 if (port->input()->tracing() != trace) {
583 port->input()->trace (trace, &cerr, string (port->name()) + string (" input: "));
588 OptionEditor::port_trace_out_toggled (MIDI::Port* port, ToggleButton* tb)
590 bool trace = tb->get_active();
592 if (port->output()->tracing() != trace) {
593 port->output()->trace (trace, &cerr, string (port->name()) + string (" output: "));
598 OptionEditor::save ()
600 /* XXX a bit odd that we save the entire session state here */
606 OptionEditor::wm_close (GdkEventAny *ev)
614 OptionEditor::raid_path_changed ()
617 Config->set_raid_path (session_raid_entry.get_text());
622 OptionEditor::click_browse_clicked ()
624 SoundFileChooser sfdb (_("Choose Click"), session);
626 int result = sfdb.run ();
628 if (result == Gtk::RESPONSE_OK) {
629 click_chosen(sfdb.get_filename());
634 OptionEditor::click_chosen (const string & path)
636 click_path_entry.set_text (path);
637 click_sound_changed ();
641 OptionEditor::click_emphasis_browse_clicked ()
643 SoundFileChooser sfdb (_("Choose Click Emphasis"), session);
645 int result = sfdb.run ();
647 if (result == Gtk::RESPONSE_OK) {
648 click_emphasis_chosen (sfdb.get_filename());
653 OptionEditor::click_emphasis_chosen (const string & path)
655 click_emphasis_path_entry.set_text (path);
656 click_emphasis_sound_changed ();
660 OptionEditor::click_sound_changed ()
663 string path = click_path_entry.get_text();
665 if (path == Config->get_click_sound()) {
669 strip_whitespace_edges (path);
671 if (path == _("internal")) {
672 Config->set_click_sound ("");
674 Config->set_click_sound (path);
680 OptionEditor::click_emphasis_sound_changed ()
683 string path = click_emphasis_path_entry.get_text();
685 if (path == Config->get_click_emphasis_sound()) {
689 strip_whitespace_edges (path);
691 if (path == _("internal")) {
692 Config->set_click_emphasis_sound ("");
694 Config->set_click_emphasis_sound (path);
700 OptionEditor::clear_click_editor ()
702 if (click_io_selector) {
703 click_packer.remove (*click_io_selector);
704 click_packer.remove (*click_gpm);
705 delete click_io_selector;
707 click_io_selector = 0;
713 OptionEditor::setup_click_editor ()
716 HBox* hpacker = manage (new HBox);
718 click_path_entry.set_sensitive (true);
719 click_emphasis_path_entry.set_sensitive (true);
721 click_path_entry.set_name ("OptionsEntry");
722 click_emphasis_path_entry.set_name ("OptionsEntry");
724 click_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_sound_changed));
725 click_emphasis_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed));
727 click_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_sound_changed));
728 click_emphasis_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_emphasis_sound_changed));
730 click_browse_button.set_name ("EditorGTKButton");
731 click_emphasis_browse_button.set_name ("EditorGTKButton");
732 click_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_browse_clicked));
733 click_emphasis_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_emphasis_browse_clicked));
735 click_packer.set_border_width (12);
736 click_packer.set_spacing (5);
738 click_io_selector = new IOSelector (*session, session->click_io(), false);
739 click_gpm = new GainMeter (session->click_io(), *session);
741 click_table.set_col_spacings (10);
743 label = manage(new Label(_("Click audio file")));
744 label->set_name ("OptionsLabel");
745 click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
746 click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
747 click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL);
749 label = manage(new Label(_("Click emphasis audiofile")));
750 label->set_name ("OptionsLabel");
751 click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
752 click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
753 click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL);
755 hpacker->set_spacing (10);
756 hpacker->pack_start (*click_io_selector, false, false);
757 hpacker->pack_start (*click_gpm, false, false);
759 click_packer.pack_start (click_table, false, false);
760 click_packer.pack_start (*hpacker, false, false);
762 click_packer.show_all ();
766 OptionEditor::clear_auditioner_editor ()
768 if (auditioner_io_selector) {
769 audition_hpacker.remove (*auditioner_io_selector);
770 audition_hpacker.remove (*auditioner_gpm);
771 delete auditioner_io_selector;
772 delete auditioner_gpm;
773 auditioner_io_selector = 0;
779 OptionEditor::setup_auditioner_editor ()
781 audition_packer.set_border_width (12);
782 audition_packer.set_spacing (5);
783 audition_hpacker.set_spacing (10);
785 audition_label.set_name ("OptionEditorAuditionerLabel");
786 audition_label.set_text (_("The auditioner is a dedicated mixer strip used\n"
787 "for listening to specific regions outside the context\n"
788 "of the overall mix. It can be connected just like any\n"
789 "other mixer strip."));
791 audition_packer.pack_start (audition_label, false, false, 10);
792 audition_packer.pack_start (audition_hpacker, false, false);
796 OptionEditor::connect_audition_editor ()
798 auditioner_io_selector = new IOSelector (*session, session->the_auditioner(), false);
799 auditioner_gpm = new GainMeter (session->the_auditioner(), *session);
801 audition_hpacker.pack_start (*auditioner_io_selector, false, false);
802 audition_hpacker.pack_start (*auditioner_gpm, false, false);
804 auditioner_io_selector->show_all ();
805 auditioner_gpm->show_all ();
809 OptionEditor::focus_out_event_handler (GdkEventFocus* ev, void (OptionEditor::*pmf)())
815 static const struct {
819 { "Shift", GDK_SHIFT_MASK },
820 { "Control", GDK_CONTROL_MASK },
821 { "Alt (Mod1)", GDK_MOD1_MASK },
822 { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK },
823 { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK },
824 { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK },
825 { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
826 { "Mod2", GDK_MOD2_MASK },
827 { "Mod3", GDK_MOD3_MASK },
828 { "Mod4", GDK_MOD4_MASK },
829 { "Mod5", GDK_MOD5_MASK },
834 OptionEditor::setup_keyboard_options ()
839 keyboard_mouse_table.set_border_width (12);
840 keyboard_mouse_table.set_row_spacings (5);
841 keyboard_mouse_table.set_col_spacings (5);
843 /* internationalize and prepare for use with combos */
845 for (int i = 0; modifiers[i].name; ++i) {
846 dumb.push_back (_(modifiers[i].name));
849 set_popdown_strings (edit_modifier_combo, dumb);
850 edit_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::edit_modifier_chosen));
852 for (int x = 0; modifiers[x].name; ++x) {
853 if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
854 edit_modifier_combo.set_active_text (_(modifiers[x].name));
859 label = manage (new Label (_("Edit using")));
860 label->set_name ("OptionsLabel");
861 label->set_alignment (1.0, 0.5);
863 keyboard_mouse_table.attach (*label, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
864 keyboard_mouse_table.attach (edit_modifier_combo, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
866 label = manage (new Label (_("+ button")));
867 label->set_name ("OptionsLabel");
869 keyboard_mouse_table.attach (*label, 3, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
870 keyboard_mouse_table.attach (edit_button_spin, 4, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
872 edit_button_spin.set_name ("OptionsEntry");
873 edit_button_adjustment.set_value (Keyboard::edit_button());
874 edit_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::edit_button_changed));
876 set_popdown_strings (delete_modifier_combo, dumb);
877 delete_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::delete_modifier_chosen));
879 for (int x = 0; modifiers[x].name; ++x) {
880 if (modifiers[x].modifier == Keyboard::delete_modifier ()) {
881 delete_modifier_combo.set_active_text (_(modifiers[x].name));
886 label = manage (new Label (_("Delete using")));
887 label->set_name ("OptionsLabel");
888 label->set_alignment (1.0, 0.5);
890 keyboard_mouse_table.attach (*label, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
891 keyboard_mouse_table.attach (delete_modifier_combo, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
893 label = manage (new Label (_("+ button")));
894 label->set_name ("OptionsLabel");
896 keyboard_mouse_table.attach (*label, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
897 keyboard_mouse_table.attach (delete_button_spin, 4, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
899 delete_button_spin.set_name ("OptionsEntry");
900 delete_button_adjustment.set_value (Keyboard::delete_button());
901 delete_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::delete_button_changed));
903 set_popdown_strings (snap_modifier_combo, dumb);
904 snap_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::snap_modifier_chosen));
906 for (int x = 0; modifiers[x].name; ++x) {
907 if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) {
908 snap_modifier_combo.set_active_text (_(modifiers[x].name));
913 label = manage (new Label (_("Ignore snap using")));
914 label->set_name ("OptionsLabel");
915 label->set_alignment (1.0, 0.5);
917 keyboard_mouse_table.attach (*label, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
918 keyboard_mouse_table.attach (snap_modifier_combo, 1, 2, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
922 OptionEditor::edit_modifier_chosen ()
926 txt = edit_modifier_combo.get_active_text();
928 for (int i = 0; modifiers[i].name; ++i) {
929 if (txt == _(modifiers[i].name)) {
930 Keyboard::set_edit_modifier (modifiers[i].modifier);
937 OptionEditor::delete_modifier_chosen ()
941 txt = delete_modifier_combo.get_active_text();
943 for (int i = 0; modifiers[i].name; ++i) {
944 if (txt == _(modifiers[i].name)) {
945 Keyboard::set_delete_modifier (modifiers[i].modifier);
952 OptionEditor::snap_modifier_chosen ()
956 txt = snap_modifier_combo.get_active_text();
958 for (int i = 0; modifiers[i].name; ++i) {
959 if (txt == _(modifiers[i].name)) {
960 Keyboard::set_snap_modifier (modifiers[i].modifier);
967 OptionEditor::delete_button_changed ()
969 Keyboard::set_delete_button ((guint) delete_button_adjustment.get_value());
973 OptionEditor::edit_button_changed ()
975 Keyboard::set_edit_button ((guint) edit_button_adjustment.get_value());
979 OptionEditor::fixup_combo_size (Gtk::ComboBoxText& combo, vector<string>& strings)
981 /* find the widest string */
983 string::size_type maxlen = 0;
986 for (vector<string>::iterator i = strings.begin(); i != strings.end(); ++i) {
989 if ((l = (*i).length()) > maxlen) {
995 /* try to include ascenders and descenders */
997 if (maxstring.length() > 2) {
1002 const guint32 FUDGE = 10; // Combo's are stupid - they steal space from the entry for the button
1004 set_size_request_to_display_given_text (combo, maxstring.c_str(), 10 + FUDGE, 10);