From d9dcd02d15130f2acc79134cf848019218b106c4 Mon Sep 17 00:00:00 2001 From: Kent Sutherland Date: Wed, 2 Nov 2005 03:56:29 +0000 Subject: [PATCH] Set rating hot key ignored if no song is playing. Track info status window toggle works based on "ToggleTrackInfoWithHotKey" key. --- MainController.m | 33 +++++++++++++++++++-------------- iTunesRemote.m | 2 +- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/MainController.m b/MainController.m index c0bec8e..927a278 100755 --- a/MainController.m +++ b/MainController.m @@ -1029,7 +1029,8 @@ static MainController *sharedController; int playCount = -1; //If we're already visible and the setting says so, vanish instead of displaying again. - if ([[StatusWindowController sharedController] currentStatusWindowType] == StatusWindowTrackInfoType && [[StatusWindow sharedWindow] visibilityState] == ITWindowVisibleState) { + if ([df boolForKey:@"ToggleTrackInfoWithHotKey"] && [statusWindowController currentStatusWindowType] == StatusWindowTrackInfoType && [[StatusWindow sharedWindow] visibilityState] == ITWindowVisibleState) { + ITDebugLog(@"Track window is already visible, hiding track window."); [self invalidateStatusWindowUpdateTimer]; [[StatusWindow sharedWindow] vanish:nil]; return; @@ -1046,16 +1047,18 @@ static MainController *sharedController; if ( title ) { if ( [df boolForKey:@"showAlbumArtwork"] ) { - NSSize oldSize, newSize; - NS_DURING - art = [[self currentRemote] currentSongAlbumArt]; - oldSize = [art size]; - if (oldSize.width > oldSize.height) newSize = NSMakeSize(110,oldSize.height * (110.0f / oldSize.width)); - else newSize = NSMakeSize(oldSize.width * (110.0f / oldSize.height),110); - art = [[[[NSImage alloc] initWithData:[art TIFFRepresentation]] autorelease] imageScaledSmoothlyToSize:newSize]; - NS_HANDLER - [self networkError:localException]; - NS_ENDHANDLER + NSSize oldSize, newSize; + NS_DURING + art = [[self currentRemote] currentSongAlbumArt]; + oldSize = [art size]; + if (oldSize.width > oldSize.height) { + newSize = NSMakeSize(110,oldSize.height * (110.0f / oldSize.width)); + } + else newSize = NSMakeSize(oldSize.width * (110.0f / oldSize.height),110); + art = [[[[NSImage alloc] initWithData:[art TIFFRepresentation]] autorelease] imageScaledSmoothlyToSize:newSize]; + NS_HANDLER + [self networkError:localException]; + NS_ENDHANDLER } if ( [df boolForKey:@"showAlbum"] ) { @@ -1336,9 +1339,11 @@ static MainController *sharedController; - (void)setRating:(ITHotKey *)sender { - int stars = [[sender name] characterAtIndex:9] - 48; - [self selectSongRating:stars * 20]; - [statusWindowController showRatingWindowWithRating:(float)stars / 5.0]; + if ([self songIsPlaying]) { + int stars = [[sender name] characterAtIndex:9] - 48; + [self selectSongRating:stars * 20]; + [statusWindowController showRatingWindowWithRating:(float)stars / 5.0]; + } } - (void)toggleLoop diff --git a/iTunesRemote.m b/iTunesRemote.m index bfd8a47..8386b3c 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -705,7 +705,7 @@ { ITDebugLog(@"Getting current song album art."); NSData *data = ([self isPlaying]) ? [ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pPCT'), from:obj { form:'indx', want:type('cArt'), seld:long(1), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } } }", 'core', 'getd', &savedPSN) data] : nil; - ITDebugLog(@"Getting current song album art done."); + ITDebugLog(@"Getting current song album art done."); if (data) { return [[[NSImage alloc] initWithData:data] autorelease]; } else { -- 2.20.1