diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 9f886ed512..fec3463dbb 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -587,19 +587,21 @@ ARDOUR_UI::post_engine () /* this is the first point at which all the keybindings are available */ if (ARDOUR_COMMAND_LINE::show_key_actions) { - vector names; - vector paths; - vector tooltips; - vector keys; - vector bindings; - ActionManager::get_all_actions (names, paths, tooltips, keys, bindings); + for (map::const_iterator mb = Bindings::bindings_for_state.begin(); mb != Bindings::bindings_for_state.end(); ++mb) { - vector::iterator n; - vector::iterator k; - vector::iterator p; - for (n = names.begin(), k = keys.begin(), p = paths.begin(); n != names.end(); ++n, ++k, ++p) { - cout << "Action: '" << (*n) << "' bound to '" << (*k) << "' Path: '" << (*p) << "'" << endl; + vector names; + vector paths; + vector keys; + + mb->second->get_all_actions (names, paths, keys); + + vector::iterator n; + vector::iterator k; + vector::iterator p; + for (n = names.begin(), k = keys.begin(), p = paths.begin(); n != names.end(); ++n, ++k, ++p) { + cout << "Action: '" << (*n) << "' bound to '" << (*k) << "' Path: '" << (*p) << "'" << endl; + } } halt_connection.disconnect (); diff --git a/gtk2_ardour/keyboard.cc b/gtk2_ardour/keyboard.cc index 3612e5facb..4856cea4fa 100644 --- a/gtk2_ardour/keyboard.cc +++ b/gtk2_ardour/keyboard.cc @@ -36,18 +36,6 @@ using namespace PBD; using namespace ARDOUR; using Gtkmm2ext::Keyboard; -static void -accel_map_changed (GtkAccelMap* /*map*/, - gchar* /*path*/, - guint /*key*/, - GdkModifierType /*mod*/, - gpointer keyboard) -{ - ArdourKeyboard* me = (ArdourKeyboard*)keyboard; - Keyboard::keybindings_changed (); - me->ui.setup_tooltips (); -} - #ifdef GTKOSX guint ArdourKeyboard::constraint_mod = Keyboard::PrimaryModifier; #else diff --git a/gtk2_ardour/keyeditor.cc b/gtk2_ardour/keyeditor.cc index f517217b0d..e95a73af32 100644 --- a/gtk2_ardour/keyeditor.cc +++ b/gtk2_ardour/keyeditor.cc @@ -121,7 +121,13 @@ KeyEditor::on_key_press_event (GdkEventKey* ev) if (!ev->is_modifier) { last_keyval = ev->keyval; } - return ArdourWindow::on_key_press_event (ev); + + /* Don't let anything else handle the key press, because navigation + * keys will be used by GTK to change the selection/treeview cursor + * position + */ + + return true; } bool @@ -145,7 +151,7 @@ KeyEditor::Tab::Tab (KeyEditor& ke, string const & str, Bindings* b) model = TreeStore::create(columns); view.set_model (model); - view.append_column (_("Action"), columns.action); + view.append_column (_("Action"), columns.name); view.append_column (_("Shortcut"), columns.binding); view.set_headers_visible (true); view.get_selection()->set_mode (SELECTION_SINGLE); @@ -200,19 +206,14 @@ KeyEditor::Tab::unbind () owner.unbind_button.set_sensitive (false); if (i != model->children().end()) { - string path = (*i)[columns.path]; + Glib::RefPtr action = (*i)[columns.action]; if (!(*i)[columns.bindable]) { return; } - - bool result = AccelMap::change_entry (path, - 0, - (ModifierType) 0, - true); - if (result) { - (*i)[columns.binding] = string (); - } + + bindings->remove (action, Gtkmm2ext::Bindings::Press, true); + (*i)[columns.binding] = string (); } } @@ -222,25 +223,20 @@ KeyEditor::Tab::bind (GdkEventKey* release_event, guint pressed_key) TreeModel::iterator i = view.get_selection()->get_selected(); if (i != model->children().end()) { - string path = (*i)[columns.path]; + + string action_name = (*i)[columns.path]; if (!(*i)[columns.bindable]) { return; } GdkModifierType mod = (GdkModifierType)(Keyboard::RelevantModifierKeyMask & release_event->state); + Gtkmm2ext::KeyboardKey new_binding (mod, pressed_key); - Gtkmm2ext::possibly_translate_keyval_to_make_legal_accelerator (release_event->keyval); - Gtkmm2ext::possibly_translate_mod_to_make_legal_accelerator (mod); - - bool result = AccelMap::change_entry (path, - pressed_key, - Gdk::ModifierType(mod), - true); + bool result = bindings->replace (new_binding, Gtkmm2ext::Bindings::Press, action_name); if (result) { - AccelKey key; - (*i)[columns.binding] = ActionManager::get_key_representation (path, key); + (*i)[columns.binding] = gtk_accelerator_get_label (new_binding.key(), (GdkModifierType) new_binding.state()); owner.unbind_button.set_sensitive (true); } } @@ -248,80 +244,93 @@ KeyEditor::Tab::bind (GdkEventKey* release_event, guint pressed_key) void KeyEditor::Tab::populate () -{ +{ vector paths; vector labels; vector tooltips; vector keys; - vector binds; + vector > actions; typedef std::map NodeMap; NodeMap nodes; NodeMap::iterator r; - bindings->get_all_actions (labels, paths, tooltips, keys, binds); + bindings->get_all_actions (paths, labels, tooltips, keys, actions); vector::iterator k; vector::iterator p; vector::iterator t; vector::iterator l; - + vector >::iterator a; + model->clear (); - for (l = labels.begin(), k = keys.begin(), p = paths.begin(), t = tooltips.begin(); l != labels.end(); ++k, ++p, ++t, ++l) { + for (a = actions.begin(), l = labels.begin(), k = keys.begin(), p = paths.begin(), t = tooltips.begin(); l != labels.end(); ++k, ++p, ++t, ++l, ++a) { TreeModel::Row row; vector parts; - parts.clear (); - split (*p, parts, '/'); - if (parts.empty()) { + string category = parts[1]; + string action_name = parts[2]; + + if (action_name.empty()) { continue; } //kinda kludgy way to avoid displaying menu items as mappable - if ((parts[1].find ("Menu") == parts[1].length() - 4) || - (parts[1].find ("menu") == parts[1].length() - 4) || - (parts[1] == _("RegionList"))) { + if ((action_name.find ("Menu") == action_name.length() - 4) || + (action_name.find ("menu") == action_name.length() - 4) || + (action_name == _("RegionList"))) { continue; } - if ((r = nodes.find (parts[1])) == nodes.end()) { + if ((r = nodes.find (category)) == nodes.end()) { - /* top level is missing */ + /* category/group is missing, so add it first */ TreeIter rowp; TreeModel::Row parent; rowp = model->append(); - nodes[parts[1]] = rowp; + nodes[category] = rowp; parent = *(rowp); - parent[columns.action] = parts[1]; + parent[columns.name] = category; parent[columns.bindable] = false; + parent[columns.action] = *a; + /* now set up the child row that we're about to fill + * out with information + */ + row = *(model->append (parent.children())); } else { + /* category/group is present, so just add the child row */ + row = *(model->append ((*r->second)->children())); } /* add this action */ + /* use the "visible label" as the action name */ + if (l->empty ()) { - row[columns.action] = *t; + /* no label, try using the tooltip instead */ + row[columns.name] = *t; } else { - row[columns.action] = *l; + row[columns.name] = *l; } - row[columns.path] = (*p); + row[columns.path] = string_compose ("%1/%2", category, action_name); row[columns.bindable] = true; if (*k == ActionManager::unbound_string) { row[columns.binding] = string(); } else { - row[columns.binding] = (*k); + row[columns.binding] = *k; } + row[columns.action] = *a; } } diff --git a/gtk2_ardour/keyeditor.h b/gtk2_ardour/keyeditor.h index 472b5063f7..046f8b0715 100644 --- a/gtk2_ardour/keyeditor.h +++ b/gtk2_ardour/keyeditor.h @@ -58,15 +58,17 @@ class KeyEditor : public ArdourWindow struct KeyEditorColumns : public Gtk::TreeModel::ColumnRecord { KeyEditorColumns () { - add (action); + add (name); add (binding); add (path); add (bindable); + add (action); } - Gtk::TreeModelColumn action; + Gtk::TreeModelColumn name; Gtk::TreeModelColumn binding; Gtk::TreeModelColumn path; Gtk::TreeModelColumn bindable; + Gtk::TreeModelColumn > action; }; Gtk::VBox vpacker;