fix bad truncation of export path for export
[ardour.git] / gtk2_ardour / export_dialog.cc
index 96222f9ac3cafda8221d0a31ed6e3d15c2b6c28a..b6bc69c9b9cbb61335b6b084ef234a56d6b43774 100644 (file)
@@ -24,7 +24,6 @@
 #include <fstream>
 
 #include <samplerate.h>
-
 #include <pbd/convert.h>
 #include <pbd/xml++.h>
 
@@ -38,6 +37,7 @@
 #include <ardour/audioengine.h>
 #include <ardour/gdither.h>
 #include <ardour/utils.h>
+#include <ardour/profile.h>
 
 #include "export_dialog.h"
 #include "ardour_ui.h"
@@ -128,7 +128,7 @@ ExportDialog::ExportDialog(PublicEditor& e)
        set_wmclass (X_("ardour_export"), "Ardour");
        set_name ("ExportWindow");
        add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
-
+       
        spec.running = false;
 
        file_entry.set_name ("ExportFileNameEntry");
@@ -142,7 +142,7 @@ ExportDialog::ExportDialog(PublicEditor& e)
        master_selector.append_column_editable(_("Left"), exp_cols.left);
        master_selector.append_column_editable(_("Right"), exp_cols.right);
        master_selector.get_column(0)->set_min_width(100);
-       
+
        master_selector.get_column(1)->set_min_width(40);
        master_selector.get_column(1)->set_sizing(Gtk::TREE_VIEW_COLUMN_AUTOSIZE);
        master_selector.get_column(2)->set_min_width(40);
@@ -318,30 +318,52 @@ ExportDialog::ExportDialog(PublicEditor& e)
        format_table.set_col_spacings (5);
        format_table.set_row_spacings (5);
 
-       format_table.attach (channel_count_label, 0, 1, 0, 1);
-       format_table.attach (channel_count_combo, 1, 2, 0, 1);
+       int row = 0;
+
+       format_table.attach (channel_count_label, 0, 1, row, row+1);
+       format_table.attach (channel_count_combo, 1, 2, row, row+1);
+
+       row++;
        
-       format_table.attach (header_format_label, 0, 1, 1, 2);
-       format_table.attach (header_format_combo, 1, 2, 1, 2);
+       format_table.attach (header_format_label, 0, 1, row, row+1);
+       format_table.attach (header_format_combo, 1, 2, row, row+1);
 
-       format_table.attach (bitdepth_format_label, 0, 1, 2, 3);
-       format_table.attach (bitdepth_format_combo, 1, 2, 2, 3);
+       row++;
 
-       format_table.attach (endian_format_label, 0, 1, 3, 4);
-       format_table.attach (endian_format_combo, 1, 2, 3, 4);
+       format_table.attach (bitdepth_format_label, 0, 1, row, row+1);
+       format_table.attach (bitdepth_format_combo, 1, 2, row, row+1);
 
-       format_table.attach (sample_rate_label, 0, 1, 4, 5);
-       format_table.attach (sample_rate_combo, 1, 2, 4, 5);
+       row++;
 
-       format_table.attach (src_quality_label, 0, 1, 5, 6);
-       format_table.attach (src_quality_combo, 1, 2, 5, 6);
+       if (!Profile->get_sae()) {
+               format_table.attach (endian_format_label, 0, 1, row, row+1);
+               format_table.attach (endian_format_combo, 1, 2, row, row+1);
+               row++;
+       }
 
-       format_table.attach (dither_type_label, 0, 1, 6, 7);
-       format_table.attach (dither_type_combo, 1, 2, 6, 7);
+       format_table.attach (sample_rate_label, 0, 1, row, row+1);
+       format_table.attach (sample_rate_combo, 1, 2, row, row+1);
 
-       format_table.attach (cue_file_label, 0, 1, 7, 8);
-       format_table.attach (cue_file_combo, 1, 2, 7, 8);
-       format_table.attach (cuefile_only_checkbox, 0, 2, 8, 9);
+       row++;
+
+       if (!Profile->get_sae()) {
+               format_table.attach (src_quality_label, 0, 1, row, row+1);
+               format_table.attach (src_quality_combo, 1, 2, row, row+1);
+               row++;
+       }
+
+       format_table.attach (dither_type_label, 0, 1, row, row+1);
+       format_table.attach (dither_type_combo, 1, 2, row, row+1);
+
+       row++;
+
+       if (!Profile->get_sae()) {
+               format_table.attach (cue_file_label, 0, 1, row, row+1);
+               format_table.attach (cue_file_combo, 1, 2, row, row+1);
+               row++;
+       
+               format_table.attach (cuefile_only_checkbox, 0, 2, row, row+1);
+       }
 
        file_entry.set_name ("ExportFileDisplay");
 
