new color management design starts to take shape (canvas color only for now)
[ardour.git] / gtk2_ardour / mixer_ui.cc
index 221f45ec2a93621d6b05cd2afdb4a82e1565f9c8..2de21b2e3547148f84b2c5660fcb67faff3e22c7 100644 (file)
@@ -21,6 +21,8 @@
 #include <algorithm>
 #include <sigc++/bind.h>
 
+#include <gtkmm/accelmap.h>
+
 #include <pbd/lockmonitor.h>
 #include <gtkmm2ext/gtk_ui.h>
 #include <gtkmm2ext/utils.h>
@@ -28,6 +30,7 @@
 
 #include <ardour/audioengine.h>
 #include <ardour/session.h>
+#include <ardour/audio_track.h>
 #include <ardour/session_route.h>
 #include <ardour/diskstream.h>
 #include <ardour/plugin_manager.h>
 #include "ardour_ui.h"
 #include "prompter.h"
 #include "utils.h"
+#include "actions.h"
 #include "gui_thread.h"
 
 #include "i18n.h"
 
 using namespace ARDOUR;
 using namespace Gtk;
+using namespace Glib;
 using namespace Gtkmm2ext;
 using namespace sigc;
+using namespace std;
 
 Mixer_UI::Mixer_UI (AudioEngine& eng)
        : Window (Gtk::WINDOW_TOPLEVEL),
