diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 00ec43aca1..7747870125 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -1239,6 +1239,7 @@ private: void align_regions_relative (ARDOUR::RegionPoint point); void align_region (boost::shared_ptr, ARDOUR::RegionPoint point, samplepos_t position); void align_region_internal (boost::shared_ptr, ARDOUR::RegionPoint point, samplepos_t position); + void recover_regions (ARDOUR::RegionList); void remove_selected_regions (); void remove_clicked_region (); void show_region_properties (); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index aa5c7dfa3e..24e1e0e80f 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -61,6 +61,7 @@ #include "ardour/selection.h" #include "ardour/session.h" #include "ardour/session_playlists.h" +#include "ardour/source.h" #include "ardour/strip_silence.h" #include "ardour/transient_detector.h" #include "ardour/transport_master_manager.h" @@ -4478,6 +4479,32 @@ Editor::remove_clicked_region () } +void +Editor::recover_regions (ARDOUR::RegionList regions) +{ +#ifdef RECOVER_REGIONS_IS_WORKING + begin_reversible_command (_("recover regions")); + + for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) { + boost::shared_ptr source = (*i)->source(); + + RouteList routes = _session->get_routelist(); + for (RouteList::iterator it = routes.begin(); it != routes.end(); ++it) { + boost::shared_ptr track = boost::dynamic_pointer_cast(*it); + if (track) { + //ToDo + if (source->captured_for() == track->) { + //_session->add_command(new StatefulDiffCommand (playlist)); + } + } + } + } + + commit_reversible_command (); +#endif +} + + /** Remove the selected regions */ void Editor::remove_selected_regions () diff --git a/gtk2_ardour/editor_sources.cc b/gtk2_ardour/editor_sources.cc index eddebdbb1d..a3f88eb362 100644 --- a/gtk2_ardour/editor_sources.cc +++ b/gtk2_ardour/editor_sources.cc @@ -537,8 +537,10 @@ EditorSources::show_context_menu (int button, int time) using namespace Gtk::Menu_Helpers; Gtk::Menu* menu = ARDOUR_UI_UTILS::shared_popup_menu (); MenuList& items = menu->items(); +#ifdef RECOVER_REGIONS_IS_WORKING items.push_back(MenuElem(_("Recover the selected Sources to their original Track & Position"), sigc::mem_fun(*this, &EditorSources::recover_selected_sources))); +#endif items.push_back(MenuElem(_("Remove the selected Sources"), sigc::mem_fun(*this, &EditorSources::remove_selected_sources))); menu->popup(1, time); @@ -547,7 +549,7 @@ EditorSources::show_context_menu (int button, int time) void EditorSources::recover_selected_sources () { - std::list > to_be_recovered; + ARDOUR::RegionList to_be_recovered; if (_display.get_selection()->count_selected_rows() > 0) { @@ -565,7 +567,7 @@ EditorSources::recover_selected_sources () /* ToDo */ -// _editor->recover_regions(); //this operation should be undo-able + _editor->recover_regions(to_be_recovered); //this operation should be undo-able } diff --git a/libs/ardour/ardour/audiosource.h b/libs/ardour/ardour/audiosource.h index 524c5fa209..80ef3f8798 100644 --- a/libs/ardour/ardour/audiosource.h +++ b/libs/ardour/ardour/audiosource.h @@ -64,9 +64,6 @@ class LIBARDOUR_API AudioSource : virtual public Source, virtual bool can_truncate_peaks() const { return true; } - void set_captured_for (std::string str) { _captured_for = str; } - std::string captured_for() const { return _captured_for; } - int read_peaks (PeakData *peaks, samplecnt_t npeaks, samplepos_t start, samplecnt_t cnt, double samples_per_visual_peak) const; @@ -124,7 +121,6 @@ class LIBARDOUR_API AudioSource : virtual public Source, samplecnt_t _length; std::string _peakpath; - std::string _captured_for; int initialize_peakfile (const std::string& path, const bool in_session = false); int build_peaks_from_scratch (); diff --git a/libs/ardour/ardour/midi_source.h b/libs/ardour/ardour/midi_source.h index 370572ea7e..3995bd4143 100644 --- a/libs/ardour/ardour/midi_source.h +++ b/libs/ardour/ardour/midi_source.h @@ -160,9 +160,6 @@ class LIBARDOUR_API MidiSource : virtual public Source virtual void session_saved(); - std::string captured_for() const { return _captured_for; } - void set_captured_for (std::string str) { _captured_for = str; } - XMLNode& get_state (); int set_state (const XMLNode&, int version); @@ -227,8 +224,6 @@ class LIBARDOUR_API MidiSource : virtual public Source samplepos_t position, samplecnt_t cnt) = 0; - std::string _captured_for; - boost::shared_ptr _model; bool _writing; diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h index 25581b2007..9c8856c438 100644 --- a/libs/ardour/ardour/source.h +++ b/libs/ardour/ardour/source.h @@ -121,6 +121,9 @@ public: std::string ancestor_name() { return _ancestor_name.empty() ? name() : _ancestor_name; } void set_ancestor_name(const std::string& name) { _ancestor_name = name; } + void set_captured_for (std::string str) { _captured_for = str; } + std::string captured_for() const { return _captured_for; } + static PBD::Signal1 > SourcePropertyChanged; protected: @@ -136,6 +139,7 @@ public: gint _use_count; /* atomic */ uint32_t _level; /* how deeply nested is this source w.r.t a disk file */ std::string _ancestor_name; + std::string _captured_for; private: void fix_writable_flags ();