Removed last usage of checkmark XPMs.
[ardour.git] / gtk2_ardour / route_params_ui.cc
index ed744c08871ec1f92d7e84a75b15e9d00ab9e4b7..7987496a815f22b1f01c9a72b2ff2477724e58c1 100644 (file)
@@ -55,14 +55,9 @@ using namespace ARDOUR;
 using namespace Gtk;
 using namespace sigc;
 
-static const gchar *route_display_titles[] = { N_("Tracks/Buses"), 0 };
-static const gchar *pre_display_titles[] = { N_("Pre Redirects"), 0 };
-static const gchar *post_display_titles[] = { N_("Post Redirects"), 0 };
-
 RouteParams_UI::RouteParams_UI (AudioEngine& eng)
        : ArdourDialog ("track/bus inspector"),
          engine (eng),
-         route_select_list (internationalize(route_display_titles)),
          _route(0), 
          track_menu(0)
 {
@@ -78,21 +73,29 @@ RouteParams_UI::RouteParams_UI (AudioEngine& eng)
        
        using namespace Notebook_Helpers;
 
-       input_frame.set_shadow_type(GTK_SHADOW_NONE);
-       output_frame.set_shadow_type(GTK_SHADOW_NONE);
+       input_frame.set_shadow_type(Gtk::SHADOW_NONE);
+       output_frame.set_shadow_type(Gtk::SHADOW_NONE);
        
        notebook.set_show_tabs (true);
        notebook.set_show_border (true);
        notebook.set_name ("RouteParamNotebook");
-       
-       route_select_list.column_titles_active();
-       route_select_list.set_name ("RouteParamsListDisplay");
-       route_select_list.set_shadow_type (Gtk::SHADOW_IN);
-       route_select_list.set_selection_mode (GTK_SELECTION_SINGLE);
-       route_select_list.set_reorderable (false);
-       route_select_list.set_size_request (75, -1);
-       route_select_scroller.add (route_select_list);
-       route_select_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
+
+       // create the tree model
+       route_display_model = ListStore::create(route_display_columns);
+
+       // setup the treeview
+       route_display.set_model(route_display_model);
+       route_display.append_column(_("Tracks/Buses"), route_display_columns.text);
+       route_display.set_name(X_("RouteParamsListDisplay"));
+       route_display.get_selection()->set_mode(Gtk::SELECTION_SINGLE); // default
+       route_display.set_reorderable(false);
+       route_display.set_size_request(75, -1);
+       route_display.set_headers_visible(true);
+       route_display.set_headers_clickable(true);
+
+       route_select_scroller.add(route_display);
+       route_select_scroller.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
+
 
        route_select_frame.set_name("RouteSelectBaseFrame");
        route_select_frame.set_shadow_type (Gtk::SHADOW_IN);
@@ -139,19 +142,17 @@ RouteParams_UI::RouteParams_UI (AudioEngine& eng)
        set_wmclass (_("ardour_route_parameters"), "Ardour");
 
        // events
-       route_select_list.select_row.connect (slot (*this, &RouteParams_UI::route_selected));
-       route_select_list.unselect_row.connect (slot (*this, &RouteParams_UI::route_unselected));
-       route_select_list.click_column.connect (slot (*this, &RouteParams_UI::show_track_menu));
-
+       route_display.get_selection()->signal_changed().connect(mem_fun(*this, &RouteParams_UI::route_selected));
+       route_display.get_column(0)->signal_clicked().connect(mem_fun(*this, &RouteParams_UI::show_track_menu));
 
        add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|Gdk::BUTTON_RELEASE_MASK);
        
        _plugin_selector = new PluginSelector (PluginManager::the_manager());
-       _plugin_selector->delete_event.connect (bind (slot (just_hide_it), 
+       _plugin_selector->signal_delete_event().connect (bind (ptr_fun (just_hide_it), 
                                                     static_cast<Window *> (_plugin_selector)));
 
 
-       delete_event.connect (bind (slot (just_hide_it), static_cast<Gtk::Window*> (this)));
+       signal_delete_event().connect(bind(ptr_fun(just_hide_it), static_cast<Gtk::Window *>(this)));
 }
 
 RouteParams_UI::~RouteParams_UI ()
@@ -161,37 +162,43 @@ RouteParams_UI::~RouteParams_UI ()
 void
 RouteParams_UI::add_route (Route* route)
 {
-       ENSURE_GUI_THREAD(bind (slot (*this, &RouteParams_UI::add_route), route));
+       ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::add_route), route));
        
        if (route->hidden()) {
                return;
        }
 
-       const gchar *rowdata[1];
-       rowdata[0] = route->name().c_str();
-       route_select_list.rows().push_back (rowdata);
-       route_select_list.rows().back().set_data (route);
+       TreeModel::Row row = *(route_display_model->append());
+       row[route_display_columns.text] = route->name();
+       row[route_display_columns.route] = route;
+
        //route_select_list.rows().back().select ();
        