@@ -53,6 +59,7 @@ Mixer_UI::Mixer_UI (AudioEngine& eng)
 {
        _strip_width = Wide;
        track_menu = 0;
+       no_track_list_redisplay = false;
 
        XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
        set_state (*node);
@@ -69,12 +76,24 @@ Mixer_UI::Mixer_UI (AudioEngine& eng)
        track_display_model = ListStore::create (track_display_columns);
        track_display.set_model (track_display_model);
        track_display.append_column (_("Strips"), track_display_columns.text);
+       track_display.append_column (_("Visible"), track_display_columns.visible);
+       track_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
+       track_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
        track_display.set_name (X_("MixerTrackDisplayList"));
-       track_display.get_selection()->set_mode (Gtk::SELECTION_MULTIPLE);
+       track_display.get_selection()->set_mode (Gtk::SELECTION_NONE);
        track_display.set_reorderable (true);
-       track_display.set_size_request (75, -1);
+       track_display.set_size_request (100, -1);
        track_display.set_headers_visible (true);
-       track_display.set_headers_clickable (true);
+
+       track_display_model->signal_row_deleted().connect (mem_fun (*this, &Mixer_UI::track_list_delete));
+       track_display_model->signal_row_changed().connect (mem_fun (*this, &Mixer_UI::track_list_change));
+
+       CellRendererToggle* track_list_visible_cell = dynamic_cast<CellRendererToggle*>(track_display.get_column_cell_renderer (1));
+       track_list_visible_cell->property_activatable() = true;
+       track_list_visible_cell->property_radio() = false;
+
+       track_display.signal_button_press_event().connect (mem_fun (*this, &Mixer_UI::track_display_button_press), false);
+
        track_display_scroller.add (track_display);
        track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
 
@@ -97,15 +116,6 @@ Mixer_UI::Mixer_UI (AudioEngine& eng)
        group_display_scroller.add (group_display);
        group_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
 
-       snapshot_display_model = ListStore::create (group_display_columns);
-       snapshot_display.set_model (snapshot_display_model);
-       snapshot_display.append_column (X_("mixgroups"), snapshot_display_columns.visible_name);
-       snapshot_display.set_name ("MixerSnapshotDisplayList");
-       snapshot_display.set_size_request (75, -1);
-       snapshot_display.set_reorderable (true);
-       snapshot_display_scroller.add (snapshot_display);
-       snapshot_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
-
        group_display_vbox.pack_start (group_display_button, false, false);
        group_display_vbox.pack_start (group_display_scroller, true, true);
 
@@ -118,10 +128,7 @@ Mixer_UI::Mixer_UI (AudioEngine& eng)
        group_display_frame.add (group_display_vbox);
 
        rhs_pane1.add1 (track_display_frame);
-       rhs_pane1.add2 (rhs_pane2);
-
-       rhs_pane2.add1 (group_display_frame);
-       rhs_pane2.add2 (snapshot_display_scroller);
+       rhs_pane1.add2 (group_display_frame);
 
        list_vpacker.pack_start (rhs_pane1, true, true);
 
@@ -133,19 +140,15 @@ Mixer_UI::Mixer_UI (AudioEngine& eng)
 
        rhs_pane1.signal_size_allocate().connect (bind (mem_fun(*this, &Mixer_UI::pane_allocation_handler), 
                                                        static_cast<Gtk::Paned*> (&rhs_pane1)));
-       rhs_pane2.signal_size_allocate().connect (bind (mem_fun(*this, &Mixer_UI::pane_allocation_handler), 
-                                                       static_cast<Gtk::Paned*> (&rhs_pane2)));
        list_hpane.signal_size_allocate().connect (bind (mem_fun(*this, &Mixer_UI::pane_allocation_handler), 
                                                         static_cast<Gtk::Paned*> (&list_hpane)));
        
 
        rhs_pane1.set_data ("collapse-direction", (gpointer) 0);
-       rhs_pane2.set_data ("collapse-direction", (gpointer) 0);
        list_hpane.set_data ("collapse-direction", (gpointer) 1);
 
-       rhs_pane1.signal_button_release_event().connect (bind (ptr_fun (pane_handler), static_cast<Paned*>(&rhs_pane1)));
-       rhs_pane2.signal_button_release_event().connect (bind (ptr_fun (pane_handler), static_cast<Paned*>(&rhs_pane2)));
-       list_hpane.signal_button_release_event().connect (bind (ptr_fun (pane_handler), static_cast<Paned*>(&list_hpane)));
+       rhs_pane1.signal_button_release_event().connect (bind (sigc::ptr_fun (pane_handler), static_cast<Paned*>(&rhs_pane1)));
+       list_hpane.signal_button_release_event().connect (bind (sigc::ptr_fun (pane_handler), static_cast<Paned*>(&list_hpane)));
        
        global_vpacker.pack_start (list_hpane, true, true);
 
@@ -154,18 +157,14 @@ Mixer_UI::Mixer_UI (AudioEngine& eng)
        set_title (_("ardour: mixer"));
        set_wmclass (_("ardour_mixer"), "Ardour");
 
-       signal_delete_event().connect (bind (ptr_fun (just_hide_it), static_cast<Gtk::Window *>(this)));
-       add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
+       add_accel_group (ActionManager::ui_manager->get_accel_group());
 
-       track_display.get_selection()->signal_changed().connect (mem_fun(*this, &Mixer_UI::track_display_selection_changed));
-       track_display_model->signal_rows_reordered().connect (mem_fun (*this, &Mixer_UI::track_display_reordered_proxy));
+       signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), static_cast<Gtk::Window *>(this)));
+       add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
 
        group_display.signal_button_press_event().connect (mem_fun (*this, &Mixer_UI::group_display_button_press));
        group_display.get_selection()->signal_changed().connect (mem_fun (*this, &Mixer_UI::group_display_selection_changed));
 
-       snapshot_display.get_selection()->signal_changed().connect (mem_fun(*this, &Mixer_UI::snapshot_display_selection_changed));
-       snapshot_display.signal_button_press_event().connect (mem_fun (*this, &Mixer_UI::snapshot_display_button_press));
-
        _plugin_selector = new PluginSelector (PluginManager::the_manager());
 
        signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
@@ -206,7 +205,7 @@ Mixer_UI::add_strip (Route* route)
        ENSURE_GUI_THREAD(bind (mem_fun(*this, &Mixer_UI::add_strip), route));
        
        MixerStrip* strip;
-       
+
        if (route->hidden()) {
                return;
        }
@@ -217,23 +216,22 @@ Mixer_UI::add_strip (Route* route)
        strip->set_width (_strip_width);
        show_strip (strip);
 
+       no_track_list_redisplay = true;
+
        TreeModel::Row row = *(track_display_model->append());
        row[track_display_columns.text] = route->name();
+
+       row[track_display_columns.visible] = true;
        row[track_display_columns.route] = route;
        row[track_display_columns.strip] = strip;
 
