From 4d7e9d5706ec7784e6d97cc4f0ac13585bf577f2 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 5 Dec 2018 15:22:48 -0500 Subject: [PATCH] add new variant of ActionMap::find_action() This is more useful when replacing ActionManager::get_action --- libs/gtkmm2ext/bindings.cc | 20 ++++++++++++++++++++ libs/gtkmm2ext/gtkmm2ext/bindings.h | 1 + 2 files changed, 21 insertions(+) diff --git a/libs/gtkmm2ext/bindings.cc b/libs/gtkmm2ext/bindings.cc index 9d61847a0e..b1abcb0507 100644 --- a/libs/gtkmm2ext/bindings.cc +++ b/libs/gtkmm2ext/bindings.cc @@ -1183,6 +1183,26 @@ ActionMap::find_action (const string& name) return a->second; } + cerr << "Failed to find action: [" << name << ']' << endl; + return RefPtr(); +} + +RefPtr +ActionMap::find_action (char const * group_name, char const * action_name) +{ + string fullpath; + + fullpath = group_name; + fullpath += '/'; + fullpath += action_name; + + _ActionMap::iterator a = _actions.find (fullpath); + + if (a != _actions.end()) { + return a->second; + } + + cerr << "Failed to find action (2): [" << fullpath << ']' << endl; return RefPtr(); } diff --git a/libs/gtkmm2ext/gtkmm2ext/bindings.h b/libs/gtkmm2ext/gtkmm2ext/bindings.h index 81f372ae31..54f1f3eee9 100644 --- a/libs/gtkmm2ext/gtkmm2ext/bindings.h +++ b/libs/gtkmm2ext/gtkmm2ext/bindings.h @@ -106,6 +106,7 @@ class LIBGTKMM2EXT_API ActionMap { const char* name, const char* label, sigc::slot sl); Glib::RefPtr find_action (const std::string& name); + Glib::RefPtr find_action (char const * group_name, char const * action_name); void set_bindings (Bindings*); Bindings* bindings() const { return _bindings; }