diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 0c2b46ce7f..31b79d1657 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -3760,6 +3760,36 @@ ARDOUR_UI::start_duplicate_routes () duplicate_routes_dialog->signal_response().connect (sigc::mem_fun (*this, &ARDOUR_UI::finish_duplicate_routes)); } + TrackSelection& tracks (editor->get_selection().tracks); + uint32_t ntracks = 0; + uint32_t nbusses = 0; + + for (TrackSelection::iterator t = tracks.begin(); t != tracks.end(); ++t) { + + RouteUI* rui = dynamic_cast (*t); + + if (!rui) { + /* some other type of timeaxis view, not a route */ + continue; + } + + boost::shared_ptr r (rui->route()); + + if (boost::dynamic_pointer_cast (r)) { + ntracks++; + } else { + if (!r->is_master() && !r->is_monitor()) { + nbusses++; + } + } + } + + if (ntracks == 0 && nbusses == 0) { + cerr << "You can't do this\n"; + return; + } + + duplicate_routes_dialog->setup (ntracks, nbusses); duplicate_routes_dialog->present (); } @@ -3793,6 +3823,11 @@ ARDOUR_UI::finish_duplicate_routes (int response) continue; } + if (rui->route()->is_master() || rui->route()->is_monitor()) { + /* no option to duplicate these */ + continue; + } + XMLNode& state (rui->route()->get_state()); RouteList rl = _session->new_route_from_template (count, state, string(), playlist_disposition); diff --git a/gtk2_ardour/duplicate_routes_dialog.cc b/gtk2_ardour/duplicate_routes_dialog.cc index 17d2acd62f..d6a90cf57c 100644 --- a/gtk2_ardour/duplicate_routes_dialog.cc +++ b/gtk2_ardour/duplicate_routes_dialog.cc @@ -32,16 +32,14 @@ DuplicateRouteDialog::DuplicateRouteDialog () , count_spinner (count_adjustment) , count_label (_("Duplicate each track/bus this number of times")) { + count_box.pack_start (count_label, false, false); + count_box.pack_start (count_spinner, false, false); + get_vbox()->pack_start (count_box, false, false, 20); + playlist_button_box.pack_start (copy_playlists_button, false, false); playlist_button_box.pack_start (new_playlists_button, false, false); playlist_button_box.pack_start (share_playlists_button, false, false); - - get_vbox()->pack_start (playlist_button_box, false, false); - - count_box.pack_start (count_label, false, false); - count_box.pack_start (count_spinner, false, false); - - get_vbox()->pack_start (count_box, false, false, 20); + playlist_button_box.show_all (); get_vbox()->show_all (); @@ -53,6 +51,20 @@ DuplicateRouteDialog::~DuplicateRouteDialog () { } +void +DuplicateRouteDialog::setup (uint32_t ntracks, uint32_t nbusses) +{ + /* XXX grrr. Gtk Boxes do not shrink when children are removed, + which is what we really want to happen here. + */ + + if (ntracks == 0) { + get_vbox()->remove (playlist_button_box); + } else { + get_vbox()->pack_end (playlist_button_box, false, false); + } +} + uint32_t DuplicateRouteDialog::count() const { diff --git a/gtk2_ardour/duplicate_routes_dialog.h b/gtk2_ardour/duplicate_routes_dialog.h index 4ba0313465..d1423a337b 100644 --- a/gtk2_ardour/duplicate_routes_dialog.h +++ b/gtk2_ardour/duplicate_routes_dialog.h @@ -38,6 +38,8 @@ class DuplicateRouteDialog : public ArdourDialog DuplicateRouteDialog (); ~DuplicateRouteDialog (); + void setup (uint32_t ntracks, uint32_t nbusses); + uint32_t count() const; ARDOUR::PlaylistDisposition playlist_disposition() const;