summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/ardour_ui.cc92
-rw-r--r--gtk2_ardour/duplicate_routes_dialog.cc103
-rw-r--r--gtk2_ardour/duplicate_routes_dialog.h10
3 files changed, 104 insertions, 101 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index 31b79d1657..eb4730a545 100644
--- a/gtk2_ardour/ardour_ui.cc
+++ b/gtk2_ardour/ardour_ui.cc
@@ -3757,98 +3757,10 @@ ARDOUR_UI::start_duplicate_routes ()
{
if (!duplicate_routes_dialog) {
duplicate_routes_dialog = new DuplicateRouteDialog;
- 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<RouteUI*> (*t);
-
- if (!rui) {
- /* some other type of timeaxis view, not a route */
- continue;
- }
-
- boost::shared_ptr<Route> r (rui->route());
-
- if (boost::dynamic_pointer_cast<Track> (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 ();
-}
-
-void
-ARDOUR_UI::finish_duplicate_routes (int response)
-{
- if (!duplicate_routes_dialog) {
- /* how could this happen? */
- return;
- }
-
- duplicate_routes_dialog->hide ();
-
- if (response != Gtk::RESPONSE_OK) {
- return;
- }
-
- ARDOUR::PlaylistDisposition playlist_disposition = duplicate_routes_dialog->playlist_disposition ();
- uint32_t count = duplicate_routes_dialog->count ();
-
- /* Copy the track selection because it will/may change as we add new ones */
- TrackSelection tracks (editor->get_selection().tracks);
- int err = 0;
-
- for (TrackSelection::iterator t = tracks.begin(); t != tracks.end(); ++t) {
-
- RouteUI* rui = dynamic_cast<RouteUI*> (*t);
-
- if (!rui) {
- /* some other type of timeaxis view, not a route */
- 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);
-
- /* normally the state node would be added to a parent, and
- * ownership would transfer. Because we don't do that here,
- * we need to delete the node ourselves.
- */
-
- delete &state;
-
- if (rl.empty()) {
- err++;
- break;
- }
- }
-
- if (err) {
- MessageDialog msg (_("1 or more tracks/busses could not be duplicated"),
- true, MESSAGE_ERROR, BUTTONS_OK, true);
- msg.set_position (WIN_POS_MOUSE);
- msg.run ();
+ if (duplicate_routes_dialog->restart ()) {
+ duplicate_routes_dialog->present ();
}
}
diff --git a/gtk2_ardour/duplicate_routes_dialog.cc b/gtk2_ardour/duplicate_routes_dialog.cc
index d6a90cf57c..6db5b158a1 100644
--- a/gtk2_ardour/duplicate_routes_dialog.cc
+++ b/gtk2_ardour/duplicate_routes_dialog.cc
@@ -19,10 +19,18 @@
#include "gtkmm/stock.h"
+#include "ardour/route.h"
+#include "ardour/session.h"
+
+#include "editor.h"
#include "duplicate_routes_dialog.h"
+#include "selection.h"
#include "i18n.h"
+using namespace ARDOUR;
+using namespace Gtk;
+
DuplicateRouteDialog::DuplicateRouteDialog ()
: ArdourDialog (_("Duplicate Tracks & Busses"), false, false)
, copy_playlists_button (playlist_button_group, _("Copy playlists"))
@@ -43,17 +51,42 @@ DuplicateRouteDialog::DuplicateRouteDialog ()
get_vbox()->show_all ();
- add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
- add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK);
+ add_button (Stock::CANCEL, RESPONSE_CANCEL);
+ add_button (Stock::OK, RESPONSE_OK);
}
-DuplicateRouteDialog::~DuplicateRouteDialog ()
+int
+DuplicateRouteDialog::restart ()
{
-}
+ TrackSelection& tracks (PublicEditor::instance().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<RouteUI*> (*t);
+
+ if (!rui) {
+ /* some other type of timeaxis view, not a route */
+ continue;
+ }
+
+ boost::shared_ptr<Route> r (rui->route());
+
+ if (boost::dynamic_pointer_cast<Track> (r)) {
+ ntracks++;
+ } else {
+ if (!r->is_master() && !r->is_monitor()) {
+ nbusses++;
+ }
+ }
+ }
+
+ if (ntracks == 0 && nbusses == 0) {
+ std::cerr << "You can't do this\n";
+ return -1;
+ }
-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.
*/
@@ -63,6 +96,8 @@ DuplicateRouteDialog::setup (uint32_t ntracks, uint32_t nbusses)
} else {
get_vbox()->pack_end (playlist_button_box, false, false);
}
+
+ return 0;
}
uint32_t
@@ -82,3 +117,57 @@ DuplicateRouteDialog::playlist_disposition() const
return ARDOUR::SharePlaylist;
}
+
+void
+DuplicateRouteDialog::on_response (int response)
+{
+ hide ();
+
+ if (response != RESPONSE_OK) {
+ return;
+ }
+
+ ARDOUR::PlaylistDisposition playlist_action = playlist_disposition ();
+ uint32_t cnt = count ();
+
+ /* Copy the track selection because it will/may change as we add new ones */
+ TrackSelection tracks (PublicEditor::instance().get_selection().tracks);
+ int err = 0;
+
+ for (TrackSelection::iterator t = tracks.begin(); t != tracks.end(); ++t) {
+
+ RouteUI* rui = dynamic_cast<RouteUI*> (*t);
+
+ if (!rui) {
+ /* some other type of timeaxis view, not a route */
+ 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 (cnt, state, std::string(), playlist_action);
+
+ /* normally the state node would be added to a parent, and
+ * ownership would transfer. Because we don't do that here,
+ * we need to delete the node ourselves.
+ */
+
+ delete &state;
+
+ if (rl.empty()) {
+ err++;
+ break;
+ }
+ }
+
+ if (err) {
+ MessageDialog msg (_("1 or more tracks/busses could not be duplicated"),
+ true, MESSAGE_ERROR, BUTTONS_OK, true);
+ msg.set_position (WIN_POS_MOUSE);
+ msg.run ();
+ }
+}
diff --git a/gtk2_ardour/duplicate_routes_dialog.h b/gtk2_ardour/duplicate_routes_dialog.h
index d1423a337b..9dee8a6e31 100644
--- a/gtk2_ardour/duplicate_routes_dialog.h
+++ b/gtk2_ardour/duplicate_routes_dialog.h
@@ -38,10 +38,7 @@ class DuplicateRouteDialog : public ArdourDialog
DuplicateRouteDialog ();
~DuplicateRouteDialog ();
- void setup (uint32_t ntracks, uint32_t nbusses);
-
- uint32_t count() const;
- ARDOUR::PlaylistDisposition playlist_disposition() const;
+ int restart ();
private:
Gtk::Entry name_template_entry;
@@ -54,6 +51,11 @@ class DuplicateRouteDialog : public ArdourDialog
Gtk::SpinButton count_spinner;
Gtk::HBox count_box;
Gtk::Label count_label;
+
+ void on_response (int);
+
+ uint32_t count() const;
+ ARDOUR::PlaylistDisposition playlist_disposition() const;
};
#endif /* __gtk_ardour_duplicate_route_dialog_h__ */