Make the wiimote code appear in the source package
[ardour.git] / gtk2_ardour / option_editor.cc
index e68be7149c631f0b2739a4a237889eecedc4bfbf..76f209e98b63ccc5d6de4a2c388eb435a263d5d4 100644 (file)
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 */
+#include <pango/pangoft2.h> // for fontmap resolution control for GnomeCanvas
+#include <pango/pangocairo.h> // for fontmap resolution control for GnomeCanvas
 
 #include <pbd/whitespace.h>
 
+#include <ardour/ardour.h>
 #include <ardour/session.h>
 #include <ardour/audioengine.h>
 #include <ardour/configuration.h>
 #include <ardour/auditioner.h>
 #include <ardour/sndfilesource.h>
 #include <ardour/crossfade.h>
+#include <ardour/profile.h>
 #include <midi++/manager.h>
 #include <midi++/factory.h>
 #include <gtkmm2ext/stop_signal.h>
@@ -42,6 +46,8 @@
 #include "editing.h"
 #include "option_editor.h"
 #include "midi_port_dialog.h"
+#include "gui_thread.h"
+#include "utils.h"
 
 #include "i18n.h"
 
@@ -55,7 +61,7 @@ using namespace std;
 static vector<string> positional_sync_strings;
 
 OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui)
-       : Dialog ("options editor"),
+       : ArdourDialog ("options editor", false),
          ui (uip),
          editor (ed),
          mixer (mixui),
@@ -63,17 +69,24 @@ OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui)
          /* Paths */
          path_table (11, 2),
 
-         /* Fades */
+         /* misc */
 
          short_xfade_adjustment (0, 1.0, 500.0, 5.0, 100.0),
          short_xfade_slider (short_xfade_adjustment),
          destructo_xfade_adjustment (1.0, 1.0, 500.0, 1.0, 100.0),
          destructo_xfade_slider (destructo_xfade_adjustment),
+         history_depth (20, -1, 100, 1.0, 10.0),
+         saved_history_depth (20, 0, 100, 1.0, 10.0),
+         history_depth_spinner (history_depth),
+         saved_history_depth_spinner (saved_history_depth),
+         limit_history_button (_("Limit undo history")),
+         save_history_button (_("Save undo history")),
 
          /* Sync */
 
          smpte_offset_clock (X_("smpteoffset"), false, X_("SMPTEOffsetClock"), true, true),
          smpte_offset_negative_button (_("SMPTE offset is negative")),
+         synced_timecode_button (_("Timecode source is sample-clock synced")),
 
          /* MIDI */
 
@@ -83,6 +96,8 @@ OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui)
          mmc_send_device_id_adjustment (0.0, 0.0, (double) 0x7f, 1.0, 16.0),
          mmc_send_device_id_spinner (mmc_send_device_id_adjustment),
          add_midi_port_button (_("Add new MIDI port")),
+         initial_program_change_adjustment (0.0, -1.0, (double) 0x7f, 1.0, 16.0),
+         initial_program_change_spinner (initial_program_change_adjustment),
 
          /* Click */
 
@@ -92,7 +107,7 @@ OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui)
 
          /* kbd/mouse */
 
-         keyboard_mouse_table (3, 4),
+         keyboard_mouse_table (4, 4),
          delete_button_adjustment (3, 1, 5),
          delete_button_spin (delete_button_adjustment),
          edit_button_adjustment (3, 1, 5),
@@ -101,18 +116,19 @@ OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui)
 {
        using namespace Notebook_Helpers;
 
+       first_click_setup = true;
        click_io_selector = 0;
        auditioner_io_selector = 0;
        session = 0;
        
        WindowTitle title(Glib::get_application_name());
-       title += _("Options Editor");
+       title += _("Preferences");
        set_title(title.get_string());
 
        set_default_size (300, 300);
-       set_wmclass (X_("ardour_option_editor"), "Ardour");
+       set_wmclass (X_("ardour_preferences"), "Ardour");
 
-       set_name ("OptionsWindow");
+       set_name ("Preferences");
        add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
        
        VBox *vbox = get_vbox();
@@ -129,22 +145,27 @@ OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui)
 
        setup_sync_options();
        setup_path_options();
