Use ardour/session_state_utils.h in Editor::redisplay_snapshots
[ardour.git] / gtk2_ardour / export_dialog.cc
index cf94233072ba15245688e1e9f9aaafb86c029c2f..2cf96fe02a8d1b20e53624f8ad4f400d43f1fd94 100644 (file)
@@ -15,7 +15,6 @@
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id$
 
 */
 
 #include <pbd/xml++.h>
 
 #include <gtkmm2ext/utils.h>
+#include <gtkmm2ext/window_title.h>
+
 #include <ardour/export.h>
+#include <ardour/session_directory.h>
 #include <ardour/sndfile_helpers.h>
 #include <ardour/audio_track.h>
 #include <ardour/audioregion.h>
@@ -52,6 +54,9 @@ using namespace ARDOUR;
 using namespace PBD;
 using namespace sigc;
 using namespace Gtk;
+using namespace Gtkmm2ext;
+
+using PBD::internationalize;
 
 static const gchar *sample_rates[] = {
        N_("22.05kHz"),
@@ -107,7 +112,6 @@ ExportDialog::ExportDialog(PublicEditor& e)
          src_quality_label (_("Conversion Quality"), 1.0, 0.5),
          dither_type_label (_("Dither Type"), 1.0, 0.5),
          cuefile_only_checkbox (_("Export CD Marker File Only")),
-         file_frame (_("Export to File")),
          file_browse_button (_("Browse")),
          track_selector_button (_("Specific tracks ..."))
 {
@@ -119,8 +123,11 @@ ExportDialog::ExportDialog(PublicEditor& e)
        track_and_master_selection_allowed = true;
        channel_count_selection_allowed = true;
        export_cd_markers_allowed = true;
+
+       WindowTitle title(Glib::get_application_name());
+       title += _("Export");
        
-       set_title (_("ardour: export"));
+       set_title (title.get_string());
        set_wmclass (X_("ardour_export"), "Ardour");
        set_name ("ExportWindow");
        add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
@@ -210,28 +217,28 @@ ExportDialog::ExportDialog(PublicEditor& e)
           takes a reference. 
        */
 
-       vector<string> pop_strings = I18N (sample_rates);
+       vector<string> pop_strings = I18N(sample_rates);
        Gtkmm2ext::set_popdown_strings (sample_rate_combo, pop_strings);
        sample_rate_combo.set_active_text (pop_strings.front());
-       pop_strings = I18N (src_quality);
+       pop_strings = I18N(src_quality);
        Gtkmm2ext::set_popdown_strings (src_quality_combo, pop_strings);
        src_quality_combo.set_active_text (pop_strings.front());
-       pop_strings = I18N (dither_types);
+       pop_strings = I18N(dither_types);
        Gtkmm2ext::set_popdown_strings (dither_type_combo, pop_strings);
        dither_type_combo.set_active_text (pop_strings.front());
-       pop_strings = I18N (channel_strings);
+       pop_strings = I18N(channel_strings);
        Gtkmm2ext::set_popdown_strings (channel_count_combo, pop_strings);
        channel_count_combo.set_active_text (pop_strings.front());
-       pop_strings = I18N ((const char **) sndfile_header_formats_strings);
+       pop_strings = I18N((const char **) sndfile_header_formats_strings);
        Gtkmm2ext::set_popdown_strings (header_format_combo, pop_strings);
        header_format_combo.set_active_text (pop_strings.front());
-       pop_strings = I18N ((const char **) sndfile_bitdepth_formats_strings);
+       pop_strings = I18N((const char **) sndfile_bitdepth_formats_strings);
        Gtkmm2ext::set_popdown_strings (bitdepth_format_combo, pop_strings);
        bitdepth_format_combo.set_active_text (pop_strings.front());
-       pop_strings = I18N ((const char **) sndfile_endian_formats_strings);
+       pop_strings = I18N((const char **) sndfile_endian_formats_strings);
        Gtkmm2ext::set_popdown_strings (endian_format_combo, pop_strings);
        endian_format_combo.set_active_text (pop_strings.front());
-       pop_strings = I18N (cue_file_types);
+       pop_strings = I18N(cue_file_types);
        Gtkmm2ext::set_popdown_strings (cue_file_combo, pop_strings);
        cue_file_combo.set_active_text (pop_strings.front());
 
@@ -394,25 +401,25 @@ ExportDialog::connect_to_session (Session *s)
 
        switch (session->frame_rate()) {
        case 22050:
-               sample_rate_combo.set_active_text (N_("22.05kHz"));
+               sample_rate_combo.set_active_text (_("22.05kHz"));
                break;
        case 44100:
-               sample_rate_combo.set_active_text (N_("44.1kHz"));
+               sample_rate_combo.set_active_text (_("44.1kHz"));
                break;
        case 48000:
-               sample_rate_combo.set_active_text (N_("48kHz"));
+               sample_rate_combo.set_active_text (_("48kHz"));
                break;
        case 88200:
-               sample_rate_combo.set_active_text (N_("88.2kHz"));
+               sample_rate_combo.set_active_text (_("88.2kHz"));
                break;
        case 96000:
-               sample_rate_combo.set_active_text (N_("96kHz"));
+               sample_rate_combo.set_active_text (_("96kHz"));
                break;
        case 192000:
-               sample_rate_combo.set_active_text (N_("192kHz"));
+               sample_rate_combo.set_active_text (_("192kHz"));
                break;
        default:
-               sample_rate_combo.set_active_text (N_("44.1kHz"));
+               sample_rate_combo.set_active_text (_("44.1kHz"));
                break;
        }
 
@@ -424,7 +431,7 @@ ExportDialog::connect_to_session (Session *s)
 void
 ExportDialog::set_state()
 {
-       XMLNode* node = session->instant_xml(X_("ExportDialog"), session->path());
+       XMLNode* node = session->instant_xml(X_("ExportDialog"));
        XMLProperty* prop;
 
        if (node) {
@@ -488,7 +495,7 @@ ExportDialog::set_state()
                        }
 
                        TreeModel::Children rows = master_selector.get_model()->children();
-                       for (uint32_t r = 0; r < session->master_out()->n_outputs(); ++r) {
+                       for (uint32_t r = 0; r < session->master_out()->n_outputs().n_audio(); ++r) {
                                if (nchns == 2) {
                                        if (r % 2) {
                                                rows[r][exp_cols.right] = true;
@@ -569,13 +576,13 @@ ExportDialog::save_state()
 
                row = *ri;
                track->add_property(X_("channel1"), row[exp_cols.left] ? X_("on") : X_("off"));
-               track->add_property(X_("channel1"), row[exp_cols.right] ? X_("on") : X_("off"));
+               track->add_property(X_("channel2"), row[exp_cols.right] ? X_("on") : X_("off"));
 
                tracks->add_child_nocopy(*track);
        }
        node->add_child_nocopy(*tracks);
        
-       session->add_instant_xml(*node, session->path());
+       session->add_instant_xml(*node);
 }
 
 void
@@ -870,7 +877,7 @@ ExportDialog::export_cue_file (Locations::LocationList& locations, const string&
 void
 ExportDialog::do_export_cd_markers (const string& path,const string& cuefile_type)
 {
-       if (cuefile_type == "TOC") {
+       if (cuefile_type == _("TOC")) {
                session->locations()->apply (*this, &ExportDialog::export_toc_file, path);      
        } else {
                session->locations()->apply (*this, &ExportDialog::export_cue_file, path);
@@ -915,11 +922,9 @@ ExportDialog::do_export ()
        end_dialog ();
 }
        
-
 void
 ExportDialog::end_dialog ()
 {
-
        if (spec.running) {
                spec.stop = true;
 
@@ -932,7 +937,7 @@ ExportDialog::end_dialog ()
                }
        }
 
-       session->engine().freewheel (false);
+       session->finalize_audio_export ();
 
        hide_all ();
 
@@ -948,21 +953,19 @@ ExportDialog::start_export ()
        }
 
        /* If the filename hasn't been set before, use the
-          directory above the current session as a default
+          current session's export directory as a default
           location for the export.  
        */
        
        if (file_entry.get_text().length() == 0) {
-               string dir = session->path();
-               string::size_type last_slash;
-               
-               if ((last_slash = dir.find_last_of ('/')) != string::npos) {
-                       dir = dir.substr (0, last_slash+1);
-               }
 
-               dir = dir + "export.wav";
+               sys::path export_file_path = session->session_directory().export_path();
+
+               if (!wants_dir()) {
+                       export_file_path /= "export.wav";
+               }
                
-               file_entry.set_text (dir);
+               file_entry.set_text (export_file_path.to_string());
        }
        
        progress_bar.set_fraction (0);
@@ -1024,15 +1027,15 @@ ExportDialog::sample_rate_chosen ()
 
        if (sr_str == N_("22.05kHz")) {
                rate = 22050;
-       } else if (sr_str == N_("44.1kHz")) {
+       } else if (sr_str == _("44.1kHz")) {
                rate = 44100;
-       } else if (sr_str == N_("48kHz")) {
+       } else if (sr_str == _("48kHz")) {
                rate = 48000;
-       } else if (sr_str == N_("88.2kHz")) {
+       } else if (sr_str == _("88.2kHz")) {
                rate = 88200;
-       } else if (sr_str == N_("96kHz")) {
+       } else if (sr_str == _("96kHz")) {
                rate = 96000;
-       } else if (sr_str == N_("192kHz")) {
+       } else if (sr_str == _("192kHz")) {
                rate = 192000;
        } else {
                rate = session->frame_rate();
@@ -1086,13 +1089,13 @@ ExportDialog::fill_lists ()
                
                boost::shared_ptr<Route> route = (*ri);
                
-               if (route->hidden()) {
+               if (route->is_hidden()) {
                        continue;
                }
 
-               for (uint32_t i=0; i < route->n_outputs(); ++i) {
+               for (uint32_t i=0; i < route->n_outputs().n_audio(); ++i) {
                        string name;
-                       if (route->n_outputs() == 1) {
+                       if (route->n_outputs().n_audio() == 1) {
                                name = route->name();
                        } else {
                                name = string_compose("%1: out-%2", route->name(), i+1);
@@ -1192,15 +1195,15 @@ ExportDialog::initSpec(string &filepath)
        string sr_str = sample_rate_combo.get_active_text();
        if (sr_str == N_("22.05kHz")) {
                spec.sample_rate = 22050;
-       } else if (sr_str == N_("44.1kHz")) {
+       } else if (sr_str == _("44.1kHz")) {
                spec.sample_rate = 44100;
-       } else if (sr_str == N_("48kHz")) {
+       } else if (sr_str == _("48kHz")) {
                spec.sample_rate = 48000;
-       } else if (sr_str == N_("88.2kHz")) {
+       } else if (sr_str == _("88.2kHz")) {
                spec.sample_rate = 88200;
-       } else if (sr_str == N_("96kHz")) {
+       } else if (sr_str == _("96kHz")) {
                spec.sample_rate = 96000;
-       } else if (sr_str == N_("192kHz")) {
+       } else if (sr_str == _("192kHz")) {
                spec.sample_rate = 192000;
        } else {
                spec.sample_rate = session->frame_rate();
@@ -1305,7 +1308,7 @@ ExportDialog::window_closed (GdkEventAny *ignored)
 void
 ExportDialog::browse ()
 {
-       FileChooserDialog dialog("Export to file", FILE_CHOOSER_ACTION_SAVE);
+       FileChooserDialog dialog("Export to file", browse_action());
        dialog.set_transient_for(*this);
        dialog.set_filename (file_entry.get_text());