convert from Glib:: to Glib::Threads for all thread-related API
[ardour.git] / libs / gtkmm2ext / gtk_ui.cc
index 9679113b47218ac3f1b59511a8b2c64428eb0a94..a1b932af59543bf412349510a0c50032b95fe0b5 100644 (file)
@@ -31,7 +31,7 @@
 #include <pbd/touchable.h>
 #include <pbd/failed_constructor.h>
 #include <pbd/pthread_utils.h>
-#include <pbd/stacktrace.h>
+#include <pbd/replace_all.h>
 
 #include <gtkmm2ext/application.h>
 #include <gtkmm2ext/gtk_ui.h>
@@ -64,6 +64,8 @@ BaseUI::RequestType Gtkmm2ext::AddTimeout = BaseUI::new_request_type();
 
 UI::UI (string namestr, int *argc, char ***argv)
        : AbstractUI<UIRequest> (namestr)
+       , _receiver (*this)
+         
 {
        theMain = new Main (argc, argv);
 
@@ -80,7 +82,7 @@ UI::UI (string namestr, int *argc, char ***argv)
           which is assumed to have called this.
        */
 
-       run_loop_thread = Thread::self();
+       run_loop_thread = Threads::Thread::self();
        
        /* store "this" as the UI-for-thread of this thread, same argument
           as for previous line.
@@ -104,7 +106,7 @@ UI::UI (string namestr, int *argc, char ***argv)
        errors->set_title (title.get_string());
 
        errors->dismiss_button().set_name ("ErrorLogCloseButton");
-       errors->signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), (Window *) errors));
+       errors->signal_delete_event().connect (sigc::bind (sigc::ptr_fun (just_hide_it), (Window *) errors));
        errors->set_type_hint (Gdk::WINDOW_TYPE_HINT_UTILITY);
 
        //load_rcfile (rcfile);
@@ -122,7 +124,7 @@ UI::~UI ()
 bool
 UI::caller_is_ui_thread ()
 {
-       return Thread::self() == run_loop_thread;
+       return Threads::Thread::self() == run_loop_thread;
 }
 
 int
@@ -252,10 +254,10 @@ UI::load_rcfile (string path, bool themechange)
 void
 UI::run (Receiver &old_receiver)
 {
-       listen_to (error);
-       listen_to (info);
-       listen_to (warning);
-       listen_to (fatal);
+       _receiver.listen_to (error);
+       _receiver.listen_to (info);
+       _receiver.listen_to (warning);
+       _receiver.listen_to (fatal);
 
        /* stop the old receiver (text/console) once we hit the first idle */
 
@@ -266,7 +268,7 @@ UI::run (Receiver &old_receiver)
        theMain->run ();
        _active = false;
        stopping ();
-       hangup ();
+       _receiver.hangup ();
        return;
 }
 
@@ -351,8 +353,13 @@ UI::set_tip (Widget *w, const gchar *tip, const gchar *hlp)
                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 (has_key) {
+                               string  abbrev = key.get_abbrev();
+                               if (!abbrev.empty()) {
+                                       replace_all (abbrev, "<", "");
+                                       replace_all (abbrev, ">", "-");
+                                       msg.append(_("\n\nKey: ")).append (abbrev);
+                               }
                        }
                }
        }
@@ -361,6 +368,7 @@ UI::set_tip (Widget *w, const gchar *tip, const gchar *hlp)
                return;
        }
 
+
        req->widget = w;
        req->msg = msg.c_str();
        req->msg2 = hlp;
@@ -559,10 +567,15 @@ UI::process_error_message (Transmitter::Channel chn, const char *str)
                handle_fatal (str);
        } else {
 
-               display_message (prefix, prefix_len, ptag, mtag, str);
-
-               if (!errors->is_visible() && chn != Transmitter::Info) {
-                       show_errors ();
+               if (!ptag || !mtag) {
+                       /* oops, message sent before we set up tags - don't crash */
+                       cerr << prefix << str << endl;
+               } else {
+                       display_message (prefix, prefix_len, ptag, mtag, str);
+                       
+                       if (!errors->is_visible() && chn != Transmitter::Info) {
+                               show_errors ();
+                       }
                }
        }