X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/9d8dbcc95c9e3ea959f034d5ddb2edcc71fe1f59..5ba3df3581e79b113dcf5eb6346baf246fa49da2:/MainController.m?ds=sidebyside diff --git a/MainController.m b/MainController.m index 06ae1d9..e6d338b 100755 --- a/MainController.m +++ b/MainController.m @@ -36,9 +36,10 @@ static MainController *sharedController; sharedController = self; remoteArray = [[NSMutableArray alloc] initWithCapacity:1]; - statusWindowController = [[StatusWindowController alloc] init]; + statusWindowController = [StatusWindowController sharedController]; menuController = [[MenuController alloc] init]; df = [[NSUserDefaults standardUserDefaults] retain]; + timerUpdating = NO; } return self; } @@ -89,6 +90,8 @@ static MainController *sharedController; [statusItem setImage:[NSImage imageNamed:@"MenuNormal"]]; [statusItem setAlternateImage:[NSImage imageNamed:@"MenuInverted"]]; + + [NSApp deactivate]; } - (ITMTRemote *)loadRemote @@ -200,15 +203,19 @@ static MainController *sharedController; - (void)timerUpdate { - if ( [self songChanged] ) { + if ( [self songChanged] && (timerUpdating != YES) ) { ITDebugLog(@"The song changed."); - [self setLatestSongIdentifier:[currentRemote playerStateUniqueIdentifier]]; + timerUpdating = YES; latestPlaylistClass = [currentRemote currentPlaylistClass]; [menuController rebuildSubmenus]; if ( [df boolForKey:@"showSongInfoOnChange"] ) { -// [self performSelector:@selector(showCurrentTrackInfo) withObject:nil afterDelay:0.0]; + [self performSelector:@selector(showCurrentTrackInfo) withObject:nil afterDelay:0.0]; } + + [self setLatestSongIdentifier:[currentRemote playerStateUniqueIdentifier]]; + + timerUpdating = NO; } } @@ -493,10 +500,11 @@ static MainController *sharedController; NSString *album = nil; NSString *artist = nil; NSString *time = nil; - int trackNumber = 0; - int trackTotal = 0; + NSString *track = nil; int rating = -1; + ITDebugLog(@"Showing track info status window."); + if ( title ) { if ( [df boolForKey:@"showAlbum"] ) { @@ -508,16 +516,27 @@ static MainController *sharedController; } if ( [df boolForKey:@"showTime"] ) { - time = [currentRemote currentSongLength]; + time = [NSString stringWithFormat:@"%@: %@ / %@", + @"Time", + [currentRemote currentSongElapsed], + [currentRemote currentSongLength]]; } - if ( [df boolForKey:@"showNumber"] ) { - trackNumber = [currentRemote currentSongTrack]; - trackTotal = [currentRemote currentAlbumTrackCount]; + if ( [df boolForKey:@"showTrackNumber"] ) { + int trackNo = [currentRemote currentSongTrack]; + int trackCount = [currentRemote currentAlbumTrackCount]; + + if ( (trackNo > 0) || (trackCount > 0) ) { + track = [NSString stringWithFormat:@"%@: %i %@ %i", + @"Track", trackNo, @"of", trackCount]; + } } - if ( [df boolForKey:@"showRating"] ) { - rating = ( [currentRemote currentSongRating] * 5 ); + if ( [df boolForKey:@"showTrackRating"] ) { + float currentRating = [currentRemote currentSongRating]; + if (currentRating >= 0.0) { + rating = ( currentRating * 5 ); + } } } else { @@ -529,8 +548,7 @@ static MainController *sharedController; album:album artist:artist time:time - trackNumber:trackNumber - trackTotal:trackTotal + track:track rating:rating]; } @@ -652,12 +670,12 @@ static MainController *sharedController; - (void)toggleShuffle { - bool newShuffleEnabled = ![currentRemote shuffleEnabled]; + BOOL newShuffleEnabled = ( ! [currentRemote shuffleEnabled] ); ITDebugLog(@"Toggling shuffle mode."); [currentRemote setShuffleEnabled:newShuffleEnabled]; //Show shuffle status window ITDebugLog(@"Setting shuffle mode to %i", newShuffleEnabled); - [statusWindowController showRepeatWindowWithMode:newShuffleEnabled]; + [statusWindowController showShuffleWindow:newShuffleEnabled]; } /*************************************************************************/