Updated config.guess file
[ardour.git] / gtk2_ardour / ardour_ui.cc
index 8708418227f477f13e7ce78d27e60873c974a86d..1887f046b8ad26ea3c7de2d6f756bcc606737c80 100644 (file)
@@ -33,7 +33,6 @@
 
 #include <pbd/error.h>
 #include <pbd/compose.h>
-#include <pbd/basename.h>
 #include <pbd/pathscanner.h>
 #include <pbd/failed_constructor.h>
 #include <gtkmm2ext/gtk_ui.h>
@@ -51,8 +50,8 @@
 #include <ardour/audioengine.h>
 #include <ardour/playlist.h>
 #include <ardour/utils.h>
-#include <ardour/diskstream.h>
-#include <ardour/filesource.h>
+#include <ardour/audio_diskstream.h>
+#include <ardour/audiofilesource.h>
 #include <ardour/recent_sessions.h>
 #include <ardour/session_diskstream.h>
 #include <ardour/port.h>
@@ -77,6 +76,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtkmm2ext;
 using namespace Gtk;
 using namespace sigc;
@@ -185,10 +185,9 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
        gettimeofday (&last_peak_grab, 0);
        gettimeofday (&last_shuttle_request, 0);
 
-       ARDOUR::DiskStream::CannotRecordNoInput.connect (mem_fun(*this, &ARDOUR_UI::cannot_record_no_input));
-       ARDOUR::DiskStream::DeleteSources.connect (mem_fun(*this, &ARDOUR_UI::delete_sources_in_the_right_thread));
-       ARDOUR::DiskStream::DiskOverrun.connect (mem_fun(*this, &ARDOUR_UI::disk_overrun_handler));
-       ARDOUR::DiskStream::DiskUnderrun.connect (mem_fun(*this, &ARDOUR_UI::disk_underrun_handler));
+       ARDOUR::AudioDiskstream::DeleteSources.connect (mem_fun(*this, &ARDOUR_UI::delete_sources_in_the_right_thread));
+       ARDOUR::AudioDiskstream::DiskOverrun.connect (mem_fun(*this, &ARDOUR_UI::disk_overrun_handler));
+       ARDOUR::AudioDiskstream::DiskUnderrun.connect (mem_fun(*this, &ARDOUR_UI::disk_underrun_handler));
 
        /* handle pending state with a dialog */
 
@@ -197,22 +196,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
        /* have to wait for AudioEngine and Configuration before proceeding */
 }
 
-void
-ARDOUR_UI::cannot_record_no_input (DiskStream* ds)
-{
-       ENSURE_GUI_THREAD (bind (mem_fun(*this, &ARDOUR_UI::cannot_record_no_input), ds));
-       
-       string msg = string_compose (_("\
-You cannot record-enable\n\
-track %1\n\
-because it has no input connections.\n\
-You would be wasting space recording silence."),
-                             ds->name());
-
-       MessageDialog message (*editor, msg);
-       message.run ();
-}
-
 void
 ARDOUR_UI::set_engine (AudioEngine& e)
 {
@@ -227,22 +210,6 @@ ARDOUR_UI::set_engine (AudioEngine& e)
 
        keyboard = new Keyboard;
 
-       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 ();
        }
@@ -275,10 +242,10 @@ ARDOUR_UI::set_engine (AudioEngine& e)
 
        /* this being a GUI and all, we want peakfiles */
 
-       FileSource::set_build_peakfiles (true);
-       FileSource::set_build_missing_peakfiles (true);
+       AudioFileSource::set_build_peakfiles (true);
+       AudioFileSource::set_build_missing_peakfiles (true);
 
-       if (Source::start_peak_thread ()) {
+       if (AudioSource::start_peak_thread ()) {
                throw failed_constructor();
        }
 
@@ -315,7 +282,7 @@ ARDOUR_UI::~ARDOUR_UI ()
                delete add_route_dialog;
        }
 
-       Source::stop_peak_thread ();
+       AudioSource::stop_peak_thread ();
 }
 
 gint
