[Slim-Checkins] r33807 - in /7.7/trunk/server: Changelog7.html Slim/Menu/TrackInfo.pm

[email protected] Thu, 02 Feb 2012 12:18:32 -0000
Newsgroups gmane.music.equipment.slimdevices.cvs
Message-ID <[email protected]>
Author: ayoung
Date: Thu Feb  2 04:18:32 2012
New Revision: 33807

URL: http://svn.slimdevices.com/slim?rev=33807&view=rev
Log:
bug 17876: Unnecessary items in context menu for current-playlist tracks 

‪1.‬ No "Remove from playlist" if only item in playlist
‪2.‬ No "Play Next" if only item in playlist or current (playing) item or next item
‪3.‬ No "Play" if current item and playing.

When playing a radio station this removes 3 unnecessary items from the top of the CM. It also removes some unnecessary items in other circumstances. 

Modified:
    7.7/trunk/server/Changelog7.html
    7.7/trunk/server/Slim/Menu/TrackInfo.pm

Modified: 7.7/trunk/server/Changelog7.html
URL: http://svn.slimdevices.com/slim/7.7/trunk/server/Changelog7.html?rev=33807&r1=33806&r2=33807&view=diff
==============================================================================
--- 7.7/trunk/server/Changelog7.html (original)
+++ 7.7/trunk/server/Changelog7.html Thu Feb  2 04:18:32 2012
@@ -5,6 +5,7 @@
 		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=17835">#17835</a> - playlistcontrol cmd:load ... play_index:yyyy doesn't work with folders</li>
 		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=17837">#17837</a> - Browse Music Folder fails if a file of unwanted/invalid type is in a folder</li>
 		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=17855">#17855</a> - Only enable single output channel mode if actively synced</li>
+		<li><a href="http://bugs.slimdevices.com/show_bug.cgi?id=17876">#17876</a> - Unnecessary items in context menu for current-playlist tracks</li>
 	</ul>
 	<br />
 </ul>

Modified: 7.7/trunk/server/Slim/Menu/TrackInfo.pm
URL: http://svn.slimdevices.com/slim/7.7/trunk/server/Slim/Menu/TrackInfo.pm?rev=33807&r1=33806&r2=33807&view=diff
==============================================================================
--- 7.7/trunk/server/Slim/Menu/TrackInfo.pm (original)
+++ 7.7/trunk/server/Slim/Menu/TrackInfo.pm Thu Feb  2 04:18:32 2012
@@ -440,6 +440,11 @@
 
 	# "Play Song" in current playlist context is 'jump'
 	if ( $tags->{menuContext} eq 'playlist' ) {
+		
+		# do not add item if this is current track and already playing
+		return [] if $tags->{playlistIndex} == Slim::Player::Source::playingSongIndex($client)
+					&& $client->isPlaying();
+		
 		$actions = {
 			go => {
 				player => 0,
@@ -485,10 +490,7 @@
 sub addTrackNext {
 	my ( $client, $url, $track, $remoteMeta, $tags ) = @_;
 	my $string = cstring($client, 'PLAY_NEXT');
-	my $cmd = 'insert';
-	if ( $tags->{menuContext} eq 'playlist' ) {
-		$cmd = 'playlistnext';
-	}
+	my $cmd = $tags->{menuContext} eq 'playlist' ? 'playlistnext' : 'insert';
 	
 	return addTrack( $client, $url, $track, $remoteMeta, $tags, $string, $cmd );
 }
@@ -496,13 +498,15 @@
 sub addTrackEnd {
 	my ( $client, $url, $track, $remoteMeta, $tags ) = @_;
 
-	my $string = cstring($client, 'ADD_TO_END');
-	my $cmd = 'add';
+	my ($string, $cmd);
 
 	# "Add Song" in current playlist context is 'delete'
 	if ( $tags->{menuContext} eq 'playlist' ) {
 		$string = cstring($client, 'REMOVE_FROM_PLAYLIST');
-		$cmd = 'delete';
+		$cmd    = 'delete';
+	} else {
+		$string = cstring($client, 'ADD_TO_END');
+		$cmd    = 'add';
 	}
 	
 	return addTrack( $client, $url, $track, $remoteMeta, $tags, $string, $cmd );
@@ -519,7 +523,10 @@
 	my $actions;
 	# remove from playlist
 	if ( $cmd eq 'delete' ) {
-		$string  = cstring($client, 'REMOVE_FROM_PLAYLIST');
+		
+		# Do not add this item if only one item in playlist
+		return [] if Slim::Player::Playlist::count($client) < 2;
+
 		$actions = {
 			go => {
 				player     => 0,
@@ -534,7 +541,15 @@
 
 	# play next in the playlist context
 	} elsif ( $cmd eq 'playlistnext' ) {
+		
+		# Do not add this item if only one item in playlist
+		return [] if Slim::Player::Playlist::count($client) < 2;
+
 		my $moveTo = Slim::Player::Source::playingSongIndex($client) || 0;
+		
+		# do not add item if this is current track or already the next track
+		return [] if $tags->{playlistIndex} == $moveTo || $tags->{playlistIndex} == $moveTo+1;
+		
 		if ( $tags->{playlistIndex} > $moveTo ) {
 			$moveTo = $moveTo + 1;
 		}

_______________________________________________
checkins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/checkins