-       setup_fade_options ();
+       setup_misc_options ();
        setup_keyboard_options ();
        setup_auditioner_editor ();
 
-       notebook.pages().push_back (TabElem (sync_packer, _("Sync")));
-       notebook.pages().push_back (TabElem (path_table, _("Paths/Files")));
-       notebook.pages().push_back (TabElem (keyboard_mouse_table, _("Kbd/Mouse")));
+       if (!Profile->get_sae()) {
+               notebook.pages().push_back (TabElem (sync_packer, _("Sync")));
+               notebook.pages().push_back (TabElem (path_table, _("Paths/Files")));
+               notebook.pages().push_back (TabElem (keyboard_mouse_table, _("Kbd/Mouse")));
+       }
        notebook.pages().push_back (TabElem (click_packer, _("Click")));
        notebook.pages().push_back (TabElem (audition_packer, _("Audition")));
-       notebook.pages().push_back (TabElem (fade_packer, _("Layers & Fades")));
+       notebook.pages().push_back (TabElem (misc_packer, _("Misc")));
 
        setup_midi_options ();
        notebook.pages().push_back (TabElem (midi_packer, _("MIDI")));
 
        set_session (0);
        show_all_children();
+
+       Config->map_parameters (mem_fun (*this, &OptionEditor::parameter_changed));
+       Config->ParameterChanged.connect (mem_fun (*this, &OptionEditor::parameter_changed));
 }
 
 void
@@ -238,12 +259,40 @@ OptionEditor::add_session_paths ()
        session_raid_entry.set_text(session->raid_path());
 }
 
+static void
+font_scale_changed (Gtk::Adjustment* adj)
+{
+       Config->set_font_scale((long)floor (adj->get_value() * 1024));
+       reset_dpi();
+}
+
 void
-OptionEditor::setup_fade_options ()
+OptionEditor::setup_misc_options ()
 {
        Gtk::HBox* hbox;
-       
-       Label* label = manage (new Label (_("Short crossfade length (msecs)")));
+       Label* label;
+
+#ifndef GTKOSX
+       /* font scaling does nothing with GDK/Quartz */
+
+       Gtk::Adjustment* dpi_adj = new Gtk::Adjustment ((double)Config->get_font_scale() / 1024, 50, 250, 1, 10);
+       Gtk::HScale * dpi_range = new Gtk::HScale (*dpi_adj);
+
+       label = manage (new Label (_("Font Scaling")));
+       label->set_name ("OptionsLabel");
+
+       dpi_range->set_update_policy (Gtk::UPDATE_DISCONTINUOUS);
+       dpi_adj->signal_value_changed().connect (bind (sigc::ptr_fun (font_scale_changed), dpi_adj));
+
+       hbox = manage (new HBox);
+       hbox->set_border_width (5);
+       hbox->set_spacing (10);
+       hbox->pack_start (*label, false, false);
+       hbox->pack_start (*dpi_range, true, true);
+       misc_packer.pack_start (*hbox, false, false);
+#endif
+
+       label = manage (new Label (_("Short crossfade length (msecs)")));
        label->set_name ("OptionsLabel");
        
        hbox = manage (new HBox);
@@ -251,7 +300,7 @@ OptionEditor::setup_fade_options ()
        hbox->set_spacing (10);
        hbox->pack_start (*label, false, false);
        hbox->pack_start (short_xfade_slider, true, true);
-       fade_packer.pack_start (*hbox, false, false);
+       misc_packer.pack_start (*hbox, false, false);
 
        short_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::short_xfade_adjustment_changed));
 
@@ -263,16 +312,94 @@ OptionEditor::setup_fade_options ()
        hbox->set_spacing (10);
        hbox->pack_start (*label, false, false);
        hbox->pack_start (destructo_xfade_slider, true, true);
-       fade_packer.pack_start (*hbox, false, false);
+       misc_packer.pack_start (*hbox, false, false);
        
+
        destructo_xfade_adjustment.signal_value_changed().connect (mem_fun(*this, &OptionEditor::destructo_xfade_adjustment_changed));
 