-       if (strip->marked_for_display() || strip->packed()) {
-               track_display.get_selection()->select (row);
-       }
-       
+       no_track_list_redisplay = false;
+       redisplay_track_list ();
+
        route->name_changed.connect (bind (mem_fun(*this, &Mixer_UI::strip_name_changed), strip));
        strip->GoingAway.connect (bind (mem_fun(*this, &Mixer_UI::remove_strip), strip));
 
        strip->signal_button_release_event().connect (bind (mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
-
-//     if (width() < gdk_screen_width()) {
-//             set_size_request (width() + (_strip_width == Wide ? 75 : 50), height());
-//     }
 }
 
 void
@@ -265,7 +263,7 @@ Mixer_UI::follow_strip_selection ()
        }
 }
 
-gint
+bool
 Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
 {
        if (ev->button == 1) {
@@ -286,7 +284,7 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
                }
        }
 
-       return TRUE;
+       return true;
 }
 
 void
@@ -298,14 +296,7 @@ Mixer_UI::connect_to_session (Session* sess)
        wintitle += session->name();
        set_title (wintitle);
 
-       // GTK2FIX
-       // track_display_list.freeze ();
-
-       track_display_model->clear ();
-
-       session->foreach_route (this, &Mixer_UI::add_strip);
-       
-       // track_display_list.thaw ();
+       initial_track_display ();
 
        session->going_away.connect (mem_fun(*this, &Mixer_UI::disconnect_from_session));
        session->RouteAdded.connect (mem_fun(*this, &Mixer_UI::add_strip));
@@ -313,9 +304,6 @@ Mixer_UI::connect_to_session (Session* sess)
 
        session->foreach_mix_group(this, &Mixer_UI::add_mix_group);
        
-       session->StateSaved.connect (mem_fun(*this, &Mixer_UI::session_state_saved));
-       redisplay_snapshots ();
-       
        _plugin_selector->set_session (session);
 
        start_updating ();
@@ -329,267 +317,336 @@ Mixer_UI::disconnect_from_session ()
        group_display_model->clear ();
        set_title (_("ardour: mixer"));
        stop_updating ();
-       hide_all_strips (false);
 }
 
 void
-Mixer_UI::hide_all_strips (bool with_select)
+Mixer_UI::show_strip (MixerStrip* ms)
 {
-       TreeModel::Children rows = track_display_model->children();
+        TreeModel::Children rows = track_display_model->children();
        TreeModel::Children::iterator i;
 
-       // GTK2FIX
-       // track_display_list.freeze ();
-       
        for (i = rows.begin(); i != rows.end(); ++i) {
-               
-               TreeModel::Row row = (*i);
-               MixerStrip* ms = row[track_display_columns.strip];
-               
-               if (with_select) {
-                       track_display.get_selection()->unselect (i);
-               } else {
-                       hide_strip (ms);
+
+               MixerStrip* strip = (*i)[track_display_columns.strip];
+               if (strip == ms) {
+                       (*i)[track_display_columns.visible] = true;
+                       break;
                }
        }
-
-       // track_display_list.thaw ();
-}
-
-void
-Mixer_UI::unselect_all_strips ()
-{
-       hide_all_strips (false);
 }
 
 void
-Mixer_UI::select_all_strips ()
+Mixer_UI::hide_strip (MixerStrip* ms)
 {
-       TreeModel::Children rows = track_display_model->children();
+        TreeModel::Children rows = track_display_model->children();
+       TreeModel::Children::iterator i;
+       
+       for (i = rows.begin(); i != rows.end(); ++i) {
+               
+               MixerStrip* strip = (*i)[track_display_columns.strip];
+               if (strip == ms) {
+                       (*i)[track_display_columns.visible] = false;
+                       break;
+               }
+        }
+ }
+
+ gint
+ Mixer_UI::start_updating ()
+ {
+        screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect (mem_fun(*this, &Mixer_UI::update_strips));
+        fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (mem_fun(*this, &Mixer_UI::fast_update_strips));
+        return 0;
+ }
+
+ gint
+ Mixer_UI::stop_updating ()
+ {
+        screen_update_connection.disconnect();
+        fast_screen_update_connection.disconnect();
+        return 0;
+ }
+
+ void
+ Mixer_UI::update_strips ()
+ {
+        if (is_mapped () && session) {
+                for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
+                        (*i)->update ();
+                }
+        }
+ }
+
+ void
+ Mixer_UI::fast_update_strips ()
+ {
+        if (is_mapped () && session) {
+                for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
+                        (*i)->fast_update ();
+                }
+        }
+ }
+
+void
+Mixer_UI::set_all_strips_visibility (bool yn)
+{
+        TreeModel::Children rows = track_display_model->children();
        TreeModel::Children::iterator i;
 
+       no_track_list_redisplay = true;
+
        for (i = rows.begin(); i != rows.end(); ++i) {
-               track_display.get_selection()->select (i);
+
+               TreeModel::Row row = (*i);
+               MixerStrip* strip = row[track_display_columns.strip];
+               
+               if (strip == 0) {
+                       continue;
+               }
+               
+               if (strip->route().master() || strip->route().control()) {
+                       continue;
+               }
+
+               (*i)[track_display_columns.visible] = yn;
        }
+
+       no_track_list_redisplay = false;
+       redisplay_track_list ();
 }
 
