introduce the notion that note additions and property changes can cause the removal...
[ardour.git] / gtk2_ardour / group_tabs.cc
index 9a10adf554f513543ad0ac78ed3fdebe976dc006..1e537176cc399a2245607aeb8f509bfb7eb08d22 100644 (file)
@@ -21,6 +21,8 @@
 #include "ardour/session.h"
 #include "ardour/route_group.h"
 #include "ardour/route.h"
+
+#include "gui_thread.h"
 #include "route_group_dialog.h"
 #include "group_tabs.h"
 #include "keyboard.h"
@@ -29,6 +31,7 @@
 using namespace std;
 using namespace Gtk;
 using namespace ARDOUR;
+using Gtkmm2ext::Keyboard;
 
 GroupTabs::GroupTabs (Editor* e)
        : EditorComponent (e),
@@ -39,11 +42,13 @@ GroupTabs::GroupTabs (Editor* e)
 }
 
 void
-GroupTabs::connect_to_session (Session* s)
+GroupTabs::set_session (Session* s)
 {
-       EditorComponent::connect_to_session (s);
+       EditorComponent::set_session (s);
 
-       _session_connections.push_back (_session->RouteGroupChanged.connect (mem_fun (*this, &GroupTabs::set_dirty)));
+       if (_session) {
+               _session->RouteGroupChanged.connect (_session_connections, invalidator (*this), boost::bind (&GroupTabs::set_dirty, this), gui_context());
+       }
 }
 
 
@@ -182,7 +187,7 @@ GroupTabs::on_button_release_event (GdkEventButton* ev)
                                RouteGroup* g = new_route_group ();
                                if (g) {
                                        for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) {
-                                               (*i)->set_route_group (g, this);
+                                               g->add (*i);
                                        }
                                }
                        } else {
@@ -192,10 +197,10 @@ GroupTabs::on_button_release_event (GdkEventButton* ev)
                                        if (find (routes.begin(), routes.end(), *i) == routes.end()) {
                                                /* this route is not on the list of those that should be in _dragging's group */
                                                if ((*i)->route_group() == _dragging->group) {
-                                                       (*i)->drop_route_group (this);
+                                                       _dragging->group->remove (*i);
                                                }
                                        } else {
-                                               (*i)->set_route_group (_dragging->group, this);
+                                               _dragging->group->add (*i);
                                        }
                                }
                        }