From 77950c36c5532b0696dc89f108fcc18af9fd08f8 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Thu, 8 Nov 2018 13:07:52 -0600 Subject: [PATCH] (Source List) Implement remove_selected_sources when the user clicks Delete key. --- gtk2_ardour/editor_sources.cc | 65 +++++++++++------------------------ gtk2_ardour/editor_sources.h | 6 +--- 2 files changed, 21 insertions(+), 50 deletions(-) diff --git a/gtk2_ardour/editor_sources.cc b/gtk2_ardour/editor_sources.cc index 6cc53d7238..2586151786 100644 --- a/gtk2_ardour/editor_sources.cc +++ b/gtk2_ardour/editor_sources.cc @@ -375,34 +375,6 @@ EditorSources::add_source (boost::shared_ptr source) populate_row (row, source); } - -void -EditorSources::remove_unused_regions () -{ -/* vector choices; - string prompt; - - if (!_session) { - return; - } - - prompt = _("Do you really want to remove unused regions?" - "\n(This is destructive and cannot be undone)"); - - choices.push_back (_("No, do nothing.")); - choices.push_back (_("Yes, remove.")); - - ArdourWidgets::Choice prompter (_("Remove unused regions"), prompt, choices); - - if (prompter.run () == 1) { - _no_redisplay = true; - _session->cleanup_regions (); - _no_redisplay = false; - redisplay (); - } -*/ -} - void EditorSources::source_changed (boost::shared_ptr source) { @@ -546,18 +518,22 @@ EditorSources::remove_selected_sources () vector choices; string prompt; - prompt = _("Do you really want to destroy the selected source files?" - "\nAll regions using the files will be deleted."); + prompt = _("Do you want to remove the selected Sources?" + "\nThis operation cannot be undone." + "\nThe source files will not actually be deleted until you execute Session->Cleanup."); choices.push_back (_("No, do nothing.")); - choices.push_back (_("Only destroy the regions, not the sources. (may be undone)")); - choices.push_back (_("Yes, destroy them. (cannot be undone!")); + choices.push_back (_("Only remove the Regions that use these Sources.")); + choices.push_back (_("Yes, remove the Regions and Sources (cannot be undone!")); - Choice prompter (_("Destroy selected Sources"), prompt, choices); + Choice prompter (_("Remove selected Sources"), prompt, choices); int opt = prompter.run (); if ( opt >= 1) { + + std::list > to_be_removed; + if (_display.get_selection()->count_selected_rows() > 0) { TreeIter iter; @@ -579,16 +555,21 @@ EditorSources::remove_selected_sources () _change_connection.block (true); _editor->set_selected_regionview_from_region_list (*region, Selection::Add); _change_connection.block (false); - } + + to_be_removed.push_back(source); } } } - } - _editor->remove_selected_regions(); - if ( opt == 2 ) { //TODO: actually delete some sources? + _editor->remove_selected_regions(); //this operation is undo-able + + if (opt==2) { + for (std::list >::iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) { + _session->remove_source(*i); //this operation is (currently) not undo-able + } + } } } @@ -601,8 +582,8 @@ EditorSources::key_press (GdkEventKey* ev) switch (ev->keyval) { case GDK_Delete: case GDK_BackSpace: - /* remove_selected_sources(); */ - return true; //for now, just "eat" this, so Delete doesn't get propogated into the canvas, based on Source selections + remove_selected_sources(); + return true; } return false; @@ -730,9 +711,3 @@ EditorSources::set_state (const XMLNode & node) bool changed = false; } - -RefPtr -EditorSources::remove_unused_regions_action () const -{ - return ActionManager::get_action (X_("SourcesList"), X_("removeUnusedRegions")); -} diff --git a/gtk2_ardour/editor_sources.h b/gtk2_ardour/editor_sources.h index 7e8b05f203..75ddf41b5c 100644 --- a/gtk2_ardour/editor_sources.h +++ b/gtk2_ardour/editor_sources.h @@ -60,8 +60,6 @@ public: _display.get_selection()->unselect_all (); } - void remove_unused_regions (); - XMLNode& get_state () const; void set_state (const XMLNode &); @@ -124,13 +122,11 @@ private: Glib::RefPtr const &, gint, gint, Gtk::SelectionData const &, guint, guint ); - Glib::RefPtr remove_unused_regions_action () const; //TODO: what is the equivalent? - Gtk::Menu* _menu; Gtk::ScrolledWindow _scroller; Gtk::Frame _frame; - Gtkmm2ext::DnDTreeView > _display; //TODO .. try changing this to region + Gtkmm2ext::DnDTreeView > _display; Glib::RefPtr _model;