added file
[ardour.git] / libs / gtkmm2ext / gtk_ui.cc
index ee9d39c91865a82ee5a308e6ff9068931e7bd8a2..660ea32ad1aa2a4b0142a702350b92eb851cf7d3 100644 (file)
@@ -114,7 +114,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,7 +129,83 @@ UI::load_rcfile (string path)
        }
        
        RC rc (path.c_str());
-       RC::reset_styles(Gtk::Settings::get_default());
+       // 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 */
+
+       Window temp_window (WINDOW_TOPLEVEL);
+       HBox box;
+       Label a_widget1;
+       Label a_widget2;
+       Label a_widget3;
+       Label a_widget4;
+       RefPtr<Gtk::Style> style;
+       RefPtr<TextBuffer> buffer (errors->text().get_buffer());
+
+       box.pack_start (a_widget1);
+       box.pack_start (a_widget2);
+       box.pack_start (a_widget3);
+       box.pack_start (a_widget4);
+
+       error_ptag = buffer->create_tag();
+       error_mtag = buffer->create_tag();
+       fatal_ptag = buffer->create_tag();
+       fatal_mtag = buffer->create_tag();
+       warning_ptag = buffer->create_tag();
+       warning_mtag = buffer->create_tag();
+       info_ptag = buffer->create_tag();
+       info_mtag = buffer->create_tag();
+
+       a_widget1.set_name ("FatalMessage");
+       a_widget1.ensure_style ();
+       style = a_widget1.get_style();
+
+       fatal_ptag->property_font_desc().set_value(style->get_font());
+       fatal_ptag->property_foreground_gdk().set_value(style->get_fg(STATE_ACTIVE));
+       fatal_ptag->property_background_gdk().set_value(style->get_bg(STATE_ACTIVE));
+       fatal_mtag->property_font_desc().set_value(style->get_font());
+       fatal_mtag->property_foreground_gdk().set_value(style->get_fg(STATE_NORMAL));
+       fatal_mtag->property_background_gdk().set_value(style->get_bg(STATE_NORMAL));
+
+       a_widget2.set_name ("ErrorMessage");
+       a_widget2.ensure_style ();
+       style = a_widget2.get_style();
+
+       error_ptag->property_font_desc().set_value(style->get_font());
+       error_ptag->property_foreground_gdk().set_value(style->get_fg(STATE_ACTIVE));
+       error_ptag->property_background_gdk().set_value(style->get_bg(STATE_ACTIVE));
+       error_mtag->property_font_desc().set_value(style->get_font());
+       error_mtag->property_foreground_gdk().set_value(style->get_fg(STATE_NORMAL));
+       error_mtag->property_background_gdk().set_value(style->get_bg(STATE_NORMAL));
+
+       a_widget3.set_name ("WarningMessage");
+       a_widget3.ensure_style ();
+       style = a_widget3.get_style();
+
+       warning_ptag->property_font_desc().set_value(style->get_font());
+       warning_ptag->property_foreground_gdk().set_value(style->get_fg(STATE_ACTIVE));
+       warning_ptag->property_background_gdk().set_value(style->get_bg(STATE_ACTIVE));
+       warning_mtag->property_font_desc().set_value(style->get_font());
+       warning_mtag->property_foreground_gdk().set_value(style->get_fg(STATE_NORMAL));
+       warning_mtag->property_background_gdk().set_value(style->get_bg(STATE_NORMAL));
+
+       a_widget4.set_name ("InfoMessage");
+       a_widget4.ensure_style ();
+       style = a_widget4.get_style();
+
+       info_ptag->property_font_desc().set_value(style->get_font());
+       info_ptag->property_foreground_gdk().set_value(style->get_fg(STATE_ACTIVE));
+       info_ptag->property_background_gdk().set_value(style->get_bg(STATE_ACTIVE));
+       info_mtag->property_font_desc().set_value(style->get_font());
+       info_mtag->property_foreground_gdk().set_value(style->get_fg(STATE_NORMAL));
+       info_mtag->property_background_gdk().set_value(style->get_bg(STATE_NORMAL));
+
        return 0;
 }
 
@@ -338,7 +414,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
@@ -504,7 +580,7 @@ UI::flush_pending ()
 bool
 UI::just_hide_it (GdkEventAny *ev, Window *win)
 {
-       win->hide_all ();
+       win->hide ();
        return true;
 }