- NSArray *myMenu = [df arrayForKey:@"menu"];
- int playlist = [currentRemote currentPlaylistIndex];
- int i;
-
- if ([currentRemote playerRunningState] == ITMTRemotePlayerNotRunning) {
- return;
- }
-
- trackInfoIndex = -1;
- lastPlaylistIndex = -1;
-
- [menu release];
- menu = [[NSMenu alloc] initWithTitle:@""];
-
- playPauseItem = nil;
-
- upcomingSongsItem = nil;
- [upcomingSongsMenu release];
- upcomingSongsMenu = nil;
-
- if (ratingItem) {
- [ratingItem setSubmenu:nil];
- }
-
- playlistItem = nil;
- [playlistMenu release];
- playlistMenu = nil;
-
- eqItem = nil;
- [eqMenu release];
- eqMenu = nil;
-
- //Build the custom menu
- for (i = 0; i < [myMenu count]; i++) {
- NSString *item = [myMenu objectAtIndex:i];
- if ([item isEqualToString:@"Play/Pause"]) {
- KeyCombo *tempCombo = [df keyComboForKey:@"PlayPause"];
- playPauseItem = [menu addItemWithTitle:@"Play"
- action:@selector(playPause:)
- keyEquivalent:@""];
-
- if (tempCombo) {
- [self setKeyEquivalentForCode:[tempCombo keyCode]
- andModifiers:[tempCombo modifiers] onItem:playPauseItem];
- [tempCombo release];
- }
- } else if ([item isEqualToString:@"Next Track"]) {
- KeyCombo *tempCombo = [df keyComboForKey:@"NextTrack"];
- NSMenuItem *nextTrack = [menu addItemWithTitle:@"Next Track"
- action:@selector(nextSong:)
- keyEquivalent:@""];
-
- if (tempCombo) {
- [self setKeyEquivalentForCode:[tempCombo keyCode]
- andModifiers:[tempCombo modifiers] onItem:nextTrack];
- [tempCombo release];
- }
- } else if ([item isEqualToString:@"Previous Track"]) {
- KeyCombo *tempCombo = [df keyComboForKey:@"PrevTrack"];
- NSMenuItem *prevTrack = [menu addItemWithTitle:@"Previous Track"
- action:@selector(prevSong:)
- keyEquivalent:@""];
-
- if (tempCombo) {
- [self setKeyEquivalentForCode:[tempCombo keyCode]
- andModifiers:[tempCombo modifiers] onItem:prevTrack];
- [tempCombo release];
- }
- } else if ([item isEqualToString:@"Fast Forward"]) {
- [menu addItemWithTitle:@"Fast Forward"
- action:@selector(fastForward:)
- keyEquivalent:@""];
- } else if ([item isEqualToString:@"Rewind"]) {
- [menu addItemWithTitle:@"Rewind"
- action:@selector(rewind:)
- keyEquivalent:@""];
- } else if ([item isEqualToString:@"Show Player"]) {
- [menu addItemWithTitle:[NSString stringWithFormat:@"Show %@", [currentRemote playerSimpleName]]
- action:@selector(showPlayer:)
- keyEquivalent:@""];
- } else if ([item isEqualToString:@"Upcoming Songs"]) {
- upcomingSongsItem = [menu addItemWithTitle:@"Upcoming Songs"
- action:nil
- keyEquivalent:@""];
- upcomingSongsMenu = [[NSMenu alloc] initWithTitle:@""];
- [upcomingSongsItem setSubmenu:upcomingSongsMenu];
- [upcomingSongsItem setEnabled:NO];
- } else if ([item isEqualToString:@"Playlists"]) {
- playlistItem = [menu addItemWithTitle:@"Playlists"
- action:nil
- keyEquivalent:@""];
- } else if ([item isEqualToString:@"EQ Presets"]) {
- eqItem = [menu addItemWithTitle:@"EQ Presets"
- action:nil
- keyEquivalent:@""];
- } else if ([item isEqualToString:@"Preferences…"]) {
- [menu addItemWithTitle:@"Preferences…"
- action:@selector(showPreferences:)
- keyEquivalent:@""];
- } else if ([item isEqualToString:@"Quit"]) {
- [menu addItemWithTitle:@"Quit"
- action:@selector(quitMenuTunes:)
- keyEquivalent:@""];
- } else if ([item isEqualToString:@"Current Track Info"]) {
- trackInfoIndex = [menu numberOfItems];
- [menu addItemWithTitle:@"No Song"
- action:nil
- keyEquivalent:@""];
- } else if ([item isEqualToString:@"Song Rating"]) {
- ratingItem = [menu addItemWithTitle:@"Song Rating"
- action:nil
- keyEquivalent:@""];
- [ratingItem setSubmenu:ratingMenu];
- } else if ([item isEqualToString:@"<separator>"]) {
- [menu addItem:[NSMenuItem separatorItem]];
- }
- }
-
- if (playlistItem) {
- [self rebuildPlaylistMenu];
- }
-
- if (eqItem) {
- [self rebuildEQPresetsMenu];
- }
-
- isPlayingRadio = ([currentRemote classOfPlaylistAtIndex:playlist] == ITMTRemotePlayerRadioPlaylist);
-
- if (upcomingSongsItem) {
- [self rebuildUpcomingSongsMenu];