X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fgtkmm2ext%2Fgtkmm2ext%2Fgtk_ui.h;h=a758ad78f4aee8f9a9a8073b28d414edfb61eff2;hb=533e40ca52c9a8f969405d4afbb82552956445ae;hp=f36f6de84f4b4dcbccdeabdb7d5979ad36cc99af;hpb=7ea68ecad60621a667c53d2450ccce9aed712589;p=ardour.git diff --git a/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h b/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h index f36f6de84f..a758ad78f4 100644 --- a/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h +++ b/libs/gtkmm2ext/gtkmm2ext/gtk_ui.h @@ -21,12 +21,18 @@ #define __pbd_gtk_ui_h__ #include -#include #include #include #include #include + +#ifdef interface +#undef interface +#endif + +#include + #include #include #ifndef GTK_NEW_TOOLTIP_API @@ -42,17 +48,14 @@ #include #include -using std::string; -using std::queue; - class Touchable; namespace Gtkmm2ext { class TextViewer; +extern BaseUI::RequestType NullMessage; extern BaseUI::RequestType ErrorMessage; -extern BaseUI::RequestType Quit; extern BaseUI::RequestType CallSlot; extern BaseUI::RequestType TouchDisplay; extern BaseUI::RequestType StateChange; @@ -76,20 +79,36 @@ struct UIRequest : public BaseUI::BaseRequestObject { Transmitter::Channel chn; void *arg; const char *msg2; - sigc::slot slot; + + UIRequest () { + type = NullMessage; + } ~UIRequest () { if (type == ErrorMessage && msg) { /* msg was strdup()'ed */ - free ((char *)msg); + free (const_cast(msg)); } } - }; +}; -class UI : public Receiver, public AbstractUI +class UI : public AbstractUI { + 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 (string name, int *argc, char **argv[]); + UI (std::string name, int *argc, char **argv[]); virtual ~UI (); static UI *instance() { return theGtkUI; } @@ -102,22 +121,22 @@ class UI : public Receiver, public AbstractUI bool caller_is_ui_thread (); - static pthread_t thread_id() { return gui_thread; } - /* Gtk-UI specific interfaces */ bool running (); void quit (); - void kill (); - int load_rcfile (string, bool themechange = false); + int load_rcfile (std::string, bool themechange = false); void run (Receiver &old_receiver); void set_state (Gtk::Widget *w, Gtk::StateType state); - void popup_error (const char *text); + 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, const gchar *hlp); + void set_tip (Gtk::Widget &w, const gchar *tip); + void set_tip (Gtk::Widget &w, const std::string &tip); + void set_tip (Gtk::Widget *w, const gchar *tip, const gchar *hlp=""); void idle_add (int (*func)(void *), void *arg); Gtk::Main& main() const { return *theMain; } @@ -127,7 +146,11 @@ class UI : public Receiver, public AbstractUI Glib::signal_idle().connect (bind (slot (&UI::idle_delete), obj)); } - Gdk::Color get_color (const string& prompt, bool& picked, const Gdk::Color *initial = 0); + template void delete_in_self (T *obj) { + call_slot (boost::bind (&UI::delete_in_self, this, obj)); + } + + Gdk::Color get_color (const std::string& prompt, bool& picked, const Gdk::Color *initial = 0); /* starting is sent just before we enter the main loop, stopping just after we return from it (at the top level) @@ -140,18 +163,15 @@ class UI : public Receiver, public AbstractUI static bool just_hide_it (GdkEventAny *, Gtk::Window *); - static pthread_t the_gui_thread() { return gui_thread; } - protected: virtual void handle_fatal (const char *); - virtual void display_message (const char *prefix, gint prefix_len, - Glib::RefPtr ptag, - Glib::RefPtr mtag, - const char *msg); + virtual void display_message (const char *prefix, gint prefix_len, + Glib::RefPtr ptag, Glib::RefPtr mtag, + const char *msg); private: static UI *theGtkUI; - static pthread_t gui_thread; + bool _active; Gtk::Main *theMain; #ifndef GTK_NEW_TOOLTIP_API @@ -176,6 +196,7 @@ class UI : public Receiver, public AbstractUI bool color_picked; void do_request (UIRequest*); + }; } /* namespace */