summaryrefslogtreecommitdiff
path: root/gtk2_ardour/route_time_axis.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-03-16 15:33:04 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-03-16 15:33:04 +0000
commit6ef5d85ae1f2c500c4163cd1df580b3f26991c1e (patch)
tree15194a52bb72f036117fc4c87c193a4cbb64be8b /gtk2_ardour/route_time_axis.cc
parent830911f6f9451d83a58043b3f9084d3caa164b7b (diff)
changes from 2.X starting in march 2009 through oct 20 2009 (5826 inclusive)
git-svn-id: svn://localhost/ardour2/branches/3.0@6761 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/route_time_axis.cc')
-rw-r--r--gtk2_ardour/route_time_axis.cc57
1 files changed, 36 insertions, 21 deletions
diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc
index 62a2b2b8a0..4674bd3c19 100644
--- a/gtk2_ardour/route_time_axis.cc
+++ b/gtk2_ardour/route_time_axis.cc
@@ -1471,6 +1471,12 @@ RouteTimeAxisView::get_child_list()
}
+struct PlaylistSorter {
+ bool operator() (boost::shared_ptr<Playlist> a, boost::shared_ptr<Playlist> b) const {
+ return a->sort_id() < b->sort_id();
+ }
+};
+
void
RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
{
@@ -1486,32 +1492,36 @@ RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
delete playlist_menu;
- playlist_menu = new Menu;
- playlist_menu->set_name ("ArdourContextMenu");
- vector<boost::shared_ptr<Playlist> > playlists;
+ vector<boost::shared_ptr<Playlist> > playlists, playlists_ds;
boost::shared_ptr<Diskstream> ds = get_diskstream();
RadioMenuItem::Group playlist_group;
_session->playlists->get (playlists);
- for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
-
- if ((*i)->get_orig_diskstream_id() == ds->id()) {
- playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist),
- boost::weak_ptr<Playlist> (*i))));
-
- if (ds->playlist()->id() == (*i)->id()) {
- static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
- }
- } else if (ds->playlist()->id() == (*i)->id()) {
- playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name(), sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist),
- boost::weak_ptr<Playlist>(*i))));
- static_cast<RadioMenuItem*>(&playlist_items.back())->set_active();
-
+ /* find the playlists for this diskstream */
+ for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists.begin(); i != playlists.end(); ++i) {
+ if (((*i)->get_orig_diskstream_id() == ds->id()) || (ds->playlist()->id() == (*i)->id())) {
+ playlists_ds.push_back(*i);
+ }
+ }
+
+ /* sort the playlists */
+ PlaylistSorter cmp;
+ sort(playlists_ds.begin(), playlists_ds.end(), cmp);
+
+ /* add the playlists to the menu */
+ for (vector<boost::shared_ptr<Playlist> >::iterator i = playlists_ds.begin(); i != playlists_ds.end(); ++i) {
+ playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name()));
+ RadioMenuItem *item = static_cast<RadioMenuItem*>(&playlist_items.back());
+ item->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist), item, boost::weak_ptr<Playlist> (*i)));
+
+ if (ds->playlist()->id() == (*i)->id()) {
+ item->set_active();
+
}
}
-
+
playlist_items.push_back (SeparatorElem());
playlist_items.push_back (MenuElem (_("Rename"), sigc::mem_fun(*this, &RouteTimeAxisView::rename_current_playlist)));
playlist_items.push_back (SeparatorElem());
@@ -1535,10 +1545,15 @@ RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu)
}
void
-RouteTimeAxisView::use_playlist (boost::weak_ptr<Playlist> wpl)
+RouteTimeAxisView::use_playlist (RadioMenuItem *item, boost::weak_ptr<Playlist> wpl)
{
assert (is_track());
+ // exit if we were triggered by deactivating the old playlist
+ if (!item->get_active()) {
+ return;
+ }
+
boost::shared_ptr<Playlist> pl (wpl.lock());
if (!pl) {
@@ -1549,8 +1564,8 @@ RouteTimeAxisView::use_playlist (boost::weak_ptr<Playlist> wpl)
if (apl) {
if (get_diskstream()->playlist() == apl) {
- // radio button cotnrols mean this function is called for both the
- // old and new playlist
+ // exit when use_playlist is called by the creation of the playlist menu
+ // or the playlist choice is unchanged
return;
}
get_diskstream()->use_playlist (apl);