diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 4fc2bd0d18..5f18d36e67 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -789,11 +789,13 @@ class Editor : public PublicEditor RegionListDisplayModelColumns region_list_columns; Gtkmm2ext::DnDTreeView > region_list_display; + std::list region_state_changed_connections; Glib::RefPtr region_list_model; Glib::RefPtr toggle_full_region_list_action; Glib::RefPtr toggle_show_auto_regions_action; + void region_list_region_changed (ARDOUR::Change, boost::weak_ptr); void region_list_selection_changed (); bool region_list_selection_filter (const Glib::RefPtr& model, const Gtk::TreeModel::Path& path, bool yn); diff --git a/gtk2_ardour/editor_region_list.cc b/gtk2_ardour/editor_region_list.cc index f1001cb8e4..3e47d26cd6 100644 --- a/gtk2_ardour/editor_region_list.cc +++ b/gtk2_ardour/editor_region_list.cc @@ -89,6 +89,10 @@ Editor::add_region_to_region_display (boost::shared_ptr 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))) + ); + missing_source = boost::dynamic_pointer_cast(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) } } + +void +Editor::region_list_region_changed (Change what_changed, boost::weak_ptr region) +{ + ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::region_list_region_changed), what_changed, region)); + + boost::shared_ptr 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 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::iterator i = region_state_changed_connections.begin(); + i != region_state_changed_connections.end(); + ++i) + { + i->disconnect (); + } + region_list_display.set_model (Glib::RefPtr(0)); region_list_model->clear ();