+- (NSMenu *)menuForNoPlayer
+{
+ NSMenu *menu = [[NSMenu alloc] initWithTitle:@""];
+ NSMenuItem *tempItem;
+ tempItem = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"open", @"Open"), [[[MainController sharedController] currentRemote] playerSimpleName]] action:@selector(performMainMenuAction:) keyEquivalent:@""];
+ [tempItem setTag:MTMenuShowPlayerItem];
+ [tempItem setTarget:self];
+ [menu addItem:[NSMenuItem separatorItem]];
+ tempItem = [menu addItemWithTitle:NSLocalizedString(@"preferences", @"Preferences...") action:@selector(performMainMenuAction:) keyEquivalent:@""];
+ [tempItem setTag:MTMenuPreferencesItem];
+ [tempItem setTarget:self];
+ tempItem = [menu addItemWithTitle:NSLocalizedString(@"quit", @"Quit") action:@selector(performMainMenuAction:) keyEquivalent:@""];
+ [tempItem setTag:MTMenuQuitItem];
+ [tempItem setTarget:self];
+ return [menu autorelease];
+}
+
+- (void)rebuildSubmenus
+{
+ currentRemote = [[MainController sharedController] currentRemote];
+ _currentPlaylist = [currentRemote currentPlaylistIndex];
+ _currentTrack = [currentRemote currentSongIndex];
+ _playingRadio = ([currentRemote currentPlaylistClass] == ITMTRemotePlayerRadioPlaylist);
+
+ [_ratingMenu release];
+ [_upcomingSongsMenu release];
+ [_playlistsMenu release];
+ [_eqMenu release];
+ _ratingMenu = [self ratingMenu];
+ _upcomingSongsMenu = [self upcomingSongsMenu];
+ _playlistsMenu = [self playlistsMenu];
+ _eqMenu = [self eqMenu];
+}
+
+- (NSMenu *)ratingMenu
+{
+ NSMenu *ratingMenu = [[NSMenu alloc] initWithTitle:@""];
+ NSEnumerator *itemEnum;
+ id anItem;
+ int itemTag = 0;
+ SEL itemSelector = @selector(performRatingMenuAction:);
+
+ [ratingMenu addItemWithTitle:[NSString stringWithUTF8String:"☆☆☆☆☆"] action:nil keyEquivalent:@""];
+ [ratingMenu addItemWithTitle:[NSString stringWithUTF8String:"★☆☆☆☆"] action:nil keyEquivalent:@""];
+ [ratingMenu addItemWithTitle:[NSString stringWithUTF8String:"★★☆☆☆"] action:nil keyEquivalent:@""];
+ [ratingMenu addItemWithTitle:[NSString stringWithUTF8String:"★★★☆☆"] action:nil keyEquivalent:@""];
+ [ratingMenu addItemWithTitle:[NSString stringWithUTF8String:"★★★★☆"] action:nil keyEquivalent:@""];
+ [ratingMenu addItemWithTitle:[NSString stringWithUTF8String:"★★★★★"] action:nil keyEquivalent:@""];
+
+ itemEnum = [[ratingMenu itemArray] objectEnumerator];
+ while ( (anItem = [itemEnum nextObject]) ) {
+ [anItem setAction:itemSelector];
+ [anItem setTarget:self];
+ [anItem setTag:itemTag];
+ itemTag += 20;
+ }
+ return ratingMenu;
+}
+
+- (NSMenu *)upcomingSongsMenu
+{
+ NSMenu *upcomingSongsMenu = [[NSMenu alloc] initWithTitle:@""];
+ int numSongs = [currentRemote numberOfSongsInPlaylistAtIndex:_currentPlaylist];
+ int numSongsInAdvance = [[NSUserDefaults standardUserDefaults] integerForKey:@"SongsInAdvance"];
+
+ if (_currentPlaylist && !_playingRadio) {
+ if (numSongs > 0) {
+ int i;
+
+ for (i = _currentTrack + 1; i <= _currentTrack + numSongsInAdvance; i++) {
+ if (i <= numSongs) {
+ NSString *curSong = [currentRemote songTitleAtIndex:i];
+ NSMenuItem *songItem;
+ songItem = [upcomingSongsMenu addItemWithTitle:curSong action:@selector(performUpcomingSongsMenuAction:) keyEquivalent:@""];
+ [songItem setTag:i];
+ [songItem setTarget:self];
+ } else {
+ break;
+ }
+ }
+ }
+ }
+ return upcomingSongsMenu;
+}
+
+- (NSMenu *)playlistsMenu
+{
+ NSMenu *playlistsMenu = [[NSMenu alloc] initWithTitle:@""];
+ NSArray *playlists = [currentRemote playlists];
+ NSMenuItem *tempItem;
+ int i;
+
+ for (i = 0; i < [playlists count]; i++) {
+ tempItem = [playlistsMenu addItemWithTitle:[playlists objectAtIndex:i] action:@selector(performPlaylistMenuAction:) keyEquivalent:@""];
+ [tempItem setTag:i + 1];
+ [tempItem setTarget:self];
+ }
+
+ if (!_playingRadio && _currentPlaylist) {
+ [[playlistsMenu itemAtIndex:_currentPlaylist - 1] setState:NSOnState];
+ }
+ return playlistsMenu;
+}
+
+- (NSMenu *)eqMenu
+{
+ NSMenu *eqMenu = [[NSMenu alloc] initWithTitle:@""];
+ NSArray *eqPresets = [currentRemote eqPresets];
+ NSMenuItem *tempItem;
+ int i;
+
+ for (i = 0; i < [eqPresets count]; i++) {
+ NSString *name;
+ if ( ( name = [eqPresets objectAtIndex:i] ) ) {
+ tempItem = [eqMenu addItemWithTitle:name action:@selector(performEqualizerMenuAction:) keyEquivalent:@""];
+ [tempItem setTag:i];
+ [tempItem setTarget:self];
+ }
+ }
+ return eqMenu;
+}
+