X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/a5c365dd668dee7c653dbafee270e5e05025a2ab..4416c262f94695ab705ab81826b10540923407e4:/MainController.m diff --git a/MainController.m b/MainController.m index 5406ad9..da07757 100755 --- a/MainController.m +++ b/MainController.m @@ -357,9 +357,22 @@ static MainController *sharedController; - (void)timerUpdate { - if ( [self songChanged] && (timerUpdating != YES) && (playerRunningState == ITMTRemotePlayerRunning) ) { - ITDebugLog(@"The song changed."); - + if ([[self currentRemote] playerStateUniqueIdentifier] == nil) { + if ([statusItem isEnabled]) { + [statusItem setToolTip:@"iTunes not responding."]; + [self clearHotKeys]; + } + [statusItem setEnabled:NO]; + return; + } else if (![statusItem isEnabled]) { + [statusItem setEnabled:YES]; + [statusItem setToolTip:_toolTip]; + [self setupHotKeys]; + return; + } + + if ( [self songChanged] && (timerUpdating != YES) && (playerRunningState == ITMTRemotePlayerRunning) ) { + ITDebugLog(@"The song changed. '%@'", _latestSongIdentifier); if ([df boolForKey:@"runScripts"]) { NSArray *scripts = [[NSFileManager defaultManager] directoryContentsAtPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"]]; NSEnumerator *scriptsEnum = [scripts objectEnumerator]; @@ -393,16 +406,15 @@ static MainController *sharedController; if ( [df boolForKey:@"showToolTip"] ) { NSString *artist = [[self currentRemote] currentSongArtist]; NSString *title = [[self currentRemote] currentSongTitle]; - NSString *toolTip; ITDebugLog(@"Creating status item tooltip."); if (artist) { - toolTip = [NSString stringWithFormat:@"%@ - %@", artist, title]; + _toolTip = [NSString stringWithFormat:@"%@ - %@", artist, title]; } else if (title) { - toolTip = title; + _toolTip = title; } else { - toolTip = @"No Song Playing"; + _toolTip = @"No Song Playing"; } - [statusItem setToolTip:toolTip]; + [statusItem setToolTip:_toolTip]; } else { [statusItem setToolTip:nil]; } @@ -422,6 +434,21 @@ static MainController *sharedController; - (void)menuClicked { ITDebugLog(@"Menu clicked."); + + if ([[self currentRemote] playerStateUniqueIdentifier] == nil) { + if ([statusItem isEnabled]) { + [statusItem setToolTip:@"iTunes not responding."]; + [self clearHotKeys]; + } + [statusItem setEnabled:NO]; + return; + } else if (![statusItem isEnabled]) { + [statusItem setEnabled:YES]; + [statusItem setToolTip:_toolTip]; + [self setupHotKeys]; + return; + } + if ([networkController isConnectedToServer]) { //Used the cached version return; @@ -1003,8 +1030,9 @@ static MainController *sharedController; - (void)popupMenu { if (!_popped) { - NSMenu *menu = [menuController menu]; _popped = YES; + [self menuClicked]; + NSMenu *menu = [statusItem menu]; [(NSCarbonMenuImpl *)[menu _menuImpl] popUpMenu:menu atLocation:[NSEvent mouseLocation] width:1 forView:nil withSelectedItem:-30 withFont:[NSFont menuFontOfSize:32]]; _popped = NO; }