diff --git a/libs/gtkmm2ext/bindings.cc b/libs/gtkmm2ext/bindings.cc index 3dbc3c0302..a0a0fa1005 100644 --- a/libs/gtkmm2ext/bindings.cc +++ b/libs/gtkmm2ext/bindings.cc @@ -26,6 +26,7 @@ #include "pbd/convert.h" #include "pbd/debug.h" #include "pbd/error.h" +#include "pbd/replace_all.h" #include "pbd/xml++.h" #include "gtkmm2ext/actions.h" @@ -279,6 +280,51 @@ KeyboardKey::native_name () const return str; } +string +KeyboardKey::native_short_name () const +{ + int s = state(); + + string str; + + if (s & Keyboard::PrimaryModifier) { + str += Keyboard::primary_modifier_short_name (); + } + if (s & Keyboard::SecondaryModifier) { + if (!str.empty()) { + str += '-'; + } + str += Keyboard::secondary_modifier_short_name (); + } + if (s & Keyboard::TertiaryModifier) { + if (!str.empty()) { + str += '-'; + } + str += Keyboard::tertiary_modifier_short_name (); + } + if (s & Keyboard::Level4Modifier) { + if (!str.empty()) { + str += '-'; + } + str += Keyboard::level4_modifier_short_name (); + } + + if (!str.empty()) { + str += '-'; + } + + char const *gdk_name = gdk_keyval_name (key()); + + if (gdk_name) { + str += gdk_name; + } else { + /* fail! */ + return string(); + } + + return str; +} + bool KeyboardKey::make_key (const string& str, KeyboardKey& k) { @@ -735,32 +781,14 @@ Bindings::save_all_bindings_as_html (ostream& ostr) ostr << "