Do MMC on playhead drag more efficiently by not doing an actual locate.
[ardour.git] / libs / gtkmm2ext / gtk_ui.cc
index 318dedd1fc450a4513ea232b61f6f845f5e04b3d..cfcc0df91a96d6d0acc932e05eb9658b5917431e 100644 (file)
@@ -38,6 +38,7 @@
 #include <gtkmm2ext/popup.h>
 #include <gtkmm2ext/utils.h>
 #include <gtkmm2ext/window_title.h>
+#include <gtkmm2ext/actions.h>
 
 #include "i18n.h"
 
@@ -297,17 +298,40 @@ UI::touch_display (Touchable *display)
        send_request (req);
 }
 
+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);
@@ -345,6 +369,23 @@ UI::idle_add (int (*func)(void *), void *arg)
 
 /* END abstract_ui interfaces */
 
+/** Create a PBD::EventLoop::InvalidationRecord and attach a callback
+ *  to a given sigc::trackable so that PBD::EventLoop::invalidate_request
+ *  is called when that trackable is destroyed.
+ */
+PBD::EventLoop::InvalidationRecord*
+__invalidator (sigc::trackable& trackable, const char* file, int line)
+{
+        PBD::EventLoop::InvalidationRecord* ir = new PBD::EventLoop::InvalidationRecord;
+
+        ir->file = file;
+        ir->line = line;
+
+        trackable.add_destroy_notify_callback (ir, PBD::EventLoop::invalidate_request);
+
+        return ir;
+}
+
 void
 UI::do_request (UIRequest* req)
 {
@@ -561,7 +602,7 @@ UI::handle_fatal (const char *message)
 }
 
 void
-UI::popup_error (const char *text)
+UI::popup_error (const string& text)
 {
        PopUp *pup;