From cd14e8f2e10c45116274da4c902f63a76e5d3a01 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 12 Jan 2017 20:50:42 +0100 Subject: [PATCH] add API to query name of bound action --- libs/gtkmm2ext/bindings.cc | 11 +++++++++++ libs/gtkmm2ext/gtkmm2ext/bindings.h | 1 + 2 files changed, 12 insertions(+) diff --git a/libs/gtkmm2ext/bindings.cc b/libs/gtkmm2ext/bindings.cc index 2b1762da90..0b03eeef15 100644 --- a/libs/gtkmm2ext/bindings.cc +++ b/libs/gtkmm2ext/bindings.cc @@ -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 { diff --git a/libs/gtkmm2ext/gtkmm2ext/bindings.h b/libs/gtkmm2ext/gtkmm2ext/bindings.h index d216e04752..f4e71f89b2 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; + 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, Operation& op); -- 2.30.2