+
 void
-Mixer_UI::strip_select_op (bool audiotrack, bool select)
+Mixer_UI::set_all_audio_visibility (int tracks, bool yn) 
 {
-       MixerStrip* ms;
-       TreeModel::Children rows = track_display_model->children();
+        TreeModel::Children rows = track_display_model->children();
        TreeModel::Children::iterator i;
 
-       // GTK2FIX
-       // track_display_list.freeze ();
-       
+       no_track_list_redisplay = true;
+
        for (i = rows.begin(); i != rows.end(); ++i) {
-               ms = (*i)[track_display_columns.strip];
+               TreeModel::Row row = (*i);
+               MixerStrip* strip = row[track_display_columns.strip];
 
-               if (ms->is_audio_track() == audiotrack) {
-                       if (select) {
-                               track_display.get_selection()->select (i);
-                       } else {
-                               track_display.get_selection()->unselect (i);
+               if (strip == 0) {
+                       continue;
+               }
+
+               if (strip->route().master() || strip->route().control()) {
+                       continue;
+               }
+
+               AudioTrack* at = dynamic_cast<AudioTrack*> (&strip->route());
+
+               switch (tracks) {
+               case 0:
+                       (*i)[track_display_columns.visible] = yn;
+                       break;
+                       
+               case 1:
+                       if (at) { /* track */
+                               (*i)[track_display_columns.visible] = yn;
+                       }
+                       break;
+                       
+               case 2:
+                       if (!at) { /* bus */
+                               (*i)[track_display_columns.visible] = yn;
                        }
+                       break;
                }
        }
-       
-       // track_display_list.thaw ();  
-}
 
-void
-Mixer_UI::select_all_audiotrack_strips ()
-{
-       strip_select_op (true, true);
+       no_track_list_redisplay = false;
+       redisplay_track_list ();
 }
+
 void
-Mixer_UI::unselect_all_audiotrack_strips ()
+Mixer_UI::hide_all_routes ()
 {
-       strip_select_op (true, false);
+       set_all_strips_visibility (false);
 }
 
 void
-Mixer_UI::select_all_audiobus_strips ()
+Mixer_UI::show_all_routes ()
 {
-       strip_select_op (false, true);
+       set_all_strips_visibility (true);
 }
 
 void
-Mixer_UI::unselect_all_audiobus_strips ()
+Mixer_UI::show_all_audiobus ()
 {
-       strip_select_op (false, false);
+       set_all_audio_visibility (2, true);
 }
-
 void
-Mixer_UI::show_strip (MixerStrip* ms)
+Mixer_UI::hide_all_audiobus ()
 {
-       if (!ms->packed()) {
-               
-               if (ms->route().master() || ms->route().control()) {
-                       out_packer.pack_start (*ms, false, false);
-               } else {
-                       strip_packer.pack_start (*ms, false, false);
-               }
-               ms->set_packed (true);
-               ms->show ();
-
-       }
+       set_all_audio_visibility (2, false);
 }
 
 void
-Mixer_UI::hide_strip (MixerStrip* ms)
+Mixer_UI::show_all_audiotracks()
 {
-       if (ms->packed()) {
-               if (ms->route().master() || ms->route().control()) {
-                       out_packer.remove (*ms);
-               } else {
-                       strip_packer.remove (*ms);
-               }
-               ms->set_packed (false);
-       }
+       set_all_audio_visibility (1, true);
 }
-
-gint
-Mixer_UI::start_updating ()
-{
-       screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect (mem_fun(*this, &Mixer_UI::update_strips));
-       fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (mem_fun(*this, &Mixer_UI::fast_update_strips));
-       return 0;
-}
-
-gint
-Mixer_UI::stop_updating ()
+void
+Mixer_UI::hide_all_audiotracks ()
 {
-       screen_update_connection.disconnect();
-       fast_screen_update_connection.disconnect();
-       return 0;
+       set_all_audio_visibility (1, false);
 }
 
 void
-Mixer_UI::update_strips ()
+Mixer_UI::track_list_change (const Gtk::TreeModel::Path& path,const Gtk::TreeModel::iterator& iter)
 {
-       if (is_mapped () && session) {
-               for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
-                       (*i)->update ();
-               }
-       }
+       redisplay_track_list ();
 }
 
 void
-Mixer_UI::fast_update_strips ()
+Mixer_UI::track_list_delete (const Gtk::TreeModel::Path& path)
 {
-       if (is_mapped () && session) {
-               for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
-                       (*i)->fast_update ();
-               }
-       }
+       redisplay_track_list ();
 }
 
 void
