show() widgets explicitly in gtk2_ardour/analysis_window.cc
[ardour.git] / gtk2_ardour / ardour_ui.cc
index a10e4b5225e5bc46b0f5cce6b6cfbcba2e0f1e3f..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,7 +55,9 @@
 
 #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>
 #include <ardour/audioengine.h>
 #include <ardour/playlist.h>
@@ -66,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"
@@ -80,7 +83,8 @@
 #include "about.h"
 #include "utils.h"
 #include "gui_thread.h"
-#include "color_manager.h"
+#include "theme_manager.h"
+
 
 #include "i18n.h"
 
@@ -91,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),
@@ -163,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;
@@ -186,12 +186,17 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
        open_session_selector = 0;
        have_configure_timeout = false;
        have_disk_speed_dialog_displayed = false;
-       _will_create_new_session_automatically = 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();
        }
 }
 
@@ -1011,7 +1017,7 @@ ARDOUR_UI::open_session ()
        bool isnew;
 
        if (session_path.length() > 0) {
-               if (Session::find_session (session_path, path, name, isnew) == 0) {
+               if (ARDOUR::find_session (session_path, path, name, isnew) == 0) {
                        _session_is_new = isnew;
                        load_session (path, name);
                }
@@ -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;
                }
@@ -1991,7 +2003,7 @@ ARDOUR_UI::new_session (std::string predetermined_path)
                                        uint32_t nphysin = (uint32_t) new_session_dialog->input_limit_count();
                                        uint32_t nphysout = (uint32_t) new_session_dialog->output_limit_count();
 
-                                       if (build_session (session_path,
+                                       if (!build_session (session_path,
                                                                session_name,
                                                                cchns,
                                                                mchns,
@@ -2076,7 +2088,7 @@ ARDOUR_UI::load_session (const string & path, const string & snap_name, string*
        return 0;
 }
 
-int
+bool
 ARDOUR_UI::build_session (const string & path, const string & snap_name, 
                          uint32_t control_channels,
                          uint32_t master_channels, 
@@ -2089,12 +2101,12 @@ ARDOUR_UI::build_session (const string & path, const string & snap_name,
        Session *new_session;
 
        if (!check_audioengine()) {
-               return -1;
+               return false;
        }
 
        session_loaded = false;
 
-       if (!unload_session ()) return -1;
+       if (!unload_session ()) return false;
        
        _session_is_new = true;
 
@@ -2107,13 +2119,13 @@ ARDOUR_UI::build_session (const string & path, const string & snap_name,
 
                MessageDialog msg (string_compose(_("Could not create session in \"%1\""), path));
                msg.run ();
-               return -1;
+               return false;
        }
 
        connect_to_session (new_session);
 
        session_loaded = true;
-       return 0;
+       return true;
 }
 
 void
@@ -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) {
@@ -2580,8 +2594,7 @@ ARDOUR_UI::cmdline_new_session (string path)
        }
 
        new_session (path);
-
-       _will_create_new_session_automatically = false; /* done it */
+       
        return FALSE; /* don't call it again */
 }