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"
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_("SMPTEOffsetClock"), true, true),
73 smpte_offset_negative_button (_("SMPTE offset is negative")),
80 click_browse_button (_("Browse")),
81 click_emphasis_browse_button (_("Browse")),
85 keyboard_mouse_table (3, 4),
86 delete_button_adjustment (3, 1, 5),
87 delete_button_spin (delete_button_adjustment),
88 edit_button_adjustment (3, 1, 5),
89 edit_button_spin (edit_button_adjustment)
92 using namespace Notebook_Helpers;
94 click_io_selector = 0;
95 auditioner_io_selector = 0;
98 set_default_size (300, 300);
99 set_title (_("ardour: options editor"));
100 set_wmclass (X_("ardour_option_editor"), "Ardour");
102 set_name ("OptionsWindow");
103 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
105 VBox *vbox = get_vbox();
106 set_border_width (3);
108 vbox->set_spacing (4);
109 vbox->pack_start(notebook);
111 signal_delete_event().connect (mem_fun(*this, &OptionEditor::wm_close));
113 notebook.set_show_tabs (true);
114 notebook.set_show_border (true);
115 notebook.set_name ("OptionsNotebook");
117 setup_sync_options();
118 setup_path_options();
119 setup_fade_options ();
120 setup_keyboard_options ();
121 setup_auditioner_editor ();
123 notebook.pages().push_back (TabElem (sync_packer, _("Sync")));
124 notebook.pages().push_back (TabElem (path_table, _("Paths/Files")));
125 notebook.pages().push_back (TabElem (keyboard_mouse_table, _("Kbd/Mouse")));
126 notebook.pages().push_back (TabElem (click_packer, _("Click")));
127 notebook.pages().push_back (TabElem (audition_packer, _("Audition")));
128 notebook.pages().push_back (TabElem (fade_packer, _("Layers & Fades")));
130 if (!MIDI::Manager::instance()->get_midi_ports().empty()) {
131 setup_midi_options ();
132 notebook.pages().push_back (TabElem (midi_packer, _("MIDI")));
140 OptionEditor::set_session (Session *s)
142 clear_click_editor ();
143 clear_auditioner_editor ();
145 click_path_entry.set_text ("");
146 click_emphasis_path_entry.set_text ("");
147 session_raid_entry.set_text ("");
149 click_path_entry.set_sensitive (false);
150 click_emphasis_path_entry.set_sensitive (false);
151 session_raid_entry.set_sensitive (false);
153 short_xfade_slider.set_sensitive (false);
154 smpte_offset_negative_button.set_sensitive (false);
156 smpte_offset_clock.set_session (s);
158 if ((session = s) == 0) {
162 click_path_entry.set_sensitive (true);
163 click_emphasis_path_entry.set_sensitive (true);
164 session_raid_entry.set_sensitive (true);
165 short_xfade_slider.set_sensitive (true);
166 smpte_offset_negative_button.set_sensitive (true);
168 smpte_offset_clock.set_session (s);
169 smpte_offset_clock.set (s->smpte_offset (), true);
171 smpte_offset_negative_button.set_active (session->smpte_offset_negative());
173 /* set up port assignments */
175 std::map<MIDI::Port*,vector<RadioButton*> >::iterator res;
177 if (session->mtc_port()) {
178 if ((res = port_toggle_buttons.find (session->mtc_port())) != port_toggle_buttons.end()) {
179 (*res).second[MtcIndex]->set_active (true);
183 if (session->mmc_port ()) {
184 if ((res = port_toggle_buttons.find (session->mmc_port())) != port_toggle_buttons.end()) {
185 (*res).second[MmcIndex]->set_active (true);
189 if (session->midi_port()) {
190 if ((res = port_toggle_buttons.find (session->midi_port())) != port_toggle_buttons.end()) {
191 (*res).second[MidiIndex]->set_active (true);
195 setup_click_editor ();
196 connect_audition_editor ();
198 short_xfade_adjustment.set_value ((Crossfade::short_xfade_length() / (float) session->frame_rate()) * 1000.0);
200 add_session_paths ();
203 OptionEditor::~OptionEditor ()
208 OptionEditor::setup_path_options()
212 path_table.set_homogeneous (false);
213 path_table.set_border_width (12);
214 path_table.set_row_spacings (5);
216 session_raid_entry.set_name ("OptionsEntry");
218 session_raid_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::raid_path_changed));
220 label = manage(new Label(_("session RAID path")));
221 label->set_name ("OptionsLabel");
222 path_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
223 path_table.attach (session_raid_entry, 1, 3, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
225 path_table.show_all();
229 OptionEditor::add_session_paths ()
231 click_path_entry.set_sensitive (true);
232 click_emphasis_path_entry.set_sensitive (true);
233 session_raid_entry.set_sensitive (true);
235 if (Config->get_click_sound().empty()) {
236 click_path_entry.set_text (_("internal"));
238 click_path_entry.set_text (Config->get_click_sound());
241 if (Config->get_click_emphasis_sound().empty()) {
242 click_emphasis_path_entry.set_text (_("internal"));
244 click_emphasis_path_entry.set_text (Config->get_click_emphasis_sound());
247 session_raid_entry.set_text(session->raid_path());
251 OptionEditor::setup_fade_options ()
255 Label* label = manage (new Label (_("Short crossfade length (msecs)")));
256 label->set_name ("OptionsLabel");
258 hbox = manage (new HBox);
259 hbox->set_border_width (5);
260 hbox->set_spacing (10);
261 hbox->pack_start (*label, false, false);
262 hbox->pack_start (short_xfade_slider, true, true);
263 fade_packer.pack_start (*hbox, false, false);
265 short_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::short_xfade_adjustment_changed));
267 label = manage (new Label (_("Destructive crossfade length (msecs)")));
268 label->set_name ("OptionsLabel");
270 hbox = manage (new HBox);
271 hbox->set_border_width (5);
272 hbox->set_spacing (10);
273 hbox->pack_start (*label, false, false);
274 hbox->pack_start (destructo_xfade_slider, true, true);
275 fade_packer.pack_start (*hbox, false, false);
277 destructo_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::destructo_xfade_adjustment_changed));
279 short_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
280 destructo_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
282 destructo_xfade_adjustment.set_value (Config->get_destructive_xfade_msecs());
284 fade_packer.show_all ();
288 OptionEditor::short_xfade_adjustment_changed ()
291 float val = short_xfade_adjustment.get_value();
293 /* val is in msecs */
295 Crossfade::set_short_xfade_length ((nframes_t) floor (session->frame_rate() * (val / 1000.0)));
300 OptionEditor::destructo_xfade_adjustment_changed ()
302 float val = destructo_xfade_adjustment.get_value();
304 /* val is in msecs */
307 Config->set_destructive_xfade_msecs ((uint32_t) floor (val));
310 SndFileSource::setup_standard_crossfades (session->frame_rate());
315 OptionEditor::setup_sync_options ()
320 smpte_offset_clock.set_mode (AudioClock::SMPTE);
321 smpte_offset_clock.ValueChanged.connect (mem_fun(*this, &OptionEditor::smpte_offset_chosen));
323 smpte_offset_negative_button.set_name ("OptionEditorToggleButton");
325 smpte_offset_negative_button.unset_flags (Gtk::CAN_FOCUS);
327 Label *smpte_offset_label = manage (new Label (_("SMPTE Offset")));
328 smpte_offset_label->set_name("OptionsLabel");
330 hbox = manage (new HBox);
331 hbox->set_border_width (5);
332 hbox->set_spacing (10);
333 hbox->pack_start (*smpte_offset_label, false, false);
334 hbox->pack_start (smpte_offset_clock, false, false);
335 hbox->pack_start (smpte_offset_negative_button, false, false);
337 sync_packer.pack_start (*hbox, false, false);
339 smpte_offset_negative_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::smpte_offset_negative_clicked));
343 OptionEditor::smpte_offset_negative_clicked ()
346 session->set_smpte_offset_negative (smpte_offset_negative_button.get_active());
351 OptionEditor::smpte_offset_chosen()
354 nframes_t frames = smpte_offset_clock.current_duration();
355 session->set_smpte_offset (frames);
361 OptionEditor::setup_midi_options ()
364 MIDI::Manager::PortMap::const_iterator i;
365 const MIDI::Manager::PortMap& ports = MIDI::Manager::instance()->get_midi_ports();
370 Gtk::Table* table = manage (new Table (ports.size() + 4, 9));
372 table->set_row_spacings (6);
373 table->set_col_spacings (10);
375 table->attach (*(manage (new Label (X_("Port")))), 0, 1, 0, 1);
376 table->attach (*(manage (new Label (X_("Offline")))), 1, 2, 0, 1);
377 table->attach (*(manage (new Label (X_("Trace\nInput")))), 2, 3, 0, 1);
378 table->attach (*(manage (new Label (X_("Trace\nOutput")))), 3, 4, 0, 1);
379 table->attach (*(manage (new Label (X_("MTC")))), 4, 5, 0, 1);
380 table->attach (*(manage (new Label (X_("MMC")))), 6, 7, 0, 1);
381 table->attach (*(manage (new Label (X_("MIDI Parameter\nControl")))), 8, 9, 0, 1);
383 table->attach (*(manage (new HSeparator())), 0, 9, 1, 2);
384 table->attach (*(manage (new VSeparator())), 5, 6, 0, 8);
385 table->attach (*(manage (new VSeparator())), 7, 8, 0, 8);
387 for (n = 0, i = ports.begin(); i != ports.end(); ++n, ++i) {
389 pair<MIDI::Port*,vector<RadioButton*> > newpair;
391 newpair.first = i->second;
393 table->attach (*(manage (new Label (i->first))), 0, 1, n+2, n+3,FILL|EXPAND, FILL );
394 tb = manage (new ToggleButton (_("online")));
395 tb->set_name ("OptionEditorToggleButton");
397 /* remember, we have to handle the i18n case where the relative
398 lengths of the strings in language N is different than in english.
401 if (strlen (_("offline")) > strlen (_("online"))) {
402 set_size_request_to_display_given_text (*tb, _("offline"), 15, 12);
404 set_size_request_to_display_given_text (*tb, _("online"), 15, 12);
407 tb->set_active (!(*i).second->input()->offline());
408 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_online_toggled), (*i).second, tb));
409 (*i).second->input()->OfflineStatusChanged.connect (bind (mem_fun(*this, &OptionEditor::map_port_online), (*i).second, tb));
410 table->attach (*tb, 1, 2, n+2, n+3, FILL|EXPAND, FILL);
412 tb = manage (new ToggleButton ());
413 tb->set_name ("OptionEditorToggleButton");
414 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_in_toggled), (*i).second, tb));
415 tb->set_size_request (10, 10);
416 table->attach (*tb, 2, 3, n+2, n+3, FILL|EXPAND, FILL);
418 tb = manage (new ToggleButton ());
419 tb->set_name ("OptionEditorToggleButton");
420 tb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::port_trace_out_toggled), (*i).second, tb));
421 tb->set_size_request (10, 10);
422 table->attach (*tb, 3, 4, n+2, n+3, FILL|EXPAND, FILL);
424 rb = manage (new RadioButton ());
425 newpair.second.push_back (rb);
426 rb->set_name ("OptionEditorToggleButton");
428 mtc_button_group = rb->get_group();
430 rb->set_group (mtc_button_group);
433 table->attach (*rb, 4, 5, n+2, n+3, FILL|EXPAND, FILL);
434 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mtc_port_chosen), (*i).second, rb));
436 if (Config->get_mtc_port_name() == i->first) {
437 rb->set_active (true);
440 rb = manage (new RadioButton ());
441 newpair.second.push_back (rb);
442 rb->set_name ("OptionEditorToggleButton");
444 mmc_button_group = rb->get_group();
446 rb->set_group (mmc_button_group);
448 table->attach (*rb, 6, 7, n+2, n+3, FILL|EXPAND, FILL);
449 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::mmc_port_chosen), (*i).second, rb));
451 if (Config->get_mmc_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 midi_button_group = rb->get_group();
461 rb->set_group (midi_button_group);
463 table->attach (*rb, 8, 9, n+2, n+3, FILL|EXPAND, FILL);
464 rb->signal_toggled().connect (bind (mem_fun(*this, &OptionEditor::midi_port_chosen), (*i).second, rb));
466 if (Config->get_midi_port_name() == i->first) {
467 rb->set_active (true);
470 port_toggle_buttons.insert (newpair);
475 hbox = manage (new HBox);
476 hbox->set_border_width (6);
477 hbox->pack_start (*table, true, false);
478 midi_packer.pack_start (*hbox, false, false);
482 OptionEditor::mtc_port_chosen (MIDI::Port *port, Gtk::RadioButton* rb)
485 if (rb->get_active()) {
486 cerr << "Activating MTC port " << port->name() << endl;
488 session->set_mtc_port (port->name());
489 Config->set_mtc_port_name (port->name());
491 session->set_mtc_port ("");
493 rb->set_active (true);
499 OptionEditor::mmc_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb)
502 if (rb->get_active()) {
503 cerr << "Activating MMC port " << port->name() << endl;
505 session->set_mmc_port (port->name());
506 Config->set_mtc_port_name (port->name());
508 session->set_mmc_port ("");
510 rb->set_active (true);
516 OptionEditor::midi_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb)
519 if (rb->get_active()) {
520 cerr << "Activating MIDI port " << port->name() << endl;
522 session->set_midi_port (port->name());
523 Config->set_midi_port_name (port->name());
525 session->set_midi_port ("");
527 rb->set_active (true);
533 OptionEditor::port_online_toggled (MIDI::Port* port, ToggleButton* tb)
535 bool wanted = tb->get_active();
537 if (wanted != port->input()->offline()) {
538 port->input()->set_offline (wanted);
543 OptionEditor::map_port_online (MIDI::Port* port, ToggleButton* tb)
545 bool bstate = tb->get_active ();
547 if (bstate != port->input()->offline()) {
548 if (port->input()->offline()) {
549 tb->set_label (_("offline"));
550 tb->set_active (false);
552 tb->set_label (_("online"));
553 tb->set_active (true);
559 OptionEditor::port_trace_in_toggled (MIDI::Port* port, ToggleButton* tb)
561 bool trace = tb->get_active();
563 if (port->input()->tracing() != trace) {
564 port->output()->trace (trace, &cerr, string (port->name()) + string (" input: "));
569 OptionEditor::port_trace_out_toggled (MIDI::Port* port, ToggleButton* tb)
571 bool trace = tb->get_active();
573 if (port->output()->tracing() != trace) {
574 port->output()->trace (trace, &cerr, string (port->name()) + string (" output: "));
579 OptionEditor::save ()
581 /* XXX a bit odd that we save the entire session state here */
587 OptionEditor::wm_close (GdkEventAny *ev)
595 OptionEditor::raid_path_changed ()
598 Config->set_raid_path (session_raid_entry.get_text());
603 OptionEditor::click_browse_clicked ()
605 SoundFileChooser sfdb (_("Choose Click"), session);
607 int result = sfdb.run ();
609 if (result == Gtk::RESPONSE_OK) {
610 click_chosen(sfdb.get_filename());
615 OptionEditor::click_chosen (const string & path)
617 click_path_entry.set_text (path);
618 click_sound_changed ();
622 OptionEditor::click_emphasis_browse_clicked ()
624 SoundFileChooser sfdb (_("Choose Click Emphasis"), session);
626 int result = sfdb.run ();
628 if (result == Gtk::RESPONSE_OK) {
629 click_emphasis_chosen (sfdb.get_filename());
634 OptionEditor::click_emphasis_chosen (const string & path)
636 click_emphasis_path_entry.set_text (path);
637 click_emphasis_sound_changed ();
641 OptionEditor::click_sound_changed ()
644 string path = click_path_entry.get_text();
646 if (path == Config->get_click_sound()) {
650 strip_whitespace_edges (path);
652 if (path == _("internal")) {
653 Config->set_click_sound ("");
655 Config->set_click_sound (path);
661 OptionEditor::click_emphasis_sound_changed ()
664 string path = click_emphasis_path_entry.get_text();
666 if (path == Config->get_click_emphasis_sound()) {
670 strip_whitespace_edges (path);
672 if (path == _("internal")) {
673 Config->set_click_emphasis_sound ("");
675 Config->set_click_emphasis_sound (path);
681 OptionEditor::clear_click_editor ()
683 if (click_io_selector) {
684 click_packer.remove (*click_io_selector);
685 click_packer.remove (*click_gpm);
686 delete click_io_selector;
688 click_io_selector = 0;
694 OptionEditor::setup_click_editor ()
697 HBox* hpacker = manage (new HBox);
699 click_path_entry.set_sensitive (true);
700 click_emphasis_path_entry.set_sensitive (true);
702 click_path_entry.set_name ("OptionsEntry");
703 click_emphasis_path_entry.set_name ("OptionsEntry");
705 click_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_sound_changed));
706 click_emphasis_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed));
708 click_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_sound_changed));
709 click_emphasis_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_emphasis_sound_changed));
711 click_browse_button.set_name ("EditorGTKButton");
712 click_emphasis_browse_button.set_name ("EditorGTKButton");
713 click_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_browse_clicked));
714 click_emphasis_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_emphasis_browse_clicked));
716 click_packer.set_border_width (12);
717 click_packer.set_spacing (5);
719 click_io_selector = new IOSelector (*session, session->click_io(), false);
720 click_gpm = new GainMeter (session->click_io(), *session);
722 click_table.set_col_spacings (10);
724 label = manage(new Label(_("Click audio file")));
725 label->set_name ("OptionsLabel");
726 click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
727 click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
728 click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL);
730 label = manage(new Label(_("Click emphasis audiofile")));
731 label->set_name ("OptionsLabel");
732 click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
733 click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
734 click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL);
736 hpacker->set_spacing (10);
737 hpacker->pack_start (*click_io_selector, false, false);
738 hpacker->pack_start (*click_gpm, false, false);
740 click_packer.pack_start (click_table, false, false);
741 click_packer.pack_start (*hpacker, false, false);
743 click_packer.show_all ();
747 OptionEditor::clear_auditioner_editor ()
749 if (auditioner_io_selector) {
750 audition_hpacker.remove (*auditioner_io_selector);
751 audition_hpacker.remove (*auditioner_gpm);
752 delete auditioner_io_selector;
753 delete auditioner_gpm;
754 auditioner_io_selector = 0;
760 OptionEditor::setup_auditioner_editor ()
762 audition_packer.set_border_width (12);
763 audition_packer.set_spacing (5);
764 audition_hpacker.set_spacing (10);
766 audition_label.set_name ("OptionEditorAuditionerLabel");
767 audition_label.set_text (_("The auditioner is a dedicated mixer strip used\n"
768 "for listening to specific regions outside the context\n"
769 "of the overall mix. It can be connected just like any\n"
770 "other mixer strip."));
772 audition_packer.pack_start (audition_label, false, false, 10);
773 audition_packer.pack_start (audition_hpacker, false, false);
777 OptionEditor::connect_audition_editor ()
779 auditioner_io_selector = new IOSelector (*session, session->the_auditioner(), false);
780 auditioner_gpm = new GainMeter (session->the_auditioner(), *session);
782 audition_hpacker.pack_start (*auditioner_io_selector, false, false);
783 audition_hpacker.pack_start (*auditioner_gpm, false, false);
785 auditioner_io_selector->show_all ();
786 auditioner_gpm->show_all ();
790 OptionEditor::focus_out_event_handler (GdkEventFocus* ev, void (OptionEditor::*pmf)())
796 static const struct {
800 { "Shift", GDK_SHIFT_MASK },
801 { "Control", GDK_CONTROL_MASK },
802 { "Alt (Mod1)", GDK_MOD1_MASK },
803 { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK },
804 { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK },
805 { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK },
806 { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
807 { "Mod2", GDK_MOD2_MASK },
808 { "Mod3", GDK_MOD3_MASK },
809 { "Mod4", GDK_MOD4_MASK },
810 { "Mod5", GDK_MOD5_MASK },
815 OptionEditor::setup_keyboard_options ()
820 keyboard_mouse_table.set_border_width (12);
821 keyboard_mouse_table.set_row_spacings (5);
822 keyboard_mouse_table.set_col_spacings (5);
824 /* internationalize and prepare for use with combos */
826 for (int i = 0; modifiers[i].name; ++i) {
827 dumb.push_back (_(modifiers[i].name));
830 set_popdown_strings (edit_modifier_combo, dumb);
831 edit_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::edit_modifier_chosen));
833 for (int x = 0; modifiers[x].name; ++x) {
834 if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
835 edit_modifier_combo.set_active_text (_(modifiers[x].name));
840 label = manage (new Label (_("Edit using")));
841 label->set_name ("OptionsLabel");
842 label->set_alignment (1.0, 0.5);
844 keyboard_mouse_table.attach (*label, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
845 keyboard_mouse_table.attach (edit_modifier_combo, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
847 label = manage (new Label (_("+ button")));
848 label->set_name ("OptionsLabel");
850 keyboard_mouse_table.attach (*label, 3, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
851 keyboard_mouse_table.attach (edit_button_spin, 4, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
853 edit_button_spin.set_name ("OptionsEntry");
854 edit_button_adjustment.set_value (Keyboard::edit_button());
855 edit_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::edit_button_changed));
857 set_popdown_strings (delete_modifier_combo, dumb);
858 delete_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::delete_modifier_chosen));
860 for (int x = 0; modifiers[x].name; ++x) {
861 if (modifiers[x].modifier == Keyboard::delete_modifier ()) {
862 delete_modifier_combo.set_active_text (_(modifiers[x].name));
867 label = manage (new Label (_("Delete using")));
868 label->set_name ("OptionsLabel");
869 label->set_alignment (1.0, 0.5);
871 keyboard_mouse_table.attach (*label, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
872 keyboard_mouse_table.attach (delete_modifier_combo, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
874 label = manage (new Label (_("+ button")));
875 label->set_name ("OptionsLabel");
877 keyboard_mouse_table.attach (*label, 3, 4, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
878 keyboard_mouse_table.attach (delete_button_spin, 4, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
880 delete_button_spin.set_name ("OptionsEntry");
881 delete_button_adjustment.set_value (Keyboard::delete_button());
882 delete_button_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::delete_button_changed));
884 set_popdown_strings (snap_modifier_combo, dumb);
885 snap_modifier_combo.signal_changed().connect (mem_fun(*this, &OptionEditor::snap_modifier_chosen));
887 for (int x = 0; modifiers[x].name; ++x) {
888 if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) {
889 snap_modifier_combo.set_active_text (_(modifiers[x].name));
894 label = manage (new Label (_("Ignore snap using")));
895 label->set_name ("OptionsLabel");
896 label->set_alignment (1.0, 0.5);
898 keyboard_mouse_table.attach (*label, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
899 keyboard_mouse_table.attach (snap_modifier_combo, 1, 2, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
903 OptionEditor::edit_modifier_chosen ()
907 txt = edit_modifier_combo.get_active_text();
909 for (int i = 0; modifiers[i].name; ++i) {
910 if (txt == _(modifiers[i].name)) {
911 Keyboard::set_edit_modifier (modifiers[i].modifier);
918 OptionEditor::delete_modifier_chosen ()
922 txt = delete_modifier_combo.get_active_text();
924 for (int i = 0; modifiers[i].name; ++i) {
925 if (txt == _(modifiers[i].name)) {
926 Keyboard::set_delete_modifier (modifiers[i].modifier);
933 OptionEditor::snap_modifier_chosen ()
937 txt = snap_modifier_combo.get_active_text();
939 for (int i = 0; modifiers[i].name; ++i) {
940 if (txt == _(modifiers[i].name)) {
941 Keyboard::set_snap_modifier (modifiers[i].modifier);
948 OptionEditor::delete_button_changed ()
950 Keyboard::set_delete_button ((guint) delete_button_adjustment.get_value());
954 OptionEditor::edit_button_changed ()
956 Keyboard::set_edit_button ((guint) edit_button_adjustment.get_value());
960 OptionEditor::fixup_combo_size (Gtk::ComboBoxText& combo, vector<string>& strings)
962 /* find the widest string */
964 string::size_type maxlen = 0;
967 for (vector<string>::iterator i = strings.begin(); i != strings.end(); ++i) {
970 if ((l = (*i).length()) > maxlen) {
976 /* try to include ascenders and descenders */
978 if (maxstring.length() > 2) {
983 const guint32 FUDGE = 10; // Combo's are stupid - they steal space from the entry for the button
985 set_size_request_to_display_given_text (combo, maxstring.c_str(), 10 + FUDGE, 10);