Finished the multiple sources playlist submenu.
authorKent Sutherland <ksuther@ithinksw.com>
Fri, 12 Dec 2003 01:47:14 +0000 (01:47 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Fri, 12 Dec 2003 01:47:14 +0000 (01:47 +0000)
ITMTRemote.h
ITMTRemote.m
MainController.m
MenuController.m
iTunesRemote.m
libValidate.a

index 82da725..0d2c21a 100755 (executable)
@@ -214,6 +214,11 @@ er's process managment.
  */
 - (ITMTRemotePlayerSource)currentSource;
 
+/*!
+ * @method currentSourceIndex
+ */
+- (int)currentSourceIndex;
+
 /*!
  * @method currentPlaylistClass
  */
@@ -374,6 +379,11 @@ er's process managment.
  */
 - (BOOL)switchToPlaylistAtIndex:(int)index;
 
+/*!
+ * @method switchToPlaylistAtIndex:
+ */
+- (BOOL)switchToPlaylistAtIndex:(int)index ofSourceAtIndex:(int)index2;
+
 /*!
  * @method switchToSongAtIndex:
  */
index 96fecda..55e599b 100755 (executable)
     return nil;
 }
 
+- (int)currentSourceIndex
+{
+    return nil;
+}
+
 - (ITMTRemotePlayerPlaylistClass)currentPlaylistClass
 {
     return nil;
     return NO;
 }
 
+- (BOOL)switchToPlaylistAtIndex:(int)index ofSourceAtIndex:(int)index2
+{
+    return NO;
+}
+
 - (BOOL)switchToSongAtIndex:(int)index
 {
     return NO;
index b041679..2b3a7fb 100755 (executable)
@@ -406,7 +406,7 @@ static MainController *sharedController;
 {
     ITDebugLog(@"Selecting playlist %i", index);
     NS_DURING
-        [[self currentRemote] switchToPlaylistAtIndex:(index / 1000) ofSourceAtIndex:(index % 1000)];
+        [[self currentRemote] switchToPlaylistAtIndex:(index % 1000) ofSourceAtIndex:(index / 1000)];
     NS_HANDLER
         [self networkError:localException];
     NS_ENDHANDLER
index 0998e06..3916267 100755 (executable)
         }
     }
     
-    [playlistsMenu addItem:[NSMenuItem separatorItem]];
+    if ( (source == ITMTRemoteRadioSource) || ([playlists count] - 2 > 0) ) {
+        [playlistsMenu addItem:[NSMenuItem separatorItem]];
+    }
+    
+    if (source == ITMTRemoteRadioSource) {
+        [[playlistsMenu addItemWithTitle:NSLocalizedString(@"radio", @"Radio") action:@selector(performPlaylistMenuAction:) keyEquivalent:@""] setState:NSOnState];
+    }
     
