Hi AND low pass filter -- fresh from the oven werks.
[ardour.git] / libs / gtkmm2ext / popup.cc
index 0a48ebfc594ce551cb85e1b84b3ed6aeb05549ba..898211c986489d2e0a10d16b258fb7a99252041e 100644 (file)
@@ -1,6 +1,6 @@
 /*
     Copyright (C) 1998-99 Paul Barton-Davis
+
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
@@ -22,6 +22,7 @@
 
 #include <gtkmm2ext/popup.h>
 #include <gtkmm2ext/utils.h>
+#include <gtkmm2ext/gtk_ui.h>
 
 using namespace std;
 using namespace Gtk;
@@ -73,35 +74,44 @@ PopUp::remove ()
 {
        hide ();
 
+       if (popdown_time != 0 && timeout != -1) {
+               g_source_remove (timeout);
+       }
+
        if (delete_on_hide) {
                std::cerr << "deleting prompter\n";
-               if (popdown_time != 0 && timeout != -1) {
-                       gtk_timeout_remove (timeout);
-               }
-               gtk_idle_add (idle_delete, this);
+               g_idle_add (idle_delete, this);
        }
 }
+#define ENSURE_GUI_THREAD(slot) \
+     if (!Gtkmm2ext::UI::instance()->caller_is_ui_thread()) {\
+             Gtkmm2ext::UI::instance()->call_slot (MISSING_INVALIDATOR, (slot)); \
+        return;\
+     }
+
 
 void
 PopUp::touch ()
 {
+       ENSURE_GUI_THREAD (mem_fun (*this, &PopUp::touch));
+
        if (is_visible ()) {
                remove ();
        } else {
                set_size_request_to_display_given_text (label, my_text.c_str(), 25, 10);
                label.set_text (my_text);
                show_all ();
-               
+
                if (popdown_time != 0) {
-                       timeout = gtk_timeout_add (popdown_time, 
-                                                  remove_prompt_timeout, 
+                       timeout = g_timeout_add (popdown_time,
+                                                  remove_prompt_timeout,
                                                   this);
                }
        }
 }
 
 gint
-PopUp::button_click (GdkEventButton *ev)
+PopUp::button_click (GdkEventButton* /*ev*/)
 {
        remove ();
        return TRUE;
@@ -121,16 +131,17 @@ PopUp::set_name (string name)
 }
 
 bool
-PopUp::on_delete_event (GdkEventAny* ev)
+PopUp::on_delete_event (GdkEventAny* /*ev*/)
 {
        hide();
 
+       if (popdown_time != 0 && timeout != -1) {
+               g_source_remove (timeout);
+       }
+
        if (delete_on_hide) {
                std::cerr << "deleting prompter\n" << endl;
-               if (popdown_time != 0 && timeout != -1) {
-                       gtk_timeout_remove (timeout);
-               }
-               gtk_idle_add (idle_delete, this);
+               g_idle_add (idle_delete, this);
        }
 
        return true;