add API to query name of bound action
authorRobin Gareus <robin@gareus.org>
Thu, 12 Jan 2017 19:50:42 +0000 (20:50 +0100)
committerRobin Gareus <robin@gareus.org>
Thu, 12 Jan 2017 19:53:20 +0000 (20:53 +0100)
libs/gtkmm2ext/bindings.cc
libs/gtkmm2ext/gtkmm2ext/bindings.h

index 2b1762da9088eba86aec456ee9a72299d2e4c2d8..0b03eeef152614f39dead0b38b32714f8c9df6a5 100644 (file)
@@ -1047,6 +1047,17 @@ Bindings::is_bound (KeyboardKey const& kb, Operation op) const
        return km.find(kb) != km.end();
 }
 
+std::string
+Bindings::bound_name (KeyboardKey const& kb, Operation op) const
+{
+       const KeybindingMap& km = get_keymap(op);
+       KeybindingMap::const_iterator b = km.find(kb);
+       if (b == km.end()) {
+               return "";
+       }
+       return b->second.action_name;
+}
+
 bool
 Bindings::is_registered (Operation op, std::string const& action_name) const
 {
index d216e0475274719d2ae79d10b2787aee6364a8f3..f4e71f89b28c12b6ba86b61334a4fe7dfa76ac1b 100644 (file)
@@ -178,6 +178,7 @@ class LIBGTKMM2EXT_API Bindings {
        bool activate (MouseButton, Operation);
 
        bool is_bound (KeyboardKey const&, Operation) const;
+       std::string bound_name (KeyboardKey const&, Operation) const;
        bool is_registered (Operation op, std::string const& action_name) const;
 
        KeyboardKey get_binding_for_action (Glib::RefPtr<Gtk::Action>, Operation& op);