-       route->name_changed.connect (bind (slot (*this, &RouteParams_UI::route_name_changed), route));
-       route->GoingAway.connect (bind (slot (*this, &RouteParams_UI::route_removed), route));
+       route->name_changed.connect (bind (mem_fun(*this, &RouteParams_UI::route_name_changed), route));
+       route->GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::route_removed), route));
 }
 
 
 void
 RouteParams_UI::route_name_changed (void *src, Route *route)
 {
-       ENSURE_GUI_THREAD(bind (slot (*this, &RouteParams_UI::route_name_changed), src, route));
-       
-       CList_Helpers::RowList::iterator i;
+       ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::route_name_changed), src, route));
+
+       bool found = false ;
+       TreeModel::Children rows = route_display_model->children();
+       for(TreeModel::Children::iterator iter = rows.begin(); iter != rows.end(); ++iter) {
+               if((*iter)[route_display_columns.route] == route) {
+                       (*iter)[route_display_columns.text] = route->name() ;
+                       found = true ;
+                       break;
+               }
+       }
 
-       if ((i = route_select_list.rows().find_data (route)) == route_select_list.rows().end()) {
+       if(!found)
+       {
                error << _("route display list item for renamed route not found!") << endmsg;
-               return;
        }
 
-       route_select_list.cell ((*i)->get_row_num(), 0).set_text (route->name());
-
        if (route == _route) {
                track_input_label.set_text (route->name());
                update_title();
@@ -210,18 +217,18 @@ RouteParams_UI::setup_redirect_boxes()
                pre_redirect_box = new RedirectBox(PreFader, *session, *_route, *_plugin_selector, _rr_selection);
                post_redirect_box = new RedirectBox(PostFader, *session, *_route, *_plugin_selector, _rr_selection);
 
-               pre_redirect_box->set_title (pre_display_titles[0]);
+               pre_redirect_box->set_title(_("Pre Redirects"));
                pre_redirect_box->set_title_shown (true);
-               post_redirect_box->set_title (post_display_titles[0]);
+               post_redirect_box->set_title(_("Post Redirects"));
                post_redirect_box->set_title_shown (true);
 
                pre_redir_hpane.add1 (*pre_redirect_box);
                post_redir_hpane.add1 (*post_redirect_box);
 
-               pre_redirect_box->RedirectSelected.connect (bind (slot (*this, &RouteParams_UI::redirect_selected), PreFader));
-               pre_redirect_box->RedirectUnselected.connect (bind (slot (*this, &RouteParams_UI::redirect_selected), PreFader));
-               post_redirect_box->RedirectSelected.connect (bind (slot (*this, &RouteParams_UI::redirect_selected), PostFader));
-               post_redirect_box->RedirectUnselected.connect (bind (slot (*this, &RouteParams_UI::redirect_selected), PostFader));
+               pre_redirect_box->RedirectSelected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PreFader));
+               pre_redirect_box->RedirectUnselected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PreFader));
+               post_redirect_box->RedirectSelected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PostFader));
+               post_redirect_box->RedirectUnselected.connect (bind (mem_fun(*this, &RouteParams_UI::redirect_selected), PostFader));
                
        }
        
@@ -317,19 +324,22 @@ RouteParams_UI::cleanup_post_view (bool stopupdate)
 void
 RouteParams_UI::route_removed (Route *route)
 {
-       ENSURE_GUI_THREAD(bind (slot (*this, &RouteParams_UI::route_removed), route));
+       ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::route_removed), route));
        /*
        route_select_list.freeze ();
        route_select_list.clear ();
        session->foreach_route (this, &RouteParams_UI::add_route);
        route_select_list.thaw ();
        */
-       
-       CList_Helpers::RowList::iterator i;
-       
-       if ((i = route_select_list.rows().find_data (route)) == route_select_list.rows().end()) {
-               // couldn't find route to be deleted
-               return;
+
+       TreeModel::Children rows = route_display_model->children();
+       TreeModel::Children::iterator ri;
+
+       for(TreeModel::Children::iterator iter = rows.begin(); iter != rows.end(); ++iter) {
+               if((*iter)[route_display_columns.route] == route) {
+                       route_display_model->erase(iter);
+                       break;
+               }
        }
 
        if (route == _route)
@@ -344,9 +354,6 @@ RouteParams_UI::route_removed (Route *route)
                _post_redirect = 0;
                update_title();
        }
-
-       route_select_list.rows().erase(i);
-       
 }
 
 void
