summaryrefslogtreecommitdiff
path: root/libs/gtkmm2ext
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-02-09 00:50:24 +0000
committerDavid Robillard <d@drobilla.net>2010-02-09 00:50:24 +0000
commitb5148d93d5a9e6949f82f8685cab50cb772f2b9d (patch)
treedc83d91573d30819adb9bb2dd91ff13d0a20addf /libs/gtkmm2ext
parent535d60237486e2227d22e5febbcfbf868abb11e3 (diff)
Add keyboard shortcut to tooltip text where possible.
git-svn-id: svn://localhost/ardour2/branches/3.0@6657 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/gtkmm2ext')
-rw-r--r--libs/gtkmm2ext/gtk_ui.cc26
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/gtk_ui.h4
2 files changed, 28 insertions, 2 deletions
diff --git a/libs/gtkmm2ext/gtk_ui.cc b/libs/gtkmm2ext/gtk_ui.cc
index 318dedd1fc..f7fbd04459 100644
--- a/libs/gtkmm2ext/gtk_ui.cc
+++ b/libs/gtkmm2ext/gtk_ui.cc
@@ -38,6 +38,7 @@
#include <gtkmm2ext/popup.h>
#include <gtkmm2ext/utils.h>
#include <gtkmm2ext/window_title.h>
+#include <gtkmm2ext/actions.h>
#include "i18n.h"
@@ -298,16 +299,39 @@ UI::touch_display (Touchable *display)
}
void
+UI::set_tip (Widget &w, const gchar *tip)
+{
+ set_tip(&w, tip, "");
+}
+
+void
+UI::set_tip (Widget &w, const std::string& tip)
+{
+ set_tip(&w, tip.c_str(), "");
+}
+
+void
UI::set_tip (Widget *w, const gchar *tip, const gchar *hlp)
{
UIRequest *req = get_request (SetTip);
+ std::string msg(tip);
+
+ Glib::RefPtr<Gtk::Action> action = w->get_action();
+ if (action) {
+ Gtk::AccelKey key;
+ bool has_key = ActionManager::lookup_entry(action->get_accel_path(), key);
+ if (has_key && key.get_abbrev() != "") {
+ msg.append("\n\n Key: ").append(key.get_abbrev());
+ }
+ }
+
if (req == 0) {
return;
}
req->widget = w;
- req->msg = tip;
+ req->msg = msg.c_str();
req->msg2 = hlp;
send_request (req);
diff --git a/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h b/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h
index 1fbfb9d800..2484b1e620 100644
--- a/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h
+++ b/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h
@@ -113,7 +113,9 @@ class UI : public Receiver, public AbstractUI<UIRequest>
void flush_pending ();
void toggle_errors ();
void touch_display (Touchable *);
- void set_tip (Gtk::Widget *w, const gchar *tip, const gchar *hlp);
+ void set_tip (Gtk::Widget &w, const gchar *tip);
+ void set_tip (Gtk::Widget &w, const std::string &tip);
+ void set_tip (Gtk::Widget *w, const gchar *tip, const gchar *hlp="");
void idle_add (int (*func)(void *), void *arg);
Gtk::Main& main() const { return *theMain; }