Apply patch from mantis 2761 from tinram to add padding and make a string translatable.
[ardour.git] / gtk2_ardour / export_channel_selector.cc
index e26d05d7c8311494813d97caeded7c61afdd904e..7b665a6087e709aef21a9baed4c785e4d23adfd9 100644 (file)
 
 #include <algorithm>
 
-#include <pbd/convert.h>
+#include "pbd/convert.h"
 
-#include <ardour/audioengine.h>
-#include <ardour/export_channel_configuration.h>
-#include <ardour/export_handler.h>
-#include <ardour/io.h>
-#include <ardour/route.h>
-#include <ardour/audio_port.h>
-#include <ardour/session.h>
+#include "ardour/audio_port.h"
+#include "ardour/audio_track.h"
+#include "ardour/audioengine.h"
+#include "ardour/export_channel_configuration.h"
+#include "ardour/export_handler.h"
+#include "ardour/io.h"
+#include "ardour/route.h"
+#include "ardour/session.h"
 
 #include <sstream>
 
 #include "i18n.h"
 
+using namespace std;
+using namespace Glib;
 using namespace ARDOUR;
 using namespace PBD;
 
-PortExportChannelSelector::PortExportChannelSelector () :
+PortExportChannelSelector::PortExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager) :
+  ExportChannelSelector (session, manager),
   channels_label (_("Channels:"), Gtk::ALIGN_LEFT),
   split_checkbox (_("Split to mono files")),
   max_channels (20),
   channel_view (max_channels)
 {
-
        channels_hbox.pack_start (channels_label, false, false, 0);
        channels_hbox.pack_end (channels_spinbutton, false, false, 0);
        
@@ -77,6 +80,7 @@ PortExportChannelSelector::PortExportChannelSelector () :
        
        /* Finalize */
        
+       sync_with_manager();
        show_all_children ();
        
 }
@@ -89,10 +93,9 @@ PortExportChannelSelector::~PortExportChannelSelector ()
 }
 
 void
