summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-11-24 05:36:31 +0000
committerDavid Robillard <d@drobilla.net>2011-11-24 05:36:31 +0000
commit0a71d52448f6144d5225269b378711bfba0bb37b (patch)
treed40c810164b7c6d85c80e006a08d9459564ed6fb /libs
parent0bd3105f50f3c82586e0924a4be9977425caaf90 (diff)
Fix key bindings in tooltips for ArdourButton buttons.
Sinced gtkmm2ext needs to get at the actions of widgets, I moved the action to Gtkmm2ext::Activatable. Not sure if the wisest thing to do here would be to use Gtkmm::Activatable, but figured there's a reason Paul didn't do so (the name set_related_action is from there so presumably it's known about), so this is the simplest change that allows access to the action in Gtkmm2ext. The vfunc calling stuff should probably move there as well... git-svn-id: svn://localhost/ardour2/branches/3.0@10818 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/gtkmm2ext/gtk_ui.cc23
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/activatable.h51
2 files changed, 67 insertions, 7 deletions
diff --git a/libs/gtkmm2ext/gtk_ui.cc b/libs/gtkmm2ext/gtk_ui.cc
index 35517e9604..f45fab6788 100644
--- a/libs/gtkmm2ext/gtk_ui.cc
+++ b/libs/gtkmm2ext/gtk_ui.cc
@@ -40,6 +40,7 @@
#include <gtkmm2ext/utils.h>
#include <gtkmm2ext/window_title.h>
#include <gtkmm2ext/actions.h>
+#include <gtkmm2ext/activatable.h>
#include "i18n.h"
@@ -340,15 +341,23 @@ UI::set_tip (Widget *w, const gchar *tip, const gchar *hlp)
std::string msg(tip);
Glib::RefPtr<Gtk::Action> action = w->get_action();
+
+ if (!action) {
+ Gtkmm2ext::Activatable* activatable;
+ if ((activatable = dynamic_cast<Gtkmm2ext::Activatable*>(w))) {
+ action = activatable->get_related_action();
+ }
+ }
+
if (action) {
Gtk::AccelKey key;
- ustring ap = action->get_accel_path();
- if (!ap.empty()) {
- bool has_key = ActionManager::lookup_entry(ap, key);
- if (has_key && key.get_abbrev() != "") {
- msg.append("\n\n Key: ").append(key.get_abbrev());
- }
- }
+ ustring ap = action->get_accel_path();
+ if (!ap.empty()) {
+ bool has_key = ActionManager::lookup_entry(ap, key);
+ if (has_key && key.get_abbrev() != "") {
+ msg.append("\n\nKey: ").append(key.get_abbrev());
+ }
+ }
}
if (req == 0) {
diff --git a/libs/gtkmm2ext/gtkmm2ext/activatable.h b/libs/gtkmm2ext/gtkmm2ext/activatable.h
new file mode 100644
index 0000000000..f8e2b5dd38
--- /dev/null
+++ b/libs/gtkmm2ext/gtkmm2ext/activatable.h
@@ -0,0 +1,51 @@
+/*
+ Copyright (C) 2011 Paul Davis
+ Author: David Robillard
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef __libgtkmm2ext_activatable_h__
+#define __libgtkmm2ext_activatable_h__
+
+#include <gtkmm/action.h>
+
+namespace Gtkmm2ext {
+
+/**
+ A Widget with an associated Action.
+
+ Gtkmm itself has a class for this. I don't know why we don't use it.
+*/
+class Activatable {
+public:
+ virtual ~Activatable() {}
+
+ virtual void set_related_action(Glib::RefPtr<Gtk::Action> a) {
+ _action = a;
+ }
+
+ Glib::RefPtr<Gtk::Action> get_related_action() {
+ return _action;
+ }
+
+protected:
+ Glib::RefPtr<Gtk::Action> _action;
+};
+
+} /* namespace */
+
+#endif /* __libgtkmm2ext_actions_h__ */