X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/796f8360ac05b39085aef9f202f635a04ba6834e..2bf1aae48a3e29857c86221d87b7841322e48423:/MenuTunes.m?ds=sidebyside diff --git a/MenuTunes.m b/MenuTunes.m index 487a5bb..532e17d 100755 --- a/MenuTunes.m +++ b/MenuTunes.m @@ -10,7 +10,6 @@ Things to do: #import "MenuTunes.h" #import "PreferencesController.h" #import "HotKeyCenter.h" -#import "StatusWindowController.h" @interface MenuTunes(Private) - (ITMTRemote *)loadRemote; @@ -36,6 +35,7 @@ Things to do: { if ( ( self = [super init] ) ) { remoteArray = [[NSMutableArray alloc] initWithCapacity:1]; + statusWindow = [ITTransientStatusWindow sharedWindow]; } return self; } @@ -126,7 +126,7 @@ Things to do: { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if (![defaults objectForKey:@"menu"]) { - bool found = NO; + BOOL found = NO; NSMutableDictionary *loginwindow; NSMutableArray *loginarray; int i; @@ -444,6 +444,7 @@ Things to do: int curIndex = [currentRemote currentPlaylistIndex]; int numSongs = [currentRemote numberOfSongsInPlaylistAtIndex:curIndex]; int numSongsInAdvance = [[NSUserDefaults standardUserDefaults] integerForKey:@"SongsInAdvance"]; + if (!isPlayingRadio) { if (numSongs > 0) { int curTrack = [currentRemote currentSongIndex]; @@ -460,7 +461,7 @@ Things to do: NSMenuItem *songItem; songItem = [[NSMenuItem alloc] initWithTitle:curSong action:@selector(playTrack:) keyEquivalent:@""]; [songItem setTarget:self]; - [songItem setRepresentedObject:[NSNumber numberWithInt:i]]; + [songItem setRepresentedObject:[NSNumber numberWithInt:i + 1]]; [upcomingSongsMenu addItem:songItem]; [songItem release]; } else { @@ -494,7 +495,7 @@ Things to do: NSMenuItem *tempItem; tempItem = [[NSMenuItem alloc] initWithTitle:playlistName action:@selector(selectPlaylist:) keyEquivalent:@""]; [tempItem setTarget:self]; - [tempItem setRepresentedObject:[NSNumber numberWithInt:i]]; + [tempItem setRepresentedObject:[NSNumber numberWithInt:i + 1]]; [playlistMenu addItem:tempItem]; [tempItem release]; } @@ -520,11 +521,13 @@ Things to do: for (i = 0; i < [eqPresets count]; i++) { NSString *setName = [eqPresets objectAtIndex:i]; NSMenuItem *tempItem; + if (setName) { tempItem = [[NSMenuItem alloc] initWithTitle:setName action:@selector(selectEQPreset:) keyEquivalent:@""]; [tempItem setTarget:self]; [tempItem setRepresentedObject:[NSNumber numberWithInt:i]]; [eqMenu addItem:tempItem]; [tempItem release]; + } } [eqItem setSubmenu:eqMenu]; @@ -578,12 +581,13 @@ Things to do: //Called when the timer fires. - (void)timerUpdate { + NSLog(@"%i", [currentRemote playerState]); if ([currentRemote playerState] != stopped) { int trackPlayingIndex = [currentRemote currentSongIndex]; int playlist = [currentRemote currentPlaylistIndex]; if (trackPlayingIndex != lastSongIndex) { - bool wasPlayingRadio = isPlayingRadio; + BOOL wasPlayingRadio = isPlayingRadio; isPlayingRadio = [[currentRemote classOfPlaylistAtIndex:playlist] isEqualToString:@"radio tuner playlist"]; if (isPlayingRadio && !wasPlayingRadio) { int i; @@ -597,13 +601,14 @@ Things to do: [menu insertItem:temp atIndex:trackInfoIndex + 1]; [temp release]; } + [self updateMenu]; lastSongIndex = trackPlayingIndex; } else { if (playlist != [currentRemote currentPlaylistIndex]) { - bool wasPlayingRadio = isPlayingRadio; + BOOL wasPlayingRadio = isPlayingRadio; isPlayingRadio = [[currentRemote classOfPlaylistAtIndex:playlist] isEqualToString:@"radio tuner playlist"]; if (isPlayingRadio && !wasPlayingRadio) { int i; @@ -701,8 +706,8 @@ Things to do: [currentRemote pause]; [playPauseMenuItem setTitle:@"Play"]; } else if ((state == forwarding) || (state == rewinding)) { - [currentRemote play]; [currentRemote pause]; + [currentRemote play]; } else { [currentRemote play]; [playPauseMenuItem setTitle:@"Pause"]; @@ -722,11 +727,13 @@ Things to do: - (void)fastForward:(id)sender { [currentRemote fastForward]; + [playPauseMenuItem setTitle:@"Play"]; } - (void)rewind:(id)sender { [currentRemote rewind]; + [playPauseMenuItem setTitle:@"Play"]; } // @@ -772,7 +779,7 @@ Things to do: - (void)showCurrentTrackInfo { NSString *trackName = [currentRemote currentSongTitle]; - if (!statusController && [trackName length]) { + if (!statusWindow && [trackName length]) { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSString *stringToShow = @""; @@ -812,8 +819,7 @@ Things to do: } } - statusController = [[StatusWindowController alloc] init]; - [statusController setTrackInfo:stringToShow]; + [statusWindow setTrackInfo:stringToShow]; [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(fadeAndCloseStatusWindow) @@ -825,7 +831,7 @@ Things to do: - (void)showUpcomingSongs { int curPlaylist = [currentRemote currentPlaylistIndex]; - if (!statusController) { + if (!statusWindow) { int numSongs = [currentRemote numberOfSongsInPlaylistAtIndex:curPlaylist]; if (numSongs > 0) { @@ -834,7 +840,7 @@ Things to do: int i; NSString *songs = @""; - statusController = [[StatusWindowController alloc] init]; + statusWindow = [ITTransientStatusWindow sharedWindow]; for (i = curTrack + 1; i <= curTrack + numSongsInAdvance; i++) { if (i <= numSongs) { NSString *curSong = [currentRemote songTitleAtIndex:i]; @@ -842,7 +848,7 @@ Things to do: songs = [songs stringByAppendingString:@"\n"]; } } - [statusController setUpcomingSongs:songs]; + [statusWindow setUpcomingSongs:songs]; [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(fadeAndCloseStatusWindow) @@ -854,9 +860,7 @@ Things to do: - (void)fadeAndCloseStatusWindow { - [statusController fadeWindowOut]; - [statusController release]; - statusController = nil; + [statusWindow orderOut:self]; } - (void)setKeyEquivalentForCode:(short)code andModifiers:(long)modifiers @@ -1067,4 +1071,4 @@ Things to do: [super dealloc]; } -@end \ No newline at end of file +@end