show() widgets explicitly, one little file at a time
[ardour.git] / gtk2_ardour / ardour_ui.cc
index 4de3b12fb2888b6fdb0aacb8c68d70b8c4b8dcb8..7359b4908170c73b47f1fc07d360e348d8e0d434 100644 (file)
 
 #include <pbd/error.h>
 #include <pbd/compose.h>
-#include <pbd/pathscanner.h>
 #include <pbd/failed_constructor.h>
 #include <pbd/enumwriter.h>
 #include <pbd/memento_command.h>
+#include <pbd/file_utils.h>
 
 #include <gtkmm2ext/gtk_ui.h>
 #include <gtkmm2ext/utils.h>
@@ -55,6 +55,7 @@
 
 #include <ardour/ardour.h>
 #include <ardour/profile.h>
+#include <ardour/session_directory.h>
 #include <ardour/session_route.h>
 #include <ardour/session_utils.h>
 #include <ardour/port.h>
@@ -67,6 +68,7 @@
 #include <ardour/port.h>
 #include <ardour/audio_track.h>
 #include <ardour/midi_track.h>
+#include <ardour/filesystem_paths.h>
 
 #include "actions.h"
 #include "ardour_ui.h"
@@ -81,7 +83,8 @@
 #include "about.h"
 #include "utils.h"
 #include "gui_thread.h"
-#include "color_manager.h"
+#include "theme_manager.h"
+
 
 #include "i18n.h"
 
@@ -92,15 +95,16 @@ using namespace Gtk;
 using namespace sigc;
 
 ARDOUR_UI *ARDOUR_UI::theArdourUI = 0;
+UIConfiguration *ARDOUR_UI::ui_config = 0;
 
 sigc::signal<void,bool> ARDOUR_UI::Blink;
 sigc::signal<void>      ARDOUR_UI::RapidScreenUpdate;
 sigc::signal<void>      ARDOUR_UI::SuperRapidScreenUpdate;
 sigc::signal<void,nframes_t, bool, nframes_t> ARDOUR_UI::Clock;
 
-ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
+ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[])
 
-       : Gtkmm2ext::UI (X_("Ardour"), argcp, argvp, rcfile),
+       : Gtkmm2ext::UI (X_("Ardour"), argcp, argvp),
          
          primary_clock (X_("primary"), false, X_("TransportClockDisplay"), true, false, true),
          secondary_clock (X_("secondary"), false, X_("SecondaryClockDisplay"), true, false, true),
@@ -164,14 +168,9 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
                theArdourUI = this;
        }
 
-       /* load colors */
-
-       color_manager = new ColorManager();
-
-       std::string color_file = ARDOUR::find_config_file("ardour.colors");
-
-       color_manager->load (color_file);
-
+       ui_config = new UIConfiguration();
+       theme_manager = new ThemeManager();
+       
        editor = 0;
        mixer = 0;
        session = 0;
@@ -189,9 +188,15 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
        have_disk_speed_dialog_displayed = false;
        session_loaded = false;
        last_speed_displayed = -1.0f;
-       keybindings_path = ARDOUR::find_config_file ("ardour.bindings");
        ab_direction = true;
 
+       sys::path key_bindings_file;
+
+       find_file_in_search_path (ardour_search_path() + system_config_search_path(),
+                       "ardour.bindings", key_bindings_file);
+
+       keybindings_path = key_bindings_file.to_string();
+
        can_save_keybindings = false;
 
        last_configure_time.tv_sec = 0;
@@ -424,11 +429,11 @@ ARDOUR_UI::save_ardour_state ()
        XMLNode mnode(mixer->get_state());
 
        if (session) {
-               session->add_instant_xml (enode, session->path());
-               session->add_instant_xml (mnode, session->path());
+               session->add_instant_xml (enode);
+               session->add_instant_xml (mnode);
        } else {
-               Config->add_instant_xml (enode, get_user_ardour_path());
-               Config->add_instant_xml (mnode, get_user_ardour_path());
+               Config->add_instant_xml (enode);
+               Config->add_instant_xml (mnode);
        }
 
        save_keybindings ();
@@ -477,7 +482,7 @@ void
 ARDOUR_UI::no_memory_warning ()
 {
        XMLNode node (X_("no-memory-warning"));
-       Config->add_instant_xml (node, get_user_ardour_path());
+       Config->add_instant_xml (node);
 }
 
 void
@@ -488,7 +493,7 @@ ARDOUR_UI::check_memory_locking ()
        return;
 #else // !__APPLE__
 
