Merge branch 'nsm' of https://github.com/royvegard/ardour
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / gtk_ui.h
index a0ea1e86ad2f2e9e6687af27eecb90aca86c7d5f..64176232f05f4a2f36d2cba695fb64217a9e202d 100644 (file)
@@ -50,6 +50,7 @@ namespace Gtkmm2ext {
 
 class TextViewer;
 
+extern BaseUI::RequestType NullMessage;
 extern BaseUI::RequestType ErrorMessage;
 extern BaseUI::RequestType CallSlot;
 extern BaseUI::RequestType TouchDisplay;
@@ -74,17 +75,34 @@ struct UIRequest : public BaseUI::BaseRequestObject {
     Transmitter::Channel chn;
     void *arg;
     const char *msg2;
+
+    UIRequest () {
+            type = NullMessage;
+    }
     
     ~UIRequest () { 
            if (type == ErrorMessage && msg) {
                    /* msg was strdup()'ed */
-                   free ((char *)msg);
+                   free (const_cast<char *>(msg));
            }
     }
 };
 
-class UI : public Receiver, public AbstractUI<UIRequest>
+class UI : public AbstractUI<UIRequest>
 {
+  private:
+       class MyReceiver : public Receiver {
+         public:
+               MyReceiver (UI& ui) : _ui (ui) {}
+               void receive (Transmitter::Channel chn, const char *msg) {
+                       _ui.receive (chn, msg);
+               }
+         private:
+               UI& _ui;
+       };
+
+       MyReceiver _receiver;
+
   public:
        UI (std::string name, int *argc, char **argv[]);
        virtual ~UI ();
@@ -99,8 +117,6 @@ class UI : public Receiver, public AbstractUI<UIRequest>
 
        bool caller_is_ui_thread ();
 
-       static Glib::Thread* thread_id() { return gui_thread; }
-
        /* Gtk-UI specific interfaces */
 
        bool running ();
@@ -112,6 +128,7 @@ class UI : public Receiver, public AbstractUI<UIRequest>
        void popup_error (const std::string& text);
        void flush_pending ();
        void toggle_errors ();
+       void show_errors ();
        void touch_display (Touchable *);
        void set_tip (Gtk::Widget &w, const gchar *tip);
        void set_tip (Gtk::Widget &w, const std::string &tip);
@@ -142,8 +159,6 @@ class UI : public Receiver, public AbstractUI<UIRequest>
 
        static bool just_hide_it (GdkEventAny *, Gtk::Window *);
 
-       static Glib::Thread* the_gui_thread() { return gui_thread; }
-
   protected:
        virtual void handle_fatal (const char *);
        virtual void display_message (const char *prefix, gint prefix_len,
@@ -152,7 +167,7 @@ class UI : public Receiver, public AbstractUI<UIRequest>
 
   private:
        static UI *theGtkUI;
-       static Glib::Thread* gui_thread;
+
        bool _active;
        Gtk::Main *theMain;
 #ifndef GTK_NEW_TOOLTIP_API
@@ -177,6 +192,7 @@ class UI : public Receiver, public AbstractUI<UIRequest>
        bool color_picked;
 
        void do_request (UIRequest*);
+
 };
 
 } /* namespace */