From 01f8ca831ae2966b4bd54c0a15a341b0b9790593 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 25 Nov 2016 14:24:15 +0100 Subject: cont'd work to prevent duplicate playlist names --- gtk2_ardour/editor.cc | 4 +- gtk2_ardour/route_time_axis.cc | 93 +++++++++++++----------------------------- gtk2_ardour/route_time_axis.h | 3 +- 3 files changed, 31 insertions(+), 69 deletions(-) (limited to 'gtk2_ardour') 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 > 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 > 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 > const & playlists_before_op) +RouteTimeAxisView::use_new_playlist (bool prompt, vector > const & playlists_before_op, bool copy) { string name; @@ -1199,91 +1199,54 @@ RouteTimeAxisView::use_copy_playlist (bool prompt, vectorname(); 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 > const & playlists_before_op) -{ - string name; - - boost::shared_ptr tr = track (); - if (!tr || tr->destructive()) { - return; - } - - boost::shared_ptr 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 > const &); - void use_copy_playlist (bool prompt, std::vector > const &); + void use_new_playlist (bool prompt, std::vector > const &, bool copy); void clear_playlist (); /* group playlist name resolving */ -- cgit v1.2.3