remove method and inline its contents. Nothing gained by wrapping this up
[ardour.git] / gtk2_ardour / playlist_selector.cc
index f81e199d625b69a7c60c588a67e7bcef845f1007..e58b69a818e22bb651be2221eb634c68ecd36446 100644 (file)
 
 #include <gtkmm/button.h>
 
-#include "ardour/session_playlist.h"
-#include "ardour/audio_diskstream.h"
-#include "ardour/playlist.h"
 #include "ardour/audio_track.h"
 #include "ardour/audioplaylist.h"
-#include "ardour/configuration.h"
+#include "ardour/playlist.h"
+#include "ardour/session_playlist.h"
 
 #include <gtkmm2ext/gtk_ui.h>
 
@@ -33,7 +31,7 @@
 #include "route_ui.h"
 #include "gui_thread.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace Gtk;
@@ -46,7 +44,6 @@ PlaylistSelector::PlaylistSelector ()
 {
        rui = 0;
 
-       set_position (WIN_POS_MOUSE);
        set_name ("PlaylistSelectorWindow");
        set_modal(true);
        add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
@@ -64,7 +61,7 @@ PlaylistSelector::PlaylistSelector ()
 
        get_vbox()->pack_start (scroller);
 
-       Button* b = add_button (_("close"), RESPONSE_CANCEL);
+       Button* b = add_button (_("Close"), RESPONSE_CANCEL);
        b->signal_clicked().connect (sigc::mem_fun(*this, &PlaylistSelector::close_button_click));
 
 }
@@ -121,31 +118,20 @@ PlaylistSelector::show_for (RouteUI* ruix)
        for (TrackPlaylistMap::iterator x = trpl_map.begin(); x != trpl_map.end(); ++x) {
 
                boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (_session->route_by_id (x->first));
-               
-               /* legacy sessions stored the diskstream ID as the original
-                * playlist owner. so try there instead.
-                */
-
-               if (tr == 0) {
-                       tr = _session->track_by_diskstream_id (x->first);
-               }
-
-               if (tr == 0) {
-                       continue;
-               }
 
                /* add a node for the track */
 
                string nodename;
 
-               if (tr->name().empty()) {
+               if (!tr || tr->name().empty()) {
                        nodename = _("unassigned");
                } else {
                        nodename = tr->name().c_str();
                }
 
                TreeModel::Row row;
-               TreeModel::Row* selected_row = 0;
+               TreeModel::Row selected_row;
+               bool have_selected = false;
                TreePath this_path;
 
                if (tr == this_track) {
@@ -173,12 +159,13 @@ PlaylistSelector::show_for (RouteUI* ruix)
                        child_row[columns.playlist] = *p;
 
                        if (*p == this_track->playlist()) {
-                               selected_row = &child_row;
+                               selected_row = child_row;
+                               have_selected = true;
                        }
                }
 
-               if (selected_row != 0) {
-                       tree.get_selection()->select (*selected_row);
+               if (have_selected) {
+                       tree.get_selection()->select (selected_row);
                }
        }
 
@@ -187,7 +174,8 @@ PlaylistSelector::show_for (RouteUI* ruix)
        _session->playlists->unassigned (unassigned);
 
        TreeModel::Row row;
-       TreeModel::Row* selected_row = 0;
+       TreeModel::Row selected_row;
+       bool have_selected = false;
        TreePath this_path;
 
        row = *(model->append (others.children()));
@@ -203,11 +191,12 @@ PlaylistSelector::show_for (RouteUI* ruix)
                child_row[columns.playlist] = *p;
 
                if (*p == this_track->playlist()) {
-                       selected_row = &child_row;
+                       selected_row = child_row;
+                       have_selected = true;
                }
 
-               if (selected_row != 0) {
-                       tree.get_selection()->select (*selected_row);
+               if (have_selected) {
+                       tree.get_selection()->select (selected_row);
                }
        }
 
@@ -271,7 +260,7 @@ PlaylistSelector::selection_changed ()
                        return;
                }
 
-               at->use_playlist (apl);
+               at->use_playlist (DataType::AUDIO, apl);
 
                hide ();
        }