#import "MenuTunes.h"
#import "PreferencesController.h"
#import "HotKeyCenter.h"
-#import "StatusWindowController.h"
@interface MenuTunes(Private)
- (ITMTRemote *)loadRemote;
{
if ( ( self = [super init] ) ) {
remoteArray = [[NSMutableArray alloc] initWithCapacity:1];
+ statusWindow = [ITTransientStatusWindow sharedWindow];
}
return self;
}
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if (![defaults objectForKey:@"menu"]) {
- bool found = NO;
+ BOOL found = NO;
NSMutableDictionary *loginwindow;
NSMutableArray *loginarray;
int i;
int curIndex = [currentRemote currentPlaylistIndex];
int numSongs = [currentRemote numberOfSongsInPlaylistAtIndex:curIndex];
int numSongsInAdvance = [[NSUserDefaults standardUserDefaults] integerForKey:@"SongsInAdvance"];
+
if (!isPlayingRadio) {
if (numSongs > 0) {
int curTrack = [currentRemote currentSongIndex];
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 {
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];
}
//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;
[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;
[currentRemote pause];
[playPauseMenuItem setTitle:@"Play"];
} else if ((state == forwarding) || (state == rewinding)) {
- [currentRemote play];
[currentRemote pause];
+ [currentRemote play];
} else {
[currentRemote play];
[playPauseMenuItem setTitle:@"Pause"];
- (void)fastForward:(id)sender
{
[currentRemote fastForward];
+ [playPauseMenuItem setTitle:@"Play"];
}
- (void)rewind:(id)sender
{
[currentRemote rewind];
+ [playPauseMenuItem setTitle:@"Play"];
}
//
- (void)showCurrentTrackInfo
{
NSString *trackName = [currentRemote currentSongTitle];
- if (!statusController && [trackName length]) {
+ if (!statusWindow && [trackName length]) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *stringToShow = @"";
}
}
- statusController = [[StatusWindowController alloc] init];
- [statusController setTrackInfo:stringToShow];
+ [statusWindow setTrackInfo:stringToShow];
[NSTimer scheduledTimerWithTimeInterval:3.0
target:self
selector:@selector(fadeAndCloseStatusWindow)
- (void)showUpcomingSongs
{
int curPlaylist = [currentRemote currentPlaylistIndex];
- if (!statusController) {
+ if (!statusWindow) {
int numSongs = [currentRemote numberOfSongsInPlaylistAtIndex:curPlaylist];
if (numSongs > 0) {
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];
songs = [songs stringByAppendingString:@"\n"];
}
}
- [statusController setUpcomingSongs:songs];
+ [statusWindow setUpcomingSongs:songs];
[NSTimer scheduledTimerWithTimeInterval:3.0
target:self
selector:@selector(fadeAndCloseStatusWindow)
- (void)fadeAndCloseStatusWindow
{
- [statusController fadeWindowOut];
- [statusController release];
- statusController = nil;
+ [statusWindow orderOut:self];
}
- (void)setKeyEquivalentForCode:(short)code andModifiers:(long)modifiers