X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fkeyboard.cc;h=6341071451f94d3b5e99b72169e8405652ff53e2;hb=cf52d6e4b40111eb04b244ec054055a4ec15dbe0;hp=4856cea4fa0a2429659033e5da5073bd1a165381;hpb=6e5581253559fee9bf82fe3ba52ab2db07d3bed2;p=ardour.git diff --git a/gtk2_ardour/keyboard.cc b/gtk2_ardour/keyboard.cc index 4856cea4fa..6341071451 100644 --- a/gtk2_ardour/keyboard.cc +++ b/gtk2_ardour/keyboard.cc @@ -20,6 +20,7 @@ #include "pbd/convert.h" #include "pbd/error.h" #include "pbd/file_utils.h" +#include "pbd/basename.h" #include "ardour/filesystem_paths.h" @@ -27,16 +28,17 @@ #include "public_editor.h" #include "keyboard.h" #include "opts.h" +#include "ui_config.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace Gtk; using namespace PBD; using namespace ARDOUR; using Gtkmm2ext::Keyboard; - -#ifdef GTKOSX + +#ifdef __APPLE__ guint ArdourKeyboard::constraint_mod = Keyboard::PrimaryModifier; #else guint ArdourKeyboard::constraint_mod = Keyboard::SecondaryModifier; @@ -48,22 +50,43 @@ guint ArdourKeyboard::fine_adjust_mod = Keyboard::SecondaryModifier; guint ArdourKeyboard::push_points_mod = Keyboard::PrimaryModifier; guint ArdourKeyboard::note_size_relative_mod = Keyboard::PrimaryModifier; +void +ArdourKeyboard::find_bindings_files (map& files) +{ + vector found; + Searchpath spath = ardour_config_search_path(); + + find_files_matching_pattern (found, spath, string_compose ("*%1", Keyboard::binding_filename_suffix)); + + if (found.empty()) { + return; + } + + for (vector::iterator x = found.begin(); x != found.end(); ++x) { + std::string path(*x); + pair namepath; + namepath.second = path; + namepath.first = PBD::basename_nosuffix (path); + files.insert (namepath); + } +} + void ArdourKeyboard::setup_keybindings () { using namespace ARDOUR_COMMAND_LINE; - string default_bindings = "mnemonic-us.bindings"; + string default_bindings = string_compose ("%1%2", UIConfiguration::instance().get_default_bindings(), Keyboard::binding_filename_suffix); vector strs; binding_files.clear (); - ARDOUR::find_bindings_files (binding_files); + find_bindings_files (binding_files); /* set up the per-user bindings path */ string lowercase_program_name = downcase (string(PROGRAM_NAME)); - user_keybindings_path = Glib::build_filename (user_config_directory(), lowercase_program_name + ".bindings"); + user_keybindings_path = Glib::build_filename (user_config_directory(), lowercase_program_name + binding_filename_suffix); if (Glib::file_test (user_keybindings_path, Glib::FILE_TEST_EXISTS)) { std::pair newpair; @@ -72,11 +95,10 @@ ArdourKeyboard::setup_keybindings () binding_files.insert (newpair); } - /* check to see if they gave a style name ("SAE", "ergonomic") or - an actual filename (*.bindings) + /* check to see if they gave a style name ("ergonomic") or an actual filename (*.bindings) */ - if (!keybindings_path.empty() && keybindings_path.find (".bindings") == string::npos) { + if (!keybindings_path.empty() && keybindings_path.find (binding_filename_suffix) == string::npos) { // just a style name - allow user to // specify the layout type. @@ -97,7 +119,7 @@ ArdourKeyboard::setup_keybindings () keybindings_path += "-us"; } - keybindings_path += ".bindings"; + keybindings_path += binding_filename_suffix; } if (keybindings_path.empty()) { @@ -120,6 +142,8 @@ ArdourKeyboard::setup_keybindings () keybindings_path = default_bindings; } + cerr << "KP is " << keybindings_path << endl; + while (true) { if (!Glib::path_is_absolute (keybindings_path)) { @@ -127,7 +151,7 @@ ArdourKeyboard::setup_keybindings () /* not absolute - look in the usual places */ std::string keybindings_file; - if ( ! find_file (ardour_config_search_path(), keybindings_path, keybindings_file)) { + if (!find_file (ardour_config_search_path(), keybindings_path, keybindings_file)) { if (keybindings_path == default_bindings) { error << string_compose (_("Default keybindings not found - %1 will be hard to use!"), PROGRAM_NAME) << endmsg; @@ -166,8 +190,10 @@ ArdourKeyboard::setup_keybindings () } } + info << string_compose (_("Loading keybindings from %1"), keybindings_path) << endmsg; + load_keybindings (keybindings_path); - + /* catch changes made via some GTK mechanism */ // GtkAccelMap* accelmap = gtk_accel_map_get(); @@ -201,7 +227,7 @@ ArdourKeyboard::get_state (void) int ArdourKeyboard::set_state (const XMLNode& node, int version) { - const XMLProperty* prop; + XMLProperty const * prop; if ((prop = node.property ("constraint-modifier")) != 0) { sscanf (prop->value().c_str(), "%d", &constraint_mod);