+       hbox = manage (new HBox);
+       hbox->set_border_width (5);
+       hbox->set_spacing (10);
+       hbox->pack_start (limit_history_button, false, false);
+       misc_packer.pack_start (*hbox, false, false);
+
+       label = manage (new Label (_("History depth (commands)")));
+       label->set_name ("OptionsLabel");
+
+       hbox = manage (new HBox);
+       hbox->set_border_width (5);
+       hbox->set_spacing (10);
+       hbox->pack_start (*label, false, false);
+       hbox->pack_start (history_depth_spinner, false, false);
+       misc_packer.pack_start (*hbox, false, false);
+
+       history_depth.signal_value_changed().connect (mem_fun (*this, &OptionEditor::history_depth_changed));
+       saved_history_depth.signal_value_changed().connect (mem_fun (*this, &OptionEditor::saved_history_depth_changed));
+       save_history_button.signal_toggled().connect (mem_fun (*this, &OptionEditor::save_history_toggled));
+       limit_history_button.signal_toggled().connect (mem_fun (*this, &OptionEditor::limit_history_toggled));
+
+       hbox = manage (new HBox);
+       hbox->set_border_width (5);
+       hbox->set_spacing (10);
+       hbox->pack_start (save_history_button, false, false);
+       misc_packer.pack_start (*hbox, false, false);
+
+       label = manage (new Label (_("Saved history depth (commands)")));
+       label->set_name ("OptionsLabel");
+
+       hbox = manage (new HBox);
+       hbox->set_border_width (5);
+       hbox->set_spacing (10);
+       hbox->pack_start (*label, false, false);
+       hbox->pack_start (saved_history_depth_spinner, false, false);
+       misc_packer.pack_start (*hbox, false, false);
+       
        short_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
        destructo_xfade_slider.set_update_policy (UPDATE_DISCONTINUOUS);
 
        destructo_xfade_adjustment.set_value (Config->get_destructive_xfade_msecs());
 
-       fade_packer.show_all ();
+       misc_packer.show_all ();
+}
+
+void
+OptionEditor::limit_history_toggled ()
+{
+       bool x = limit_history_button.get_active();
+       
+       if (!x) {
+               Config->set_history_depth (0);
+               history_depth_spinner.set_sensitive (false);
+       } else {
+               if (Config->get_history_depth() == 0) {
+                       /* get back to a sane default */
+                       Config->set_history_depth (20);
+               }
+               history_depth_spinner.set_sensitive (true);
+       }
+}
+
+void
+OptionEditor::save_history_toggled ()
+{
+       bool x = save_history_button.get_active();
+
+       if (x != Config->get_save_history()) {
+               Config->set_save_history (x);
+               saved_history_depth_spinner.set_sensitive (x);
+       }
+}
+
+void
+OptionEditor::history_depth_changed()
+{
+       Config->set_history_depth ((int32_t) floor (history_depth.get_value()));
+}
+
+void
+OptionEditor::saved_history_depth_changed()
+{
+       Config->set_saved_history_depth ((int32_t) floor (saved_history_depth.get_value()));
 }
 
 void
@@ -326,8 +453,10 @@ OptionEditor::setup_sync_options ()
        hbox->pack_start (smpte_offset_negative_button, false, false);
 
        sync_packer.pack_start (*hbox, false, false);
+       sync_packer.pack_start (synced_timecode_button, false, false);
 
        smpte_offset_negative_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::smpte_offset_negative_clicked));
+       synced_timecode_button.signal_toggled().connect (mem_fun(*this, &OptionEditor::synced_timecode_toggled));
 }
 
 void
@@ -338,6 +467,17 @@ OptionEditor::smpte_offset_negative_clicked ()
        }
 }
 
