(12:51) Kent: Shall I commit my l33tness/
[MenuTunes.git] / MenuTunes.m
index 7c5e543..54f5768 100755 (executable)
@@ -594,7 +594,7 @@ Things to do:
 - (void)timerUpdate
 {
     int playlist = [currentRemote currentPlaylistIndex];
-    PlayerState playerState = [currentRemote playerState];
+    ITMTRemotePlayerState playerState = [currentRemote playerState];
     
     if ((playlist > 0) || playerState != stopped) {
         int trackPlayingIndex = [currentRemote currentSongIndex];
@@ -661,6 +661,41 @@ Things to do:
                 [playPauseMenuItem setTitle:@"Play"];
             }
         }
+    } else if ((lastPlaylistIndex > 0) && (playlist == 0)) {
+        NSMenuItem *menuItem;
+        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+        //Remote the now playing item and add no song item
+        [menu removeItemAtIndex:trackInfoIndex];
+        
+        if ([defaults boolForKey:@"showName"] == YES) {
+            [menu removeItemAtIndex:trackInfoIndex];
+        }
+        
+        if ([defaults boolForKey:@"showTime"] == YES) {
+            [menu removeItemAtIndex:trackInfoIndex];
+        }
+        
+        if (didHaveArtistName && [defaults boolForKey:@"showArtist"]) {
+            [menu removeItemAtIndex:trackInfoIndex];
+        }
+        
+        if (didHaveAlbumName && [defaults boolForKey:@"showAlbum"]) {
+            [menu removeItemAtIndex:trackInfoIndex];
+        }
+        
+        [playPauseMenuItem setTitle:@"Play"];
+        
+        didHaveArtistName = NO;
+        didHaveAlbumName = NO;
+        lastPlaylistIndex = -1;
+        lastSongIndex = -1;
+        
+        [upcomingSongsItem setSubmenu:nil];
+        [upcomingSongsItem setEnabled:NO];
+        
+        menuItem = [[NSMenuItem alloc] initWithTitle:@"No Song" action:nil keyEquivalent:@""];
+        [menu insertItem:menuItem atIndex:trackInfoIndex];
+        [menuItem release];
     }
 }
 
@@ -713,7 +748,9 @@ Things to do:
     int playlist = [[sender representedObject] intValue];
     if (!isPlayingRadio) {
         int curPlaylist = [currentRemote currentPlaylistIndex];
-        [[playlistMenu itemAtIndex:curPlaylist - 1] setState:NSOffState];
+        if (curPlaylist > 0) {
+            [[playlistMenu itemAtIndex:curPlaylist - 1] setState:NSOffState];
+        }
     }
     [currentRemote switchToPlaylistAtIndex:playlist];
     [[playlistMenu itemAtIndex:playlist - 1] setState:NSOnState];
@@ -731,7 +768,7 @@ Things to do:
 
 - (void)playPause:(id)sender
 {
-    PlayerState state = [currentRemote playerState];
+    ITMTRemotePlayerState state = [currentRemote playerState];
     
     if (state == playing) {
         [currentRemote pause];