partial dialog to control track duplication
authorPaul Davis <paul@linuxaudiosystems.com>
Sat, 14 Nov 2015 15:29:50 +0000 (10:29 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Sat, 14 Nov 2015 15:30:08 +0000 (10:30 -0500)
gtk2_ardour/ardour_ui.cc
gtk2_ardour/ardour_ui.h
gtk2_ardour/ardour_ui_ed.cc
gtk2_ardour/duplicate_routes_dialog.cc [new file with mode: 0644]
gtk2_ardour/duplicate_routes_dialog.h [new file with mode: 0644]
gtk2_ardour/wscript

index 6b10f51b4fd3e50c1b4f814aa1f33019f7f3f7a3..0c2b46ce7f2d3661246585ab52b4e65bfd189d7d 100644 (file)
@@ -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,
index d10b7c7ac502e1a187150c6c9527a83895ef46f1..f2fa7c9fe63bf06571fd35677e38cc5f525a3a0f 100644 (file)
@@ -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__ */
index e848f8d194c534d4cc7d2513c7410a1f56a843c7..1b2bfcc895ade99e97401cb4d67b182ffb3adf38 100644 (file)
@@ -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 (file)
index 0000000..4c0e26b
--- /dev/null
@@ -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 (file)
index 0000000..8182c88
--- /dev/null
@@ -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 <gtkmm/entry.h>
+#include <gtkmm/box.h>
+#include <gtkmm/radiobutton.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/spinbutton.h>
+
+#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__ */
index 9831069d295dc1fddf9fd2e94784a2d0ab2b7e49..19c092fa3d1910f565dc8a7ec32f41924bd06f11 100644 (file)
@@ -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',