+void
+OptionEditor::synced_timecode_toggled ()
+{
+       bool x;
+
+       if ((x = synced_timecode_button.get_active()) != Config->get_timecode_source_is_synced()) {
+               Config->set_timecode_source_is_synced (x);
+               Config->save_state();
+       }
+}
+
 void
 OptionEditor::smpte_offset_chosen()
 {
@@ -378,7 +518,9 @@ OptionEditor::setup_midi_options ()
        label = (manage (new Label (_("Inbound MMC Device ID")))); 
        hbox->pack_start (mmc_receive_device_id_spinner, false, false);
        hbox->pack_start (*label, false, false);
-       midi_packer.pack_start (*hbox, false, false);
+       midi_packer.pack_start (*hbox, false, false); 
+
+       mmc_receive_device_id_spinner.set_value(Config->get_mmc_receive_device_id ());
 
        hbox = manage (new HBox);
        hbox->set_border_width (6);
@@ -388,9 +530,28 @@ OptionEditor::setup_midi_options ()
        hbox->pack_start (*label, false, false);
        midi_packer.pack_start (*hbox, false, false);
 
+       mmc_send_device_id_spinner.set_value(Config->get_mmc_send_device_id ());
+
+       hbox = manage (new HBox);
+       hbox->set_border_width (6);
+       hbox->set_spacing (6);
+       label = (manage (new Label (_("Startup program change")))); 
+       hbox->pack_start (initial_program_change_spinner, false, false);
+       hbox->pack_start (*label, false, false);
+       midi_packer.pack_start (*hbox, false, false);
+
+       initial_program_change_spinner.set_value (Config->get_initial_program_change());
+       initial_program_change_adjustment.signal_value_changed().connect (mem_fun (*this, &OptionEditor::initial_program_change_adjusted));
+
        add_midi_port_button.signal_clicked().connect (mem_fun (*this, &OptionEditor::add_midi_port));
 }
 
+void
+OptionEditor::initial_program_change_adjusted ()
+{
+       Config->set_initial_program_change (((int32_t) floor (initial_program_change_adjustment.get_value())) & 0x7f);
+}
+
 void
 OptionEditor::redisplay_midi_ports ()
 {
@@ -606,12 +767,15 @@ OptionEditor::add_midi_port ()
                smod = "duplex";
        }
 
-       MIDI::PortRequest req (X_("ardour"),
-                              dialog.port_name.get_text(),
-                              smod,
-                              MIDI::PortFactory::default_port_type());
 
-       if (MIDI::Manager::instance()->add_port (req) != 0) {
+       XMLNode node (X_("MIDI-port"));
+
+       node.add_property ("tag", dialog.port_name.get_text());
+       node.add_property ("device", X_("ardour")); // XXX this can't be right for all types
+       node.add_property ("type", MIDI::PortFactory::default_port_type());
+       node.add_property ("mode", smod);
+
+       if (MIDI::Manager::instance()->add_port (node) != 0) {
                redisplay_midi_ports ();
        }
 }
@@ -768,10 +932,13 @@ OptionEditor::raid_path_changed ()
 void
 OptionEditor::click_browse_clicked ()
 {
-       SoundFileChooser sfdb (_("Choose Click"), session);
+       SoundFileChooser sfdb (*this, _("Choose Click"), session);
        
-       int result = sfdb.run ();
+       sfdb.show_all ();
+       sfdb.present ();
 
+       int result = sfdb.run ();
        if (result == Gtk::RESPONSE_OK) {
                click_chosen(sfdb.get_filename());
        }
@@ -787,7 +954,10 @@ OptionEditor::click_chosen (const string & path)
 void
 OptionEditor::click_emphasis_browse_clicked ()
 {
-       SoundFileChooser sfdb (_("Choose Click Emphasis"), session);
+       SoundFileChooser sfdb (*this, _("Choose Click Emphasis"), session);
+
+       sfdb.show_all ();
+       sfdb.present ();
 
        int result = sfdb.run ();
 
@@ -847,8 +1017,8 @@ void
 OptionEditor::clear_click_editor ()
 {
        if (click_io_selector) {
-               click_packer.remove (*click_io_selector);
-               click_packer.remove (*click_gpm);
+               click_hpacker.remove (*click_io_selector);
+               click_hpacker.remove (*click_gpm);
                delete click_io_selector;
                delete click_gpm;
                click_io_selector = 0;
@@ -860,51 +1030,59 @@ void
 OptionEditor::setup_click_editor ()
 {
        Label* label;
-       HBox* hpacker = manage (new HBox);
 
-       click_path_entry.set_sensitive (true);
-       click_emphasis_path_entry.set_sensitive (true);
+       if (first_click_setup) {
+               
+               click_path_entry.set_name ("OptionsEntry");
+               click_emphasis_path_entry.set_name ("OptionsEntry");
+               
+               click_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_sound_changed));
+               click_emphasis_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed));
+               
+               click_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_sound_changed));
+               click_emphasis_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_emphasis_sound_changed));
+               
+               click_browse_button.set_name ("EditorGTKButton");
+               click_emphasis_browse_button.set_name ("EditorGTKButton");
 
