X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/a509b00348962d2980891d0c66657028e280e162..36c3c74d44819ba8132041dc3b4ee793c2109a69:/MainController.m diff --git a/MainController.m b/MainController.m index a480e3b..518d86f 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; } @@ -50,6 +51,9 @@ static MainController *sharedController; SetITDebugMode(YES); } + bling = [[MTBlingController alloc] init]; + blingDate = nil; + currentRemote = [self loadRemote]; [currentRemote begin]; @@ -86,6 +90,8 @@ static MainController *sharedController; [statusItem setImage:[NSImage imageNamed:@"MenuNormal"]]; [statusItem setAlternateImage:[NSImage imageNamed:@"MenuInverted"]]; + + [NSApp deactivate]; } - (ITMTRemote *)loadRemote @@ -142,6 +148,32 @@ static MainController *sharedController; [pool release]; }*/ +- (void)blingTime +{ + NSDate *now = [NSDate date]; + if ( (! blingDate) || ([now timeIntervalSinceDate:blingDate] >= 86400) ) { + [bling showPanelIfNeeded]; + [blingDate autorelease]; + blingDate = [now retain]; + } +} + +- (void)blingNow +{ + [bling showPanel]; + [blingDate autorelease]; + blingDate = [[NSDate date] retain]; +} + +- (BOOL)blingBling +{ + if ( ! ([bling checkDone] == 2475) ) { + return NO; + } else { + return YES; + } +} + - (BOOL)songIsPlaying { return ( ! ([[currentRemote playerStateUniqueIdentifier] isEqualToString:@"0-0"]) ); @@ -171,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; } } @@ -464,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"] ) { @@ -479,15 +516,23 @@ 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"] ) { + if ( [df boolForKey:@"showTrackRating"] ) { rating = ( [currentRemote currentSongRating] * 5 ); } @@ -500,8 +545,7 @@ static MainController *sharedController; album:album artist:artist time:time - trackNumber:trackNumber - trackTotal:trackTotal + track:track rating:rating]; } @@ -623,12 +667,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]; } /*************************************************************************/ @@ -688,6 +732,7 @@ static MainController *sharedController; - (void)dealloc { [self applicationTerminated:nil]; + [bling release]; [statusItem release]; [statusWindowController release]; [menuController release];