only do the widget packing style hack once, instead of everytime there is a theme...
authorDoug McLain <doug@nostar.net>
Fri, 29 Jun 2007 21:12:52 +0000 (21:12 +0000)
committerDoug McLain <doug@nostar.net>
Fri, 29 Jun 2007 21:12:52 +0000 (21:12 +0000)
git-svn-id: svn://localhost/ardour2/trunk@2091 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/theme_manager.cc
libs/gtkmm2ext/gtk_ui.cc
libs/gtkmm2ext/gtkmm2ext/gtk_ui.h

index fd7d7d92b57d6929f4d6f9c37ad830e66a800c22..d89ca812f81067f248660e83e047d18c91414ab6 100644 (file)
@@ -178,7 +178,7 @@ ThemeManager::button_press_event (GdkEventButton* ev)
 }
 
 void
-load_rc_file (const string& filename)
+load_rc_file (const string& filename, bool themechange)
 {
        sys::path rc_file_path;
 
@@ -196,7 +196,7 @@ load_rc_file (const string& filename)
 
        info << "Loading ui configuration file " << rc_file_path.to_string() << endmsg;
 
-       Gtkmm2ext::UI::instance()->load_rcfile (rc_file_path.to_string());
+       Gtkmm2ext::UI::instance()->load_rcfile (rc_file_path.to_string(), themechange);
 }
 
 void
@@ -205,7 +205,7 @@ ThemeManager::on_dark_theme_button_toggled()
        if (!dark_button.get_active()) return;
 
        ARDOUR_UI::config()->ui_rc_file.set("ardour2_ui_dark.rc");
-       load_rc_file (ARDOUR_UI::config()->ui_rc_file.get());
+       load_rc_file (ARDOUR_UI::config()->ui_rc_file.get(), true);
 }
 
 void
@@ -214,7 +214,7 @@ ThemeManager::on_light_theme_button_toggled()
        if (!light_button.get_active()) return;
 
        ARDOUR_UI::config()->ui_rc_file.set("ardour2_ui_light.rc");
-       load_rc_file (ARDOUR_UI::config()->ui_rc_file.get());
+       load_rc_file (ARDOUR_UI::config()->ui_rc_file.get(), true);
 }
 
 void
@@ -254,6 +254,6 @@ ThemeManager::setup_theme ()
                light_button.set_active();
        }
 
-       load_rc_file(rcfile);
+       load_rc_file(rcfile, false);
 }
 
index 2e130f066eacbbd0090085801edd551af8dc2066..442a5a22deeb2677d2bd130b453391506267b298 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,6 +129,12 @@ UI::load_rcfile (string path)
        }
        
        RC rc (path.c_str());
+       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 */
 
@@ -199,11 +205,6 @@ UI::load_rcfile (string path)
        info_mtag->property_foreground_gdk().set_value(style->get_fg(STATE_NORMAL));
        info_mtag->property_background_gdk().set_value(style->get_bg(STATE_NORMAL));
 
-
-       RC::reset_styles(Gtk::Settings::get_default());
-       
-       theme_changed.emit();
-
        return 0;
 }
 
index 37945fd490b320999af86e150b16a93092f8bc48..0c2ff0d7982c78f4072d5c486b61f6c684ad92f1 100644 (file)
@@ -107,7 +107,7 @@ class UI : public Receiver, public AbstractUI<UIRequest>
        bool running ();
        void quit    ();
        void kill    ();
-       int  load_rcfile (string);
+       int  load_rcfile (string, bool themechange = false);
        void run (Receiver &old_receiver);
 
        void set_state (Gtk::Widget *w, Gtk::StateType state);