-       click_path_entry.set_name ("OptionsEntry");
-       click_emphasis_path_entry.set_name ("OptionsEntry");
-       
-       click_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_sound_changed));
-       click_emphasis_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed));
+               click_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_browse_clicked));
+               click_emphasis_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_emphasis_browse_clicked));
 
-       click_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_sound_changed));
-       click_emphasis_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_emphasis_sound_changed));
+               click_packer.set_border_width (12);
+               click_packer.set_spacing (5);
 
-       click_browse_button.set_name ("EditorGTKButton");
-       click_emphasis_browse_button.set_name ("EditorGTKButton");
-       click_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_browse_clicked));
-       click_emphasis_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_emphasis_browse_clicked));
+               click_table.set_col_spacings (10);
+               
+               label = manage(new Label(_("Click audio file")));
+               label->set_name ("OptionsLabel");
+               click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
+               click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
+               click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL);
+               
+               label = manage(new Label(_("Click emphasis audiofile")));
+               label->set_name ("OptionsLabel");
+               click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
+               click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
+               click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL);
+
+               click_packer.pack_start (click_table, false, false);
+               click_packer.pack_start (click_hpacker, false, false);
+       
 
-       click_packer.set_border_width (12);
-       click_packer.set_spacing (5);
+               click_hpacker.set_spacing (10);
 
-       click_io_selector = new IOSelector (*session, session->click_io(), false);
-       click_gpm = new GainMeter (session->click_io(), *session);
+               first_click_setup = false;
+       }
 
-       click_table.set_col_spacings (10);
-       
-       label = manage(new Label(_("Click audio file")));
-       label->set_name ("OptionsLabel");
-       click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
-       click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
-       click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL);
-       
-       label = manage(new Label(_("Click emphasis audiofile")));
-       label->set_name ("OptionsLabel");
-       click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
-       click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
-       click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL);
+       click_path_entry.set_sensitive (true);
+       click_emphasis_path_entry.set_sensitive (true);
 
-       hpacker->set_spacing (10);
-       hpacker->pack_start (*click_io_selector, false, false);
-       hpacker->pack_start (*click_gpm, false, false);
+       click_io_selector = new IOSelector (*session, session->click_io(), false);
+       click_gpm = new GainMeter (*session);
+       click_gpm->set_io (session->click_io());
 
-       click_packer.pack_start (click_table, false, false);
-       click_packer.pack_start (*hpacker, false, false);
+       click_hpacker.pack_start (*click_io_selector, false, false);
+       click_hpacker.pack_start (*click_gpm, false, false);
 
        click_packer.show_all ();
 }
