2022-01-18 19:59:05 -05:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2021 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ardour/region.h"
|
|
|
|
#include "ardour/session.h"
|
|
|
|
|
|
|
|
#include "gui_thread.h"
|
|
|
|
#include "source_list_base.h"
|
|
|
|
|
|
|
|
#include "pbd/i18n.h"
|
|
|
|
|
|
|
|
using namespace Gtk;
|
|
|
|
|
|
|
|
SourceListBase::SourceListBase ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SourceListBase::set_session (ARDOUR::Session* s)
|
|
|
|
{
|
2023-05-29 12:04:27 -04:00
|
|
|
RegionListBase::set_session (s);
|
2022-01-18 19:59:05 -05:00
|
|
|
if (s) {
|
2024-10-18 19:51:44 -04:00
|
|
|
s->SourceRemoved.connect (_session_connections, MISSING_INVALIDATOR, std::bind (&SourceListBase::remove_weak_source, this, _1), gui_context ());
|
2022-01-18 19:59:05 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
SourceListBase::remove_weak_source (std::weak_ptr<ARDOUR::Source> src)
|
2022-01-18 19:59:05 -05:00
|
|
|
{
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::Source> source = src.lock ();
|
2022-01-18 19:59:05 -05:00
|
|
|
if (source) {
|
|
|
|
remove_source (source);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
SourceListBase::remove_source (std::shared_ptr<ARDOUR::Source> source)
|
2022-01-18 19:59:05 -05:00
|
|
|
{
|
|
|
|
TreeModel::iterator i;
|
|
|
|
TreeModel::Children rows = _model->children ();
|
2023-05-29 12:04:27 -04:00
|
|
|
for (i = rows.begin (); i != rows.end ();) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::Region> rr = (*i)[_columns.region];
|
2023-05-29 12:04:27 -04:00
|
|
|
if (rr->uses_source (source)) {
|
2022-01-18 19:59:05 -05:00
|
|
|
RegionRowMap::iterator map_it = region_row_map.find (rr);
|
|
|
|
assert (map_it != region_row_map.end () && i == map_it->second);
|
|
|
|
region_row_map.erase (map_it);
|
2023-05-29 12:04:27 -04:00
|
|
|
i = _model->erase (i);
|
|
|
|
} else {
|
|
|
|
++i;
|
2022-01-18 19:59:05 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2023-02-16 18:33:28 -05:00
|
|
|
SourceListBase::list_region (std::shared_ptr<ARDOUR::Region> region) const
|
2022-01-18 19:59:05 -05:00
|
|
|
{
|
|
|
|
/* by definition, the Source List only shows whole-file regions
|
|
|
|
* this roughly equates to Source objects, but preserves the stereo-ness
|
|
|
|
* (or multichannel-ness) of a stereo source file.
|
|
|
|
*/
|
|
|
|
return region->whole_file ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SourceListBase::tag_edit (const std::string& path, const std::string& new_text)
|
|
|
|
{
|
|
|
|
RegionListBase::tag_edit (path, new_text);
|
|
|
|
|
|
|
|
TreeIter row_iter;
|
|
|
|
if ((row_iter = _model->get_iter (path))) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::Region> region = (*row_iter)[_columns.region];
|
2022-01-18 19:59:05 -05:00
|
|
|
if (region) {
|
|
|
|
_session->set_dirty (); // whole-file regions aren't in a playlist to catch property changes, so we need to explicitly set the session dirty
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SourceListBase::name_edit (const std::string& path, const std::string& new_text)
|
|
|
|
{
|
|
|
|
RegionListBase::name_edit (path, new_text);
|
|
|
|
|
|
|
|
TreeIter row_iter;
|
|
|
|
if ((row_iter = _model->get_iter (path))) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::Region> region = (*row_iter)[_columns.region];
|
2022-01-18 19:59:05 -05:00
|
|
|
if (region) {
|
|
|
|
_session->set_dirty (); // whole-file regions aren't in a playlist to catch property changes, so we need to explicitly set the session dirty
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|