-Mixer_UI::snapshot_display_selection_changed ()
+Mixer_UI::redisplay_track_list ()
 {
-       TreeModel::iterator i = snapshot_display.get_selection()->get_selected();
+       TreeModel::Children rows = track_display_model->children();
+       TreeModel::Children::iterator i;
+       long order;
 
-       Glib::ustring snap_name = (*i)[snapshot_display_columns.real_name];
-       
-       if (session->snap_name() == snap_name) {
+       if (no_track_list_redisplay) {
                return;
        }
-       
-       ARDOUR_UI::instance()->load_session(session->path(), string (snap_name));
-}
 
-bool
-Mixer_UI::snapshot_display_button_press (GdkEventButton* ev)
-{
-       return false;
-}
+       for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) {
+               MixerStrip* strip = (*i)[track_display_columns.strip];
 
-void
-Mixer_UI::track_display_selection_changed ()
-{
-       MixerStrip* strip;
-       TreeModel::Children rows = track_display_model->children();
-       TreeModel::Children::iterator i;
-       Glib::RefPtr<TreeSelection> selection = track_display.get_selection();
+               if (strip == 0) {
+                       cerr << "row with text = " << (*i)[track_display_columns.text] << " has no strip\n";
+                       /* we're in the middle of changing a row, don't worry */
+                       continue;
+               }
+
+               bool visible = (*i)[track_display_columns.visible];
+
+               if (visible) {
+                       strip->set_marked_for_display (true);
+                       strip->route().set_order_key (N_("signal"), order);
+
+                       if (strip->packed()) {
+
+                               if (strip->route().master() || strip->route().control()) {
+                                       out_packer.reorder_child (*strip, -1);
+                               } else {
+                                       strip_packer.reorder_child (*strip, -1); /* put at end */
+                               }
+
+                       } else {
+
+                               if (strip->route().master() || strip->route().control()) {
+                                       out_packer.pack_start (*strip, false, false);
+                               } else {
+                                       strip_packer.pack_start (*strip, false, false);
+                               }
+                               strip->set_packed (true);
+                               strip->show_all ();
+                       }
 
-       for (i = rows.begin(); i != rows.end(); ++i) {
-               if (selection->is_selected (i)) {
-                       strip->set_marked_for_display  (true);
-                       show_strip (strip);
                } else {
-                       strip->set_marked_for_display (false);
-                       hide_strip (strip);
-               }
-       }
-       
-       track_display_reordered ();
-}
 
-void
-Mixer_UI::select_strip_op (MixerStrip *strip, bool yn)
-{
-       TreeModel::Children rows = track_display_model->children();
-       TreeModel::Children::iterator i;
-       Glib::RefPtr<TreeSelection> selection = track_display.get_selection();
-       
-       for (i = rows.begin(); i != rows.end(); ++i) {
-               if ((*i)[track_display_columns.strip] == strip) {
-                       if (yn) {
-                               selection->select (*i);
+                       if (strip->route().master() || strip->route().control()) {
+                               /* do nothing, these cannot be hidden */
                        } else {
-                               selection->unselect (*i);
+                               strip_packer.remove (*strip);
+                               strip->set_packed (false);
                        }
-                       break;
                }
        }
 }
 
-void
-Mixer_UI::unselect_strip_in_display (MixerStrip *strip)
-{
-       select_strip_op (strip, true);
-}
-void
-Mixer_UI::select_strip_in_display (MixerStrip *strip)
-{
-       select_strip_op (strip, false);
-}
+struct SignalOrderRouteSorter {
+    bool operator() (Route* a, Route* b) {
+           /* use of ">" forces the correct sort order */
+           return a->order_key ("signal") < b->order_key ("signal");
+    }
+};
 
 void
-Mixer_UI::track_display_reordered_proxy (const TreeModel::Path& path, const TreeModel::iterator& i, int* n)
+Mixer_UI::initial_track_display ()
 {
-       track_display_reordered ();
-}
+       Session::RouteList routes = session->get_routes();
+       SignalOrderRouteSorter sorter;
 
-void
-Mixer_UI::track_display_reordered ()
-{
-       TreeModel::Children rows = track_display_model->children();
-       TreeModel::Children::iterator i;
-       long order;
+       routes.sort (sorter);
        
-       for (order = 0, i = rows.begin(); i != rows.end(); ++i, ++order) {
-               MixerStrip* strip = (*i)[track_display_columns.strip];
+       no_track_list_redisplay = true;
 
-               if (strip->marked_for_display()) {
-                       strip->route().set_order_key (N_("signal"), order);
-                       strip_packer.reorder_child (*strip, -1); /* put at end */
-               }
+       track_display_model->clear ();
+
+       for (Session::RouteList::iterator i = routes.begin(); i != routes.end(); ++i) {
+               add_strip (*i);
        }
+
+       no_track_list_redisplay = false;
+
+       redisplay_track_list ();
 }
 
 void
-Mixer_UI::track_column_click (gint col)
+Mixer_UI::show_track_list_menu ()
 {
        if (track_menu == 0) {
                build_track_menu ();
        }
 
-       track_menu->popup (0, 0);
+       track_menu->popup (1, 0);
+}
+
+bool
+Mixer_UI::track_display_button_press (GdkEventButton* ev)
+{
+       if (Keyboard::is_context_menu_event (ev)) {
+               show_track_list_menu ();
+               return true;
+       }
+
+       TreeIter iter;
+       TreeModel::Path path;
+       TreeViewColumn* column;
+       int cellx;
+       int celly;
+       
+       if (!track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
+               return false;
+       }
+
+       switch (GPOINTER_TO_UINT (column->get_data (X_("colnum")))) {
+       case 0:
+               /* allow normal processing to occur */
+               return false;
+
+       case 1: /* visibility */
+
+               if ((iter = track_display_model->get_iter (path))) {
+                       MixerStrip* strip = (*iter)[track_display_columns.strip];
+                       if (strip) {
+
+                               if (!strip->route().master() && !strip->route().control()) {
+                                       bool visible = (*iter)[track_display_columns.visible];
+                                       (*iter)[track_display_columns.visible] = !visible;
+                               }
+                       }
+               }
+               return true;
+
+       default:
+               break;
+       }
+
+       return false;
 }
 
+
 void
 Mixer_UI::build_track_menu ()
 {
@@ -599,14 +656,13 @@ Mixer_UI::build_track_menu ()
        track_menu = new Menu;
        track_menu->set_name ("ArdourContextMenu");
        MenuList& items = track_menu->items();
-       track_menu->set_name ("ArdourContextMenu");
        
-       items.push_back (MenuElem (_("Show All"), mem_fun(*this, &Mixer_UI::select_all_strips)));
-       items.push_back (MenuElem (_("Hide All"), mem_fun(*this, &Mixer_UI::unselect_all_strips)));
-       items.push_back (MenuElem (_("Show All AudioTrack MixerStrips"), mem_fun(*this, &Mixer_UI::select_all_audiotrack_strips)));
-       items.push_back (MenuElem (_("Hide All AudioTrack MixerStrips"), mem_fun(*this, &Mixer_UI::unselect_all_audiotrack_strips)));
-       items.push_back (MenuElem (_("Show All AudioBus MixerStrips"), mem_fun(*this, &Mixer_UI::select_all_audiobus_strips)));
-       items.push_back (MenuElem (_("Hide All AudioBus MixerStrips"), mem_fun(*this, &Mixer_UI::unselect_all_audiobus_strips)));
+       items.push_back (MenuElem (_("Show All"), mem_fun(*this, &Mixer_UI::show_all_routes)));
+       items.push_back (MenuElem (_("Hide All"), mem_fun(*this, &Mixer_UI::hide_all_routes)));
+       items.push_back (MenuElem (_("Show All Audio Tracks"), mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
+       items.push_back (MenuElem (_("Hide All Audio Tracks"), mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
+       items.push_back (MenuElem (_("Show All Audio Busses"), mem_fun(*this, &Mixer_UI::show_all_audiobus)));
+       items.push_back (MenuElem (_("Hide All Audio Busses"), mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
 
 }
 
@@ -638,7 +694,7 @@ Mixer_UI::new_mix_group ()
        prompter.show_all ();
        
        switch (prompter.run ()) {
-       case GTK_RESPONSE_ACCEPT:
+       case Gtk::RESPONSE_ACCEPT:
                prompter.get_result (result);
                if (result.length()) {
                        session->add_mix_group (result);
@@ -647,15 +703,6 @@ Mixer_UI::new_mix_group ()
        }
 }
 
-// GTK2FIX
-//void
-//Mixer_UI::group_display_button_clicked ()
-//{
-//     if (session) {
-//             new_mix_group ();
-//     }
-//}
-
 bool
 Mixer_UI::group_display_button_press (GdkEventButton* ev)
 {
@@ -717,7 +764,7 @@ Mixer_UI::group_display_selection_changed ()
                }
        }
 
-       track_display_reordered ();
+       redisplay_track_list ();
 }
 
 void
@@ -725,37 +772,16 @@ Mixer_UI::group_flags_changed (void* src, RouteGroup* group)
 {
        ENSURE_GUI_THREAD(bind (mem_fun(*this, &Mixer_UI::group_flags_changed), src, group));
        
-       if (src != this) {
-               // select row
-       }
-
+       TreeModel::iterator i;
        TreeModel::Children rows = group_display_model->children();
-       TreeModel::Children::iterator gi;
-       TreeModel::Children::iterator ti;
-
-       for (gi = rows.begin(); gi != rows.end(); ++gi) {
-               if ((*gi)[group_display_columns.group] == group) {
+       Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
+       
+       for (i = rows.begin(); i != rows.end(); ++i) {
+               if ((*i)[group_display_columns.group] == group) {
+                       (*i)[group_display_columns.visible] = group->is_hidden ();
                        break;
                }
        }
-
-       if (gi == rows.end()) {
-               return;
-       }
-               
-       rows = track_display_model->children();
-
-       for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
-               if ((*i)->route().mix_group() == group) {
-                       if (group->is_hidden ()) {
-                               unselect_strip_in_display(*i);
-                               group_display.get_selection()->unselect (*gi);
-                       } else {
-                               select_strip_in_display(*i);
-                               group_display.get_selection()->select (*gi);
-                       }
-               }
-       }
 }
 
 void
@@ -766,54 +792,24 @@ Mixer_UI::add_mix_group (RouteGroup* group)
 
        TreeModel::Row row = *(group_display_model->append());
        row[group_display_columns.active] = group->is_active();
+       row[group_display_columns.visible] = true;
        row[group_display_columns.text] = group->name();
        row[group_display_columns.group] = group;
 
        group->FlagsChanged.connect (bind (mem_fun(*this, &Mixer_UI::group_flags_changed), group));
 }
 
-void
-Mixer_UI::redisplay_snapshots ()
-{
-       if (session == 0) {
-               return;
-       }
-
-       vector<string*>* states;
-       if ((states = session->possible_states()) == 0) {
-               return;
-       }
-
-       snapshot_display_model->clear ();
-
-       for (vector<string*>::iterator i = states->begin(); i != states->end(); ++i) {
-               string statename = *(*i);
-               TreeModel::Row row = *(snapshot_display_model->append());
-               row[snapshot_display_columns.visible_name] = statename;
-               row[snapshot_display_columns.real_name] = statename;
-       }
-
-       delete states;
-}
-
-void
-Mixer_UI::session_state_saved (string snap_name)
-{
-       ENSURE_GUI_THREAD (bind (mem_fun(*this, &Mixer_UI::session_state_saved), snap_name));
-       redisplay_snapshots ();
-}
-
-gint
+bool
 Mixer_UI::strip_scroller_button_release (GdkEventButton* ev)
 {
        using namespace Menu_Helpers;
 
        if (Keyboard::is_context_menu_event (ev)) {
                ARDOUR_UI::instance()->add_route();
-               return TRUE;
+               return true;
        }
 
-       return FALSE;
+       return false;
 }
 
 void
@@ -832,12 +828,13 @@ Mixer_UI::set_state (const XMLNode& node)
 {
        const XMLProperty* prop;
        XMLNode* geometry;
-       int x, y, width, height, xoff, yoff;
+       Gdk::Geometry g;
+       int x, y, xoff, yoff;
        
        if ((geometry = find_named_node (node, "geometry")) == 0) {
 
-               width = default_width;
-               height = default_height;
+               g.base_width = default_width;
+               g.base_height = default_height;
                x = 1;
                y = 1;
                xoff = 0;
@@ -845,17 +842,17 @@ Mixer_UI::set_state (const XMLNode& node)
 
        } else {
 
-               width = atoi(geometry->property("x_size")->value().c_str());
-               height = atoi(geometry->property("y_size")->value().c_str());
+               g.base_width = atoi(geometry->property("x_size")->value().c_str());
+               g.base_height = atoi(geometry->property("y_size")->value().c_str());
                x = atoi(geometry->property("x_pos")->value().c_str());
                y = atoi(geometry->property("y_pos")->value().c_str());
                xoff = atoi(geometry->property("x_off")->value().c_str());
                yoff = atoi(geometry->property("y_off")->value().c_str());
        }
-               
-       set_default_size(width, height);
-       // GTK2FIX
-       // set_uposition(x, y-yoff);
+
+       set_geometry_hints (global_vpacker, g, Gdk::HINT_BASE_SIZE);
+       set_default_size(g.base_width, g.base_height);
+       move (x, y);
 
        if ((prop = node.property ("narrow-strips"))) {
                if (prop->value() == "yes") {
@@ -898,8 +895,6 @@ Mixer_UI::get_state (void)
 
                snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&rhs_pane1)->gobj()));
                geometry->add_property(X_("mixer_rhs_pane1_pos"), string(buf));
-               snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&rhs_pane2)->gobj()));
-               geometry->add_property(X_("mixer_rhs_pane2_pos"), string(buf));
                snprintf(buf,sizeof(buf), "%d",gtk_paned_get_position (static_cast<Paned*>(&list_hpane)->gobj()));
                geometry->add_property(X_("mixer_list_hpane_pos"), string(buf));
 
@@ -948,23 +943,6 @@ Mixer_UI::pane_allocation_handler (Allocation& alloc, Gtk::Paned* which)
                        rhs_pane1.set_position (pos);
                }
 
-       } else if (which == static_cast<Gtk::Paned*> (&rhs_pane2)) {
-
-               if (done[1]) {
-                       return;
-               }
-
-               if (!geometry || (prop = geometry->property("mixer_rhs_pane2_pos")) == 0) {
-                       pos = height / 3;
-                       snprintf (buf, sizeof(buf), "%d", pos);
-               } else {
-                       pos = atoi (prop->value());
-               }
-
-               if ((done[1] = GTK_WIDGET(rhs_pane2.gobj())->allocation.height > pos)) {
-                       rhs_pane2.set_position (pos);
-               }
-
        } else if (which == static_cast<Gtk::Paned*> (&list_hpane)) {
 
                if (done[2]) {