@@ -913,12 +935,24 @@ void
 ExportDialog::do_export ()
 {
        string filepath = file_entry.get_text();
-       
+
+       if (!ARDOUR_UI::instance()->the_engine().connected()) {
+               MessageDialog msg (*this, 
+                                  _("Not connected to audioengine"),
+                                  true,
+                                  MESSAGE_ERROR,
+                                  BUTTONS_OK);
+               msg.set_secondary_text (_("Ardour cannot export audio when disconnected"));
+               msg.present ();
+               msg.run ();
+               return;
+       }
+               
        if(!is_filepath_valid(filepath)){
                return;
        }
 
-       if (export_cd_markers_allowed) {
+       if (!Profile->get_sae() && export_cd_markers_allowed) {
                if (cue_file_combo.get_active_text () != _("None")) {
                        do_export_cd_markers (file_entry.get_text(), cue_file_combo.get_active_text ());
                }
@@ -982,18 +1016,13 @@ ExportDialog::start_export ()
        */
        
        if (file_entry.get_text().length() == 0) {
-               string dir = session->export_dir();
-               string::size_type last_slash;
-               
-               if ((last_slash = dir.find_last_of ('/')) != string::npos && last_slash != 0) {
-                       dir = dir.substr (0, last_slash+1);
-               }
+               Glib::ustring export_path = session->export_dir();
 
                if (!wants_dir()) {
-                       dir = dir + "export.wav";
+                       export_path = Glib::build_filename (export_path, "export.wav");
                }
                
-               file_entry.set_text (dir);
+               file_entry.set_text (export_path);
        }
        
        progress_bar.set_fraction (0);
@@ -1212,10 +1241,12 @@ ExportDialog::initSpec(string &filepath)
        spec.format = 0;
 
        spec.format |= sndfile_header_format_from_string (header_format_combo.get_active_text ());
-       
-       if ((spec.format & SF_FORMAT_WAV) == 0) {
-               /* RIFF/WAV specifies endianess */
-               spec.format |= sndfile_endian_format_from_string (endian_format_combo.get_active_text ());
+
+       if (!Profile->get_sae()) {
+               if ((spec.format & SF_FORMAT_WAV) == 0) {
+                       /* RIFF/WAV specifies endianess */
+                       spec.format |= sndfile_endian_format_from_string (endian_format_combo.get_active_text ());
+               }
        }
 
        spec.format |= sndfile_bitdepth_format_from_string (bitdepth_format_combo.get_active_text ());
@@ -1237,17 +1268,21 @@ ExportDialog::initSpec(string &filepath)
                spec.sample_rate = session->frame_rate();
        }
        
-       string src_str = src_quality_combo.get_active_text();
-       if (src_str == _("fastest")) {
-               spec.src_quality = SRC_ZERO_ORDER_HOLD;
-       } else if (src_str == _("linear")) {
-               spec.src_quality = SRC_LINEAR;
-       } else if (src_str == _("better")) {
-               spec.src_quality = SRC_SINC_FASTEST;
-       } else if (src_str == _("intermediate")) {
-               spec.src_quality = SRC_SINC_MEDIUM_QUALITY;
-       } else {
+       if (Profile->get_sae()) {
                spec.src_quality = SRC_SINC_BEST_QUALITY;
+       } else {
+               string src_str = src_quality_combo.get_active_text();
+               if (src_str == _("fastest")) {
+                       spec.src_quality = SRC_ZERO_ORDER_HOLD;
+               } else if (src_str == _("linear")) {
+                       spec.src_quality = SRC_LINEAR;
+               } else if (src_str == _("better")) {
+                       spec.src_quality = SRC_SINC_FASTEST;
+               } else if (src_str == _("intermediate")) {
+                       spec.src_quality = SRC_SINC_MEDIUM_QUALITY;
+               } else {
+                       spec.src_quality = SRC_SINC_BEST_QUALITY;
+               }
        }
 
        string dither_str = dither_type_combo.get_active_text();