From: Kent Sutherland Date: Mon, 12 Sep 2005 23:53:47 +0000 (+0000) Subject: Fixed the state for the playlists menu item to show the currently playing playlist. X-Git-Tag: v1.6~8 X-Git-Url: http://git.ithinksw.org/MenuTunes.git/commitdiff_plain/5e4dec969868a410da088273791f228def3b36a7 Fixed the state for the playlists menu item to show the currently playing playlist. Added a new hotkey to toggle if a song should appear in shuffle. Slightly modified the table view in the hot keys tab of the preferences. I still have to make a status window for shufflability state. Changed multiple instances of iTunesRemote using int32Value to typeCodeValue, which will hopefully reduce breakage in the future. --- diff --git a/English.lproj/Preferences.nib/info.nib b/English.lproj/Preferences.nib/info.nib index d935081..e50d6ba 100755 --- a/English.lproj/Preferences.nib/info.nib +++ b/English.lproj/Preferences.nib/info.nib @@ -12,7 +12,7 @@ 386 450 380 122 0 0 1152 746 IBFramework Version - 364.0 + 439.0 IBLockedObjects 281 @@ -22,6 +22,6 @@ 6 IBSystem Version - 7H63 + 8C46 diff --git a/English.lproj/Preferences.nib/keyedobjects.nib b/English.lproj/Preferences.nib/keyedobjects.nib index 82b46aa..338c636 100755 Binary files a/English.lproj/Preferences.nib/keyedobjects.nib and b/English.lproj/Preferences.nib/keyedobjects.nib differ diff --git a/ITMTRemote.h b/ITMTRemote.h index 9cd019b..6f10b7b 100755 --- a/ITMTRemote.h +++ b/ITMTRemote.h @@ -324,6 +324,16 @@ er's process managment. */ - (BOOL)setCurrentSongRating:(float)rating; +/*! + * @method currentSongShuffable + */ +- (BOOL)currentSongShufflable; + +/*! + * @method setCurrentSongShuffable: + */ +- (BOOL)setCurrentSongShufflable:(BOOL)shufflable; + /*! * @method equalizerEnabled */ diff --git a/ITMTRemote.m b/ITMTRemote.m index 3b4a828..75ed74f 100755 --- a/ITMTRemote.m +++ b/ITMTRemote.m @@ -204,6 +204,16 @@ return NO; } +- (BOOL)currentSongShufflable +{ + return NO; +} + +- (BOOL)setCurrentSongShufflable:(BOOL)shufflable +{ + return NO; +} + - (BOOL)equalizerEnabled { return NO; diff --git a/MainController.m b/MainController.m index 5819acd..7b008dd 100755 --- a/MainController.m +++ b/MainController.m @@ -768,7 +768,7 @@ static MainController *sharedController; { ITDebugLog(@"Show preferences."); [[PreferencesController sharedPrefs] showPrefsWindow:self]; - [[StatusWindow sharedWindow] setLocked:NO]; + [(StatusWindow *)[StatusWindow sharedWindow] setLocked:NO]; [[StatusWindow sharedWindow] vanish:self]; [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES]; } @@ -975,6 +975,16 @@ static MainController *sharedController; [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]]; } + if ([df objectForKey:@"ToggleShufflability"] != nil) { + ITDebugLog(@"Setting up toggle song shufflability hot key."); + hotKey = [[ITHotKey alloc] init]; + [hotKey setName:@"ToggleShufflability"]; + [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"ToggleShufflability"]]]; + [hotKey setTarget:self]; + [hotKey setAction:@selector(toggleSongShufflable)]; + [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]]; + } + if ([df objectForKey:@"PopupMenu"] != nil) { ITDebugLog(@"Setting up popup menu hot key."); hotKey = [[ITHotKey alloc] init]; @@ -1318,9 +1328,22 @@ static MainController *sharedController; NS_ENDHANDLER } +- (void)toggleSongShufflable +{ + NS_DURING + BOOL flag = ![[self currentRemote] currentSongShufflable]; + ITDebugLog(@"Toggling shufflability."); + [[self currentRemote] setCurrentSongShufflable:flag]; + //Show song shufflability status window + //[statusWindowController showSongShuffabilityWindow:flag]; + NS_HANDLER + [self networkError:localException]; + NS_ENDHANDLER +} + - (void)registerNowOK { - [[StatusWindow sharedWindow] setLocked:NO]; + [(StatusWindow *)[StatusWindow sharedWindow] setLocked:NO]; [[StatusWindow sharedWindow] vanish:self]; [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES]; @@ -1329,7 +1352,7 @@ static MainController *sharedController; - (void)registerNowCancel { - [[StatusWindow sharedWindow] setLocked:NO]; + [(StatusWindow *)[StatusWindow sharedWindow] setLocked:NO]; [[StatusWindow sharedWindow] vanish:self]; [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES]; @@ -1484,14 +1507,14 @@ static MainController *sharedController; [NSTimer scheduledTimerWithTimeInterval:90.0 target:self selector:@selector(checkForRemoteServer) userInfo:nil repeats:NO]; }*/ [self checkForRemoteServerAndConnectImmediately:YES]; - [[StatusWindow sharedWindow] setLocked:NO]; + [(StatusWindow *)[StatusWindow sharedWindow] setLocked:NO]; [[StatusWindow sharedWindow] vanish:self]; [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES]; } - (void)cancelReconnect { - [[StatusWindow sharedWindow] setLocked:NO]; + [(StatusWindow *)[StatusWindow sharedWindow] setLocked:NO]; [[StatusWindow sharedWindow] vanish:self]; [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES]; } diff --git a/MenuController.m b/MenuController.m index 382e6f2..50ffb98 100755 --- a/MenuController.m +++ b/MenuController.m @@ -740,9 +740,9 @@ if (source == ITMTRemoteRadioSource) { [playlistsMenu addItem:[NSMenuItem separatorItem]]; [[playlistsMenu addItemWithTitle:NSLocalizedString(@"radio", @"Radio") action:@selector(performPlaylistMenuAction:) keyEquivalent:@""] setState:NSOnState]; - } - } else { - [playlistsMenu addItem:[NSMenuItem separatorItem]]; + } else if ([playlists count] > 2) { + [playlistsMenu addItem:[NSMenuItem separatorItem]]; + } } //Add other sources as needed (shared music, iPods, CDs) @@ -773,7 +773,7 @@ [tempItem setState:NSOnState]; [[[tempItem submenu] itemAtIndex:_currentPlaylist - 1] setState:NSOnState]; } else if (source == ITMTRemoteLibrarySource && _currentPlaylist) { - [[playlistsMenu itemAtIndex:_currentPlaylist - 1] setState:NSOnState]; + [[playlistsMenu itemAtIndex:_currentPlaylist - 2] setState:NSOnState]; } } NS_HANDLER diff --git a/PreferencesController.m b/PreferencesController.m index 247dca7..02ba0a0 100755 --- a/PreferencesController.m +++ b/PreferencesController.m @@ -98,6 +98,7 @@ static PreferencesController *prefs = nil; @"DecrementRating", @"ToggleShuffle", @"ToggleLoop", + @"ToggleShufflability", @"PopupMenu", @"SetRating0", @"SetRating1", @@ -121,6 +122,7 @@ static PreferencesController *prefs = nil; @"Decrement Rating", @"Toggle Shuffle", @"Toggle Loop", + @"Toggle Song Included In Shuffle", @"Pop-up status menu", [NSString stringWithUTF8String:"Set Rating: ☆☆☆☆☆"], [NSString stringWithUTF8String:"Set Rating: ★☆☆☆☆"], diff --git a/iTunesRemote.m b/iTunesRemote.m index ef53fc5..3dc2504 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -258,7 +258,7 @@ //Loop through each source for (i = 1; i <= numSources; i++) { - SInt32 fourcc = [ITSendAEWithString([NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pKnd'), from:obj { form:'indx', want:type('cSrc'), seld:long(%i), from:() } }", i], 'core', 'getd', &savedPSN) int32Value]; //Type of the current source + FourCharCode fourcc = [ITSendAEWithString([NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pKnd'), from:obj { form:'indx', want:type('cSrc'), seld:long(%i), from:() } }", i], 'core', 'getd', &savedPSN) typeCodeValue]; //Type of the current source NSString *sourceName = [ITSendAEWithString([NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pnam'), from:obj { form:'indx', want:type('cSrc'), seld:long(%i), from:() } }", i], 'core', 'getd', &savedPSN) stringValue]; //Name of the current source SInt32 index = [ITSendAEWithString([NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pidx'), from:obj { form:'indx', want:type('cSrc'), seld:long(%i), from:() } }", i], 'core', 'getd', &savedPSN) int32Value]; //Index of the current source ITMTRemotePlayerSource class; //The class of the current source @@ -448,7 +448,7 @@ ITDebugLog(@"Getting current source."); - fourcc = ([self isPlaying]) ? [ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pKnd'), from:obj { form:'prop', want:type('prop'), seld:type('ctnr'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } } }", 'core', 'getd', &savedPSN) int32Value] : 'kLib'; + fourcc = ([self isPlaying]) ? [ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pKnd'), from:obj { form:'prop', want:type('prop'), seld:type('ctnr'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } } }", 'core', 'getd', &savedPSN) typeCodeValue] : 'kLib'; switch (fourcc) { case 'kTun': @@ -488,9 +488,9 @@ - (ITMTRemotePlayerPlaylistClass)currentPlaylistClass { - SInt32 realResult; + FourCharCode realResult; ITDebugLog(@"Getting current playlist class"); - realResult = [ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pcls'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } }", 'core', 'getd', &savedPSN) int32Value]; + realResult = [ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pcls'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } }", 'core', 'getd', &savedPSN) typeCodeValue]; switch (realResult) { case 'cLiP': @@ -550,12 +550,12 @@ NSString *temp1; ITDebugLog(@"Getting current unique identifier."); NSAppleEventDescriptor *descriptor = ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pcls'), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } }", 'core', 'getd', &savedPSN); - if ([descriptor int32Value] == 'prop') { + if ([descriptor typeCodeValue] == 'prop') { return @"0-0"; } else if (descriptor == nil) { return nil; } - SInt32 cls = [descriptor int32Value]; + FourCharCode cls = [descriptor typeCodeValue]; if ( ([self currentPlaylistClass] == ITMTRemotePlayerRadioPlaylist) || (cls == 'cURT') ) { NSString *bad = [NSString stringWithUTF8String:"浳湧"]; temp1 = [ITSendAEWithKey('pStT', 'core', 'getd', &savedPSN) stringValue]; @@ -582,7 +582,7 @@ { NSString *temp1; ITDebugLog(@"Getting current song title."); - SInt32 result = [ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pcls'), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } }", 'core', 'getd', &savedPSN) int32Value]; + FourCharCode result = [ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pcls'), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } }", 'core', 'getd', &savedPSN) typeCodeValue]; //If we're listening to the radio. if (result == 'cURT') { @@ -731,6 +731,27 @@ return YES; } +- (BOOL)currentSongShufflable +{ + BOOL temp1; + ITDebugLog(@"Getting current song shufflable status."); + temp1 = (![self isPlaying] || ([self currentPlaylistClass] == ITMTRemotePlayerRadioPlaylist)) ? NO : [ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pSfa'), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } }", 'core', 'getd', &savedPSN) booleanValue]; + ITDebugLog(@"Getting current song shufflable status done."); + return temp1; +} + +- (BOOL)setCurrentSongShufflable:(BOOL)shufflable +{ + ITDebugLog(@"Setting current song shufflable status to %i.", shufflable); + if ([self currentPlaylistClass] == ITMTRemotePlayerRadioPlaylist) { + ITDebugLog(@"Not a valid track to set status to, returning."); + return NO; + } + ITSendAEWithString([NSString stringWithFormat:@"data:long(%lu), '----':obj { form:'prop', want:type('prop'), seld:type('pSfa'), from:obj { form:'indx', want:type('cTrk'), seld:long(%lu), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } } }", !shufflable, [self currentSongIndex]], 'core', 'setd', &savedPSN); + ITDebugLog(@"Setting current song shufflable status to %i done.", shufflable); + return YES; +} + - (BOOL)equalizerEnabled { ITDebugLog(@"Getting equalizer enabled status."); @@ -998,7 +1019,7 @@ - (BOOL)isPlaying { - return ([ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pcls'), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } }", 'core', 'getd', &savedPSN) int32Value] != 'prop'); + return ([ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pcls'), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } }", 'core', 'getd', &savedPSN) typeCodeValue] != 'prop'); } - (void)notificationHandler:(NSNotification *)note