-       XMLNode* memory_warning_node = Config->instant_xml (X_("no-memory-warning"), get_user_ardour_path());
+       XMLNode* memory_warning_node = Config->instant_xml (X_("no-memory-warning"));
 
        if (engine->is_realtime() && memory_warning_node == 0) {
 
@@ -567,6 +572,7 @@ If you still wish to quit, please use the\n\n\
        }
        engine->stop (true);
        Config->save_state();
+       ARDOUR_UI::config()->save_state();
        quit ();
 }
 
@@ -721,7 +727,7 @@ ARDOUR_UI::count_recenabled_streams (Route& route)
 {
        Track* track = dynamic_cast<Track*>(&route);
        if (track && track->diskstream()->record_enabled()) {
-               rec_enabled_streams += track->n_inputs().get_total();
+               rec_enabled_streams += track->n_inputs().n_total();
        }
 }
 
@@ -1240,7 +1246,7 @@ ARDOUR_UI::transport_record ()
                        break;
                case Session::Recording:
                case Session::Enabled:
-                       session->disable_record (true);
+                       session->disable_record (false, true);
                }
        }
 }
@@ -1503,6 +1509,12 @@ ARDOUR_UI::do_engine_start ()
        return 0;
 }
 
+void
+ARDOUR_UI::setup_theme ()
+{
+       theme_manager->setup_theme();
+}
+
 gint
 ARDOUR_UI::start_engine ()
 {
@@ -1593,7 +1605,7 @@ ARDOUR_UI::name_io_setup (AudioEngine& engine,
                          bool in)
 {
        if (in) {
-               if (io.n_inputs().get_total() == 0) {
+               if (io.n_inputs().n_total() == 0) {
                        buf = _("none");
                        return;
                }
@@ -1612,7 +1624,7 @@ ARDOUR_UI::name_io_setup (AudioEngine& engine,
 
        } else {
 
-               if (io.n_outputs().get_total() == 0) {
+               if (io.n_outputs().n_total() == 0) {
                        buf = _("none");
                        return;
                }
@@ -2212,17 +2224,19 @@ require some unused files to continue to exist."));
 
        dimage->set_alignment(ALIGN_LEFT, ALIGN_TOP);
 
+       const string dead_sound_directory = session->session_directory().dead_sound_path().to_string();
+
        if (rep.space < 1048576.0f) {
                if (removed > 1) {
-                 txt.set_text (string_compose (msg, removed, _("files were"), session->path() + "dead_sounds", (float) rep.space / 1024.0f, "kilo"));
+                       txt.set_text (string_compose (msg, removed, _("files were"), dead_sound_directory, (float) rep.space / 1024.0f, "kilo"));
                } else {
-                       txt.set_text (string_compose (msg, removed, _("file was"), session->path() + "dead_sounds", (float) rep.space / 1024.0f, "kilo"));
+                       txt.set_text (string_compose (msg, removed, _("file was"), dead_sound_directory, (float) rep.space / 1024.0f, "kilo"));
                }
        } else {
                if (removed > 1) {
-                       txt.set_text (string_compose (msg, removed, _("files were"), session->path() + "dead_sounds", (float) rep.space / 1048576.0f, "mega"));
+                       txt.set_text (string_compose (msg, removed, _("files were"), dead_sound_directory, (float) rep.space / 1048576.0f, "mega"));
                } else {
-                       txt.set_text (string_compose (msg, removed, _("file was"), session->path() + "dead_sounds", (float) rep.space / 1048576.0f, "mega"));
+                       txt.set_text (string_compose (msg, removed, _("file was"), dead_sound_directory, (float) rep.space / 1048576.0f, "mega"));
                }
        }
 
@@ -2416,9 +2430,9 @@ ARDOUR_UI::mixer_settings () const
        XMLNode* node = 0;
 
        if (session) {
-               node = session->instant_xml(X_("Mixer"), session->path());
+               node = session->instant_xml(X_("Mixer"));
        } else {
-               node = Config->instant_xml(X_("Mixer"), get_user_ardour_path());
+               node = Config->instant_xml(X_("Mixer"));
        }
 
        if (!node) {
@@ -2434,9 +2448,9 @@ ARDOUR_UI::editor_settings () const
        XMLNode* node = 0;
 
        if (session) {
-               node = session->instant_xml(X_("Editor"), session->path());
+               node = session->instant_xml(X_("Editor"));
        } else {
-               node = Config->instant_xml(X_("Editor"), get_user_ardour_path());
+               node = Config->instant_xml(X_("Editor"));
        }
 
        if (!node) {