Readding multisource playlist thingy. Added a tooltip showing the current
authorKent Sutherland <ksuther@ithinksw.com>
Tue, 3 Feb 2004 02:28:19 +0000 (02:28 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Tue, 3 Feb 2004 02:28:19 +0000 (02:28 +0000)
track and artist to the status item. Show Player now toggles the iTunes
interface between max/min.

MainController.m
MenuController.m
iTunesRemote.m

index f9e23ed..05ef785 100755 (executable)
@@ -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
index c2970f6..4ab0bf4 100755 (executable)
@@ -22,7 +22,7 @@
 - (NSMenu *)eqMenu;
 - (void)setKeyEquivalentForCode:(short)code andModifiers:(long)modifiers
         onItem:(id <NSMenuItem>)item;
-//- (BOOL)iPodAtPathAutomaticallyUpdates:(NSString *)name;
+- (BOOL)iPodAtPathAutomaticallyUpdates:(NSString *)name;
 @end
 
 @implementation MenuController
     return upcomingSongsMenu;
 }
 
-- (NSMenu *)playlistsMenu
+/*- (NSMenu *)playlistsMenu
 {
     NSMenu *playlistsMenu = [[NSMenu alloc] initWithTitle:@""];
     NSArray *playlists;
     }
     ITDebugLog(@"Done Building \"Playlists\" menu");
     return playlistsMenu;
-}
+}*/
 
 
-/*- (NSMenu *)playlistsMenu
+- (NSMenu *)playlistsMenu
 {
     NSMenu *playlistsMenu = [[NSMenu alloc] initWithTitle:@""];
     NSArray *playlists;
-    NSMenuItem *tempItem;
+    id <NSMenuItem> tempItem;
     ITMTRemotePlayerSource source = [[[MainController sharedController] currentRemote] currentSource];
     int i, j;
     NS_DURING
             [tempItem setTarget:self];
         }
     }
-    
     if ( (source == ITMTRemoteRadioSource) || ([playlists count] - 2 > 0) ) {
         [playlistsMenu addItem:[NSMenuItem separatorItem]];
     }
     }
     ITDebugLog(@"Done Building \"Playlists\" menu");
     return playlistsMenu;
-}*/
+}
 
 - (NSMenu *)eqMenu
 {
     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];
             }
         }
     }
-}*/
+    return NO;
+}
 
 @end
\ No newline at end of file
index 4b04840..0a1335e 100755 (executable)
 - (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 {
     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];
         [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];
         NSNumber *sourceClass;
         NSMutableArray *aSource = [[NSMutableArray alloc] init];
         [aSource addObject:sourceName];
-        
         switch (fourcc) {
             case 'kTun':
                 sourceClass = [NSNumber numberWithInt:ITMTRemoteRadioSource];
                 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
 {