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>
32 #include "public_editor.h"
35 #include "ardour_ui.h"
36 #include "io_selector.h"
37 #include "gain_meter.h"
41 #include "option_editor.h"
45 using namespace ARDOUR;
48 using namespace Editing;
49 using namespace Gtkmm2ext;
52 static vector<string> positional_sync_strings;
54 OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui)
55 : Dialog ("option editor"),
65 short_xfade_adjustment (0, 1.0, 500.0, 5.0, 100.0),
66 short_xfade_slider (short_xfade_adjustment),
67 destructo_xfade_adjustment (1.0, 1.0, 500.0, 1.0, 100.0),
68 destructo_xfade_slider (destructo_xfade_adjustment),
72 smpte_offset_clock (X_("smpteoffset"), false, X_("SMPTEOffsetClock"), true, true),
73 smpte_offset_negative_button (_("SMPTE offset is negative")),
77 mmc_device_id_adjustment (0.0, 0.0, (double) 0x7f, 1.0, 16.0),
78 mmc_device_id_spinner (mmc_device_id_adjustment),
83 click_browse_button (_("Browse")),
84 click_emphasis_browse_button (_("Browse")),
88 keyboard_mouse_table (3, 4),
89 delete_button_adjustment (3, 1, 5),
90 delete_button_spin (delete_button_adjustment),
91 edit_button_adjustment (3, 1, 5),
92 edit_button_spin (edit_button_adjustment)
95 using namespace Notebook_Helpers;
97 click_io_selector = 0;
98 auditioner_io_selector = 0;
101 set_default_size (300, 300);
102 set_title (_("ardour: options editor"));
103 set_wmclass (X_("ardour_option_editor"), "Ardour");
105 set_name ("OptionsWindow");
106 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
108 VBox *vbox = get_vbox();
109 set_border_width (3);
111 vbox->set_spacing (4);
112 vbox->pack_start(notebook);
114 signal_delete_event().connect (mem_fun(*this, &OptionEditor::wm_close));
116 notebook.set_show_tabs (true);
117 notebook.set_show_border (true);
118 notebook.set_name ("OptionsNotebook");
120 setup_sync_options();
121 setup_path_options();
122 setup_fade_options ();
123 setup_keyboard_options ();
124 setup_auditioner_editor ();
126 notebook.pages().push_back (TabElem (sync_packer, _("Sync")));
127 notebook.pages().push_back (TabElem (path_table, _("Paths/Files")));
128 notebook.pages().push_back (TabElem (keyboard_mouse_table, _("Kbd/Mouse")));
129 notebook.pages().push_back (TabElem (click_packer, _("Click")));
130 notebook.pages().push_back (TabElem (audition_packer, _("Audition")));
131 notebook.pages().push_back (TabElem (fade_packer, _("Layers & Fades")));
133 if (!MIDI::Manager::instance()->get_midi_ports().empty()) {
134 setup_midi_options ();
135 notebook.pages().push_back (TabElem (midi_packer, _("MIDI")));
143 OptionEditor::set_session (Session *s)
145 clear_click_editor ();
146 clear_auditioner_editor ();
148 click_path_entry.set_text ("");
149 click_emphasis_path_entry.set_text ("");
150 session_raid_entry.set_text ("");
152 click_path_entry.set_sensitive (false);
153 click_emphasis_path_entry.set_sensitive (false);
154 session_raid_entry.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 short_xfade_slider.set_sensitive (true);
169 smpte_offset_negative_button.set_sensitive (true);
171 smpte_offset_clock.set_session (s);
172 smpte_offset_clock.set (s->smpte_offset (), true);
174 smpte_offset_negative_button.set_active (session->smpte_offset_negative());
176 /* set up port assignments */
178 std::map<MIDI::Port*,vector<RadioButton*> >::iterator res;
180 if (session->mtc_port()) {
181 if ((res = port_toggle_buttons.find (session->mtc_port())) != port_toggle_buttons.end()) {
182 (*res).second[MtcIndex]->set_active (true);
186 if (session->mmc_port ()) {
187 if ((res = port_toggle_buttons.find (session->mmc_port())) != port_toggle_buttons.end()) {
188 (*res).second[MmcIndex]->set_active (true);
192 if (session->midi_port()) {
193 if ((res = port_toggle_buttons.find (session->midi_port())) != port_toggle_buttons.end()) {
194 (*res).second[MidiIndex]->set_active (true);
198 setup_click_editor ();
199 connect_audition_editor ();
201 short_xfade_adjustment.set_value ((Crossfade::short_xfade_length() / (float) session->frame_rate()) * 1000.0);
203 add_session_paths ();
206 OptionEditor::~OptionEditor ()
211 OptionEditor::setup_path_options()
215 path_table.set_homogeneous (false);
216 path_table.set_border_width (12);
217 path_table.set_row_spacings (5);
219 session_raid_entry.set_name ("OptionsEntry");
221 session_raid_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::raid_path_changed));
223 label = manage(new Label(_("session RAID path")));
224 label->set_name ("OptionsLabel");
225 path_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
226 path_table.attach (session_raid_entry, 1, 3, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
228 path_table.show_all();
232 OptionEditor::add_session_paths ()
234 click_path_entry.set_sensitive (true);
235 click_emphasis_path_entry.set_sensitive (true);
236 session_raid_entry.set_sensitive (true);
238 if (Config->get_click_sound().empty()) {
239 click_path_entry.set_text (_("internal"));
241 click_path_entry.set_text (Config->get_click_sound());
244 if (Config->get_click_emphasis_sound().empty()) {
245 click_emphasis_path_entry.set_text (_("internal"));
247 click_emphasis_path_entry.set_text (Config->get_click_emphasis_sound());
250 session_raid_entry.set_text(session->raid_path());
254 OptionEditor::setup_fade_options ()
258 Label* label = manage (new Label (_("Short crossfade length (msecs)")));
259 label->set_name ("OptionsLabel");
261 hbox = manage (new HBox);
262 hbox->set_border_width (5);
263 hbox->set_spacing (10);
264 hbox->pack_start (*label, false, false);
265 hbox->pack_start (short_xfade_slider, true, true);
266 fade_packer.pack_start (*hbox, false, false);
268 short_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::short_xfade_adjustment_changed));
270 label = manage (new Label (_("Destructive crossfade length (msecs)")));
271 label->set_name ("OptionsLabel");
273 hbox = manage (new HBox);
274 hbox->set_border_width (5);
275 hbox->set_spacing (10);
276 hbox->pack_start (*label, false, false);
277 hbox->pack_start (destructo_xfade_slider, true, true);
278 fade_packer.pack_start (*hbox, false, false);
280 destructo_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::destructo_xfade_adjustment_changed));
282 short_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
283 destructo_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
285 destructo_xfade_adjustment.set_value (Config->get_destructive_xfade_msecs());
287 fade_packer.show_all ();
291 OptionEditor::short_xfade_adjustment_changed ()
294 float val = short_xfade_adjustment.get_value();
296 /* val is in msecs */
298 Crossfade::set_short_xfade_length ((nframes_t) floor (session->frame_rate() * (val / 1000.0)));
303 OptionEditor::destructo_xfade_adjustment_changed ()
305 float val = destructo_xfade_adjustment.get_value();
307 /* val is in msecs */
310 Config->set_destructive_xfade_msecs ((uint32_t) floor (val));
313 SndFileSource::setup_standard_crossfades (session->frame_rate());
318 OptionEditor::setup_sync_options ()
323 smpte_offset_clock.set_mode (AudioClock::SMPTE);
324 smpte_offset_clock.ValueChanged.connect (mem_fun(*this, &OptionEditor::smpte_offset_chosen));
326 smpte_offset_negative_button.set_name ("OptionEditorToggleButton");
328 smpte_offset_negative_button.unset_flags (Gtk::CAN_FOCUS);
330 Label *smpte_offset_label = manage (new Label (_("SMPTE Offset")));
331 smpte_offset_label->set_name("OptionsLabel");
333 hbox = manage (new HBox);
334 hbox->set_border_width (5);
335 hbox->set_spacing (10);
336 hbox->pack_start (*smpte_offset_label, false, false);
337 hbox->pack_start (smpte_offset_clock, false, false);
338 hbox->pack_start (smpte_offset_negative_button, false, false);
340 sync_packer.pack_start (*hbox, false, false);
342 smpte_offset_negative_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::smpte_offset_negative_clicked));
346 OptionEditor::smpte_offset_negative_clicked ()
349 session->set_smpte_offset_negative (smpte_offset_negative_button.get_active());
354 OptionEditor::smpte_offset_chosen()
357 nframes_t frames = smpte_offset_clock.current_duration();
358 session->set_smpte_offset (frames);
364 OptionEditor::setup_midi_options ()
367 MIDI::Manager::PortMap::const_iterator i;
368 const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports();
373 Gtk::Table* table = manage (new Table (ports.size() + 4, 10));
375 table->set_row_spacings (6);
376 table->set_col_spacings (10);
378 table->attach (*(manage (new Label (_("Port")))), 0, 1, 0, 1);
379 table->attach (*(manage (new Label (_("Offline")))), 1, 2, 0, 1);
380 table->attach (*(manage (new Label (_("Trace\nInput")))), 2, 3, 0, 1);
381 table->attach (*(manage (new Label (_("Trace\nOutput")))), 3, 4, 0, 1);
382 table->attach (*(manage (new Label (_("MTC")))), 4, 5, 0, 1);
383 table->attach (*(manage (new Label (_("MMC")))), 6, 7, 0, 1);
384 table->attach (*(manage (new Label (_("MIDI Parameter\nControl")))), 8, 9, 0, 1);
386 table->attach (*(manage (new HSeparator())), 0, 9, 1, 2);
387 table->attach (*(manage (new VSeparator())), 5, 6, 0, 8);
388 table->attach (*(manage (new VSeparator())), 7, 8, 0, 8);
390 table->attach (*(manage (new Label (_("MMC Device ID")))), 9, 10, 0, 1);
391 table->attach (mmc_device_id_spinner, 9, 10, 1, 2);
393 mmc_device_id_adjustment.signal_value_changed().connect (mem_fun (*this, &OptionEditor::mmc_device_id_adjusted));
395 for (n = 0, i = ports.begin(); i != ports.end(); ++n, ++i) {
397 pair<MIDI::Port*,vector<RadioButton*> > newpair;
399 newpair.first = i->second;
401 table->attach (*(manage (new Label (i->first))), 0, 1, n+2, n+3,FILL|EXPAND, FILL );
402 tb = manage (new ToggleButton (_("online")));
403 tb->set_name ("OptionEditorToggleButton");
405 /* remember, we have to handle the i18n case where the relative
406 lengths of the strings in language N is different than in english.
409 if (strlen (_("offline")) > strlen (_("online"))) {
410 set_size_request_to_display_given_text (*tb, _("offline"), 15, 12);
412 set_size_request_to_display_given_text (*tb, _("online"), 15, 12);
415 tb->set_active (!(*i).second->input()->offline());
416 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_online_toggled), (*i).second, tb));
417 (*i).second->input()->OfflineStatusChanged.connect (bind (mem_fun(*this, &OptionEditor::map_port_online), (*i).second, tb));
418 table->attach (*tb, 1, 2, n+2, n+3, FILL|EXPAND, FILL);
420 tb = manage (new ToggleButton ());
421 tb->set_name ("OptionEditorToggleButton");
422 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_in_toggled), (*i).second, tb));
423 tb->set_size_request (10, 10);
424 table->attach (*tb, 2, 3, n+2, n+3, FILL|EXPAND, FILL);
426 tb = manage (new ToggleButton ());
427 tb->set_name ("OptionEditorToggleButton");
428 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_out_toggled), (*i).second, tb));
429 tb->set_size_request (10, 10);
430 table->attach (*tb, 3, 4, n+2, n+3, FILL|EXPAND, FILL);
432 rb = manage (new RadioButton ());
433 newpair.second.push_back (rb);
434 rb->set_name ("OptionEditorToggleButton");
436 mtc_button_group = rb->get_group();
438 rb->set_group (mtc_button_group);
441 table->attach (*rb, 4, 5, n+2, n+3, FILL|EXPAND, FILL);
442 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mtc_port_chosen), (*i).second, rb));
444 if (Config->get_mtc_port_name() == i->first) {
445 rb->set_active (true);
448 rb = manage (new RadioButton ());
449 newpair.second.push_back (rb);
450 rb->set_name ("OptionEditorToggleButton");
452 mmc_button_group = rb->get_group();
454 rb->set_group (mmc_button_group);
456 table->attach (*rb, 6, 7, n+2, n+3, FILL|EXPAND, FILL);
457 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mmc_port_chosen), (*i).second, rb));
459 if (Config->get_mmc_port_name() == i->first) {
460 rb->set_active (true);
463 rb = manage (new RadioButton ());
464 newpair.second.push_back (rb);
465 rb->set_name ("OptionEditorToggleButton");
467 midi_button_group = rb->get_group();
469 rb->set_group (midi_button_group);
471 table->attach (*rb, 8, 9, n+2, n+3, FILL|EXPAND, FILL);
472 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_port_chosen), (*i).second, rb));
474 if (Config->get_midi_port_name() == i->first) {
475 rb->set_active (true);
478 port_toggle_buttons.insert (newpair);
483 hbox = manage (new HBox);
484 hbox->set_border_width (6);
485 hbox->pack_start (*table, true, false);
486 midi_packer.pack_start (*hbox, false, false);
490 OptionEditor::mtc_port_chosen (MIDI::Port *port, Gtk::RadioButton* rb)
493 if (rb->get_active()) {
495 session->set_mtc_port (port->name());
496 Config->set_mtc_port_name (port->name());
498 session->set_mtc_port ("");
500 rb->set_active (true);
506 OptionEditor::mmc_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb)
509 if (rb->get_active()) {
511 session->set_mmc_port (port->name());
512 Config->set_mtc_port_name (port->name());
514 session->set_mmc_port ("");
516 rb->set_active (true);
522 OptionEditor::midi_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb)
525 if (rb->get_active()) {
527 session->set_midi_port (port->name());
528 Config->set_midi_port_name (port->name());
530 session->set_midi_port ("");
532 rb->set_active (true);
538 OptionEditor::port_online_toggled (MIDI::Port* port, ToggleButton* tb)
540 bool wanted = tb->get_active();
542 if (wanted != port->input()->offline()) {
543 port->input()->set_offline (wanted);
548 OptionEditor::map_port_online (MIDI::Port* port, ToggleButton* tb)
550 bool bstate = tb->get_active ();
552 if (bstate != port->input()->offline()) {
553 if (port->input()->offline()) {
554 tb->set_label (_("offline"));
555 tb->set_active (false);
557 tb->set_label (_("online"));
558 tb->set_active (true);
564 OptionEditor::mmc_device_id_adjusted ()
566 uint8_t id = (uint8_t) mmc_device_id_spinner.get_value();
568 if (id != Config->get_mmc_device_id()) {
569 Config->set_mmc_device_id (id);
574 OptionEditor::port_trace_in_toggled (MIDI::Port* port, ToggleButton* tb)
576 bool trace = tb->get_active();
578 if (port->input()->tracing() != trace) {
579 port->input()->trace (trace, &cerr, string (port->name()) + string (" input: "));
584 OptionEditor::port_trace_out_toggled (MIDI::Port* port, ToggleButton* tb)
586 bool trace = tb->get_active();
588 if (port->output()->tracing() != trace) {
589 port->output()->trace (trace, &cerr, string (port->name()) + string (" output: "));
594 OptionEditor::save ()
596 /* XXX a bit odd that we save the entire session state here */
602 OptionEditor::wm_close (GdkEventAny *ev)
610 OptionEditor::raid_path_changed ()
613 Config->set_raid_path (session_raid_entry.get_text());
618 OptionEditor::click_browse_clicked ()
620 SoundFileChooser sfdb (_("Choose Click"), session);
622 int result = sfdb.run ();
624 if (result == Gtk::RESPONSE_OK) {
625 click_chosen(sfdb.get_filename());
630 OptionEditor::click_chosen (const string & path)
632 click_path_entry.set_text (path);
633 click_sound_changed ();
637 OptionEditor::click_emphasis_browse_clicked ()
639 SoundFileChooser sfdb (_("Choose Click Emphasis"), session);
641 int result = sfdb.run ();
643 if (result == Gtk::RESPONSE_OK) {
644 click_emphasis_chosen (sfdb.get_filename());
649 OptionEditor::click_emphasis_chosen (const string & path)
651 click_emphasis_path_entry.set_text (path);
652 click_emphasis_sound_changed ();
656 OptionEditor::click_sound_changed ()
659 string path = click_path_entry.get_text();
661 if (path == Config->get_click_sound()) {
665 strip_whitespace_edges (path);
667 if (path == _("internal")) {
668 Config->set_click_sound ("");
670 Config->set_click_sound (path);
676 OptionEditor::click_emphasis_sound_changed ()
679 string path = click_emphasis_path_entry.get_text();
681 if (path == Config->get_click_emphasis_sound()) {
685 strip_whitespace_edges (path);
687 if (path == _("internal")) {
688 Config->set_click_emphasis_sound ("");
690 Config->set_click_emphasis_sound (path);
696 OptionEditor::clear_click_editor ()
698 if (click_io_selector) {
699 click_packer.remove (*click_io_selector);
700 click_packer.remove (*click_gpm);
701 delete click_io_selector;
703 click_io_selector = 0;
709 OptionEditor::setup_click_editor ()
712 HBox* hpacker = manage (new HBox);
714 click_path_entry.set_sensitive (true);
715 click_emphasis_path_entry.set_sensitive (true);
717 click_path_entry.set_name ("OptionsEntry");
718 click_emphasis_path_entry.set_name ("OptionsEntry");
720 click_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_sound_changed));
721 click_emphasis_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed));
723 click_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_sound_changed));
724 click_emphasis_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_emphasis_sound_changed));
726 click_browse_button.set_name ("EditorGTKButton");
727 click_emphasis_browse_button.set_name ("EditorGTKButton");
728 click_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_browse_clicked));
729 click_emphasis_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_emphasis_browse_clicked));
731 click_packer.set_border_width (12);
732 click_packer.set_spacing (5);
734 click_io_selector = new IOSelector (*session, session->click_io(), false);
735 click_gpm = new GainMeter (session->click_io(), *session);
737 click_table.set_col_spacings (10);
739 label = manage(new Label(_("Click audio file")));
740 label->set_name ("OptionsLabel");
741 click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
742 click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
743 click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL);
745 label = manage(new Label(_("Click emphasis audiofile")));
746 label->set_name ("OptionsLabel");
747 click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
748 click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
749 click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL);
751 hpacker->set_spacing (10);
752 hpacker->pack_start (*click_io_selector, false, false);
753 hpacker->pack_start (*click_gpm, false, false);
755 click_packer.pack_start (click_table, false, false);
756 click_packer.pack_start (*hpacker, false, false);
758 click_packer.show_all ();
762 OptionEditor::clear_auditioner_editor ()
764 if (auditioner_io_selector) {
765 audition_hpacker.remove (*auditioner_io_selector);
766 audition_hpacker.remove (*auditioner_gpm);
767 delete auditioner_io_selector;
768 delete auditioner_gpm;
769 auditioner_io_selector = 0;
775 OptionEditor::setup_auditioner_editor ()
777 audition_packer.set_border_width (12);
778 audition_packer.set_spacing (5);
779 audition_hpacker.set_spacing (10);
781 audition_label.set_name ("OptionEditorAuditionerLabel");
782 audition_label.set_text (_("The auditioner is a dedicated mixer strip used\n"
783 "for listening to specific regions outside the context\n"
784 "of the overall mix. It can be connected just like any\n"
785 "other mixer strip."));
787 audition_packer.pack_start (audition_label, false, false, 10);
788 audition_packer.pack_start (audition_hpacker, false, false);
792 OptionEditor::connect_audition_editor ()
794 auditioner_io_selector = new IOSelector (*session, session->the_auditioner(), false);
795 auditioner_gpm = new GainMeter (session->the_auditioner(), *session);
797 audition_hpacker.pack_start (*auditioner_io_selector, false, false);
798 audition_hpacker.pack_start (*auditioner_gpm, false, false);
800 auditioner_io_selector->show_all ();
801 auditioner_gpm->show_all ();
805 OptionEditor::focus_out_event_handler (GdkEventFocus* ev, void (OptionEditor::*pmf)())
811 static const struct {
815 { "Shift", GDK_SHIFT_MASK },
816 { "Control", GDK_CONTROL_MASK },
817 { "Alt (Mod1)", GDK_MOD1_MASK },
818 { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK },
819 { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK },
820 { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK },
821 { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
822 { "Mod2", GDK_MOD2_MASK },
823 { "Mod3", GDK_MOD3_MASK },
824 { "Mod4", GDK_MOD4_MASK },
825 { "Mod5", GDK_MOD5_MASK },
830 OptionEditor::setup_keyboard_options ()
835 keyboard_mouse_table.set_border_width (12);
836 keyboard_mouse_table.set_row_spacings (5);
837 keyboard_mouse_table.set_col_spacings (5);
839 /* internationalize and prepare for use with combos */
841 for (int i = 0; modifiers[i].name; ++i) {
842 dumb.push_back (_(modifiers[i].name));
845 set_popdown_strings (edit_modifier_combo, dumb);
846 edit_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::edit_modifier_chosen));
848 for (int x = 0; modifiers[x].name; ++x) {
849 if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
850 edit_modifier_combo.set_active_text (_(modifiers[x].name));
855 label = manage (new Label (_("Edit using")));
856 label->set_name ("OptionsLabel");
857 label->set_alignment (1.0, 0.5);
859 keyboard_mouse_table.attach (*label, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
860 keyboard_mouse_table.attach (edit_modifier_combo, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
862 label = manage (new Label (_("+ button")));
863 label->set_name ("OptionsLabel");
865 keyboard_mouse_table.attach (*label, 3, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
866 keyboard_mouse_table.attach (edit_button_spin, 4, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
868 edit_button_spin.set_name ("OptionsEntry");
869 edit_button_adjustment.set_value (Keyboard::edit_button());
870 edit_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::edit_button_changed));
872 set_popdown_strings (delete_modifier_combo, dumb);
873 delete_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::delete_modifier_chosen));
875 for (int x = 0; modifiers[x].name; ++x) {
876 if (modifiers[x].modifier == Keyboard::delete_modifier ()) {
877 delete_modifier_combo.set_active_text (_(modifiers[x].name));
882 label = manage (new Label (_("Delete using")));
883 label->set_name ("OptionsLabel");
884 label->set_alignment (1.0, 0.5);
886 keyboard_mouse_table.attach (*label, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
887 keyboard_mouse_table.attach (delete_modifier_combo, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
889 label = manage (new Label (_("+ button")));
890 label->set_name ("OptionsLabel");
892 keyboard_mouse_table.attach (*label, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
893 keyboard_mouse_table.attach (delete_button_spin, 4, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
895 delete_button_spin.set_name ("OptionsEntry");
896 delete_button_adjustment.set_value (Keyboard::delete_button());
897 delete_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::delete_button_changed));
899 set_popdown_strings (snap_modifier_combo, dumb);
900 snap_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::snap_modifier_chosen));
902 for (int x = 0; modifiers[x].name; ++x) {
903 if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) {
904 snap_modifier_combo.set_active_text (_(modifiers[x].name));
909 label = manage (new Label (_("Ignore snap using")));
910 label->set_name ("OptionsLabel");
911 label->set_alignment (1.0, 0.5);
913 keyboard_mouse_table.attach (*label, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
914 keyboard_mouse_table.attach (snap_modifier_combo, 1, 2, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
918 OptionEditor::edit_modifier_chosen ()
922 txt = edit_modifier_combo.get_active_text();
924 for (int i = 0; modifiers[i].name; ++i) {
925 if (txt == _(modifiers[i].name)) {
926 Keyboard::set_edit_modifier (modifiers[i].modifier);
933 OptionEditor::delete_modifier_chosen ()
937 txt = delete_modifier_combo.get_active_text();
939 for (int i = 0; modifiers[i].name; ++i) {
940 if (txt == _(modifiers[i].name)) {
941 Keyboard::set_delete_modifier (modifiers[i].modifier);
948 OptionEditor::snap_modifier_chosen ()
952 txt = snap_modifier_combo.get_active_text();
954 for (int i = 0; modifiers[i].name; ++i) {
955 if (txt == _(modifiers[i].name)) {
956 Keyboard::set_snap_modifier (modifiers[i].modifier);
963 OptionEditor::delete_button_changed ()
965 Keyboard::set_delete_button ((guint) delete_button_adjustment.get_value());
969 OptionEditor::edit_button_changed ()
971 Keyboard::set_edit_button ((guint) edit_button_adjustment.get_value());
975 OptionEditor::fixup_combo_size (Gtk::ComboBoxText& combo, vector<string>& strings)
977 /* find the widest string */
979 string::size_type maxlen = 0;
982 for (vector<string>::iterator i = strings.begin(); i != strings.end(); ++i) {
985 if ((l = (*i).length()) > maxlen) {
991 /* try to include ascenders and descenders */
993 if (maxstring.length() > 2) {
998 const guint32 FUDGE = 10; // Combo's are stupid - they steal space from the entry for the button
1000 set_size_request_to_display_given_text (combo, maxstring.c_str(), 10 + FUDGE, 10);