+ [tempItem setTarget:self];
+ [tempItem setTag:MTMenuShowPlayerItem];
+ } else if ([nextObject isEqualToString:@"preferences"]) {
+ ITDebugLog(@"Add \"Preferences...\" menu item.");
+ tempItem = [menu addItemWithTitle:NSLocalizedString(@"preferences", @"Preferences...")
+ action:@selector(performMainMenuAction:)
+ keyEquivalent:@""];
+ [tempItem setTag:MTMenuPreferencesItem];
+ [tempItem setTarget:self];
+ } else if ([nextObject isEqualToString:@"quit"]) {
+ if ([[MainController sharedController] blingBling] == NO) {
+ ITDebugLog(@"Add \"Register MenuTunes...\" menu item.");
+ tempItem = [menu addItemWithTitle:NSLocalizedString(@"register", @"Register MenuTunes...") action:@selector(performMainMenuAction:) keyEquivalent:@""];
+ [tempItem setTag:MTMenuRegisterItem];
+ [tempItem setTarget:self];
+ }
+ ITDebugLog(@"Add \"Quit\" menu item.");
+ tempItem = [menu addItemWithTitle:NSLocalizedString(@"quit", @"Quit")
+ action:@selector(performMainMenuAction:)
+ keyEquivalent:@""];
+ [tempItem setTag:MTMenuQuitItem];
+ [tempItem setTarget:self];
+ } else if ([nextObject isEqualToString:@"trackInfo"]) {
+ ITDebugLog(@"Check to see if a Track is playing...");
+ //Handle playing radio too
+ if (_currentPlaylist) {
+ NSString *title;
+ NS_DURING
+ title = [[[MainController sharedController] currentRemote] currentSongTitle];
+ NS_HANDLER
+ [[MainController sharedController] networkError:localException];
+ NS_ENDHANDLER
+ ITDebugLog(@"A Track is Playing, Add \"Track Info\" menu items.");
+ ITDebugLog(@"Add \"Now Playing\" menu item.");
+ [menu addItemWithTitle:NSLocalizedString(@"nowPlaying", @"Now Playing") action:NULL keyEquivalent:@""];
+
+ if ([title length] > 0) {
+ ITDebugLog(@"Add Track Title (\"%@\") menu item.", title);
+ [menu indentItem:
+ [menu addItemWithTitle:title action:nil keyEquivalent:@""]];
+ }
+
+ if (!_playingRadio) {
+ if ([defaults boolForKey:@"showAlbum"]) {
+ NSString *curAlbum;
+ NS_DURING
+ curAlbum = [[[MainController sharedController] currentRemote] currentSongAlbum];
+ NS_HANDLER
+ [[MainController sharedController] networkError:localException];
+ NS_ENDHANDLER
+ ITDebugLog(@"Add Track Album (\"%@\") menu item.", curAlbum);
+ if ( curAlbum ) {
+ [menu indentItem:
+ [menu addItemWithTitle:curAlbum action:nil keyEquivalent:@""]];
+ }
+ }
+
+ if ([defaults boolForKey:@"showArtist"]) {
+ NSString *curArtist;
+ NS_DURING
+ curArtist = [[[MainController sharedController] currentRemote] currentSongArtist];
+ NS_HANDLER
+ [[MainController sharedController] networkError:localException];
+ NS_ENDHANDLER
+ ITDebugLog(@"Add Track Artist (\"%@\") menu item.", curArtist);
+ if ( curArtist ) {
+ [menu indentItem:
+ [menu addItemWithTitle:curArtist action:nil keyEquivalent:@""]];
+ }
+ }
+
+ if ([defaults boolForKey:@"showTrackNumber"]) {
+ int track;
+ NS_DURING
+ track = [[[MainController sharedController] currentRemote] currentSongTrack];
+ NS_HANDLER
+ [[MainController sharedController] networkError:localException];
+ NS_ENDHANDLER
+ ITDebugLog(@"Add Track Number (\"Track %i\") menu item.", track);
+ if ( track > 0 ) {
+ [menu indentItem:
+ [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %i", NSLocalizedString(@"track", @"Track"), track] action:nil keyEquivalent:@""]];
+ }
+ }
+ }
+
+ NS_DURING
+ if ([defaults boolForKey:@"showTime"] && ( ([[[MainController sharedController] currentRemote] currentSongElapsed] != nil) || ([[[MainController sharedController] currentRemote] currentSongLength] != nil) )) {
+ ITDebugLog(@"Add Track Elapsed (\"%@/%@\") menu item.", [[[MainController sharedController] currentRemote] currentSongElapsed], [[[MainController sharedController] currentRemote] currentSongLength]);
+ [menu indentItem:[menu addItemWithTitle:[NSString stringWithFormat:@"%@/%@", [[[MainController sharedController] currentRemote] currentSongElapsed], [[[MainController sharedController] currentRemote] currentSongLength]] action:nil keyEquivalent:@""]];
+ }
+ NS_HANDLER
+ [[MainController sharedController] networkError:localException];
+ NS_ENDHANDLER
+
+ if (!_playingRadio) {
+ NS_DURING
+ if ([defaults boolForKey:@"showTrackRating"] && ( [[[MainController sharedController] currentRemote] currentSongRating] != -1.0 )) {
+ NSString *string = nil;
+ switch ((int)([[[MainController sharedController] currentRemote] currentSongRating] * 5)) {
+ case 0:
+ string = [NSString stringWithUTF8String:"☆☆☆☆☆"];
+ break;
+ case 1:
+ string = [NSString stringWithUTF8String:"★☆☆☆☆"];
+ break;
+ case 2:
+ string = [NSString stringWithUTF8String:"★★☆☆☆"];
+ break;
+ case 3:
+ string = [NSString stringWithUTF8String:"★★★☆☆"];
+ break;
+ case 4:
+ string = [NSString stringWithUTF8String:"★★★★☆"];
+ break;
+ case 5:
+ string = [NSString stringWithUTF8String:"★★★★★"];
+ break;
+ }
+ ITDebugLog(@"Add Track Rating (\"%@\") menu item.", string);
+ [menu indentItem:[menu addItemWithTitle:string action:nil keyEquivalent:@""]];
+ }
+ NS_HANDLER
+ [[MainController sharedController] networkError:localException];
+ NS_ENDHANDLER
+ }
+ } else {
+ ITDebugLog(@"No Track is Playing, Add \"No Song\" menu item.");
+ [menu addItemWithTitle:NSLocalizedString(@"noSong", @"No Song") action:NULL keyEquivalent:@""];
+ }
+ } else if ([nextObject isEqualToString:@"separator"]) {
+ ITDebugLog(@"Add a separator menu item.");
+ [menu addItem:[NSMenuItem separatorItem]];
+ //Submenu items
+ } else if ([nextObject isEqualToString:@"playlists"]) {
+ ITDebugLog(@"Add \"Playlists\" submenu.");
+ tempItem = [menu addItemWithTitle:NSLocalizedString(@"playlists", @"Playlists")
+ action:nil
+ keyEquivalent:@""];
+ [tempItem setSubmenu:_playlistsMenu];
+ [tempItem setTag:3];
+ } else if ([nextObject isEqualToString:@"eqPresets"]) {
+ ITDebugLog(@"Add \"EQ Presets\" submenu.");
+ tempItem = [menu addItemWithTitle:NSLocalizedString(@"eqPresets", @"EQ Presets")
+ action:nil
+ keyEquivalent:@""];
+ [tempItem setSubmenu:_eqMenu];
+ [tempItem setTag:4];
+
+ itemEnum = [[_eqMenu itemArray] objectEnumerator];
+ while ( (tempItem = [itemEnum nextObject]) ) {
+ [tempItem setState:NSOffState];
+ }
+ NS_DURING
+ [[_eqMenu itemAtIndex:([[[MainController sharedController] currentRemote] currentEQPresetIndex] - 1)] setState:NSOnState];
+ NS_HANDLER
+ [[MainController sharedController] networkError:localException];
+ NS_ENDHANDLER
+ } else if ([nextObject isEqualToString:@"songRating"] && currentSongRating) {
+ ITDebugLog(@"Add \"Song Rating\" submenu.");
+ tempItem = [menu addItemWithTitle:NSLocalizedString(@"songRating", @"Song Rating")
+ action:nil
+ keyEquivalent:@""];
+ [tempItem setSubmenu:_ratingMenu];
+ [tempItem setTag:1];
+ if (_playingRadio || !_currentPlaylist) {
+ [tempItem setEnabled:NO];
+ }
+
+ itemEnum = [[_ratingMenu itemArray] objectEnumerator];
+ while ( (tempItem = [itemEnum nextObject]) ) {
+ [tempItem setState:NSOffState];
+ }
+
+ NS_DURING
+ [[_ratingMenu itemAtIndex:([[[MainController sharedController] currentRemote] currentSongRating] * 5)] setState:NSOnState];
+ NS_HANDLER
+ [[MainController sharedController] networkError:localException];
+ NS_ENDHANDLER
+ } else if ([nextObject isEqualToString:@"upcomingSongs"]) {
+ ITDebugLog(@"Add \"Upcoming Songs\" submenu.");
+ tempItem = [menu addItemWithTitle:NSLocalizedString(@"upcomingSongs", @"Upcoming Songs")
+ action:nil
+ keyEquivalent:@""];
+ [tempItem setSubmenu:_upcomingSongsMenu];
+ [tempItem setTag:2];
+ if (_playingRadio || !_currentPlaylist) {
+ [tempItem setEnabled:NO];
+ }