remove duplicate/wrong includes in last commit.
[ardour.git] / libs / gtkmm2ext / gtk_ui.cc
index 903f56ba6fb5a4ef878ce8ce8b818a41bdf8ee5c..4ca23b024088ec7f9eb0337e38848d366f13d97e 100644 (file)
@@ -61,11 +61,10 @@ BaseUI::RequestType Gtkmm2ext::AddTimeout = BaseUI::new_request_type();
 #include <pbd/abstract_ui.cc>  /* instantiate the template */
 
 
-UI::UI (string namestr, int *argc, char ***argv, string rcfile
+UI::UI (string namestr, int *argc, char ***argv) 
        : AbstractUI<UIRequest> (namestr, true)
 {
        theMain = new Main (argc, argv);
-       tips = new Tooltips;
 
        _active = false;
 
@@ -99,7 +98,7 @@ UI::UI (string namestr, int *argc, char ***argv, string rcfile)
 
        register_thread (pthread_self(), X_("GUI"));
 
-       load_rcfile (rcfile);
+       //load_rcfile (rcfile);
 }
 
 UI::~UI ()
@@ -114,7 +113,7 @@ UI::caller_is_ui_thread ()
 }
 
 int
-UI::load_rcfile (string path)
+UI::load_rcfile (string path, bool themechange)
 {
        if (path.length() == 0) {
                return -1;
@@ -129,6 +128,13 @@ UI::load_rcfile (string path)
        }
        
        RC rc (path.c_str());
+       // RC::reset_styles (Gtk::Settings::get_default());
+       gtk_rc_reset_styles (gtk_settings_get_default());
+       theme_changed.emit();
+
+       if (themechange) {
+               return 0; //Don't continue on every time there is a theme change
+       }
 
        /* have to pack widgets into a toplevel window so that styles will stick */
 
@@ -407,7 +413,7 @@ UI::process_error_message (Transmitter::Channel chn, const char *str)
        RefPtr<Style> style;
        RefPtr<TextBuffer::Tag> ptag;
        RefPtr<TextBuffer::Tag> mtag;
-       char *prefix;
+       const char *prefix;
        size_t prefix_len;
        bool fatal_received = false;
 #ifndef OLD_STYLE_ERRORS
@@ -553,10 +559,31 @@ UI::popup_error (const char *text)
        pup->touch ();
 }
 
+#ifdef GTKOSX
+extern "C" {
+       int gdk_quartz_in_carbon_menu_event_handler ();
+}
+#endif
 
 void
 UI::flush_pending ()
 {
+#ifdef GTKOSX
+       /* as of february 11th 2008, gtk/osx has a problem in that mac menu events
+          are handled using Carbon with an "internal" event handling system that 
+          doesn't pass things back to the glib/gtk main loop. this makes
+          gtk_main_iteration() block if we call it while in a menu event handler 
+          because glib gets confused and thinks there are two threads running
+          g_main_poll_func(). 
+
+          this hack (relies on code in gtk2_ardour/sync-menu.c) works
+          around that.
+       */
+
+       if (gdk_quartz_in_carbon_menu_event_handler()) {
+               return;
+       }
+#endif
        if (!caller_is_ui_thread()) {
                error << "non-UI threads cannot call UI::flush_pending()"
                      << endmsg;
@@ -573,7 +600,7 @@ UI::flush_pending ()
 bool
 UI::just_hide_it (GdkEventAny *ev, Window *win)
 {
-       win->hide_all ();
+       win->hide ();
        return true;
 }