X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fplaylist_selector.cc;h=cdc144d1b7c7cde680a5acef4ad778da5d4c77ca;hb=5fef65538040fbac1b9edd1847a269aa925a49c9;hp=0ca9432fcb45af9cd1eee3defe63752622b4ea7d;hpb=572fa80aa713e723f63e1e1822db614307eea6af;p=ardour.git diff --git a/gtk2_ardour/playlist_selector.cc b/gtk2_ardour/playlist_selector.cc index 0ca9432fcb..cdc144d1b7 100644 --- a/gtk2_ardour/playlist_selector.cc +++ b/gtk2_ardour/playlist_selector.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2004 Paul Davis + Copyright (C) 2004 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,15 +20,12 @@ #include -#include -#include -#include -#include -#include -#include +#include "ardour/audio_track.h" +#include "ardour/audioplaylist.h" +#include "ardour/playlist.h" +#include "ardour/session_playlist.h" #include -#include #include "playlist_selector.h" #include "route_ui.h" @@ -37,27 +34,21 @@ #include "i18n.h" using namespace std; -using namespace sigc; using namespace Gtk; using namespace Gtkmm2ext; using namespace ARDOUR; using namespace PBD; PlaylistSelector::PlaylistSelector () - : ArdourDialog ("playlist selector") + : ArdourDialog (_("Playlists")) { rui = 0; - - set_position (WIN_POS_MOUSE); + set_name ("PlaylistSelectorWindow"); set_modal(true); add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK); set_size_request (300, 200); - WindowTitle title(Glib::get_application_name()); - title += _("Playlists"); - set_title(title.get_string()); - model = TreeStore::create (columns); tree.set_model (model); tree.append_column (_("Playlists grouped by track"), columns.text); @@ -70,8 +61,8 @@ PlaylistSelector::PlaylistSelector () get_vbox()->pack_start (scroller); - Button* b = add_button (_("close"), RESPONSE_CANCEL); - b->signal_clicked().connect (mem_fun(*this, &PlaylistSelector::close_button_click)); + Button* b = add_button (_("Close"), RESPONSE_CANCEL); + b->signal_clicked().connect (sigc::mem_fun(*this, &PlaylistSelector::close_button_click)); } @@ -83,10 +74,10 @@ PlaylistSelector::~PlaylistSelector () void PlaylistSelector::clear_map () { - for (DSPL_Map::iterator x = dspl_map.begin(); x != dspl_map.end(); ++x) { + for (TrackPlaylistMap::iterator x = trpl_map.begin(); x != trpl_map.end(); ++x) { delete x->second; } - dspl_map.clear (); + trpl_map.clear (); } bool @@ -103,53 +94,59 @@ void PlaylistSelector::show_for (RouteUI* ruix) { vector item; - boost::shared_ptr this_ds; string str; rui = ruix; - WindowTitle title(Glib::get_application_name()); - title += string_compose (_("Playlist for %1"), rui->route()->name()); - set_title (title.get_string()); + set_title (string_compose (_("Playlist for %1"), rui->route()->name())); clear_map (); select_connection.disconnect (); model->clear (); - - session->foreach_playlist (this, &PlaylistSelector::add_playlist_to_map); - this_ds = rui->get_diskstream(); + _session->playlists->foreach (this, &PlaylistSelector::add_playlist_to_map); + + boost::shared_ptr this_track = rui->track(); TreeModel::Row others = *(model->append ()); others[columns.text] = _("Other tracks"); boost::shared_ptr proxy = others[columns.playlist]; proxy.reset (); - - for (DSPL_Map::iterator x = dspl_map.begin(); x != dspl_map.end(); ++x) { - boost::shared_ptr ds = session->diskstream_by_id (x->first); + for (TrackPlaylistMap::iterator x = trpl_map.begin(); x != trpl_map.end(); ++x) { + + boost::shared_ptr tr = boost::dynamic_pointer_cast (_session->route_by_id (x->first)); + + /* legacy sessions stored the diskstream ID as the original + * playlist owner. so try there instead. + */ - if (ds == 0) { + if (tr == 0) { + tr = _session->track_by_diskstream_id (x->first); + } + + if (tr == 0) { continue; } - /* add a node for the diskstream */ + /* add a node for the track */ string nodename; - if (ds->name().empty()) { + if (tr->name().empty()) { nodename = _("unassigned"); } else { - nodename = ds->name().c_str(); + 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 (ds == this_ds) { + if (tr == this_track) { row = *(model->prepend()); row[columns.text] = nodename; boost::shared_ptr proxy = row[columns.playlist]; @@ -162,9 +159,9 @@ PlaylistSelector::show_for (RouteUI* ruix) } /* Now insert all the playlists for this diskstream/track in a subtree */ - - list > *pls = x->second; - + + list >* pls = x->second; + for (list >::iterator p = pls->begin(); p != pls->end(); ++p) { TreeModel::Row child_row; @@ -173,22 +170,24 @@ PlaylistSelector::show_for (RouteUI* ruix) child_row[columns.text] = (*p)->name(); child_row[columns.playlist] = *p; - if (*p == this_ds->playlist()) { - selected_row = &child_row; - } + if (*p == this_track->playlist()) { + 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); } } // Add unassigned (imported) playlists to the list list > unassigned; - session->unassigned_playlists (unassigned); + _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,17 +202,18 @@ PlaylistSelector::show_for (RouteUI* ruix) child_row[columns.text] = (*p)->name(); child_row[columns.playlist] = *p; - if (*p == this_ds->playlist()) { - selected_row = &child_row; + if (*p == this_track->playlist()) { + 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); } } show_all (); - select_connection = tree.get_selection()->signal_changed().connect (mem_fun(*this, &PlaylistSelector::selection_changed)); + select_connection = tree.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &PlaylistSelector::selection_changed)); } void @@ -224,35 +224,20 @@ PlaylistSelector::add_playlist_to_map (boost::shared_ptr pl) if (pl->frozen()) { return; } - + if ((apl = boost::dynamic_pointer_cast (pl)) == 0) { return; } - DSPL_Map::iterator x; - - if ((x = dspl_map.find (apl->get_orig_diskstream_id())) == dspl_map.end()) { + TrackPlaylistMap::iterator x; - pair >*> newp (apl->get_orig_diskstream_id(), new list >); - - x = dspl_map.insert (dspl_map.end(), newp); + if ((x = trpl_map.find (apl->get_orig_track_id())) == trpl_map.end()) { + x = trpl_map.insert (trpl_map.end(), make_pair (apl->get_orig_track_id(), new list >)); } x->second->push_back (pl); } -void -PlaylistSelector::set_session (Session* s) -{ - ENSURE_GUI_THREAD(bind (mem_fun(*this, &PlaylistSelector::set_session), s)); - - session = s; - - if (session) { - session->GoingAway.connect (bind (mem_fun(*this, &PlaylistSelector::set_session), static_cast (0))); - } -} - void PlaylistSelector::close_button_click () { @@ -273,24 +258,24 @@ PlaylistSelector::selection_changed () } if ((playlist = ((*iter)[columns.playlist])) != 0) { - + boost::shared_ptr at; boost::shared_ptr apl; - + if ((at = rui->audio_track()) == 0) { /* eh? */ return; } - + if ((apl = boost::dynamic_pointer_cast (playlist)) == 0) { /* eh? */ return; } - - at->diskstream()->use_playlist (apl); + + at->use_playlist (apl); hide (); } } - +