From: Kent Sutherland Date: Fri, 12 Dec 2003 01:47:14 +0000 (+0000) Subject: Finished the multiple sources playlist submenu. X-Git-Tag: v1.2~13 X-Git-Url: http://git.ithinksw.org/MenuTunes.git/commitdiff_plain/b69eee35badf2aaca494fe27250fcd3f5f077cbb Finished the multiple sources playlist submenu. --- diff --git a/ITMTRemote.h b/ITMTRemote.h index 82da725..0d2c21a 100755 --- a/ITMTRemote.h +++ b/ITMTRemote.h @@ -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: */ diff --git a/ITMTRemote.m b/ITMTRemote.m index 96fecda..55e599b 100755 --- a/ITMTRemote.m +++ b/ITMTRemote.m @@ -89,6 +89,11 @@ return nil; } +- (int)currentSourceIndex +{ + return nil; +} + - (ITMTRemotePlayerPlaylistClass)currentPlaylistClass { return nil; @@ -259,6 +264,11 @@ return NO; } +- (BOOL)switchToPlaylistAtIndex:(int)index ofSourceAtIndex:(int)index2 +{ + return NO; +} + - (BOOL)switchToSongAtIndex:(int)index { return NO; diff --git a/MainController.m b/MainController.m index b041679..2b3a7fb 100755 --- a/MainController.m +++ b/MainController.m @@ -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 diff --git a/MenuController.m b/MenuController.m index 0998e06..3916267 100755 --- a/MenuController.m +++ b/MenuController.m @@ -593,9 +593,15 @@ } } - [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]; @@ -603,24 +609,19 @@ 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; } diff --git a/iTunesRemote.m b/iTunesRemote.m index 108c9ce..5f3944c 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -209,6 +209,12 @@ } } +- (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]; @@ -587,7 +593,7 @@ - (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; } @@ -595,8 +601,8 @@ - (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; } diff --git a/libValidate.a b/libValidate.a index 6f4a9db..907ced5 100755 Binary files a/libValidate.a and b/libValidate.a differ