- } else if ([currentItem isEqualToString:@"Fast Forward"]) {
- [[mainMenu addItemWithTitle:@"Fast Forward"action:@selector(fastForward:) keyEquivalent:@""] setTarget:self];
- } else if ([currentItem isEqualToString:@"Rewind"]) {
- [[mainMenu addItemWithTitle:@"Rewind" action:@selector(rewind:) keyEquivalent:@""] setTarget:self];
- } else if ([currentItem isEqualToString:@"EQ Presets"]) {
- [[mainMenu addItemWithTitle:@"EQ Presets" action:NULL keyEquivalent:@""] setSubmenu:[self eqPresetsMenu]];
- } else if ([currentItem isEqualToString:@"Playlists"]) {
- [[mainMenu addItemWithTitle:@"Playlists" action:NULL keyEquivalent:@""] setSubmenu:[self playlistsMenu]];
- } else if ([currentItem isEqualToString:@"Song Rating"]) {
- [[mainMenu addItemWithTitle:@"Song Rating"action:NULL keyEquivalent:@""] setSubmenu:[self songRatingMenu]];
- } else if ([currentItem isEqualToString:@"Upcoming Songs"]) {
- [[mainMenu addItemWithTitle:@"Upcoming Songs"action:NULL keyEquivalent:@""] setSubmenu:[self upcomingSongsMenu]];
- } else if ([currentItem isEqualToString:@"PreferencesÉ"]) {
- [[mainMenu addItemWithTitle:@"Preferences..." action:@selector(showPreferences:) keyEquivalent:@""] setTarget:self];
- } else if ([currentItem isEqualToString:@"Quit"]) {
- [[mainMenu addItemWithTitle:@"Quit" action:@selector(quitMenuTunes:) keyEquivalent:@""] setTarget:self];
- } else if ([currentItem isEqualToString:@"Current Song Info"]) {
- //Current Song Info
- {
- int currentSongIndex = [currentRemote currentSongIndex];
-
- if (currentSongIndex == 0) {
- [mainMenu addItemWithTitle:@"No Song" action:NULL keyEquivalent:@""];
+ } 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:@"Upcoming Songs"]) {
+ upcomingSongsItem = [menu addItemWithTitle:@"Upcoming Songs"
+ action:nil
+ keyEquivalent:@""];
+ } 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"]) {
+ unichar fullstar = 0x2605;
+ unichar emptystar = 0x2606;
+ NSString *fullStarChar = [NSString stringWithCharacters:&fullstar length:1];
+ NSString *emptyStarChar = [NSString stringWithCharacters:&emptystar length:1];
+ NSMenuItem *item;
+
+ ratingItem = [menu addItemWithTitle:@"Song Rating"
+ action:nil
+ keyEquivalent:@""];
+
+ ratingMenu = [[NSMenu alloc] initWithTitle:@""];
+
+ item = [ratingMenu addItemWithTitle:[NSString stringWithFormat:@"%@%@%@%@%@", emptyStarChar, emptyStarChar, emptyStarChar, emptyStarChar, emptyStarChar] action:@selector(selectSongRating:) keyEquivalent:@""];
+ [item setTag:0];
+
+ item = [ratingMenu addItemWithTitle:[NSString stringWithFormat:@"%@%@%@%@%@", fullStarChar, emptyStarChar, emptyStarChar, emptyStarChar, emptyStarChar] action:@selector(selectSongRating:) keyEquivalent:@""];
+ [item setTag:20];
+
+ item = [ratingMenu addItemWithTitle:[NSString stringWithFormat:@"%@%@%@%@%@", fullStarChar, fullStarChar, emptyStarChar, emptyStarChar, emptyStarChar] action:@selector(selectSongRating:) keyEquivalent:@""];
+ [item setTag:40];
+
+ item = [ratingMenu addItemWithTitle:[NSString stringWithFormat:@"%@%@%@%@%@", fullStarChar, fullStarChar, fullStarChar, emptyStarChar, emptyStarChar] action:@selector(selectSongRating:) keyEquivalent:@""];
+ [item setTag:60];
+
+ item = [ratingMenu addItemWithTitle:[NSString stringWithFormat:@"%@%@%@%@%@", fullStarChar, fullStarChar, fullStarChar, fullStarChar, emptyStarChar] action:@selector(selectSongRating:) keyEquivalent:@""];
+ [item setTag:80];
+
+ item = [ratingMenu addItemWithTitle:[NSString stringWithFormat:@"%@%@%@%@%@", fullStarChar, fullStarChar, fullStarChar, fullStarChar, fullStarChar] action:@selector(selectSongRating:) keyEquivalent:@""];
+ [item setTag:100];
+ } else if ([item isEqualToString:@"<separator>"]) {
+ [menu addItem:[NSMenuItem separatorItem]];
+ }
+ }
+
+ [statusItem setMenu:menu];
+
+ [self updateMenu];
+
+ [self clearHotKeys];
+ [self setupHotKeys];
+}
+
+//Rebuild the upcoming songs submenu. Can be improved a lot.
+- (void)rebuildUpcomingSongsMenu
+{
+ int curIndex = [currentRemote currentPlaylistIndex];
+ int numSongs = [currentRemote numberOfSongsInPlaylistAtIndex:curIndex];
+ int numSongsInAdvance = [[NSUserDefaults standardUserDefaults] integerForKey:@"SongsInAdvance"];
+
+ if (!isPlayingRadio) {
+ if (numSongs > 0) {
+ int curTrack = [currentRemote currentSongIndex];
+ int i;
+
+ [upcomingSongsMenu release];
+ upcomingSongsMenu = [[NSMenu alloc] initWithTitle:@""];
+ [upcomingSongsItem setSubmenu:upcomingSongsMenu];
+ [upcomingSongsItem setEnabled:YES];
+
+ for (i = curTrack + 1; i <= curTrack + numSongsInAdvance; i++) {
+ if (i <= numSongs) {
+ NSString *curSong = [currentRemote songTitleAtIndex:i];
+ NSMenuItem *songItem;
+ songItem = [[NSMenuItem alloc] initWithTitle:curSong action:@selector(selectSong:) keyEquivalent:@""];
+ [songItem setRepresentedObject:[NSNumber numberWithInt:i]];
+ [upcomingSongsMenu addItem:songItem];
+ [songItem release];