2 Copyright (C) 2001-2006 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <pbd/whitespace.h>
23 #include <ardour/audio_library.h>
24 #include <ardour/session.h>
25 #include <ardour/audioengine.h>
26 #include <ardour/configuration.h>
27 #include <ardour/auditioner.h>
28 #include <ardour/destructive_filesource.h>
29 #include <ardour/crossfade.h>
30 #include <midi++/manager.h>
31 #include <gtkmm2ext/stop_signal.h>
32 #include <gtkmm2ext/utils.h>
34 #include "public_editor.h"
36 #include "ardour_ui.h"
37 #include "io_selector.h"
38 #include "gain_meter.h"
42 #include "option_editor.h"
46 using namespace ARDOUR;
49 using namespace Editing;
50 using namespace Gtkmm2ext;
53 static vector<string> positional_sync_strings;
55 OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui)
56 : Dialog ("option editor"),
67 short_xfade_adjustment (0, 1.0, 500.0, 5.0, 100.0),
68 short_xfade_slider (short_xfade_adjustment),
69 destructo_xfade_adjustment (1.0, 1.0, 500.0, 1.0, 100.0),
70 destructo_xfade_slider (destructo_xfade_adjustment),
74 smpte_offset_clock (X_("SMPTEOffsetClock"), true, true),
75 smpte_offset_negative_button (_("SMPTE offset is negative")),
82 click_browse_button (_("Browse")),
83 click_emphasis_browse_button (_("Browse")),
87 keyboard_mouse_table (3, 4),
88 delete_button_adjustment (3, 1, 5),
89 delete_button_spin (delete_button_adjustment),
90 edit_button_adjustment (3, 1, 5),
91 edit_button_spin (edit_button_adjustment)
94 using namespace Notebook_Helpers;
96 click_io_selector = 0;
97 auditioner_io_selector = 0;
100 set_default_size (300, 300);
101 set_title (_("ardour: options editor"));
102 set_wmclass (_("ardour_option_editor"), "Ardour");
104 set_name ("OptionsWindow");
105 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
107 VBox *vbox = get_vbox();
108 set_border_width (3);
110 vbox->set_spacing (4);
111 vbox->pack_start(notebook);
113 signal_delete_event().connect (mem_fun(*this, &OptionEditor::wm_close));
115 notebook.set_show_tabs (true);
116 notebook.set_show_border (true);
117 notebook.set_name ("OptionsNotebook");
119 setup_sync_options();
120 setup_path_options();
121 setup_fade_options ();
122 setup_keyboard_options ();
123 setup_auditioner_editor ();
125 notebook.pages().push_back (TabElem (sync_packer, _("Sync")));
126 notebook.pages().push_back (TabElem (path_table, _("Paths/Files")));
127 notebook.pages().push_back (TabElem (keyboard_mouse_table, _("Kbd/Mouse")));
128 notebook.pages().push_back (TabElem (click_packer, _("Click")));
129 notebook.pages().push_back (TabElem (audition_packer, _("Audition")));
130 notebook.pages().push_back (TabElem (fade_packer, _("Layers & Fades")));
132 if (!MIDI::Manager::instance()->get_midi_ports().empty()) {
133 setup_midi_options ();
134 notebook.pages().push_back (TabElem (midi_packer, _("MIDI")));
142 OptionEditor::set_session (Session *s)
144 clear_click_editor ();
145 clear_auditioner_editor ();
147 click_path_entry.set_text ("");
148 click_emphasis_path_entry.set_text ("");
149 session_raid_entry.set_text ("");
151 click_path_entry.set_sensitive (false);
152 click_emphasis_path_entry.set_sensitive (false);
153 session_raid_entry.set_sensitive (false);
155 short_xfade_slider.set_sensitive (false);
156 smpte_offset_negative_button.set_sensitive (false);
158 smpte_offset_clock.set_session (s);
160 if ((session = s) == 0) {
164 click_path_entry.set_sensitive (true);
165 click_emphasis_path_entry.set_sensitive (true);
166 session_raid_entry.set_sensitive (true);
167 short_xfade_slider.set_sensitive (true);
168 smpte_offset_negative_button.set_sensitive (true);
170 smpte_offset_clock.set_session (s);
171 smpte_offset_clock.set (s->smpte_offset (), true);
173 smpte_offset_negative_button.set_active (session->smpte_offset_negative());
175 /* set up port assignments */
177 std::map<MIDI::Port*,vector<RadioButton*> >::iterator res;
179 if (session->mtc_port()) {
180 if ((res = port_toggle_buttons.find (session->mtc_port())) != port_toggle_buttons.end()) {
181 (*res).second[MtcIndex]->set_active (true);
185 if (session->mmc_port ()) {
186 if ((res = port_toggle_buttons.find (session->mmc_port())) != port_toggle_buttons.end()) {
187 (*res).second[MmcIndex]->set_active (true);
191 if (session->midi_port()) {
192 if ((res = port_toggle_buttons.find (session->midi_port())) != port_toggle_buttons.end()) {
193 (*res).second[MidiIndex]->set_active (true);
197 setup_click_editor ();
198 connect_audition_editor ();
200 short_xfade_adjustment.set_value ((Crossfade::short_xfade_length() / (float) session->frame_rate()) * 1000.0);
202 add_session_paths ();
205 OptionEditor::~OptionEditor ()
210 OptionEditor::setup_path_options()
214 path_table.set_homogeneous (false);
215 path_table.set_border_width (12);
216 path_table.set_row_spacings (5);
218 session_raid_entry.set_name ("OptionsEntry");
220 session_raid_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::raid_path_changed));
222 label = manage(new Label(_("session RAID path")));
223 label->set_name ("OptionsLabel");
224 path_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
225 path_table.attach (session_raid_entry, 1, 3, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
227 label = manage(new Label(_("Soundfile Search Paths")));
228 label->set_name("OptionsLabel");
229 path_table.attach(*label, 0, 1, 2, 3, FILL|EXPAND, FILL);
230 path_table.attach(sfdb_path_view, 1, 3, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
232 sfdb_path_view.set_paths(Library->get_paths());
233 sfdb_path_view.PathsUpdated.connect (mem_fun(*this, &OptionEditor::sfdb_paths_changed));
235 path_table.show_all();
239 OptionEditor::sfdb_paths_changed ()
241 Library->set_paths (sfdb_path_view.get_paths());
245 OptionEditor::add_session_paths ()
247 click_path_entry.set_sensitive (true);
248 click_emphasis_path_entry.set_sensitive (true);
249 session_raid_entry.set_sensitive (true);
251 if (Config->get_click_sound().empty()) {
252 click_path_entry.set_text (_("internal"));
254 click_path_entry.set_text (Config->get_click_sound());
257 if (Config->get_click_emphasis_sound().empty()) {
258 click_emphasis_path_entry.set_text (_("internal"));
260 click_emphasis_path_entry.set_text (Config->get_click_emphasis_sound());
263 session_raid_entry.set_text(session->raid_path());
267 OptionEditor::setup_fade_options ()
271 Label* label = manage (new Label (_("Short 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 (short_xfade_slider, true, true);
279 fade_packer.pack_start (*hbox, false, false);
281 short_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::short_xfade_adjustment_changed));
283 label = manage (new Label (_("Destructive crossfade length (msecs)")));
284 label->set_name ("OptionsLabel");
286 hbox = manage (new HBox);
287 hbox->set_border_width (5);
288 hbox->set_spacing (10);
289 hbox->pack_start (*label, false, false);
290 hbox->pack_start (destructo_xfade_slider, true, true);
291 fade_packer.pack_start (*hbox, false, false);
293 destructo_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::destructo_xfade_adjustment_changed));
295 short_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
296 destructo_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
298 destructo_xfade_adjustment.set_value (Config->get_destructive_xfade_msecs());
300 fade_packer.show_all ();
304 OptionEditor::short_xfade_adjustment_changed ()
307 float val = short_xfade_adjustment.get_value();
309 /* val is in msecs */
311 Crossfade::set_short_xfade_length ((jack_nframes_t) floor (session->frame_rate() * (val / 1000.0)));
316 OptionEditor::destructo_xfade_adjustment_changed ()
318 float val = destructo_xfade_adjustment.get_value();
320 /* val is in msecs */
322 Config->set_destructive_xfade_msecs ((uint32_t) floor (val));
325 DestructiveFileSource::setup_standard_crossfades (session->frame_rate());
330 OptionEditor::setup_sync_options ()
335 smpte_offset_clock.set_mode (AudioClock::SMPTE);
336 smpte_offset_clock.ValueChanged.connect (mem_fun(*this, &OptionEditor::smpte_offset_chosen));
338 smpte_offset_negative_button.set_name ("OptionEditorToggleButton");
340 smpte_offset_negative_button.unset_flags (Gtk::CAN_FOCUS);
342 Label *smpte_offset_label = manage (new Label (_("SMPTE Offset")));
343 smpte_offset_label->set_name("OptionsLabel");
345 hbox = manage (new HBox);
346 hbox->set_border_width (5);
347 hbox->set_spacing (10);
348 hbox->pack_start (*smpte_offset_label, false, false);
349 hbox->pack_start (smpte_offset_clock, false, false);
350 hbox->pack_start (smpte_offset_negative_button, false, false);
352 sync_packer.pack_start (*hbox, false, false);
354 smpte_offset_negative_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::smpte_offset_negative_clicked));
358 OptionEditor::smpte_offset_negative_clicked ()
361 session->set_smpte_offset_negative (smpte_offset_negative_button.get_active());
366 OptionEditor::smpte_offset_chosen()
369 jack_nframes_t frames = smpte_offset_clock.current_duration();
370 session->set_smpte_offset (frames);
376 OptionEditor::setup_midi_options ()
379 MIDI::Manager::PortMap::const_iterator i;
380 const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports();
385 Gtk::Table* table = manage (new Table (ports.size() + 4, 9));
387 table->set_row_spacings (6);
388 table->set_col_spacings (10);
390 table->attach (*(manage (new Label (X_("Port")))), 0, 1, 0, 1);
391 table->attach (*(manage (new Label (X_("Offline")))), 1, 2, 0, 1);
392 table->attach (*(manage (new Label (X_("Trace\nInput")))), 2, 3, 0, 1);
393 table->attach (*(manage (new Label (X_("Trace\nOutput")))), 3, 4, 0, 1);
394 table->attach (*(manage (new Label (X_("MTC")))), 4, 5, 0, 1);
395 table->attach (*(manage (new Label (X_("MMC")))), 6, 7, 0, 1);
396 table->attach (*(manage (new Label (X_("MIDI Parameter\nControl")))), 8, 9, 0, 1);
398 table->attach (*(manage (new HSeparator())), 0, 9, 1, 2);
399 table->attach (*(manage (new VSeparator())), 5, 6, 0, 8);
400 table->attach (*(manage (new VSeparator())), 7, 8, 0, 8);
402 for (n = 0, i = ports.begin(); i != ports.end(); ++n, ++i) {
404 pair<MIDI::Port*,vector<RadioButton*> > newpair;
406 newpair.first = i->second;
408 table->attach (*(manage (new Label (i->first))), 0, 1, n+2, n+3,FILL|EXPAND, FILL );
409 tb = manage (new ToggleButton (_("online")));
410 tb->set_name ("OptionEditorToggleButton");
412 /* remember, we have to handle the i18n case where the relative
413 lengths of the strings in language N is different than in english.
416 if (strlen (_("offline")) > strlen (_("online"))) {
417 set_size_request_to_display_given_text (*tb, _("offline"), 15, 12);
419 set_size_request_to_display_given_text (*tb, _("online"), 15, 12);
422 tb->set_active (!(*i).second->input()->offline());
423 tb->signal_button_press_event().connect (bind (mem_fun(*this, &OptionEditor::port_online_toggled), (*i).second, tb));
424 (*i).second->input()->OfflineStatusChanged.connect (bind (mem_fun(*this, &OptionEditor::map_port_online), (*i).second, tb));
425 table->attach (*tb, 1, 2, n+2, n+3, FILL|EXPAND, FILL);
427 tb = manage (new ToggleButton ());
428 tb->set_name ("OptionEditorToggleButton");
429 tb->signal_button_press_event().connect (bind (mem_fun(*this, &OptionEditor::port_trace_in_toggled), (*i).second, tb));
430 tb->set_size_request (10, 10);
431 table->attach (*tb, 2, 3, n+2, n+3, FILL|EXPAND, FILL);
433 tb = manage (new ToggleButton ());
434 tb->set_name ("OptionEditorToggleButton");
435 tb->signal_button_press_event().connect (bind (mem_fun(*this, &OptionEditor::port_trace_out_toggled), (*i).second, tb));
436 tb->set_size_request (10, 10);
437 table->attach (*tb, 3, 4, n+2, n+3, FILL|EXPAND, FILL);
439 rb = manage (new RadioButton ());
440 newpair.second.push_back (rb);
441 rb->set_name ("OptionEditorToggleButton");
443 mtc_button_group = rb->get_group();
445 rb->set_group (mtc_button_group);
448 table->attach (*rb, 4, 5, n+2, n+3, FILL|EXPAND, FILL);
449 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mtc_port_chosen), (*i).second, rb));
451 if (Config->get_mtc_port_name() == i->first) {
452 rb->set_active (true);
455 rb = manage (new RadioButton ());
456 newpair.second.push_back (rb);
457 rb->set_name ("OptionEditorToggleButton");
459 mmc_button_group = rb->get_group();
461 rb->set_group (mmc_button_group);
463 table->attach (*rb, 6, 7, n+2, n+3, FILL|EXPAND, FILL);
464 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mmc_port_chosen), (*i).second, rb));
466 if (Config->get_mmc_port_name() == i->first) {
467 rb->set_active (true);
470 rb = manage (new RadioButton ());
471 newpair.second.push_back (rb);
472 rb->set_name ("OptionEditorToggleButton");
474 midi_button_group = rb->get_group();
476 rb->set_group (midi_button_group);
478 table->attach (*rb, 8, 9, n+2, n+3, FILL|EXPAND, FILL);
479 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_port_chosen), (*i).second, rb));
481 if (Config->get_midi_port_name() == i->first) {
482 rb->set_active (true);
485 port_toggle_buttons.insert (newpair);
490 hbox = manage (new HBox);
491 hbox->set_border_width (6);
492 hbox->pack_start (*table, true, false);
493 midi_packer.pack_start (*hbox, false, false);
497 OptionEditor::mtc_port_chosen (MIDI::Port *port, Gtk::RadioButton* rb)
500 if (rb->get_active()) {
501 cerr << "Activating MTC port " << port->name() << endl;
503 session->set_mtc_port (port->name());
504 Config->set_mtc_port_name (port->name());
506 session->set_mtc_port ("");
508 rb->set_active (true);
514 OptionEditor::mmc_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb)
517 if (rb->get_active()) {
518 cerr << "Activating MMC port " << port->name() << endl;
520 session->set_mmc_port (port->name());
521 Config->set_mtc_port_name (port->name());
523 session->set_mmc_port ("");
525 rb->set_active (true);
531 OptionEditor::midi_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb)
534 if (rb->get_active()) {
535 cerr << "Activating MIDI port " << port->name() << endl;
537 session->set_midi_port (port->name());
538 Config->set_midi_port_name (port->name());
540 session->set_midi_port ("");
542 rb->set_active (true);
548 OptionEditor::port_online_toggled (GdkEventButton* ev, MIDI::Port* port, ToggleButton* tb)
550 bool wanted = tb->get_active(); /* it hasn't changed at this point */
552 if (wanted != port->input()->offline()) {
553 port->input()->set_offline (wanted);
555 return stop_signal (*tb, "button_press_event");
559 OptionEditor::map_port_online (MIDI::Port* port, ToggleButton* tb)
561 if (port->input()->offline()) {
562 tb->set_label (_("offline"));
563 tb->set_active (false);
565 tb->set_label (_("online"));
566 tb->set_active (true);
571 OptionEditor::port_trace_in_toggled (GdkEventButton* ev, MIDI::Port* port, ToggleButton* tb)
573 /* XXX not very good MVC style here */
575 port->input()->trace (!tb->get_active(), &cerr, string (port->name()) + string (" input: "));
576 tb->set_active (!tb->get_active());
577 return stop_signal (*tb, "button_press_event");
581 OptionEditor::port_trace_out_toggled (GdkEventButton* ev,MIDI::Port* port, ToggleButton* tb)
583 /* XXX not very good MVC style here */
585 port->output()->trace (!tb->get_active(), &cerr, string (port->name()) + string (" output: "));
586 tb->set_active (!tb->get_active());
587 return stop_signal (*tb, "button_press_event");
591 OptionEditor::save ()
593 /* XXX a bit odd that we save the entire session state here */
599 OptionEditor::wm_close (GdkEventAny *ev)
607 OptionEditor::raid_path_changed ()
610 Config->set_raid_path (session_raid_entry.get_text());
615 OptionEditor::click_browse_clicked ()
617 SoundFileChooser sfdb (_("Choose Click"), session);
619 int result = sfdb.run ();
621 if (result == Gtk::RESPONSE_OK) {
622 click_chosen(sfdb.get_filename());
627 OptionEditor::click_chosen (const string & path)
629 click_path_entry.set_text (path);
630 click_sound_changed ();
634 OptionEditor::click_emphasis_browse_clicked ()
636 SoundFileChooser sfdb (_("Choose Click Emphasis"), session);
638 int result = sfdb.run ();
640 if (result == Gtk::RESPONSE_OK) {
641 click_emphasis_chosen (sfdb.get_filename());
646 OptionEditor::click_emphasis_chosen (const string & path)
648 click_emphasis_path_entry.set_text (path);
649 click_emphasis_sound_changed ();
653 OptionEditor::click_sound_changed ()
656 string path = click_path_entry.get_text();
658 if (path == Config->get_click_sound()) {
664 Config->set_click_sound ("");
668 strip_whitespace_edges (path);
670 if (path == _("internal")) {
671 Config->set_click_sound ("");
673 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()) {
691 Config->set_click_emphasis_sound ("");
695 strip_whitespace_edges (path);
697 if (path == _("internal")) {
698 Config->set_click_emphasis_sound ("");
700 Config->set_click_emphasis_sound (path);
707 OptionEditor::clear_click_editor ()
709 if (click_io_selector) {
710 click_packer.remove (*click_io_selector);
711 click_packer.remove (*click_gpm);
712 delete click_io_selector;
714 click_io_selector = 0;
720 OptionEditor::setup_click_editor ()
723 HBox* hpacker = manage (new HBox);
725 click_path_entry.set_sensitive (true);
726 click_emphasis_path_entry.set_sensitive (true);
728 click_path_entry.set_name ("OptionsEntry");
729 click_emphasis_path_entry.set_name ("OptionsEntry");
731 click_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_sound_changed));
732 click_emphasis_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed));
734 click_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_sound_changed));
735 click_emphasis_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_emphasis_sound_changed));
737 click_browse_button.set_name ("EditorGTKButton");
738 click_emphasis_browse_button.set_name ("EditorGTKButton");
739 click_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_browse_clicked));
740 click_emphasis_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_emphasis_browse_clicked));
742 click_packer.set_border_width (12);
743 click_packer.set_spacing (5);
745 click_io_selector = new IOSelector (*session, session->click_io(), false);
746 click_gpm = new GainMeter (session->click_io(), *session);
748 click_table.set_col_spacings (10);
750 label = manage(new Label(_("Click audio file")));
751 label->set_name ("OptionsLabel");
752 click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
753 click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
754 click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL);
756 label = manage(new Label(_("Click emphasis audiofile")));
757 label->set_name ("OptionsLabel");
758 click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
759 click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
760 click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL);
762 hpacker->set_spacing (10);
763 hpacker->pack_start (*click_io_selector, false, false);
764 hpacker->pack_start (*click_gpm, false, false);
766 click_packer.pack_start (click_table, false, false);
767 click_packer.pack_start (*hpacker, false, false);
769 click_packer.show_all ();
773 OptionEditor::clear_auditioner_editor ()
775 if (auditioner_io_selector) {
776 audition_hpacker.remove (*auditioner_io_selector);
777 audition_hpacker.remove (*auditioner_gpm);
778 delete auditioner_io_selector;
779 delete auditioner_gpm;
780 auditioner_io_selector = 0;
786 OptionEditor::setup_auditioner_editor ()
788 audition_packer.set_border_width (12);
789 audition_packer.set_spacing (5);
790 audition_hpacker.set_spacing (10);
792 audition_label.set_name ("OptionEditorAuditionerLabel");
793 audition_label.set_text (_("The auditioner is a dedicated mixer strip used\n"
794 "for listening to specific regions outside the context\n"
795 "of the overall mix. It can be connected just like any\n"
796 "other mixer strip."));
798 audition_packer.pack_start (audition_label, false, false, 10);
799 audition_packer.pack_start (audition_hpacker, false, false);
803 OptionEditor::connect_audition_editor ()
805 auditioner_io_selector = new IOSelector (*session, session->the_auditioner(), false);
806 auditioner_gpm = new GainMeter (session->the_auditioner(), *session);
808 audition_hpacker.pack_start (*auditioner_io_selector, false, false);
809 audition_hpacker.pack_start (*auditioner_gpm, false, false);
811 auditioner_io_selector->show_all ();
812 auditioner_gpm->show_all ();
816 OptionEditor::focus_out_event_handler (GdkEventFocus* ev, void (OptionEditor::*pmf)())
822 static const struct {
826 { "Shift", GDK_SHIFT_MASK },
827 { "Control", GDK_CONTROL_MASK },
828 { "Alt (Mod1)", GDK_MOD1_MASK },
829 { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK },
830 { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK },
831 { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK },
832 { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
833 { "Mod2", GDK_MOD2_MASK },
834 { "Mod3", GDK_MOD3_MASK },
835 { "Mod4", GDK_MOD4_MASK },
836 { "Mod5", GDK_MOD5_MASK },
841 OptionEditor::setup_keyboard_options ()
846 keyboard_mouse_table.set_border_width (12);
847 keyboard_mouse_table.set_row_spacings (5);
848 keyboard_mouse_table.set_col_spacings (5);
850 /* internationalize and prepare for use with combos */
852 for (int i = 0; modifiers[i].name; ++i) {
853 dumb.push_back (_(modifiers[i].name));
856 set_popdown_strings (edit_modifier_combo, dumb);
857 edit_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::edit_modifier_chosen));
859 for (int x = 0; modifiers[x].name; ++x) {
860 if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
861 edit_modifier_combo.set_active_text (_(modifiers[x].name));
866 label = manage (new Label (_("Edit using")));
867 label->set_name ("OptionsLabel");
868 label->set_alignment (1.0, 0.5);
870 keyboard_mouse_table.attach (*label, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
871 keyboard_mouse_table.attach (edit_modifier_combo, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
873 label = manage (new Label (_("+ button")));
874 label->set_name ("OptionsLabel");
876 keyboard_mouse_table.attach (*label, 3, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
877 keyboard_mouse_table.attach (edit_button_spin, 4, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
879 edit_button_spin.set_name ("OptionsEntry");
880 edit_button_adjustment.set_value (Keyboard::edit_button());
881 edit_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::edit_button_changed));
883 set_popdown_strings (delete_modifier_combo, dumb);
884 delete_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::delete_modifier_chosen));
886 for (int x = 0; modifiers[x].name; ++x) {
887 if (modifiers[x].modifier == Keyboard::delete_modifier ()) {
888 delete_modifier_combo.set_active_text (_(modifiers[x].name));
893 label = manage (new Label (_("Delete using")));
894 label->set_name ("OptionsLabel");
895 label->set_alignment (1.0, 0.5);
897 keyboard_mouse_table.attach (*label, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
898 keyboard_mouse_table.attach (delete_modifier_combo, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
900 label = manage (new Label (_("+ button")));
901 label->set_name ("OptionsLabel");
903 keyboard_mouse_table.attach (*label, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
904 keyboard_mouse_table.attach (delete_button_spin, 4, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
906 delete_button_spin.set_name ("OptionsEntry");
907 delete_button_adjustment.set_value (Keyboard::delete_button());
908 delete_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::delete_button_changed));
910 set_popdown_strings (snap_modifier_combo, dumb);
911 snap_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::snap_modifier_chosen));
913 for (int x = 0; modifiers[x].name; ++x) {
914 if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) {
915 snap_modifier_combo.set_active_text (_(modifiers[x].name));
920 label = manage (new Label (_("Ignore snap using")));
921 label->set_name ("OptionsLabel");
922 label->set_alignment (1.0, 0.5);
924 keyboard_mouse_table.attach (*label, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
925 keyboard_mouse_table.attach (snap_modifier_combo, 1, 2, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
929 OptionEditor::edit_modifier_chosen ()
933 txt = edit_modifier_combo.get_active_text();
935 for (int i = 0; modifiers[i].name; ++i) {
936 if (txt == _(modifiers[i].name)) {
937 Keyboard::set_edit_modifier (modifiers[i].modifier);
944 OptionEditor::delete_modifier_chosen ()
948 txt = delete_modifier_combo.get_active_text();
950 for (int i = 0; modifiers[i].name; ++i) {
951 if (txt == _(modifiers[i].name)) {
952 Keyboard::set_delete_modifier (modifiers[i].modifier);
959 OptionEditor::snap_modifier_chosen ()
963 txt = snap_modifier_combo.get_active_text();
965 for (int i = 0; modifiers[i].name; ++i) {
966 if (txt == _(modifiers[i].name)) {
967 Keyboard::set_snap_modifier (modifiers[i].modifier);
974 OptionEditor::delete_button_changed ()
976 Keyboard::set_delete_button ((guint) delete_button_adjustment.get_value());
980 OptionEditor::edit_button_changed ()
982 Keyboard::set_edit_button ((guint) edit_button_adjustment.get_value());
986 OptionEditor::fixup_combo_size (Gtk::ComboBoxText& combo, vector<string>& strings)
988 /* find the widest string */
990 string::size_type maxlen = 0;
993 for (vector<string>::iterator i = strings.begin(); i != strings.end(); ++i) {
996 if ((l = (*i).length()) > maxlen) {
1002 /* try to include ascenders and descenders */
1004 if (maxstring.length() > 2) {
1009 const guint32 FUDGE = 10; // Combo's are stupid - they steal space from the entry for the button
1011 set_size_request_to_display_given_text (combo, maxstring.c_str(), 10 + FUDGE, 10);