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/session.h>
24 #include <ardour/audioengine.h>
25 #include <ardour/configuration.h>
26 #include <ardour/auditioner.h>
27 #include <ardour/destructive_filesource.h>
28 #include <ardour/crossfade.h>
29 #include <midi++/manager.h>
30 #include <gtkmm2ext/stop_signal.h>
31 #include <gtkmm2ext/utils.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 ("option 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 set_default_size (300, 300);
103 set_title (_("ardour: options editor"));
104 set_wmclass (X_("ardour_option_editor"), "Ardour");
106 set_name ("OptionsWindow");
107 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
109 VBox *vbox = get_vbox();
110 set_border_width (3);
112 vbox->set_spacing (4);
113 vbox->pack_start(notebook);
115 signal_delete_event().connect (mem_fun(*this, &OptionEditor::wm_close));
117 notebook.set_show_tabs (true);
118 notebook.set_show_border (true);
119 notebook.set_name ("OptionsNotebook");
121 setup_sync_options();
122 setup_path_options();
123 setup_fade_options ();
124 setup_keyboard_options ();
125 setup_auditioner_editor ();
127 notebook.pages().push_back (TabElem (sync_packer, _("Sync")));
128 notebook.pages().push_back (TabElem (path_table, _("Paths/Files")));
129 notebook.pages().push_back (TabElem (keyboard_mouse_table, _("Kbd/Mouse")));
130 notebook.pages().push_back (TabElem (click_packer, _("Click")));
131 notebook.pages().push_back (TabElem (audition_packer, _("Audition")));
132 notebook.pages().push_back (TabElem (fade_packer, _("Layers & Fades")));
134 if (!MIDI::Manager::instance()->get_midi_ports().empty()) {
135 setup_midi_options ();
136 notebook.pages().push_back (TabElem (midi_packer, _("MIDI")));
144 OptionEditor::set_session (Session *s)
146 clear_click_editor ();
147 clear_auditioner_editor ();
149 click_path_entry.set_text ("");
150 click_emphasis_path_entry.set_text ("");
151 session_raid_entry.set_text ("");
153 click_path_entry.set_sensitive (false);
154 click_emphasis_path_entry.set_sensitive (false);
155 session_raid_entry.set_sensitive (false);
157 short_xfade_slider.set_sensitive (false);
158 smpte_offset_negative_button.set_sensitive (false);
160 smpte_offset_clock.set_session (s);
162 if ((session = s) == 0) {
166 click_path_entry.set_sensitive (true);
167 click_emphasis_path_entry.set_sensitive (true);
168 session_raid_entry.set_sensitive (true);
169 short_xfade_slider.set_sensitive (true);
170 smpte_offset_negative_button.set_sensitive (true);
172 smpte_offset_clock.set_session (s);
173 smpte_offset_clock.set (s->smpte_offset (), true);
175 smpte_offset_negative_button.set_active (session->smpte_offset_negative());
177 /* set up port assignments */
179 std::map<MIDI::Port*,vector<RadioButton*> >::iterator res;
181 if (session->mtc_port()) {
182 if ((res = port_toggle_buttons.find (session->mtc_port())) != port_toggle_buttons.end()) {
183 (*res).second[MtcIndex]->set_active (true);
187 if (session->mmc_port ()) {
188 if ((res = port_toggle_buttons.find (session->mmc_port())) != port_toggle_buttons.end()) {
189 (*res).second[MmcIndex]->set_active (true);
193 if (session->midi_port()) {
194 if ((res = port_toggle_buttons.find (session->midi_port())) != port_toggle_buttons.end()) {
195 (*res).second[MidiIndex]->set_active (true);
199 setup_click_editor ();
200 connect_audition_editor ();
202 short_xfade_adjustment.set_value ((Crossfade::short_xfade_length() / (float) session->frame_rate()) * 1000.0);
204 add_session_paths ();
207 OptionEditor::~OptionEditor ()
212 OptionEditor::setup_path_options()
216 path_table.set_homogeneous (false);
217 path_table.set_border_width (12);
218 path_table.set_row_spacings (5);
220 session_raid_entry.set_name ("OptionsEntry");
222 session_raid_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::raid_path_changed));
224 label = manage(new Label(_("session RAID path")));
225 label->set_name ("OptionsLabel");
226 path_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
227 path_table.attach (session_raid_entry, 1, 3, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
229 path_table.show_all();
233 OptionEditor::add_session_paths ()
235 click_path_entry.set_sensitive (true);
236 click_emphasis_path_entry.set_sensitive (true);
237 session_raid_entry.set_sensitive (true);
239 if (Config->get_click_sound().empty()) {
240 click_path_entry.set_text (_("internal"));
242 click_path_entry.set_text (Config->get_click_sound());
245 if (Config->get_click_emphasis_sound().empty()) {
246 click_emphasis_path_entry.set_text (_("internal"));
248 click_emphasis_path_entry.set_text (Config->get_click_emphasis_sound());
251 session_raid_entry.set_text(session->raid_path());
255 OptionEditor::setup_fade_options ()
259 Label* label = manage (new Label (_("Short crossfade length (msecs)")));
260 label->set_name ("OptionsLabel");
262 hbox = manage (new HBox);
263 hbox->set_border_width (5);
264 hbox->set_spacing (10);
265 hbox->pack_start (*label, false, false);
266 hbox->pack_start (short_xfade_slider, true, true);
267 fade_packer.pack_start (*hbox, false, false);
269 short_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::short_xfade_adjustment_changed));
271 label = manage (new Label (_("Destructive crossfade length (msecs)")));
272 label->set_name ("OptionsLabel");
274 hbox = manage (new HBox);
275 hbox->set_border_width (5);
276 hbox->set_spacing (10);
277 hbox->pack_start (*label, false, false);
278 hbox->pack_start (destructo_xfade_slider, true, true);
279 fade_packer.pack_start (*hbox, false, false);
281 destructo_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::destructo_xfade_adjustment_changed));
283 short_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
284 destructo_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
286 destructo_xfade_adjustment.set_value (Config->get_destructive_xfade_msecs());
288 fade_packer.show_all ();
292 OptionEditor::short_xfade_adjustment_changed ()
295 float val = short_xfade_adjustment.get_value();
297 /* val is in msecs */
299 Crossfade::set_short_xfade_length ((nframes_t) floor (session->frame_rate() * (val / 1000.0)));
304 OptionEditor::destructo_xfade_adjustment_changed ()
306 float val = destructo_xfade_adjustment.get_value();
308 /* val is in msecs */
311 Config->set_destructive_xfade_msecs ((uint32_t) floor (val));
314 SndFileSource::setup_standard_crossfades (session->frame_rate());
319 OptionEditor::setup_sync_options ()
324 smpte_offset_clock.set_mode (AudioClock::SMPTE);
325 smpte_offset_clock.ValueChanged.connect (mem_fun(*this, &OptionEditor::smpte_offset_chosen));
327 smpte_offset_negative_button.set_name ("OptionEditorToggleButton");
329 smpte_offset_negative_button.unset_flags (Gtk::CAN_FOCUS);
331 Label *smpte_offset_label = manage (new Label (_("SMPTE Offset")));
332 smpte_offset_label->set_name("OptionsLabel");
334 hbox = manage (new HBox);
335 hbox->set_border_width (5);
336 hbox->set_spacing (10);
337 hbox->pack_start (*smpte_offset_label, false, false);
338 hbox->pack_start (smpte_offset_clock, false, false);
339 hbox->pack_start (smpte_offset_negative_button, false, false);
341 sync_packer.pack_start (*hbox, false, false);
343 smpte_offset_negative_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::smpte_offset_negative_clicked));
347 OptionEditor::smpte_offset_negative_clicked ()
350 session->set_smpte_offset_negative (smpte_offset_negative_button.get_active());
355 OptionEditor::smpte_offset_chosen()
358 nframes_t frames = smpte_offset_clock.current_duration();
359 session->set_smpte_offset (frames);
365 OptionEditor::setup_midi_options ()
368 MIDI::Manager::PortMap::const_iterator i;
369 const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports();
374 Gtk::Table* table = manage (new Table (ports.size() + 4, 10));
376 table->set_row_spacings (6);
377 table->set_col_spacings (10);
379 table->attach (*(manage (new Label (_("Port")))), 0, 1, 0, 1);
380 table->attach (*(manage (new Label (_("Offline")))), 1, 2, 0, 1);
381 table->attach (*(manage (new Label (_("Trace\nInput")))), 2, 3, 0, 1);
382 table->attach (*(manage (new Label (_("Trace\nOutput")))), 3, 4, 0, 1);
383 table->attach (*(manage (new Label (_("MTC")))), 4, 5, 0, 1);
384 table->attach (*(manage (new Label (_("MMC")))), 6, 7, 0, 1);
385 table->attach (*(manage (new Label (_("MIDI Parameter\nControl")))), 8, 9, 0, 1);
387 table->attach (*(manage (new HSeparator())), 0, 9, 1, 2);
388 table->attach (*(manage (new VSeparator())), 5, 6, 0, 8);
389 table->attach (*(manage (new VSeparator())), 7, 8, 0, 8);
391 table->attach (*(manage (new Label (_("MMC Device ID")))), 9, 10, 0, 1);
392 table->attach (mmc_device_id_spinner, 9, 10, 1, 2);
394 mmc_device_id_adjustment.signal_value_changed().connect (mem_fun (*this, &OptionEditor::mmc_device_id_adjusted));
396 for (n = 0, i = ports.begin(); i != ports.end(); ++n, ++i) {
398 pair<MIDI::Port*,vector<RadioButton*> > newpair;
400 newpair.first = i->second;
402 table->attach (*(manage (new Label (i->first))), 0, 1, n+2, n+3,FILL|EXPAND, FILL );
403 tb = manage (new ToggleButton (_("online")));
404 tb->set_name ("OptionEditorToggleButton");
406 /* remember, we have to handle the i18n case where the relative
407 lengths of the strings in language N is different than in english.
410 if (strlen (_("offline")) > strlen (_("online"))) {
411 set_size_request_to_display_given_text (*tb, _("offline"), 15, 12);
413 set_size_request_to_display_given_text (*tb, _("online"), 15, 12);
416 tb->set_active (!(*i).second->input()->offline());
417 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_online_toggled), (*i).second, tb));
418 (*i).second->input()->OfflineStatusChanged.connect (bind (mem_fun(*this, &OptionEditor::map_port_online), (*i).second, tb));
419 table->attach (*tb, 1, 2, n+2, n+3, FILL|EXPAND, FILL);
421 tb = manage (new ToggleButton ());
422 tb->set_name ("OptionEditorToggleButton");
423 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_in_toggled), (*i).second, tb));
424 tb->set_size_request (10, 10);
425 table->attach (*tb, 2, 3, n+2, n+3, FILL|EXPAND, FILL);
427 tb = manage (new ToggleButton ());
428 tb->set_name ("OptionEditorToggleButton");
429 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_out_toggled), (*i).second, tb));
430 tb->set_size_request (10, 10);
431 table->attach (*tb, 3, 4, n+2, n+3, FILL|EXPAND, FILL);
433 rb = manage (new RadioButton ());
434 newpair.second.push_back (rb);
435 rb->set_name ("OptionEditorToggleButton");
437 mtc_button_group = rb->get_group();
439 rb->set_group (mtc_button_group);
442 table->attach (*rb, 4, 5, n+2, n+3, FILL|EXPAND, FILL);
443 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mtc_port_chosen), (*i).second, rb));
445 if (Config->get_mtc_port_name() == i->first) {
446 rb->set_active (true);
449 rb = manage (new RadioButton ());
450 newpair.second.push_back (rb);
451 rb->set_name ("OptionEditorToggleButton");
453 mmc_button_group = rb->get_group();
455 rb->set_group (mmc_button_group);
457 table->attach (*rb, 6, 7, n+2, n+3, FILL|EXPAND, FILL);
458 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mmc_port_chosen), (*i).second, rb));
460 if (Config->get_mmc_port_name() == i->first) {
461 rb->set_active (true);
464 rb = manage (new RadioButton ());
465 newpair.second.push_back (rb);
466 rb->set_name ("OptionEditorToggleButton");
468 midi_button_group = rb->get_group();
470 rb->set_group (midi_button_group);
472 table->attach (*rb, 8, 9, n+2, n+3, FILL|EXPAND, FILL);
473 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_port_chosen), (*i).second, rb));
475 if (Config->get_midi_port_name() == i->first) {
476 rb->set_active (true);
479 port_toggle_buttons.insert (newpair);
484 hbox = manage (new HBox);
485 hbox->set_border_width (6);
486 hbox->pack_start (*table, true, false);
487 midi_packer.pack_start (*hbox, false, false);
491 OptionEditor::mtc_port_chosen (MIDI::Port *port, Gtk::RadioButton* rb)
494 if (rb->get_active()) {
496 session->set_mtc_port (port->name());
497 Config->set_mtc_port_name (port->name());
499 session->set_mtc_port ("");
501 rb->set_active (true);
507 OptionEditor::mmc_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb)
510 if (rb->get_active()) {
512 session->set_mmc_port (port->name());
513 Config->set_mtc_port_name (port->name());
515 session->set_mmc_port ("");
517 rb->set_active (true);
523 OptionEditor::midi_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb)
526 if (rb->get_active()) {
528 session->set_midi_port (port->name());
529 Config->set_midi_port_name (port->name());
531 session->set_midi_port ("");
533 rb->set_active (true);
539 OptionEditor::port_online_toggled (MIDI::Port* port, ToggleButton* tb)
541 bool wanted = tb->get_active();
543 if (wanted != port->input()->offline()) {
544 port->input()->set_offline (wanted);
549 OptionEditor::map_port_online (MIDI::Port* port, ToggleButton* tb)
551 bool bstate = tb->get_active ();
553 if (bstate != port->input()->offline()) {
554 if (port->input()->offline()) {
555 tb->set_label (_("offline"));
556 tb->set_active (false);
558 tb->set_label (_("online"));
559 tb->set_active (true);
565 OptionEditor::mmc_device_id_adjusted ()
567 uint8_t id = (uint8_t) mmc_device_id_spinner.get_value();
569 if (id != Config->get_mmc_device_id()) {
570 Config->set_mmc_device_id (id);
575 OptionEditor::port_trace_in_toggled (MIDI::Port* port, ToggleButton* tb)
577 bool trace = tb->get_active();
579 if (port->input()->tracing() != trace) {
580 port->input()->trace (trace, &cerr, string (port->name()) + string (" input: "));
585 OptionEditor::port_trace_out_toggled (MIDI::Port* port, ToggleButton* tb)
587 bool trace = tb->get_active();
589 if (port->output()->tracing() != trace) {
590 port->output()->trace (trace, &cerr, string (port->name()) + string (" output: "));
595 OptionEditor::save ()
597 /* XXX a bit odd that we save the entire session state here */
603 OptionEditor::wm_close (GdkEventAny *ev)
611 OptionEditor::raid_path_changed ()
614 Config->set_raid_path (session_raid_entry.get_text());
619 OptionEditor::click_browse_clicked ()
621 SoundFileChooser sfdb (_("Choose Click"), session);
623 int result = sfdb.run ();
625 if (result == Gtk::RESPONSE_OK) {
626 click_chosen(sfdb.get_filename());
631 OptionEditor::click_chosen (const string & path)
633 click_path_entry.set_text (path);
634 click_sound_changed ();
638 OptionEditor::click_emphasis_browse_clicked ()
640 SoundFileChooser sfdb (_("Choose Click Emphasis"), session);
642 int result = sfdb.run ();
644 if (result == Gtk::RESPONSE_OK) {
645 click_emphasis_chosen (sfdb.get_filename());
650 OptionEditor::click_emphasis_chosen (const string & path)
652 click_emphasis_path_entry.set_text (path);
653 click_emphasis_sound_changed ();
657 OptionEditor::click_sound_changed ()
660 string path = click_path_entry.get_text();
662 if (path == Config->get_click_sound()) {
666 strip_whitespace_edges (path);
668 if (path == _("internal")) {
669 Config->set_click_sound ("");
671 Config->set_click_sound (path);
677 OptionEditor::click_emphasis_sound_changed ()
680 string path = click_emphasis_path_entry.get_text();
682 if (path == Config->get_click_emphasis_sound()) {
686 strip_whitespace_edges (path);
688 if (path == _("internal")) {
689 Config->set_click_emphasis_sound ("");
691 Config->set_click_emphasis_sound (path);
697 OptionEditor::clear_click_editor ()
699 if (click_io_selector) {
700 click_packer.remove (*click_io_selector);
701 click_packer.remove (*click_gpm);
702 delete click_io_selector;
704 click_io_selector = 0;
710 OptionEditor::setup_click_editor ()
713 HBox* hpacker = manage (new HBox);
715 click_path_entry.set_sensitive (true);
716 click_emphasis_path_entry.set_sensitive (true);
718 click_path_entry.set_name ("OptionsEntry");
719 click_emphasis_path_entry.set_name ("OptionsEntry");
721 click_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_sound_changed));
722 click_emphasis_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed));
724 click_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_sound_changed));
725 click_emphasis_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_emphasis_sound_changed));
727 click_browse_button.set_name ("EditorGTKButton");
728 click_emphasis_browse_button.set_name ("EditorGTKButton");
729 click_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_browse_clicked));
730 click_emphasis_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_emphasis_browse_clicked));
732 click_packer.set_border_width (12);
733 click_packer.set_spacing (5);
735 click_io_selector = new IOSelector (*session, session->click_io(), false);
736 click_gpm = new GainMeter (session->click_io(), *session);
738 click_table.set_col_spacings (10);
740 label = manage(new Label(_("Click audio file")));
741 label->set_name ("OptionsLabel");
742 click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
743 click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
744 click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL);
746 label = manage(new Label(_("Click emphasis audiofile")));
747 label->set_name ("OptionsLabel");
748 click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
749 click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
750 click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL);
752 hpacker->set_spacing (10);
753 hpacker->pack_start (*click_io_selector, false, false);
754 hpacker->pack_start (*click_gpm, false, false);
756 click_packer.pack_start (click_table, false, false);
757 click_packer.pack_start (*hpacker, false, false);
759 click_packer.show_all ();
763 OptionEditor::clear_auditioner_editor ()
765 if (auditioner_io_selector) {
766 audition_hpacker.remove (*auditioner_io_selector);
767 audition_hpacker.remove (*auditioner_gpm);
768 delete auditioner_io_selector;
769 delete auditioner_gpm;
770 auditioner_io_selector = 0;
776 OptionEditor::setup_auditioner_editor ()
778 audition_packer.set_border_width (12);
779 audition_packer.set_spacing (5);
780 audition_hpacker.set_spacing (10);
782 audition_label.set_name ("OptionEditorAuditionerLabel");
783 audition_label.set_text (_("The auditioner is a dedicated mixer strip used\n"
784 "for listening to specific regions outside the context\n"
785 "of the overall mix. It can be connected just like any\n"
786 "other mixer strip."));
788 audition_packer.pack_start (audition_label, false, false, 10);
789 audition_packer.pack_start (audition_hpacker, false, false);
793 OptionEditor::connect_audition_editor ()
795 auditioner_io_selector = new IOSelector (*session, session->the_auditioner(), false);
796 auditioner_gpm = new GainMeter (session->the_auditioner(), *session);
798 audition_hpacker.pack_start (*auditioner_io_selector, false, false);
799 audition_hpacker.pack_start (*auditioner_gpm, false, false);
801 auditioner_io_selector->show_all ();
802 auditioner_gpm->show_all ();
806 OptionEditor::focus_out_event_handler (GdkEventFocus* ev, void (OptionEditor::*pmf)())
812 static const struct {
816 { "Shift", GDK_SHIFT_MASK },
817 { "Control", GDK_CONTROL_MASK },
818 { "Alt (Mod1)", GDK_MOD1_MASK },
819 { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK },
820 { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK },
821 { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK },
822 { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
823 { "Mod2", GDK_MOD2_MASK },
824 { "Mod3", GDK_MOD3_MASK },
825 { "Mod4", GDK_MOD4_MASK },
826 { "Mod5", GDK_MOD5_MASK },
831 OptionEditor::setup_keyboard_options ()
836 keyboard_mouse_table.set_border_width (12);
837 keyboard_mouse_table.set_row_spacings (5);
838 keyboard_mouse_table.set_col_spacings (5);
840 /* internationalize and prepare for use with combos */
842 for (int i = 0; modifiers[i].name; ++i) {
843 dumb.push_back (_(modifiers[i].name));
846 set_popdown_strings (edit_modifier_combo, dumb);
847 edit_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::edit_modifier_chosen));
849 for (int x = 0; modifiers[x].name; ++x) {
850 if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
851 edit_modifier_combo.set_active_text (_(modifiers[x].name));
856 label = manage (new Label (_("Edit using")));
857 label->set_name ("OptionsLabel");
858 label->set_alignment (1.0, 0.5);
860 keyboard_mouse_table.attach (*label, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
861 keyboard_mouse_table.attach (edit_modifier_combo, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
863 label = manage (new Label (_("+ button")));
864 label->set_name ("OptionsLabel");
866 keyboard_mouse_table.attach (*label, 3, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
867 keyboard_mouse_table.attach (edit_button_spin, 4, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
869 edit_button_spin.set_name ("OptionsEntry");
870 edit_button_adjustment.set_value (Keyboard::edit_button());
871 edit_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::edit_button_changed));
873 set_popdown_strings (delete_modifier_combo, dumb);
874 delete_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::delete_modifier_chosen));
876 for (int x = 0; modifiers[x].name; ++x) {
877 if (modifiers[x].modifier == Keyboard::delete_modifier ()) {
878 delete_modifier_combo.set_active_text (_(modifiers[x].name));
883 label = manage (new Label (_("Delete using")));
884 label->set_name ("OptionsLabel");
885 label->set_alignment (1.0, 0.5);
887 keyboard_mouse_table.attach (*label, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
888 keyboard_mouse_table.attach (delete_modifier_combo, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
890 label = manage (new Label (_("+ button")));
891 label->set_name ("OptionsLabel");
893 keyboard_mouse_table.attach (*label, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
894 keyboard_mouse_table.attach (delete_button_spin, 4, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
896 delete_button_spin.set_name ("OptionsEntry");
897 delete_button_adjustment.set_value (Keyboard::delete_button());
898 delete_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::delete_button_changed));
900 set_popdown_strings (snap_modifier_combo, dumb);
901 snap_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::snap_modifier_chosen));
903 for (int x = 0; modifiers[x].name; ++x) {
904 if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) {
905 snap_modifier_combo.set_active_text (_(modifiers[x].name));
910 label = manage (new Label (_("Ignore snap using")));
911 label->set_name ("OptionsLabel");
912 label->set_alignment (1.0, 0.5);
914 keyboard_mouse_table.attach (*label, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
915 keyboard_mouse_table.attach (snap_modifier_combo, 1, 2, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
919 OptionEditor::edit_modifier_chosen ()
923 txt = edit_modifier_combo.get_active_text();
925 for (int i = 0; modifiers[i].name; ++i) {
926 if (txt == _(modifiers[i].name)) {
927 Keyboard::set_edit_modifier (modifiers[i].modifier);
934 OptionEditor::delete_modifier_chosen ()
938 txt = delete_modifier_combo.get_active_text();
940 for (int i = 0; modifiers[i].name; ++i) {
941 if (txt == _(modifiers[i].name)) {
942 Keyboard::set_delete_modifier (modifiers[i].modifier);
949 OptionEditor::snap_modifier_chosen ()
953 txt = snap_modifier_combo.get_active_text();
955 for (int i = 0; modifiers[i].name; ++i) {
956 if (txt == _(modifiers[i].name)) {
957 Keyboard::set_snap_modifier (modifiers[i].modifier);
964 OptionEditor::delete_button_changed ()
966 Keyboard::set_delete_button ((guint) delete_button_adjustment.get_value());
970 OptionEditor::edit_button_changed ()
972 Keyboard::set_edit_button ((guint) edit_button_adjustment.get_value());
976 OptionEditor::fixup_combo_size (Gtk::ComboBoxText& combo, vector<string>& strings)
978 /* find the widest string */
980 string::size_type maxlen = 0;
983 for (vector<string>::iterator i = strings.begin(); i != strings.end(); ++i) {
986 if ((l = (*i).length()) > maxlen) {
992 /* try to include ascenders and descenders */
994 if (maxstring.length() > 2) {
999 const guint32 FUDGE = 10; // Combo's are stupid - they steal space from the entry for the button
1001 set_size_request_to_display_given_text (combo, maxstring.c_str(), 10 + FUDGE, 10);