@@ -354,19 +361,21 @@ RouteParams_UI::set_session (Session *sess)
 {
        ArdourDialog::set_session (sess);
 
-       route_select_list.freeze ();
-       route_select_list.clear ();
+       // GTK2FIX
+       // route_select_list.freeze ();
+
+       route_display_model->clear();
 
        if (session) {
                session->foreach_route (this, &RouteParams_UI::add_route);
-               session->going_away.connect (slot (*this, &ArdourDialog::session_gone));
-               session->RouteAdded.connect (slot (*this, &RouteParams_UI::add_route));
+               session->going_away.connect (mem_fun(*this, &ArdourDialog::session_gone));
+               session->RouteAdded.connect (mem_fun(*this, &RouteParams_UI::add_route));
                start_updating ();
        } else {
                stop_updating ();
        }
 
-       route_select_list.thaw ();
+       //route_select_list.thaw ();
 
        _plugin_selector->set_session (session);
 }      
@@ -375,8 +384,9 @@ RouteParams_UI::set_session (Session *sess)
 void
 RouteParams_UI::session_gone ()
 {
+       ENSURE_GUI_THREAD(mem_fun(*this, &RouteParams_UI::session_gone));
 
-       route_select_list.clear ();
+       route_display_model->clear();
 
        cleanup_io_frames();
        cleanup_pre_view();
@@ -393,17 +403,19 @@ RouteParams_UI::session_gone ()
 }
 
 void
-RouteParams_UI::route_selected (gint row, gint col, GdkEvent *ev)
+RouteParams_UI::route_selected()
 {
-       Route *route;
-
-       if ((route = (Route *) route_select_list.get_row_data (row)) != 0) {
+       Glib::RefPtr<TreeSelection> selection = route_display.get_selection();
+       TreeModel::iterator iter = selection->get_selected(); // only used with Gtk::SELECTION_SINGLE
+       if(iter) {
+               //If anything is selected
+               Route* route = (*iter)[route_display_columns.route] ;
 
                if (_route == route) {
                        // do nothing
                        return;
                }
-               
+
                // remove event binding from previously selected
                if (_route) {
                        _route_conn.disconnect();
@@ -413,48 +425,65 @@ RouteParams_UI::route_selected (gint row, gint col, GdkEvent *ev)
                        cleanup_post_view();
                        cleanup_io_frames();
                }
-       
+
                // update the other panes with the correct info
                _route = route;
                //update_routeinfo (route);
 
                setup_io_frames();
                setup_redirect_boxes();
-               
+
                // bind to redirects changed event for this route
-               _route_conn = route->redirects_changed.connect (slot (*this, &RouteParams_UI::redirects_changed));
+               _route_conn = route->redirects_changed.connect (mem_fun(*this, &RouteParams_UI::redirects_changed));
 
                track_input_label.set_text (_route->name());
-               
+
                update_title();
+       } else {
+               // no selection
+               if (_route) {
+                       _route_conn.disconnect();
+
+                       // remove from view
+                       cleanup_io_frames();
+                       cleanup_pre_view();
+                       cleanup_post_view();
+                       cleanup_redirect_boxes();
+
+                       _route = 0;
+                       _pre_redirect = 0;
+                       _post_redirect = 0;
+                       track_input_label.set_text(_("NO TRACK"));
+                       update_title();
+               }
        }
 }
 
-void
-RouteParams_UI::route_unselected (gint row, gint col, GdkEvent *ev)
-{
-       if (_route) {
-               _route_conn.disconnect();
+//void
+//RouteParams_UI::route_unselected (gint row, gint col, GdkEvent *ev)
+//{
+//     if (_route) {
+//             _route_conn.disconnect();
 
                // remove from view
-               cleanup_io_frames();
-               cleanup_pre_view();
-               cleanup_post_view();
-               cleanup_redirect_boxes();
+//             cleanup_io_frames();
+//             cleanup_pre_view();
+//             cleanup_post_view();
+//             cleanup_redirect_boxes();
                
-               _route = 0;
-               _pre_redirect = 0;
-               _post_redirect = 0;
-               track_input_label.set_text(_("NO TRACK"));
-               update_title();
-       }
-}
+//             _route = 0;
+//             _pre_redirect = 0;
+//             _post_redirect = 0;
+//             track_input_label.set_text(_("NO TRACK"));
+//             update_title();
+//     }
+//}
 
 void
 RouteParams_UI::redirects_changed (void *src)
 
 {
-       ENSURE_GUI_THREAD(bind (slot (*this, &RouteParams_UI::redirects_changed), src));
+       ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::redirects_changed), src));
        
 //     pre_redirect_list.freeze ();
 //     pre_redirect_list.clear ();
@@ -477,7 +506,7 @@ RouteParams_UI::redirects_changed (void *src)
 
 
 void
