summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-11-25 14:24:15 +0100
committerRobin Gareus <robin@gareus.org>2016-11-25 14:24:29 +0100
commit01f8ca831ae2966b4bd54c0a15a341b0b9790593 (patch)
tree738f0566e8f7e571094ea272a32cfef498fc68ed /gtk2_ardour
parent174d5e05c9dfcec77df82c58008cf4724ee21822 (diff)
cont'd work to prevent duplicate playlist names
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/editor.cc4
-rw-r--r--gtk2_ardour/route_time_axis.cc93
-rw-r--r--gtk2_ardour/route_time_axis.h3
3 files changed, 31 insertions, 69 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 806ec3cd1c..f23f6b22f4 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -4330,13 +4330,13 @@ Editor::clear_playlists (TimeAxisView* v)
void
Editor::mapped_use_new_playlist (RouteTimeAxisView& atv, uint32_t sz, vector<boost::shared_ptr<ARDOUR::Playlist> > const & playlists)
{
- atv.use_new_playlist (sz > 1 ? false : true, playlists);
+ atv.use_new_playlist (sz > 1 ? false : true, playlists, false);
}
void
Editor::mapped_use_copy_playlist (RouteTimeAxisView& atv, uint32_t sz, vector<boost::shared_ptr<ARDOUR::Playlist> > const & playlists)
{
- atv.use_copy_playlist (sz > 1 ? false : true, playlists);
+ atv.use_new_playlist (sz > 1 ? false : true, playlists, true);
}
void
diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc
index 7bb41cf8ec..24ed6bd556 100644
--- a/gtk2_ardour/route_time_axis.cc
+++ b/gtk2_ardour/route_time_axis.cc
@@ -1182,7 +1182,7 @@ RouteTimeAxisView::resolve_new_group_playlist_name(std::string &basename, vector
}
void
-RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
+RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op, bool copy)
{
string name;
@@ -1199,91 +1199,54 @@ RouteTimeAxisView::use_copy_playlist (bool prompt, vector<boost::shared_ptr<Play
name = pl->name();
if (route_group() && route_group()->is_active() && route_group()->enabled_property (ARDOUR::Properties::group_select.property_id)) {
- name = resolve_new_group_playlist_name(name, playlists_before_op);
+ name = resolve_new_group_playlist_name(name,playlists_before_op);
}
while (_session->playlists->by_name(name)) {
name = Playlist::bump_name (name, *_session);
}
- // TODO: The prompter "new" button should be de-activated if the user
- // specifies a playlist name which already exists in the session.
-
if (prompt) {
+ // TODO: The prompter "new" button should be de-activated if the user
+ // specifies a playlist name which already exists in the session.
ArdourPrompter prompter (true);
- prompter.set_title (_("New Copy Playlist"));
- prompter.set_prompt (_("Name for new playlist:"));
+ if (copy) {
+ prompter.set_title (_("New Copy Playlist"));
+ prompter.set_prompt (_("Name for playlist copy:"));
+ } else {
+ prompter.set_title (_("New Playlist"));
+ prompter.set_prompt (_("Name for new playlist:"));
+ }
prompter.set_initial_text (name);
prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
prompter.show_all ();
- switch (prompter.run ()) {
- case Gtk::RESPONSE_ACCEPT:
+ while (true) {
+ if (prompter.run () != Gtk::RESPONSE_ACCEPT) {
+ return;
+ }
prompter.get_result (name);
- break;
-
- default:
- return;
+ if (name.length()) {
+ if (_session->playlists->by_name (name)) {
+ MessageDialog msg (_("Given playlist name is not unique."));
+ msg.run ();
+ prompter.set_initial_text (Playlist::bump_name (name, *_session));
+ } else {
+ break;
+ }
+ }
}
}
if (name.length()) {
- tr->use_copy_playlist ();
- tr->playlist()->set_name (name);
- }
-}
-
-void
-RouteTimeAxisView::use_new_playlist (bool prompt, vector<boost::shared_ptr<Playlist> > const & playlists_before_op)
-{
- string name;
-
- boost::shared_ptr<Track> tr = track ();
- if (!tr || tr->destructive()) {
- return;
- }
-
- boost::shared_ptr<const Playlist> pl = tr->playlist();
- if (!pl) {
- return;
- }
-
- name = pl->name();
-
- if (route_group() && route_group()->is_active() && route_group()->enabled_property (ARDOUR::Properties::group_select.property_id)) {
- name = resolve_new_group_playlist_name(name,playlists_before_op);
- }
-
- while (_session->playlists->by_name(name)) {
- name = Playlist::bump_name (name, *_session);
- }
-
-
- if (prompt) {
-
- ArdourPrompter prompter (true);
-
- prompter.set_title (_("New Playlist"));
- prompter.set_prompt (_("Name for new playlist:"));
- prompter.set_initial_text (name);
- prompter.add_button (Gtk::Stock::NEW, Gtk::RESPONSE_ACCEPT);
- prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, true);
-
- switch (prompter.run ()) {
- case Gtk::RESPONSE_ACCEPT:
- prompter.get_result (name);
- break;
-
- default:
- return;
+ if (copy) {
+ tr->use_new_playlist ();
+ } else {
+ tr->use_copy_playlist ();
}
- }
-
- if (name.length()) {
- tr->use_new_playlist ();
tr->playlist()->set_name (name);
}
}
diff --git a/gtk2_ardour/route_time_axis.h b/gtk2_ardour/route_time_axis.h
index 825a286360..1a26868b47 100644
--- a/gtk2_ardour/route_time_axis.h
+++ b/gtk2_ardour/route_time_axis.h
@@ -115,8 +115,7 @@ public:
void fade_range (TimeSelection&);
/* The editor calls these when mapping an operation across multiple tracks */
- void use_new_playlist (bool prompt, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
- void use_copy_playlist (bool prompt, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
+ void use_new_playlist (bool prompt, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &, bool copy);
void clear_playlist ();
/* group playlist name resolving */