a) start at creating ControlProtocol objects
[ardour.git] / gtk2_ardour / ardour_ui.cc
index 6c21cdc1dfc0a02a8ebcc6b27a23cb307aac619f..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>
@@ -228,10 +228,22 @@ ARDOUR_UI::set_engine (AudioEngine& e)
        _tooltips.enable();
 
        keyboard = new Keyboard;
-       install_keybindings ();
 
-       FastMeter::set_vertical_xpm (ARDOUR::find_data_file("v_meter_strip.xpm", "pixmaps"));
-       FastMeter::set_horizontal_xpm (ARDOUR::find_data_file("h_meter_strip.xpm", "pixmaps"));
+       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 ();
@@ -259,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);
@@ -368,6 +384,10 @@ ARDOUR_UI::save_ardour_state ()
                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
@@ -773,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);
@@ -783,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 ()
 {
@@ -1231,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 ()
 {
@@ -2253,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 ()
 {
@@ -2314,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 ();
+       }       
+}