remove commented debug output
[ardour.git] / libs / gtkmm2ext / gtk_ui.cc
index 1f8e919af4b474135c8e66e57051d01daf7b045d..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"
 
@@ -80,6 +81,12 @@ UI::UI (string namestr, int *argc, char ***argv)
        */
 
        run_loop_thread = Thread::self();
+       
+       /* store "this" as the UI-for-thread of this thread, same argument
+          as for previous line.
+       */
+
+       set_event_loop_for_thread (this);
 
        /* attach our request source to the default main context */
 
@@ -291,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);
@@ -339,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)
 {
@@ -353,7 +400,11 @@ UI::do_request (UIRequest* req)
                do_quit ();
 
        } else if (req->type == CallSlot) {
-
+#ifndef NDEBUG
+               if (getenv ("DEBUG_THREADED_SIGNALS")) {
+                       cerr << "call slot for " << name() << endl;
+               }
+#endif
                req->the_slot ();
 
        } else if (req->type == TouchDisplay) {
@@ -551,7 +602,7 @@ UI::handle_fatal (const char *message)
 }
 
 void
-UI::popup_error (const char *text)
+UI::popup_error (const string& text)
 {
        PopUp *pup;