From c321d82e2ad5c49aef55f1b847336026668badcf Mon Sep 17 00:00:00 2001
From: ArdourEnv <ardourenv@Roberts-iMac.home>
Date: Sun, 28 Aug 2016 11:53:48 -0400
Subject: [PATCH] Unfortunate little patch for more clear binding's error
 dialog

---
 gtk2_ardour/keyeditor.cc            | 9 ++++++---
 libs/gtkmm2ext/bindings.cc          | 7 +++++++
 libs/gtkmm2ext/gtkmm2ext/bindings.h | 1 +
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/gtk2_ardour/keyeditor.cc b/gtk2_ardour/keyeditor.cc
index aea8185..18d8a3d 100644
--- a/gtk2_ardour/keyeditor.cc
+++ b/gtk2_ardour/keyeditor.cc
@@ -62,10 +62,13 @@ using Gtkmm2ext::Bindings;
 
 sigc::signal<void> KeyEditor::UpdateBindings;
 
-void bindings_collision_dialog (Gtk::Window& parent)
+void bindings_collision_dialog (Gtk::Window& parent, const string &missing_binding, Gtkmm2ext::KeyboardKey& key)
 {
 	ArdourDialog dialog (parent, _("Colliding keybindings"), true);
-	Label label (_("The key sequence is already bound. Please remove the other binding first."));
+    // Clearly _exceptionally_ ugly. I didn't want to mess with localization stuff.
+    string const label_text(string("The key sequence is already bound. Please remove the other binding first.").insert(33, " to " + key.display_label()).insert(17, missing_binding + " "));
+
+	Label label (label_text);
 
 	dialog.get_vbox()->pack_start (label, true, true);
 	dialog.add_button (_("Ok"), Gtk::RESPONSE_ACCEPT);
@@ -316,7 +319,7 @@ KeyEditor::Tab::bind (GdkEventKey* release_event, guint pressed_key)
 	Gtkmm2ext::KeyboardKey new_binding (mod, pressed_key);
 
 	if (bindings->is_bound (new_binding, Gtkmm2ext::Bindings::Press)) {
-		bindings_collision_dialog (owner);
+		bindings_collision_dialog (owner, bindings->get_action_name_by_key(new_binding, Gtkmm2ext::Bindings::Press), new_binding);
 		return;
 	}
 
diff --git a/libs/gtkmm2ext/bindings.cc b/libs/gtkmm2ext/bindings.cc
index e25ed20..de45495 100644
--- a/libs/gtkmm2ext/bindings.cc
+++ b/libs/gtkmm2ext/bindings.cc
@@ -1066,6 +1066,13 @@ Bindings::is_bound (KeyboardKey const& kb, Operation op) const
 	return km.find(kb) != km.end();
 }
 
+string const&
+Bindings::get_action_name_by_key (KeyboardKey const& kb, Operation op) const
+{
+	const KeybindingMap& km = get_keymap(op);
+	return km.find(kb)->second.action_name;
+}
+
 bool
 Bindings::is_registered (Operation op, std::string const& action_name) const
 {
diff --git a/libs/gtkmm2ext/gtkmm2ext/bindings.h b/libs/gtkmm2ext/gtkmm2ext/bindings.h
index d216e04..05d44c3 100644
--- a/libs/gtkmm2ext/gtkmm2ext/bindings.h
+++ b/libs/gtkmm2ext/gtkmm2ext/bindings.h
@@ -178,6 +178,7 @@ class LIBGTKMM2EXT_API Bindings {
 	bool activate (MouseButton, Operation);
 
 	bool is_bound (KeyboardKey const&, Operation) const;
+    const std::string &get_action_name_by_key(KeyboardKey const&, Operation op) const; 
 	bool is_registered (Operation op, std::string const& action_name) const;
 
 	KeyboardKey get_binding_for_action (Glib::RefPtr<Gtk::Action>, Operation& op);
-- 
2.7.4 (Apple Git-66)

