Add a couple of visibility specifiers that were missing
[ardour.git] / libs / gtkmm2ext / gtk_ui.cc
index f45fab6788588ff1b1de00704965b7e95e318a25..33841cd0beb6821c61a5927c2a848437e1eeb2f7 100644 (file)
 #include <cctype>
 
 #include <gtkmm.h>
-#include <pbd/error.h>
-#include <pbd/touchable.h>
-#include <pbd/failed_constructor.h>
-#include <pbd/pthread_utils.h>
-#include <pbd/stacktrace.h>
-
-#include <gtkmm2ext/application.h>
-#include <gtkmm2ext/gtk_ui.h>
-#include <gtkmm2ext/textviewer.h>
-#include <gtkmm2ext/popup.h>
-#include <gtkmm2ext/utils.h>
-#include <gtkmm2ext/window_title.h>
-#include <gtkmm2ext/actions.h>
-#include <gtkmm2ext/activatable.h>
+
+#include "pbd/error.h"
+#include "pbd/touchable.h"
+#include "pbd/failed_constructor.h"
+#include "pbd/pthread_utils.h"
+#include "pbd/replace_all.h"
+
+#include "gtkmm2ext/application.h"
+#include "gtkmm2ext/gtk_ui.h"
+#include "gtkmm2ext/textviewer.h"
+#include "gtkmm2ext/popup.h"
+#include "gtkmm2ext/utils.h"
+#include "gtkmm2ext/window_title.h"
+#include "gtkmm2ext/actions.h"
+#include "gtkmm2ext/activatable.h"
+#include "gtkmm2ext/actions.h"
+#include "gtkmm2ext/gui_thread.h"
 
 #include "i18n.h"
 
@@ -64,11 +67,10 @@ 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);
-#ifndef GTK_NEW_TOOLTIP_API
-       tips = new Tooltips;
-#endif
 
        _active = false;
 
@@ -83,7 +85,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.
@@ -93,7 +95,7 @@ UI::UI (string namestr, int *argc, char ***argv)
 
        /* attach our request source to the default main context */
 
-       request_channel.ios()->attach (MainContext::get_default());
+       attach_request_source ();
 
        errors = new TextViewer (800,600);
        errors->text().set_editable (false);
@@ -107,7 +109,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);
@@ -119,13 +121,13 @@ UI::UI (string namestr, int *argc, char ***argv)
 
 UI::~UI ()
 {
+       _receiver.hangup ();
 }
 
-
 bool
 UI::caller_is_ui_thread ()
 {
-       return Thread::self() == run_loop_thread;
+       return Threads::Thread::self() == run_loop_thread;
 }
 
 int
@@ -255,21 +257,23 @@ 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 */
 
        Glib::signal_idle().connect (bind_return (mem_fun (old_receiver, &Receiver::hangup), false));
 
-       starting ();
+       if (starting ()) {
+               return;
+       }
+
        _active = true;
        theMain->run ();
        _active = false;
-       stopping ();
-       hangup ();
+
        return;
 }
 
@@ -353,9 +357,11 @@ UI::set_tip (Widget *w, const gchar *tip, const gchar *hlp)
                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\nKey: ").append(key.get_abbrev());
+                       string shortcut = ActionManager::get_key_representation (ap, key);
+                       if (!shortcut.empty()) {
+                               replace_all (shortcut, "<", "");
+                               replace_all (shortcut, ">", "-");
+                               msg.append(_("\n\nShortcut: ")).append (shortcut);
                        }
                }
        }
@@ -364,6 +370,7 @@ UI::set_tip (Widget *w, const gchar *tip, const gchar *hlp)
                return;
        }
 
+
        req->widget = w;
        req->msg = msg.c_str();
        req->msg2 = hlp;
@@ -454,16 +461,7 @@ UI::do_request (UIRequest* req)
 
        } else if (req->type == SetTip) {
 
-#ifdef GTK_NEW_TOOLTIP_API
-               /* even if the installed GTK is up to date,
-                  at present (November 2008) our included
-                  version of gtkmm is not. so use the GTK
-                  API that we've verified has the right function.
-               */
-               gtk_widget_set_tooltip_text (req->widget->gobj(), req->msg);
-#else
-               tips->set_tip (*req->widget, req->msg, "");
-#endif
+               gtk_widget_set_tooltip_markup (req->widget->gobj(), req->msg);
 
        } else {
 
@@ -571,10 +569,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 ();
+                       }
                }
        }
 
@@ -689,7 +692,7 @@ UI::flush_pending ()
 }
 
 bool
-UI::just_hide_it (GdkEventAny */*ev*/, Window *win)
+UI::just_hide_it (GdkEventAny/*ev*/, Window *win)
 {
        win->hide ();
        return true;
@@ -739,7 +742,7 @@ UI::color_selection_done (bool status)
 }
 
 bool
-UI::color_selection_deleted (GdkEventAny */*ev*/)
+UI::color_selection_deleted (GdkEventAny/*ev*/)
 {
        Main::quit ();
        return true;