@@ -943,7 +1121,8 @@ void
 OptionEditor::connect_audition_editor ()
 {
        auditioner_io_selector = new IOSelector (*session, session->the_auditioner(), false);
-       auditioner_gpm = new GainMeter (session->the_auditioner(), *session);
+       auditioner_gpm = new GainMeter (*session);
+       auditioner_gpm->set_io (session->the_auditioner());
 
        audition_hpacker.pack_start (*auditioner_io_selector, false, false);
        audition_hpacker.pack_start (*auditioner_gpm, false, false);
@@ -963,6 +1142,23 @@ static const struct {
     const char *name;
     guint   modifier;
 } modifiers[] = {
+
+#ifdef GTKOSX 
+
+       /* Command = Meta
+          Option/Alt = Mod1
+       */
+
+       { "Shift", GDK_SHIFT_MASK },
+       { "Command", GDK_META_MASK },
+       { "Control", GDK_CONTROL_MASK },
+       { "Option", GDK_MOD1_MASK },
+       { "Command-Shift", GDK_MOD1_MASK|GDK_SHIFT_MASK },
+       { "Command-Option", GDK_MOD1_MASK|GDK_MOD5_MASK },
+       { "Shift-Option", GDK_SHIFT_MASK|GDK_MOD5_MASK },
+       { "Shift-Command-Option", GDK_MOD5_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
+
+#else
        { "Shift", GDK_SHIFT_MASK },
        { "Control", GDK_CONTROL_MASK },
        { "Alt (Mod1)", GDK_MOD1_MASK },
@@ -974,6 +1170,7 @@ static const struct {
        { "Mod3", GDK_MOD3_MASK },
        { "Mod4", GDK_MOD4_MASK },
        { "Mod5", GDK_MOD5_MASK },
+#endif
        { 0, 0 }
 };
 
@@ -1063,6 +1260,39 @@ OptionEditor::setup_keyboard_options ()
        
        keyboard_mouse_table.attach (*label, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
        keyboard_mouse_table.attach (snap_modifier_combo, 1, 2, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL);
+
+       vector<string> strs;
+       
+       for (std::map<std::string,std::string>::iterator bf = Keyboard::binding_files.begin(); bf != Keyboard::binding_files.end(); ++bf) {
+               strs.push_back (bf->first);
+       }
+       
+       set_popdown_strings (keyboard_layout_selector, strs);
+       keyboard_layout_selector.set_active_text (Keyboard::current_binding_name());
+       keyboard_layout_selector.signal_changed().connect (mem_fun (*this, &OptionEditor::bindings_changed));
+
+       label = manage (new Label (_("Keyboard layout")));
+       label->set_name ("OptionsLabel");
+       label->set_alignment (1.0, 0.5);
+
+       keyboard_mouse_table.attach (*label, 0, 1, 3, 4, Gtk::FILL|Gtk::EXPAND, FILL);
+       keyboard_mouse_table.attach (keyboard_layout_selector, 1, 2, 3, 4, Gtk::FILL|Gtk::EXPAND, FILL);
+}
+
+void
+OptionEditor::bindings_changed ()
+{
+       string txt;
+       
+       txt = keyboard_layout_selector.get_active_text();
+
+       for (std::map<string,string>::iterator i = Keyboard::binding_files.begin(); i != Keyboard::binding_files.end(); ++i) {
+               if (txt == i->first) {
+                       if (Keyboard::load_keybindings (i->second)) {
+                               Keyboard::save_keybindings ();
+                       }
+               }
+       }
 }
 
 void
@@ -1151,3 +1381,33 @@ OptionEditor::fixup_combo_size (Gtk::ComboBoxText& combo, vector<string>& string
        set_size_request_to_display_given_text (combo, maxstring.c_str(), 10 + FUDGE, 10);
 }
 
+void
+OptionEditor::parameter_changed (const char* parameter_name)
+{
+       ENSURE_GUI_THREAD (bind (mem_fun (*this, &OptionEditor::parameter_changed), parameter_name));
+
+#define PARAM_IS(x) (!strcmp (parameter_name, (x)))
+       
+       if (PARAM_IS ("timecode-source-is-synced")) {
+               synced_timecode_button.set_active (Config->get_timecode_source_is_synced());
+       } else if (PARAM_IS ("history-depth")) {
+               int32_t depth = Config->get_history_depth();
+               
+               history_depth.set_value (depth);
+               history_depth_spinner.set_sensitive (depth != 0);
+               limit_history_button.set_active (depth != 0);
+
+       } else if (PARAM_IS ("saved-history-depth")) {
+
+               saved_history_depth.set_value (Config->get_saved_history_depth());
+
+       } else if (PARAM_IS ("save-history")) {
+
+               bool x = Config->get_save_history();
+
+               save_history_button.set_active (x);
+               saved_history_depth_spinner.set_sensitive (x);
+       } else if (PARAM_IS ("font-scale")) {
+               reset_dpi();
+       }
+}