-
- for (i = 2; i < [playlists count]; i++) {
- NSArray *curPlaylist = [playlists objectAtIndex:i];
- NSString *name = [curPlaylist objectAtIndex:0];
- NSMenu *submenu = [[NSMenu alloc] init];
- ITDebugLog(@"Adding source: %@", name);
-
- if ( ([[curPlaylist objectAtIndex:i] intValue] == ITMTRemoteiPodSource) && (![self iPodAtPathAutomaticallyUpdates:[curPlaylist objectAtIndex:j]]) ) {
- ITDebugLog(@"Invalid iPod source.");
- } else {
- for (j = 2; j < [curPlaylist count]; j++) {
- ITDebugLog(@"Adding playlist: %@", [curPlaylist objectAtIndex:j]);
- tempItem = [submenu addItemWithTitle:[curPlaylist objectAtIndex:j] action:@selector(performPlaylistMenuAction:) keyEquivalent:@""];
- [tempItem setTag:(i * 1000) + j];
- [tempItem setTarget:self];
+
+ //Next go through the other sources
+ if ([playlists count] > 1) {
+ //Add the radio source if it is playing
+ if ([[playlists objectAtIndex:1] sourceType] == ITMTRemoteRadioSource) {
+ [indices addObject:[NSNumber numberWithInt:[[playlists objectAtIndex:1] index]]];
+ if (source == ITMTRemoteRadioSource) {
+ [playlistsMenu addItem:[NSMenuItem separatorItem]];
+ [[playlistsMenu addItemWithTitle:NSLocalizedString(@"radio", @"Radio") action:@selector(performPlaylistMenuAction:) keyEquivalent:@""] setState:NSOnState];
+ } else if ([playlists count] > 2) {
+ [playlistsMenu addItem:[NSMenuItem separatorItem]];
+ }
+ }
+
+ //Add other sources as needed (shared music, iPods, CDs)
+ for (i = [playlists count] - 1; i > 1 ; i--) {
+ PlaylistNode *nextSource = [playlists objectAtIndex:i];
+ if ([nextSource type] != ITMTRemoteRadioSource) {
+ NSString *name = [nextSource name];
+ ITDebugLog(@"Adding source: %@", name);
+
+ if ( ([nextSource type] == ITMTRemoteiPodSource) && [self iPodWithNameAutomaticallyUpdates:name] ) {
+ ITDebugLog(@"Invalid iPod source.");
+ [playlistsMenu addItemWithTitle:name action:NULL keyEquivalent:@""];
+ } else {
+ NSMenu *menu = [[NSMenu alloc] init];
+ [[playlistsMenu addItemWithTitle:name action:NULL keyEquivalent:@""] setSubmenu:[menu autorelease]];
+ [self playlistsMenuAux:menu node:nextSource tagPrefix:(i * 1000)];
+ }
+ ITDebugLog(@"Adding index to the index array.");
+ [indices addObject:[NSNumber numberWithInt:[nextSource index]]];