From 0b727e3ec3a58f5751bb8f41079162c1c4c09e2d Mon Sep 17 00:00:00 2001 From: Kent Sutherland Date: Sun, 12 Sep 2004 23:41:03 +0000 Subject: [PATCH] More fixes on timeout poop --- MainController.m | 8 +++++++- MenuController.m | 1 - iTunesRemote.m | 14 +++++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/MainController.m b/MainController.m index da07757..4eb7891 100755 --- a/MainController.m +++ b/MainController.m @@ -11,6 +11,10 @@ #import "StatusWindowController.h" #import "StatusItemHack.h" +@interface NSMenu (MenuImpl) +- (id)_menuImpl; +@end + @interface NSCarbonMenuImpl:NSObject { NSMenu *_menu; @@ -435,7 +439,7 @@ static MainController *sharedController; { ITDebugLog(@"Menu clicked."); - if ([[self currentRemote] playerStateUniqueIdentifier] == nil) { + if ( ([[self currentRemote] playerStateUniqueIdentifier] == nil) && playerRunningState == ITMTRemotePlayerRunning ) { if ([statusItem isEnabled]) { [statusItem setToolTip:@"iTunes not responding."]; [self clearHotKeys]; @@ -1393,6 +1397,8 @@ static MainController *sharedController; [refreshTimer invalidate]; [refreshTimer release]; refreshTimer = nil; + [statusItem setEnabled:YES]; + [statusItem setToolTip:@"iTunes not running."]; [self clearHotKeys]; if ([df objectForKey:@"ShowPlayer"] != nil) { diff --git a/MenuController.m b/MenuController.m index 7cc59fb..424957f 100755 --- a/MenuController.m +++ b/MenuController.m @@ -570,7 +570,6 @@ { NSMenu *upcomingSongsMenu = [[NSMenu alloc] initWithTitle:@""]; int numSongs = 0, numSongsInAdvance = [[NSUserDefaults standardUserDefaults] integerForKey:@"SongsInAdvance"]; - NS_DURING numSongs = [[[MainController sharedController] currentRemote] numberOfSongsInPlaylistAtIndex:_currentPlaylist]; NS_HANDLER diff --git a/iTunesRemote.m b/iTunesRemote.m index b6b539c..34d49bd 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -262,9 +262,17 @@ - (int)numberOfSongsInPlaylistAtIndex:(int)index { + /* + This method only returns the proper number if there's something playing. + This is because it gets the container of the current playlist so that it + gets the playlist index from the current source. Operating this way is fine, + since MT only ever calls this method when there is something playlist. + A working version of this that works in just the main source is in the + makePlaylistWithTerm:ofType: method. + */ int temp1; ITDebugLog(@"Getting number of songs in playlist at index %i", index); - temp1 = [ITSendAEWithString([NSString stringWithFormat:@"kocl:type('cTrk'), '----':obj { form:'indx', want:type('cPly'), seld:long(%lu), from:obj { form:'prop', want:type('prop'), seld:type('ctnr'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } } }",index], 'core', 'getd', &savedPSN) int32Value]; + temp1 = (int)[ITSendAEWithString([NSString stringWithFormat:@"kocl:type('cTrk'), '----':obj { form:'indx', want:type('cPly'), seld:long(%lu), from:obj { form:'prop', want:type('prop'), seld:type('ctnr'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } } }", index], 'core', 'cnte', &savedPSN) int32Value]; ITDebugLog(@"Getting number of songs in playlist at index %i done", index); return temp1; } @@ -766,7 +774,7 @@ - (BOOL)makePlaylistWithTerm:(NSString *)term ofType:(int)type { int i; - + //Get fixed indexing status BOOL fixed = [ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pFix'), from:'null'() }", 'core', 'getd', &savedPSN) booleanValue]; @@ -779,7 +787,7 @@ //If MenuTunes playlist exists if ([ITSendAEWithString(@"'----':obj { form:'name', want:type('cPly'), seld:\"MenuTunes\", from:'null'() }", 'core', 'doex', &savedPSN) booleanValue]) { //Clear old MenuTunes playlist - int numSongs = [ITSendAEWithString(@"kocl:type('cTrk'), '----':obj { form:'name', want:type('cPly'), seld:\"MenuTunes\", from:obj { form:'prop', want:type('prop'), seld:type('ctnr'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } } }", 'core', 'cnte', &savedPSN) int32Value]; + int numSongs = [ITSendAEWithString(@"kocl:type('cTrk'), '----':obj { form:'name', want:type('cPly'), seld:\"MenuTunes\", from:'null'() }", 'core', 'cnte', &savedPSN) int32Value]; for (i = 1; i <= numSongs; i++) { ITSendAEWithString(@"'----':obj { form:'indx', want:type('cTrk'), seld:long(1), from:obj { form:'name', want:type('cPly'), seld:\"MenuTunes\", from:'null'() } }", 'core', 'delo', &savedPSN); } -- 2.20.1