summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Loftis <ben@harrisonconsoles.com>2018-11-08 13:07:52 -0600
committerBen Loftis <ben@harrisonconsoles.com>2019-08-01 12:11:31 -0500
commit77950c36c5532b0696dc89f108fcc18af9fd08f8 (patch)
tree2f1e82c21b13704367cd37094a7927dd4bb504de
parent98c509cc4828b94795ad0de6f74f3ccb309b0e9f (diff)
(Source List) Implement remove_selected_sources when the user clicks Delete key.
-rw-r--r--gtk2_ardour/editor_sources.cc65
-rw-r--r--gtk2_ardour/editor_sources.h6
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<ARDOUR::Source> source)
populate_row (row, source);
}
-
-void
-EditorSources::remove_unused_regions ()
-{
-/* vector<string> 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<ARDOUR::Source> source)
{
@@ -546,18 +518,22 @@ EditorSources::remove_selected_sources ()
vector<string> 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<boost::weak_ptr<ARDOUR::Source> > 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<boost::weak_ptr<ARDOUR::Source> >::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<Action>
-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<Gdk::DragContext> const &, gint, gint, Gtk::SelectionData const &, guint, guint
);
- Glib::RefPtr<Gtk::Action> remove_unused_regions_action () const; //TODO: what is the equivalent?
-
Gtk::Menu* _menu;
Gtk::ScrolledWindow _scroller;
Gtk::Frame _frame;
- Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Source> > _display; //TODO .. try changing this to region
+ Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Source> > _display;
Glib::RefPtr<Gtk::TreeStore> _model;