From aeb72469777560360453d963c5e07173bb21402d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 14 Nov 2015 10:29:50 -0500 Subject: partial dialog to control track duplication --- gtk2_ardour/ardour_ui.cc | 31 ++++++++++++++-- gtk2_ardour/ardour_ui.h | 7 +++- gtk2_ardour/ardour_ui_ed.cc | 2 +- gtk2_ardour/duplicate_routes_dialog.cc | 65 ++++++++++++++++++++++++++++++++++ gtk2_ardour/duplicate_routes_dialog.h | 55 ++++++++++++++++++++++++++++ gtk2_ardour/wscript | 1 + 6 files changed, 157 insertions(+), 4 deletions(-) create mode 100644 gtk2_ardour/duplicate_routes_dialog.cc create mode 100644 gtk2_ardour/duplicate_routes_dialog.h diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 6b10f51b4f..0c2b46ce7f 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -111,6 +111,7 @@ typedef uint64_t microseconds_t; #include "audio_region_view.h" #include "big_clock_window.h" #include "bundle_manager.h" +#include "duplicate_routes_dialog.h" #include "engine_dialog.h" #include "export_video_dialog.h" #include "export_video_infobox.h" @@ -284,6 +285,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir) , _status_bar_visibility (X_("status-bar")) , _feedback_exists (false) , _log_not_acknowledged (LogLevelNone) + , duplicate_routes_dialog (0) { Gtkmm2ext::init (localedir); @@ -3751,8 +3753,33 @@ ARDOUR_UI::setup_order_hint (AddRouteDialog::InsertAt place) } void -ARDOUR_UI::duplicate_routes () +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)); + } + + 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; @@ -3767,7 +3794,7 @@ ARDOUR_UI::duplicate_routes () } XMLNode& state (rui->route()->get_state()); - RouteList rl = _session->new_route_from_template (1, state, string(), SharePlaylist); + 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, diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index d10b7c7ac5..f2fa7c9fe6 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -112,6 +112,7 @@ class ArdourKeyboard; class AudioClock; class ButtonJoiner; class ConnectionEditor; +class DuplicateRouteDialog; class MainClock; class Mixer_UI; class ArdourPrompter; @@ -248,7 +249,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr void add_routes_part_two (); void add_routes_thread (); - void duplicate_routes (); + void start_duplicate_routes (); void add_video (Gtk::Window* float_window); void remove_video (); @@ -787,6 +788,10 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr int do_audio_midi_setup (uint32_t); void audioengine_became_silent (); + + DuplicateRouteDialog* duplicate_routes_dialog; + void build_duplicate_routes_dialog (); + void finish_duplicate_routes (int response); }; #endif /* __ardour_gui_h__ */ diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index e848f8d194..1b2bfcc895 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -133,7 +133,7 @@ ARDOUR_UI::install_actions () ActionManager::write_sensitive_actions.push_back (act); act = ActionManager::register_action (main_actions, X_("duplicate-routes"), _("Duplicate Tracks/Busses"), - sigc::mem_fun(*this, &ARDOUR_UI::duplicate_routes)); + sigc::mem_fun(*this, &ARDOUR_UI::start_duplicate_routes)); ActionManager::session_sensitive_actions.push_back (act); ActionManager::write_sensitive_actions.push_back (act); ActionManager::track_selection_sensitive_actions.push_back (act); diff --git a/gtk2_ardour/duplicate_routes_dialog.cc b/gtk2_ardour/duplicate_routes_dialog.cc new file mode 100644 index 0000000000..4c0e26b454 --- /dev/null +++ b/gtk2_ardour/duplicate_routes_dialog.cc @@ -0,0 +1,65 @@ +/* + Copyright (C) 2015 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "gtkmm/stock.h" + +#include "duplicate_routes_dialog.h" + +#include "i18n.h" + +DuplicateRouteDialog::DuplicateRouteDialog () + : ArdourDialog (_("Duplicate Tracks & Busses"), false, false) + , copy_playlists_button (playlist_button_group, _("Copy playlists")) + , new_playlists_button (playlist_button_group, _("Create new (empty) playlists")) + , share_playlists_button (playlist_button_group, _("Share playlists")) + , count_adjustment (1.0, 1.0, 999, 1.0, 10.0) + , count_spinner (count_adjustment) +{ + 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); + get_vbox()->show_all (); + + add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK); +} + +DuplicateRouteDialog::~DuplicateRouteDialog () +{ +} + +uint32_t +DuplicateRouteDialog::count() const +{ + return count_adjustment.get_value (); +} + +ARDOUR::PlaylistDisposition +DuplicateRouteDialog::playlist_disposition() const +{ + if (new_playlists_button.get_active()) { + return ARDOUR::NewPlaylist; + } else if (copy_playlists_button.get_active()) { + return ARDOUR::CopyPlaylist; + } + + return ARDOUR::SharePlaylist; +} diff --git a/gtk2_ardour/duplicate_routes_dialog.h b/gtk2_ardour/duplicate_routes_dialog.h new file mode 100644 index 0000000000..8182c8826a --- /dev/null +++ b/gtk2_ardour/duplicate_routes_dialog.h @@ -0,0 +1,55 @@ +/* + Copyright (C) 2015 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __gtk_ardour_duplicate_route_dialog_h__ +#define __gtk_ardour_duplicate_route_dialog_h__ + +#include +#include +#include +#include +#include + +#include "ardour/types.h" + +#include "ardour_dialog.h" + +class Editor; + +class DuplicateRouteDialog : public ArdourDialog +{ + public: + DuplicateRouteDialog (); + ~DuplicateRouteDialog (); + + uint32_t count() const; + ARDOUR::PlaylistDisposition playlist_disposition() const; + + private: + Gtk::Entry name_template_entry; + Gtk::VBox playlist_button_box; + Gtk::RadioButtonGroup playlist_button_group; + Gtk::RadioButton copy_playlists_button; + Gtk::RadioButton new_playlists_button; + Gtk::RadioButton share_playlists_button; + Gtk::Adjustment count_adjustment; + Gtk::SpinButton count_spinner; +}; + +#endif /* __gtk_ardour_duplicate_route_dialog_h__ */ diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 9831069d29..19c092fa3d 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -56,6 +56,7 @@ gtk2_ardour_sources = [ 'cursor_context.cc', 'curvetest.cc', 'debug.cc', + 'duplicate_routes_dialog.cc', 'edit_note_dialog.cc', 'editing.cc', 'editor.cc', -- cgit v1.2.3