13
0

Update region names in the region list when they change, to fix #1584

git-svn-id: svn://localhost/ardour2/trunk@2587 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2007-11-04 21:40:12 +00:00
parent 48b685dad1
commit 39bdbf5db9
2 changed files with 51 additions and 0 deletions

View File

@ -789,11 +789,13 @@ class Editor : public PublicEditor
RegionListDisplayModelColumns region_list_columns;
Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Region> > region_list_display;
std::list<sigc::connection> region_state_changed_connections;
Glib::RefPtr<Gtk::TreeStore> region_list_model;
Glib::RefPtr<Gtk::ToggleAction> toggle_full_region_list_action;
Glib::RefPtr<Gtk::ToggleAction> toggle_show_auto_regions_action;
void region_list_region_changed (ARDOUR::Change, boost::weak_ptr<ARDOUR::Region>);
void region_list_selection_changed ();
bool region_list_selection_filter (const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path, bool yn);

View File

@ -89,6 +89,10 @@ Editor::add_region_to_region_display (boost::shared_ptr<Region> region)
Gdk::Color c;
bool missing_source;
region_state_changed_connections.push_back (
region->StateChanged.connect (bind (mem_fun (*this, &Editor::region_list_region_changed), boost::weak_ptr<Region> (region)))
);
missing_source = boost::dynamic_pointer_cast<SilentFileSource>(region->source());
if (!show_automatic_regions_in_region_list && region->automatic()) {
@ -217,6 +221,44 @@ Editor::add_region_to_region_display (boost::shared_ptr<Region> region)
}
}
void
Editor::region_list_region_changed (Change what_changed, boost::weak_ptr<Region> region)
{
ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::region_list_region_changed), what_changed, region));
boost::shared_ptr<Region> r = region.lock ();
if (!r) {
return;
}
if (what_changed & ARDOUR::NameChanged) {
/* find the region in our model and change its name */
TreeModel::Children rows = region_list_model->children ();
TreeModel::iterator i = rows.begin ();
while (i != rows.end ()) {
TreeModel::Children children = (*i)->children ();
TreeModel::iterator j = children.begin ();
while (j != children.end()) {
boost::shared_ptr<Region> c = (*j)[region_list_columns.region];
if (c == r) {
break;
}
++j;
}
if (j != children.end()) {
(*j)[region_list_columns.name] = r->name ();
break;
}
++i;
}
}
}
void
Editor::region_list_selection_changed()
{
@ -267,6 +309,13 @@ Editor::redisplay_regions ()
{
if (session) {
for (std::list<connection>::iterator i = region_state_changed_connections.begin();
i != region_state_changed_connections.end();
++i)
{
i->disconnect ();
}
region_list_display.set_model (Glib::RefPtr<Gtk::TreeStore>(0));
region_list_model->clear ();