-    for (i = 1; i < [playlists count]; i++) {
+    for (i = 2; i < [playlists count]; i++) {
         NSArray *curPlaylist = [playlists objectAtIndex:i];
         NSString *name = [curPlaylist objectAtIndex:0];
         NSMenu *submenu = [[NSMenu alloc] init];
         for (j = 1; j < [curPlaylist count]; j++) {
             ITDebugLog(@"Adding playlist: %@", [curPlaylist objectAtIndex:j]);
             tempItem = [submenu addItemWithTitle:[curPlaylist objectAtIndex:j] action:@selector(performPlaylistMenuAction:) keyEquivalent:@""];
-            [tempItem setTag:(j * 1000) + (j + 1)];
+            [tempItem setTag:(i * 1000) + (j + 1)];
             [tempItem setTarget:self];
         }
         [[playlistsMenu addItemWithTitle:name action:NULL keyEquivalent:@""] setSubmenu:[submenu autorelease]];
     }
-    /*if (source == ITMTRemoteRadioSource) {
-        [[playlistsMenu addItemWithTitle:NSLocalizedString(@"radio", @"Radio") action:NULL keyEquivalent:@""] setState:NSOnState];
-    } else if (source == ITMTRemoteGenericDeviceSource) {
-        [[playlistsMenu addItemWithTitle:NSLocalizedString(@"genericDevice", @"Generic Device") action:NULL keyEquivalent:@""] setState:NSOnState];
-    } else if (source == ITMTRemoteiPodSource) {
-        [[playlistsMenu addItemWithTitle:NSLocalizedString(@"iPod", @"iPod") action:NULL keyEquivalent:@""] setState:NSOnState];
-    } else if (source == ITMTRemoteCDSource) {
-        [[playlistsMenu addItemWithTitle:NSLocalizedString(@"cd", @"CD") action:NULL keyEquivalent:@""] setState:NSOnState];
-    } else if (source == ITMTRemoteSharedLibrarySource) {
-        [[playlistsMenu addItemWithTitle:NSLocalizedString(@"sharedLibrary", @"Shared Library") action:NULL keyEquivalent:@""] setState:NSOnState];
+    
+    if ( (source == ITMTRemoteSharedLibrarySource) || (source == ITMTRemoteiPodSource) || (source == ITMTRemoteGenericDeviceSource) || (source == ITMTRemoteCDSource) ){
+        tempItem = [playlistsMenu itemAtIndex:(int)[[[MainController sharedController] currentRemote] currentSourceIndex] + [playlistsMenu numberOfItems] - 6];
+        [tempItem setState:NSOnState];
+        [[[tempItem submenu] itemAtIndex:_currentPlaylist - 1] setState:NSOnState];
     } else if (source == ITMTRemoteLibrarySource && _currentPlaylist) {
         [[playlistsMenu itemAtIndex:_currentPlaylist - 1] setState:NSOnState];
-    }*/
+    }
     ITDebugLog(@"Done Building \"Playlists\" menu");
     return playlistsMenu;
 }
index 108c9ce..5f3944c 100755 (executable)
     }
 }
 
+- (int)currentSourceIndex
+{
+    ITDebugLog(@"Getting current source.");   
+    return [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:[NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pidx'), from:obj { form:'prop', want:type('prop'), seld:type('ctnr'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } } }"] eventClass:@"core" eventID:@"getd" appPSN:savedPSN];
+}
+
 - (ITMTRemotePlayerPlaylistClass)currentPlaylistClass
 {
     int realResult = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pcls" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:savedPSN];
 - (BOOL)switchToPlaylistAtIndex:(int)index
 {
     ITDebugLog(@"Switching to playlist at index %i", index);
-    [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"'----':obj { form:'indx', want:type('cPly'), seld:long(%lu), from:() }",index] eventClass:@"hook" eventID:@"Play" appPSN:savedPSN];
+    [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"'----':obj { form:'indx', want:type('cPly'), seld:long(%lu), from:() }", index] eventClass:@"hook" eventID:@"Play" appPSN:savedPSN];
     ITDebugLog(@"Done switching to playlist at index %i", index);
     return YES;
 }
 - (BOOL)switchToPlaylistAtIndex:(int)index ofSourceAtIndex:(int)index2
 {
     ITDebugLog(@"Switching to playlist at index %i of source %i", index, index2);
-    [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"'----':obj { form:'indx', want:type('cPly'), seld:long(%lu), from:obj { form:'indx', want:type('cSrc'), seld:long('%lu'), from:() } }",index, index2] eventClass:@"hook" eventID:@"Play" appPSN:savedPSN];
-    //[NSString stringWithFormat:@"'----':obj { form:'indx', want:type('cPly'), seld:long(%lu), from:'null'() }, data:obj { form:'indx', want:type('cSrc'), seld:long('%lu'), from:'null'() }",index, index2]
+    [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"'----':obj { form:'indx', want:type('cPly'), seld:long(%lu), from: obj { form:'indx', want:type('cSrc'), seld:long(%lu), from:'null'() } }", index - 1, index2 + 1] eventClass:@"hook" eventID:@"Play" appPSN:savedPSN];
+    //{ form:'indx', want:type('cPly'), seld:long(%lu), from:obj { form:'indx', want:type('cSrc'), seld:long('%lu'), from:'null'() } } -- obj { form:'indx', want:type('cSrc'), seld:long(1), from:'null'() }
     ITDebugLog(@"Done switching to playlist at index %i of source %i", index, index2);
     return YES;
 }
index 6f4a9db..907ced5 100755 (executable)
Binary files a/libValidate.a and b/libValidate.a differ