-PortExportChannelSelector::set_state (ARDOUR::ExportProfileManager::ChannelConfigStatePtr const state_, ARDOUR::Session * session_)
+PortExportChannelSelector::sync_with_manager ()
 {
-       state = state_;
-       session = session_;
+       state = manager->get_channel_configs().front();
        
        split_checkbox.set_active (state->config->get_split());
        channels_spinbutton.set_value (state->config->get_n_chans());
@@ -105,18 +108,18 @@ void
 PortExportChannelSelector::fill_route_list ()
 {
        channel_view.clear_routes ();
-       Session::RouteList routes = *session->get_routes();
+       RouteList routes = *session->get_routes();
 
        /* Add master bus and then everything else */
        
-       ARDOUR::IO * master = session->master_out().get();
+       ARDOUR::IO* master = session->master_out()->output().get();
        channel_view.add_route (master);
        
-       for (Session::RouteList::iterator it = routes.begin(); it != routes.end(); ++it) {
-               if (it->get() == master) {
+       for (RouteList::iterator it = routes.begin(); it != routes.end(); ++it) {
+               if ((*it)->output().get() == master) {
                        continue;
                }
-               channel_view.add_route (it->get());
+               channel_view.add_route ((*it)->output().get());
        }
        
        update_channel_count ();
@@ -258,27 +261,27 @@ PortExportChannelSelector::ChannelTreeView::set_config (ChannelConfigPtr c)
 }
 
 void
-PortExportChannelSelector::ChannelTreeView::add_route (ARDOUR::IO * route)
+PortExportChannelSelector::ChannelTreeView::add_route (ARDOUR::IO * io)
 {
        Gtk::TreeModel::iterator iter = route_list->append();
        Gtk::TreeModel::Row row = *iter;
 
        row[route_cols.selected] = false;
-       row[route_cols.name] = route->name();
-       row[route_cols.io] = route;
+       row[route_cols.name] = io->name();
+       row[route_cols.io] = io;
        
        /* Initialize port list */
        
        Glib::RefPtr<Gtk::ListStore> port_list = Gtk::ListStore::create (route_cols.port_cols);
        row[route_cols.port_list_col] = port_list;
        
-       uint32_t outs = route->n_outputs().n_audio();
+       uint32_t outs = io->n_ports().n_audio();
        for (uint32_t i = 0; i < outs; ++i) {
                iter = port_list->append();
                row = *iter;
                
                row[route_cols.port_cols.selected] = false;
-               row[route_cols.port_cols.port] = route->audio_output (i);
+               row[route_cols.port_cols.port] = io->audio (i);
                
                std::ostringstream oss;
                oss << "Out-" << (i + 1);
@@ -432,36 +435,43 @@ PortExportChannelSelector::ChannelTreeView::update_selection_text (Glib::ustring
        update_config ();
 }
 
-RegionExportChannelSelector::RegionExportChannelSelector (ARDOUR::AudioRegion const & region, ARDOUR::AudioTrack & track) :
-  session (0),
+RegionExportChannelSelector::RegionExportChannelSelector (ARDOUR::Session * session,
+                                                          ProfileManagerPtr manager,
+                                                          ARDOUR::AudioRegion const & region,
+                                                          ARDOUR::AudioTrack & track) :
+  ExportChannelSelector (session, manager),
   region (region),
   track (track),
   region_chans (region.n_channels()),
   track_chans (track.n_outputs().n_audio()),
 
   raw_button (type_group),
+  fades_button (type_group),
   processed_button (type_group)
 {
        pack_start (vbox);
 
-       raw_button.set_label (string_compose (_("Raw region export, no fades or plugins (%1 channels)"), region_chans));
+       raw_button.set_label (string_compose (_("Region contents without fades (channels: %1)"), region_chans));
        raw_button.signal_toggled ().connect (sigc::mem_fun (*this, &RegionExportChannelSelector::handle_selection));
        vbox.pack_start (raw_button);
        
-       processed_button.set_label (string_compose (_("Processed region export with fades and plugins applied (%1 channels)"), track_chans));
+       fades_button.set_label (string_compose (_("Region contents with fades (channels: %1)"), region_chans));
+       fades_button.signal_toggled ().connect (sigc::mem_fun (*this, &RegionExportChannelSelector::handle_selection));
+       vbox.pack_start (fades_button);
+       
+       processed_button.set_label (string_compose (_("Track output (channels: %1)"), track_chans));
        processed_button.signal_toggled ().connect (sigc::mem_fun (*this, &RegionExportChannelSelector::handle_selection));
        vbox.pack_start (processed_button);
        
+       sync_with_manager();
        vbox.show_all_children ();
        show_all_children ();
 }
 
 void
-RegionExportChannelSelector::set_state (ARDOUR::ExportProfileManager::ChannelConfigStatePtr const state_, ARDOUR::Session * session_)
+RegionExportChannelSelector::sync_with_manager ()
 {
-       state = state_;
-       session = session_;
-       
+       state = manager->get_channel_configs().front();
        handle_selection ();
 }
 
@@ -475,21 +485,18 @@ RegionExportChannelSelector::handle_selection ()
        state->config->clear_channels ();
        
        if (raw_button.get_active ()) {
-       
                factory.reset (new RegionExportChannelFactory (session, region, track, RegionExportChannelFactory::Raw));
-               
-               for (size_t chan = 0; chan < region_chans; ++chan) {
-                       state->config->register_channel (factory->create (chan));
-               }
-               
+       } else if (fades_button.get_active ()) {
+               factory.reset (new RegionExportChannelFactory (session, region, track, RegionExportChannelFactory::Fades));
        } else if (processed_button.get_active ()) {
-       
                factory.reset (new RegionExportChannelFactory(session, region, track, RegionExportChannelFactory::Processed));
-               
-               for (size_t chan = 0; chan < region_chans; ++chan) {
-                       state->config->register_channel (factory->create (chan));
-               }
-               
+       } else {
+               CriticalSelectionChanged ();
+               return;
+       }
+       
+       for (size_t chan = 0; chan < region_chans; ++chan) {
+               state->config->register_channel (factory->create (chan));
        }
        
        CriticalSelectionChanged ();