a) start at creating ControlProtocol objects
[ardour.git] / gtk2_ardour / ardour_ui.cc
index 72bc9948eefdbe0b159eb9017a228cbb621594ea..79c81992dcc6573d4a163f3ca87507519b7f07c0 100644 (file)
@@ -29,6 +29,7 @@
 #include <iostream>
 
 #include <gtkmm/messagedialog.h>
+#include <gtkmm/accelmap.h>
 
 #include <pbd/error.h>
 #include <pbd/compose.h>
@@ -36,7 +37,6 @@
 #include <pbd/pathscanner.h>
 #include <pbd/failed_constructor.h>
 #include <gtkmm2ext/gtk_ui.h>
-#include <gtkmm2ext/pix.h>
 #include <gtkmm2ext/utils.h>
 #include <gtkmm2ext/click_box.h>
 #include <gtkmm2ext/fastmeter.h>
@@ -72,7 +72,6 @@
 #include "about.h"
 #include "utils.h"
 #include "gui_thread.h"
-#include "meter_xpms.h"
 #include "color_manager.h"
 
 #include "i18n.h"
@@ -131,11 +130,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
        using namespace Gtk::Menu_Helpers;
 
        Gtkmm2ext::init();
-
-       /* actually, its already loaded, but ... */
-
-       cerr << "Loading UI configuration file " << rcfile << endl;
-
+       
        about = 0;
 
        if (theArdourUI == 0) {
@@ -148,12 +143,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
 
        color_manager = new ColorManager();
 
-       std::string color_file = Glib::getenv(X_("ARDOUR_COLORS"));
-       if(!Glib::file_test(color_file, Glib::FILE_TEST_EXISTS)) {
-               color_file = ARDOUR::find_config_file("ardour.colors");
-       }
-
-       cerr << "Loading UI color configuration file " << color_file << endl;
+       std::string color_file = ARDOUR::find_config_file("ardour.colors");
        
        color_manager->load (color_file);
 
@@ -186,6 +176,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
 
        shuttle_grabbed = false;
        shuttle_fract = 0.0;
+       shuttle_max_speed = 8.0f;
 
        set_shuttle_units (Percentage);
        set_shuttle_behaviour (Sprung);
@@ -237,10 +228,22 @@ ARDOUR_UI::set_engine (AudioEngine& e)
        _tooltips.enable();
 
        keyboard = new Keyboard;
-       install_keybindings ();
 
-       FastMeter::set_vertical_xpm (v_meter_strip_xpm);
-       FastMeter::set_horizontal_xpm (h_meter_strip_xpm);
+       string meter_path;
+
+       meter_path = ARDOUR::find_data_file("v_meter_strip.xpm", "pixmaps");
+       if (meter_path.empty()) {
+               error << _("no vertical meter strip image found") << endmsg;
+               exit (1);
+       }
+       FastMeter::set_vertical_xpm (meter_path);
+
+       meter_path = ARDOUR::find_data_file("h_meter_strip.xpm", "pixmaps");
+       if (meter_path.empty()) {
+               error << _("no horizontal meter strip image found") << endmsg;
+               exit (1);
+       }
+       FastMeter::set_horizontal_xpm (meter_path);
 
        if (setup_windows ()) {
                throw failed_constructor ();
@@ -268,6 +271,10 @@ ARDOUR_UI::set_engine (AudioEngine& e)
        
        blink_timeout_tag = -1;
 
+       /* the global configuration object is now valid */
+
+       use_config ();
+
        /* this being a GUI and all, we want peakfiles */
 
        FileSource::set_build_peakfiles (true);
@@ -374,9 +381,13 @@ ARDOUR_UI::save_ardour_state ()
                session->add_instant_xml(enode, session->path());
                session->add_instant_xml(mnode, session->path());
        } else {
-               Config->add_instant_xml(enode, Config->get_user_ardour_path());
-               Config->add_instant_xml(mnode, Config->get_user_ardour_path());
+               Config->add_instant_xml(enode, get_user_ardour_path());
+               Config->add_instant_xml(mnode, get_user_ardour_path());
        }
+
+       /* keybindings */
+
+       AccelMap::save ("ardour.saved_bindings");
 }
 
 void
@@ -782,6 +793,9 @@ ARDOUR_UI::build_session_selector ()
        recent_session_display.set_model (recent_session_model);
        recent_session_display.append_column (_("Recent Sessions"), recent_session_columns.visible_name);
        recent_session_display.set_headers_visible (false);
+       recent_session_display.get_selection()->set_mode (SELECTION_SINGLE);
+
+       recent_session_display.signal_row_activated().connect (mem_fun (*this, &ARDOUR_UI::recent_session_row_activated));
 
        scroller->add (recent_session_display);
        scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