@@ -372,15 +339,15 @@ ARDOUR_UI::save_ardour_state ()
        Config->add_extra_xml (*node);
        Config->save_state();
 
-       XMLNode& enode (static_cast<Stateful*>(editor)->get_state());
-       XMLNode& mnode (mixer->get_state());
+       XMLNode* enode = new XMLNode (static_cast<Stateful*>(editor)->get_state());
+       XMLNode* mnode = new XMLNode (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->path());
+               session->add_instant_xml(*mnode, session->path());
        } else {
-               Config->add_instant_xml(enode, get_user_ardour_path());
-               Config->add_instant_xml(mnode, get_user_ardour_path());
+               Config->add_instant_xml(*enode, get_user_ardour_path());
+               Config->add_instant_xml(*mnode, get_user_ardour_path());
        }
 
        /* keybindings */
@@ -426,7 +393,7 @@ If you still wish to quit, please use the\n\n\
                        break;
                }
        }
-
+       Config->save_state();
        quit ();
 }
 
@@ -576,7 +543,7 @@ ARDOUR_UI::update_buffer_load ()
 }
 
 void
-ARDOUR_UI::count_recenabled_diskstreams (DiskStream& ds)
+ARDOUR_UI::count_recenabled_diskstreams (AudioDiskstream& ds)
 {
        if (ds.record_enabled()) {
                rec_enabled_diskstreams++;
@@ -604,7 +571,7 @@ ARDOUR_UI::update_disk_space()
                if (session->actively_recording()){
                        
                        rec_enabled_diskstreams = 0;
-                       session->foreach_diskstream (this, &ARDOUR_UI::count_recenabled_diskstreams);
+                       session->foreach_audio_diskstream (this, &ARDOUR_UI::count_recenabled_diskstreams);
                        
                        if (rec_enabled_diskstreams) {
                                frames /= rec_enabled_diskstreams;
@@ -734,7 +701,7 @@ ARDOUR_UI::redisplay_recent_sessions ()
 
                TreeModel::Row row = *(recent_session_model->append());
 
-               row[recent_session_columns.visible_name] = PBD::basename (fullpath);
+               row[recent_session_columns.visible_name] = Glib::path_get_basename (fullpath);
                row[recent_session_columns.fullpath] = fullpath;
 
                if (states->size() > 1) {
@@ -841,9 +808,11 @@ ARDOUR_UI::filter_ardour_session_dirs (const FileFilter::Info& info)
                return false;
        }
 
+        // XXX Portability
+        
        string session_file = info.filename;
        session_file += '/';
-       session_file += PBD::basename (info.filename);
+       session_file += Glib::path_get_basename (info.filename);
        session_file += ".ardour";
        
        if (stat (session_file.c_str(), &statbuf) != 0) {
@@ -949,7 +918,7 @@ restart JACK with more ports."));
 }
 
 void
-ARDOUR_UI::diskstream_added (DiskStream* ds)
+ARDOUR_UI::diskstream_added (AudioDiskstream* ds)
 {
 }
 
@@ -1190,31 +1159,21 @@ ARDOUR_UI::transport_forward (int option)
 }
 
 void
-ARDOUR_UI::toggle_monitor_enable (guint32 dstream)
+ARDOUR_UI::toggle_record_enable (uint32_t dstream)
 {
        if (session == 0) {
                return;
        }
 
-       DiskStream *ds;
-
-       if ((ds = session->diskstream_by_id (dstream)) != 0) {
-               Port *port = ds->io()->input (0);
-               port->request_monitor_input (!port->monitoring_input());
-       }
-}
-
-void
-ARDOUR_UI::toggle_record_enable (guint32 dstream)
-{
-       if (session == 0) {
-               return;
-       }
+       Route* r;
+       
+       if ((r = session->route_by_remote_id (dstream)) != 0) {
 
-       DiskStream *ds;
+               AudioTrack* at;
 
-       if ((ds = session->diskstream_by_id (dstream)) != 0) {
-               ds->set_record_enabled (!ds->record_enabled(), this);
+               if ((at = dynamic_cast<AudioTrack*>(r)) != 0) {
+                       at->disk_stream().set_record_enabled (!at->disk_stream().record_enabled(), this);
+               }
        }
 }
 
@@ -1416,63 +1375,6 @@ ARDOUR_UI::stop_blinking ()
        }
 }
 
-
-void
-ARDOUR_UI::add_diskstream_to_menu (DiskStream& dstream)
-{
-       using namespace Gtk;
-       using namespace Menu_Helpers;
-
-       if (dstream.hidden()) {
-               return;
-       }
-
-       MenuList& items = diskstream_menu->items();
-       items.push_back (MenuElem (dstream.name(), bind (mem_fun(*this, &ARDOUR_UI::diskstream_selected), (gint32) dstream.id())));
-}
-       
-void
-ARDOUR_UI::diskstream_selected (gint32 id)
-{
-       selected_dstream = id;
-       Main::quit ();
-}
-
-gint32
-ARDOUR_UI::select_diskstream (GdkEventButton *ev)
-{
-       using namespace Gtk;
-       using namespace Menu_Helpers;
-
-       if (session == 0) {
-               return -1;
-       }
-
-       diskstream_menu = new Menu();
-       diskstream_menu->set_name ("ArdourContextMenu");
-       using namespace Gtk;
-       using namespace Menu_Helpers;
-
-       MenuList& items = diskstream_menu->items();
-       items.push_back (MenuElem (_("No Stream"), (bind (mem_fun(*this, &ARDOUR_UI::diskstream_selected), -1))));
-
-       session->foreach_diskstream (this, &ARDOUR_UI::add_diskstream_to_menu);
-
-       if (ev) {
-               diskstream_menu->popup (ev->button, ev->time);
-       } else {
-               diskstream_menu->popup (0, 0);
-       }
-
-       selected_dstream = -1;
-
-       Main::run ();
-
-       delete diskstream_menu;
-
-       return selected_dstream;
-}
-
 void
 ARDOUR_UI::name_io_setup (AudioEngine& engine, 
                          string& buf,
@@ -1601,7 +1503,7 @@ ARDOUR_UI::secondary_clock_value_changed ()
 }
 
 void
-ARDOUR_UI::rec_enable_button_blink (bool onoff, DiskStream *dstream, Widget *w)
+ARDOUR_UI::rec_enable_button_blink (bool onoff, AudioDiskstream *dstream, Widget *w)
 {
        if (session && dstream && dstream->record_enabled()) {
 
@@ -2248,11 +2150,11 @@ ARDOUR_UI::halt_on_xrun_message ()
 }
 
 void 
-ARDOUR_UI::delete_sources_in_the_right_thread (list<ARDOUR::Source*>* deletion_list)
+ARDOUR_UI::delete_sources_in_the_right_thread (list<ARDOUR::AudioFileSource*>* deletion_list)
 {
        ENSURE_GUI_THREAD (bind (mem_fun(*this, &ARDOUR_UI::delete_sources_in_the_right_thread), deletion_list));
 
-       for (list<Source*>::iterator i = deletion_list->begin(); i != deletion_list->end(); ++i) {
+       for (list<AudioFileSource*>::iterator i = deletion_list->begin(); i != deletion_list->end(); ++i) {
                delete *i;
        }
 
@@ -2409,6 +2311,12 @@ ARDOUR_UI::set_native_file_header_format (HeaderFormat hf)
        case RF64:
                act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatRF64"));
                break;
+       case CAF:
+               act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatCAF"));
+               break;
+       case AIFF:
+               act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatAIFF"));
+               break;
        }
 
        if (act) {
@@ -2483,6 +2391,12 @@ ARDOUR_UI::use_config ()
        case RF64:
                act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatRF64"));
                break;
+       case CAF:
+               act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatCAF"));
+               break;
+       case AIFF:
+               act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatAIFF"));
+               break;
        }
 
        if (act) {