From 67c27db4fde8f76cff3e419768d8d7a047f4eb50 Mon Sep 17 00:00:00 2001 From: Kent Sutherland Date: Tue, 3 Feb 2004 02:28:19 +0000 Subject: [PATCH] Readding multisource playlist thingy. Added a tooltip showing the current track and artist to the status item. Show Player now toggles the iTunes interface between max/min. --- MainController.m | 12 ++++++++++++ MenuController.m | 18 +++++++++--------- iTunesRemote.m | 20 +++++++++++--------- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/MainController.m b/MainController.m index f9e23ed..05ef785 100755 --- a/MainController.m +++ b/MainController.m @@ -331,6 +331,18 @@ static MainController *sharedController; } [self setLatestSongIdentifier:[[self currentRemote] playerStateUniqueIdentifier]]; + + NSString *artist = [[self currentRemote] currentSongArtist]; + NSString *title = [[self currentRemote] currentSongTitle]; + NSString *toolTip; + if (artist) { + toolTip = [NSString stringWithFormat:@"%@ - %@", artist, title]; + } else if (title) { + toolTip = title; + } else { + toolTip = @"No Song Playing"; + } + [statusItem setToolTip:toolTip]; NS_HANDLER [self networkError:localException]; NS_ENDHANDLER diff --git a/MenuController.m b/MenuController.m index c2970f6..4ab0bf4 100755 --- a/MenuController.m +++ b/MenuController.m @@ -22,7 +22,7 @@ - (NSMenu *)eqMenu; - (void)setKeyEquivalentForCode:(short)code andModifiers:(long)modifiers onItem:(id )item; -//- (BOOL)iPodAtPathAutomaticallyUpdates:(NSString *)name; +- (BOOL)iPodAtPathAutomaticallyUpdates:(NSString *)name; @end @implementation MenuController @@ -525,7 +525,7 @@ return upcomingSongsMenu; } -- (NSMenu *)playlistsMenu +/*- (NSMenu *)playlistsMenu { NSMenu *playlistsMenu = [[NSMenu alloc] initWithTitle:@""]; NSArray *playlists; @@ -563,14 +563,14 @@ } ITDebugLog(@"Done Building \"Playlists\" menu"); return playlistsMenu; -} +}*/ -/*- (NSMenu *)playlistsMenu +- (NSMenu *)playlistsMenu { NSMenu *playlistsMenu = [[NSMenu alloc] initWithTitle:@""]; NSArray *playlists; - NSMenuItem *tempItem; + id tempItem; ITMTRemotePlayerSource source = [[[MainController sharedController] currentRemote] currentSource]; int i, j; NS_DURING @@ -590,7 +590,6 @@ [tempItem setTarget:self]; } } - if ( (source == ITMTRemoteRadioSource) || ([playlists count] - 2 > 0) ) { [playlistsMenu addItem:[NSMenuItem separatorItem]]; } @@ -627,7 +626,7 @@ } ITDebugLog(@"Done Building \"Playlists\" menu"); return playlistsMenu; -}*/ +} - (NSMenu *)eqMenu { @@ -980,7 +979,7 @@ ITDebugLog(@"Done setting key equivalent on menu item: %@", [item title]); } -/*- (BOOL)iPodAtPathAutomaticallyUpdates:(NSString *)name +- (BOOL)iPodAtPathAutomaticallyUpdates:(NSString *)name { NSArray *volumes = [[NSWorkspace sharedWorkspace] mountedLocalVolumePaths]; NSEnumerator *volEnum = [volumes objectEnumerator]; @@ -1010,6 +1009,7 @@ } } } -}*/ + return NO; +} @end \ No newline at end of file diff --git a/iTunesRemote.m b/iTunesRemote.m index 4b04840..0a1335e 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -65,8 +65,10 @@ - (BOOL)showPrimaryInterface { ITDebugLog(@"Showing player primary interface."); - //If not minimized - if ([[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"'----':obj { form:'prop', want:type('prop'), seld:type('pMin'), from:obj { form:'indx', want:type('cBrW'), seld:1, from:'null'() } }" eventClass:@"core" eventID:@"getd" appPSN:savedPSN] == 0) { + //If not minimized and visible + if ( ([[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"'----':obj { form:'prop', want:type('prop'), seld:type('pMin'), from:obj { form:'indx', want:type('cBrW'), seld:1, from:'null'() } }" eventClass:@"core" eventID:@"getd" appPSN:savedPSN] == 0) && + ([[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"'----':obj { form:'prop', want:type('prop'), seld:type('pvis'), from:obj { form:'indx', want:type('cBrW'), seld:1, from:'null'() } }" eventClass:@"core" eventID:@"getd" appPSN:savedPSN] != 0) && + [[[[NSWorkspace sharedWorkspace] activeApplication] objectForKey:@"NSApplicationName"] isEqualToString:@"iTunes"] ) { //set minimized of browser window 1 to true [[ITAppleEventCenter sharedCenter] sendAEWithSendString:@"data:long(1), '----':obj { form:'prop', want:type('prop'), seld:type('pMin'), from:obj { form:'indx', want:type('cBrW'), seld:1, from:'null'() } }" eventClass:@"core" eventID:@"setd" appPSN:savedPSN]; } else { @@ -128,7 +130,7 @@ return ITMTRemotePlayerStopped; } -- (NSArray *)playlists +/*- (NSArray *)playlists { long i = 0; const signed long numPlaylists = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"kocl:type('cPly'), '----':()" eventClass:@"core" eventID:@"cnte" appPSN:savedPSN]; @@ -141,10 +143,10 @@ [playlists addObject:theObj]; } return [playlists autorelease]; -} +}*/ //Full source awareness -/*- (NSArray *)playlists +- (NSArray *)playlists { unsigned long i,k; const signed long numSources = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"kocl:type('cSrc'), '----':()" eventClass:@"core" eventID:@"cnte" appPSN:savedPSN]; NSMutableArray *allSources = [[NSMutableArray alloc] init]; @@ -157,7 +159,6 @@ NSNumber *sourceClass; NSMutableArray *aSource = [[NSMutableArray alloc] init]; [aSource addObject:sourceName]; - switch (fourcc) { case 'kTun': sourceClass = [NSNumber numberWithInt:ITMTRemoteRadioSource]; @@ -181,19 +182,20 @@ sourceClass = [NSNumber numberWithInt:ITMTRemoteLibrarySource]; break; } - + ITDebugLog(@"Adding source %@ of type %i", sourceName, [sourceClass intValue]); [aSource addObject:sourceClass]; for (i = 1; i <= numPlaylists; i++) { NSString *sendStr = [NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pnam'), from:obj { form:'indx', want:type('cPly'), seld:long(%u), from:obj { form:'indx', want:type('cSrc'), seld:long(%u), from:() } } }",i,k]; NSString *theObj = [[ITAppleEventCenter sharedCenter] sendAEWithSendString:sendStr eventClass:@"core" eventID:@"getd" appPSN:savedPSN]; + ITDebugLog(@" - Adding playlist %@", theObj); [aSource addObject:theObj]; } [allSources addObject:aSource]; [aSource release]; } ITDebugLog(@"Finished getting playlists."); - return [NSArray arrayWithArray:[allSources autorelease]]; -}*/ + return [allSources autorelease]; +} - (int)numberOfSongsInPlaylistAtIndex:(int)index { -- 2.20.1