enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / gtk2_ardour / export_channel_selector.cc
index c411c2b22c3acc490cc8ea5ae1c9406eb6d5871a..acbed62030a7396ddb91d403f5d2f334ff8ee3d1 100644 (file)
@@ -18,8 +18,6 @@
 
 */
 
-#include "export_channel_selector.h"
-
 #include <algorithm>
 
 #include "pbd/convert.h"
 
 #include <sstream>
 
-#include "i18n.h"
+#include "export_channel_selector.h"
+#include "route_sorter.h"
+
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace Glib;
 using namespace ARDOUR;
 using namespace PBD;
 
-struct EditorOrderRouteSorter {
-    bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) {
-           return a->order_key () < b->order_key ();
-    }
-};
-
 PortExportChannelSelector::PortExportChannelSelector (ARDOUR::Session * session, ProfileManagerPtr manager) :
   ExportChannelSelector (session, manager),
   channels_label (_("Channels:"), Gtk::ALIGN_LEFT),
@@ -126,7 +121,7 @@ PortExportChannelSelector::fill_route_list ()
                channel_view.add_route (master);
        }
 
-       routes.sort (EditorOrderRouteSorter ());
+       routes.sort (Stripable::PresentationOrderSorter ());
 
        for (RouteList::iterator it = routes.begin(); it != routes.end(); ++it) {
                if ((*it)->is_master () || (*it)->is_monitor ()) {
@@ -700,7 +695,7 @@ TrackExportChannelSelector::add_track (boost::shared_ptr<Route> route)
        row[track_cols.selected] = false;
        row[track_cols.label] = route->name();
        row[track_cols.route] = route;
-       row[track_cols.order_key] = route->order_key();
+       row[track_cols.order_key] = route->presentation_info().order();
 }
 
 void
@@ -715,7 +710,7 @@ TrackExportChannelSelector::update_config()
                        continue;
                }
 
-               ExportProfileManager::ChannelConfigStatePtr state = manager->add_channel_config();
+               ExportProfileManager::ChannelConfigStatePtr state;
 
                boost::shared_ptr<Route> route = row[track_cols.route];
 
@@ -727,16 +722,25 @@ TrackExportChannelSelector::update_config()
                                        ExportChannelPtr channel (new PortExportChannel ());
                                        PortExportChannel * pec = static_cast<PortExportChannel *> (channel.get());
                                        pec->add_port(port);
+                                       if (!state) {
+                                               state = manager->add_channel_config();
+                                       }
                                        state->config->register_channel(channel);
                                }
                        }
                } else {
                        std::list<ExportChannelPtr> list;
                        RouteExportChannel::create_from_route (list, route);
+                       if (list.size () == 0) {
+                               continue;
+                       }
+                       state = manager->add_channel_config();
                        state->config->register_channels (list);
                }
 
-               state->config->set_name (route->name());
+               if (state) {
+                       state->config->set_name (route->name());
+               }
 
        }