-RouteParams_UI::show_track_menu (gint arg)
+RouteParams_UI::show_track_menu()
 {
        using namespace Menu_Helpers;
        
@@ -486,7 +515,7 @@ RouteParams_UI::show_track_menu (gint arg)
                track_menu->set_name ("ArdourContextMenu");
                track_menu->items().push_back 
                                (MenuElem (_("Add Track/Bus"), 
-                                          slot (*(ARDOUR_UI::instance()), &ARDOUR_UI::add_route)));
+                                          mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::add_route)));
        }
        track_menu->popup (1, 0);
 }
@@ -515,7 +544,7 @@ RouteParams_UI::redirect_selected (ARDOUR::Redirect *redirect, ARDOUR::Placement
 
                        if (place == PreFader) {
                                cleanup_pre_view();
-                               _pre_plugin_conn = send->GoingAway.connect (slot (*this, &RouteParams_UI::redirect_going_away));
+                               _pre_plugin_conn = send->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
                                _active_pre_view = send_ui;
                                
                                pre_redir_hpane.add2 (*_active_pre_view);
@@ -523,7 +552,7 @@ RouteParams_UI::redirect_selected (ARDOUR::Redirect *redirect, ARDOUR::Placement
                        }
                        else {
                                cleanup_post_view();
-                               _post_plugin_conn = send->GoingAway.connect (slot (*this, &RouteParams_UI::redirect_going_away));
+                               _post_plugin_conn = send->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
                                _active_post_view = send_ui;
                                
                                post_redir_hpane.add2 (*_active_post_view);
@@ -543,7 +572,7 @@ RouteParams_UI::redirect_selected (ARDOUR::Redirect *redirect, ARDOUR::Placement
 
                        if (place == PreFader) {
                                cleanup_pre_view();
-                               _pre_plugin_conn = plugin_insert->plugin().GoingAway.connect (bind (slot (*this, &RouteParams_UI::plugin_going_away), PreFader));
+                               _pre_plugin_conn = plugin_insert->plugin().GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), PreFader));
                                plugin_ui->start_updating (0);
                                _active_pre_view = plugin_ui;
                                pre_redir_hpane.add2 (*_active_pre_view);
@@ -551,7 +580,7 @@ RouteParams_UI::redirect_selected (ARDOUR::Redirect *redirect, ARDOUR::Placement
                        }
                        else {
                                cleanup_post_view();
-                               _post_plugin_conn = plugin_insert->plugin().GoingAway.connect (bind (slot (*this, &RouteParams_UI::plugin_going_away), PostFader));
+                               _post_plugin_conn = plugin_insert->plugin().GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), PostFader));
                                plugin_ui->start_updating (0);
                                _active_post_view = plugin_ui;
                                post_redir_hpane.add2 (*_active_post_view);
@@ -564,7 +593,7 @@ RouteParams_UI::redirect_selected (ARDOUR::Redirect *redirect, ARDOUR::Placement
                                        
                        if (place == PreFader) {
                                cleanup_pre_view();
-                               _pre_plugin_conn = port_insert->GoingAway.connect (slot (*this, &RouteParams_UI::redirect_going_away));
+                               _pre_plugin_conn = port_insert->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
                                _active_pre_view = portinsert_ui;
                                pre_redir_hpane.add2 (*_active_pre_view);
                                portinsert_ui->redisplay();
@@ -572,7 +601,7 @@ RouteParams_UI::redirect_selected (ARDOUR::Redirect *redirect, ARDOUR::Placement
                        }
                        else {
                                cleanup_post_view();
-                               _post_plugin_conn = port_insert->GoingAway.connect (slot (*this, &RouteParams_UI::redirect_going_away));
+                               _post_plugin_conn = port_insert->GoingAway.connect (mem_fun(*this, &RouteParams_UI::redirect_going_away));
                                _active_post_view = portinsert_ui;
                                post_redir_hpane.add2 (*_active_post_view);
                                portinsert_ui->redisplay();
@@ -613,7 +642,7 @@ RouteParams_UI::redirect_unselected (ARDOUR::Redirect *redirect)
 void
 RouteParams_UI::plugin_going_away (Plugin *plugin, Placement place)
 {
-       ENSURE_GUI_THREAD(bind (slot (*this, &RouteParams_UI::plugin_going_away), plugin, place));
+       ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), plugin, place));
        
        // delete the current view without calling finish
 
@@ -631,7 +660,7 @@ void
 RouteParams_UI::redirect_going_away (ARDOUR::Redirect *plugin)
 
 {
-       ENSURE_GUI_THREAD(bind (slot (*this, &RouteParams_UI::redirect_going_away), plugin));
+       ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::redirect_going_away), plugin));
        
        printf ("redirect going away\n");
        // delete the current view without calling finish
@@ -680,7 +709,7 @@ void
 RouteParams_UI::start_updating ()
 {
        update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect 
-               (slot (*this, &RouteParams_UI::update_views));
+               (mem_fun(*this, &RouteParams_UI::update_views));
 }
 
 void