@@ -792,6 +806,12 @@ ARDOUR_UI::build_session_selector ()
        session_selector_window->show_all_children();
 }
 
+void
+ARDOUR_UI::recent_session_row_activated (const TreePath& path, TreeViewColumn* col)
+{
+       session_selector_window->response (RESPONSE_ACCEPT);
+}
+
 void
 ARDOUR_UI::open_recent_session ()
 {
@@ -1240,14 +1260,6 @@ ARDOUR_UI::map_transport_state ()
        }
 }
 
-void
-ARDOUR_UI::send_all_midi_feedback ()
-{
-       if (session) {
-               session->send_all_midi_feedback();
-       }
-}
-
 void
 ARDOUR_UI::allow_local_only ()
 {
@@ -2130,7 +2142,7 @@ ARDOUR_UI::mixer_settings () const
        if (session) {
                node = session->instant_xml(X_("Mixer"), session->path());
        } else {
-               node = Config->instant_xml(X_("Mixer"), Config->get_user_ardour_path());
+               node = Config->instant_xml(X_("Mixer"), get_user_ardour_path());
        }
 
        if (!node) {
@@ -2148,7 +2160,7 @@ ARDOUR_UI::editor_settings () const
        if (session) {
                node = session->instant_xml(X_("Editor"), session->path());
        } else {
-               node = Config->instant_xml(X_("Editor"), Config->get_user_ardour_path());
+               node = Config->instant_xml(X_("Editor"), get_user_ardour_path());
        }
 
        if (!node) {
@@ -2262,15 +2274,12 @@ what you would like to do.\n"));
        
        switch (dialog.run ()) {
        case RESPONSE_ACCEPT:
-               break;
-       default:
                return 1;
+       default:
+               return 0;
        }
-
-       return 0;
 }
        
-       
 void
 ARDOUR_UI::disconnect_from_jack ()
 {
@@ -2323,3 +2332,106 @@ ARDOUR_UI::cmdline_new_session (string path)
        _will_create_new_session_automatically = false; /* done it */
        return FALSE; /* don't call it again */
 }
+
+void
+ARDOUR_UI::set_native_file_header_format (HeaderFormat hf)
+{
+       Glib::RefPtr<Action> act;
+       
+       switch (hf) {
+       case BWF:
+               act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatBWF"));
+               break;
+       case WAVE:
+               act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatWAVE"));
+               break;
+       case WAVE64:
+               act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatWAVE64"));
+               break;
+       case iXML:
+               act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatiXML"));
+               break;
+       case RF64:
+               act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatRF64"));
+               break;
+       }
+
+       if (act) {
+               Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
+               if (ract && ract->get_active() && Config->get_native_file_header_format() != hf) {
+                       Config->set_native_file_header_format (hf);
+                       if (session) {
+                               session->reset_native_file_format ();
+                       }
+               }
+       }
+}
+
+void
+ARDOUR_UI::set_native_file_data_format (SampleFormat sf)
+{
+       Glib::RefPtr<Action> act;
+       
+       switch (sf) {
+       case FormatFloat:
+               act = ActionManager::get_action (X_("options"), X_("FileDataFormatFloat"));
+               break;
+       case FormatInt24:
+               act = ActionManager::get_action (X_("options"), X_("FileDataFormat24bit"));
+               break;
+       }
+
+       if (act) {
+               Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
+
+               if (ract && ract->get_active() && Config->get_native_file_data_format() != sf) {
+                       Config->set_native_file_data_format (sf);
+                       if (session) {
+                               session->reset_native_file_format ();
+                       }
+               }
+       }
+}
+
+void
+ARDOUR_UI::use_config ()
+{
+       Glib::RefPtr<Action> act;
+
+       switch (Config->get_native_file_data_format ()) {
+       case FormatFloat:
+               act = ActionManager::get_action (X_("options"), X_("FileDataFormatFloat"));
+               break;
+       case FormatInt24:
+               act = ActionManager::get_action (X_("options"), X_("FileDataFormat24bit"));
+               break;
+       }
+
+       if (act) {
+               Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
+               ract->set_active ();
+       }       
+
+       switch (Config->get_native_file_header_format ()) {
+       case BWF:
+               act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatBWF"));
+               break;
+       case WAVE:
+               act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatWAVE"));
+               break;
+       case WAVE64:
+               act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatWAVE64"));
+               break;
+       case iXML:
+               act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatiXML"));
+               break;
+       case RF64:
+               act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatRF64"));
+               break;
+       }
+
+       if (act) {
+               Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
+               ract->set_active ();
+       }       
+}