#import <ITKit/ITHotKeyCenter.h>
#import <ITKit/ITHotKey.h>
#import <ITKit/ITKeyCombo.h>
#import <ITKit/ITHotKeyCenter.h>
#import <ITKit/ITHotKey.h>
#import <ITKit/ITKeyCombo.h>
_currentPlaylist = [currentRemote currentPlaylistIndex];
_playingRadio = ([currentRemote currentPlaylistClass] == ITMTRemotePlayerRadioPlaylist);
_currentPlaylist = [currentRemote currentPlaylistIndex];
_playingRadio = ([currentRemote currentPlaylistClass] == ITMTRemotePlayerRadioPlaylist);
tempItem = [menu addItemWithTitle:NSLocalizedString(@"play", @"Play")
action:@selector(performMainMenuAction:)
keyEquivalent:@""];
tempItem = [menu addItemWithTitle:NSLocalizedString(@"play", @"Play")
action:@selector(performMainMenuAction:)
keyEquivalent:@""];
switch ([currentRemote playerPlayingState]) {
case ITMTRemotePlayerPlaying:
[tempItem setTitle:NSLocalizedString(@"pause", @"Pause")];
switch ([currentRemote playerPlayingState]) {
case ITMTRemotePlayerPlaying:
[tempItem setTitle:NSLocalizedString(@"pause", @"Pause")];
tempItem = [menu addItemWithTitle:NSLocalizedString(@"nextTrack", @"Next Track")
action:@selector(performMainMenuAction:)
keyEquivalent:@""];
tempItem = [menu addItemWithTitle:NSLocalizedString(@"nextTrack", @"Next Track")
action:@selector(performMainMenuAction:)
keyEquivalent:@""];
tempItem = [menu addItemWithTitle:NSLocalizedString(@"prevTrack", @"Previous Track")
action:@selector(performMainMenuAction:)
keyEquivalent:@""];
tempItem = [menu addItemWithTitle:NSLocalizedString(@"prevTrack", @"Previous Track")
action:@selector(performMainMenuAction:)
keyEquivalent:@""];
tempItem = [menu addItemWithTitle:NSLocalizedString(@"fastForward", @"Fast Forward")
action:@selector(performMainMenuAction:)
keyEquivalent:@""];
tempItem = [menu addItemWithTitle:NSLocalizedString(@"fastForward", @"Fast Forward")
action:@selector(performMainMenuAction:)
keyEquivalent:@""];
tempItem = [menu addItemWithTitle:NSLocalizedString(@"rewind", @"Rewind")
action:@selector(performMainMenuAction:)
keyEquivalent:@""];
tempItem = [menu addItemWithTitle:NSLocalizedString(@"rewind", @"Rewind")
action:@selector(performMainMenuAction:)
keyEquivalent:@""];
tempItem = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@",
NSLocalizedString(@"show", @"Show"),
[[[MainController sharedController] currentRemote] playerSimpleName]]
tempItem = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@",
NSLocalizedString(@"show", @"Show"),
[[[MainController sharedController] currentRemote] playerSimpleName]]
[tempItem setTarget:self];
[tempItem setTag:MTMenuShowPlayerItem];
} else if ([nextObject isEqualToString:@"preferences"]) {
[tempItem setTarget:self];
[tempItem setTag:MTMenuShowPlayerItem];
} else if ([nextObject isEqualToString:@"preferences"]) {
tempItem = [menu addItemWithTitle:NSLocalizedString(@"preferences", @"Preferences...")
action:@selector(performMainMenuAction:)
keyEquivalent:@""];
[tempItem setTag:MTMenuPreferencesItem];
[tempItem setTarget:self];
} else if ([nextObject isEqualToString:@"quit"]) {
tempItem = [menu addItemWithTitle:NSLocalizedString(@"preferences", @"Preferences...")
action:@selector(performMainMenuAction:)
keyEquivalent:@""];
[tempItem setTag:MTMenuPreferencesItem];
[tempItem setTarget:self];
} else if ([nextObject isEqualToString:@"quit"]) {
tempItem = [menu addItemWithTitle:NSLocalizedString(@"quit", @"Quit")
action:@selector(performMainMenuAction:)
keyEquivalent:@""];
[tempItem setTag:MTMenuQuitItem];
[tempItem setTarget:self];
tempItem = [menu addItemWithTitle:NSLocalizedString(@"quit", @"Quit")
action:@selector(performMainMenuAction:)
keyEquivalent:@""];
[tempItem setTag:MTMenuQuitItem];
[tempItem setTarget:self];
+ if ([[MainController sharedController] blingBling] == NO) {
+ ITDebugLog(@"Add \"Register MenuTunes...\" menu item.");
+ tempItem = [menu addItemWithTitle:NSLocalizedString(@"register", @"Register MenuTunes...") action:@selector(performMainMenuAction:) keyEquivalent:@""];
+ [tempItem setTag:MTMenuRegisterItem];
+ [tempItem setTarget:self];
+ }
[menu addItemWithTitle:NSLocalizedString(@"nowPlaying", @"Now Playing") action:NULL keyEquivalent:@""];
if ([title length] > 0) {
[menu addItemWithTitle:NSLocalizedString(@"nowPlaying", @"Now Playing") action:NULL keyEquivalent:@""];
if ([title length] > 0) {
- [menu addItemWithTitle:[NSString stringWithFormat:@" %@ %i", NSLocalizedString(@"track", @"Track"), track]
- action:nil
- keyEquivalent:@""];
+ [menu indentItem:
+ [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %i", NSLocalizedString(@"track", @"Track"), track] action:nil keyEquivalent:@""]];
}
}
if ([defaults boolForKey:@"showTime"]) {
int left = [[currentRemote currentSongRemaining] intValue];
NSString *remaining = [NSString stringWithFormat:@"%i:%02i", left / 60, left % 60];
}
}
if ([defaults boolForKey:@"showTime"]) {
int left = [[currentRemote currentSongRemaining] intValue];
NSString *remaining = [NSString stringWithFormat:@"%i:%02i", left / 60, left % 60];
- [menu addItemWithTitle:[NSString stringWithFormat:@" %@/%@", remaining, [currentRemote currentSongLength]]
- action:nil
- keyEquivalent:@""];
+ ITDebugLog(@"Add Track Remaining (\"%@/%@\") menu item.", remaining, [currentRemote currentSongLength]);
+ [menu indentItem:[menu addItemWithTitle:[NSString stringWithFormat:@"%@/%@", remaining, [currentRemote currentSongLength]] action:nil keyEquivalent:@""]];
switch ((int)([currentRemote currentSongRating] * 5)) {
case 0:
string = [NSString stringWithUTF8String:"☆☆☆☆☆"];
switch ((int)([currentRemote currentSongRating] * 5)) {
case 0:
string = [NSString stringWithUTF8String:"☆☆☆☆☆"];
- [menu addItemWithTitle:
- [@" " stringByAppendingString:string]
- action:nil
- keyEquivalent:@""];
+ ITDebugLog(@"Add Track Rating (\"%@\") menu item.", string);
+ [menu indentItem:[menu addItemWithTitle:string action:nil keyEquivalent:@""]];
[menu addItemWithTitle:NSLocalizedString(@"noSong", @"No Song") action:NULL keyEquivalent:@""];
}
} else if ([nextObject isEqualToString:@"separator"]) {
[menu addItemWithTitle:NSLocalizedString(@"noSong", @"No Song") action:NULL keyEquivalent:@""];
}
} else if ([nextObject isEqualToString:@"separator"]) {
[[_ratingMenu itemAtIndex:([currentRemote currentSongRating] * 5)] setState:NSOnState];
} else if ([nextObject isEqualToString:@"upcomingSongs"]) {
[[_ratingMenu itemAtIndex:([currentRemote currentSongRating] * 5)] setState:NSOnState];
} else if ([nextObject isEqualToString:@"upcomingSongs"]) {
tempItem = [menu addItemWithTitle:NSLocalizedString(@"playlists", @"Playlists")
action:nil
keyEquivalent:@""];
[tempItem setSubmenu:_playlistsMenu];
[tempItem setTag:3];
} else if ([nextObject isEqualToString:@"eqPresets"]) {
tempItem = [menu addItemWithTitle:NSLocalizedString(@"playlists", @"Playlists")
action:nil
keyEquivalent:@""];
[tempItem setSubmenu:_playlistsMenu];
[tempItem setTag:3];
} else if ([nextObject isEqualToString:@"eqPresets"]) {
tempItem = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"open", @"Open"), [[[MainController sharedController] currentRemote] playerSimpleName]] action:@selector(performMainMenuAction:) keyEquivalent:@""];
[tempItem setTag:MTMenuShowPlayerItem];
[tempItem setTarget:self];
tempItem = [menu addItemWithTitle:[NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"open", @"Open"), [[[MainController sharedController] currentRemote] playerSimpleName]] action:@selector(performMainMenuAction:) keyEquivalent:@""];
[tempItem setTag:MTMenuShowPlayerItem];
[tempItem setTarget:self];
tempItem = [menu addItemWithTitle:NSLocalizedString(@"preferences", @"Preferences...") action:@selector(performMainMenuAction:) keyEquivalent:@""];
[tempItem setTag:MTMenuPreferencesItem];
[tempItem setTarget:self];
tempItem = [menu addItemWithTitle:NSLocalizedString(@"preferences", @"Preferences...") action:@selector(performMainMenuAction:) keyEquivalent:@""];
[tempItem setTag:MTMenuPreferencesItem];
[tempItem setTarget:self];
+ if ([[MainController sharedController] blingBling] == NO) {
+ ITDebugLog(@"Add \"Register MenuTunes...\" menu item.");
+ tempItem = [menu addItemWithTitle:NSLocalizedString(@"register", @"Register MenuTunes...") action:@selector(performMainMenuAction:) keyEquivalent:@""];
+ [tempItem setTag:MTMenuRegisterItem];
+ [tempItem setTarget:self];
+ }
+ ITDebugLog(@"Add \"Quit\" menu item.");
tempItem = [menu addItemWithTitle:NSLocalizedString(@"quit", @"Quit") action:@selector(performMainMenuAction:) keyEquivalent:@""];
[tempItem setTag:MTMenuQuitItem];
[tempItem setTarget:self];
tempItem = [menu addItemWithTitle:NSLocalizedString(@"quit", @"Quit") action:@selector(performMainMenuAction:) keyEquivalent:@""];
[tempItem setTag:MTMenuQuitItem];
[tempItem setTarget:self];
currentRemote = [[MainController sharedController] currentRemote];
_currentPlaylist = [currentRemote currentPlaylistIndex];
_currentTrack = [currentRemote currentSongIndex];
currentRemote = [[MainController sharedController] currentRemote];
_currentPlaylist = [currentRemote currentPlaylistIndex];
_currentTrack = [currentRemote currentSongIndex];
[ratingMenu addItemWithTitle:[NSString stringWithUTF8String:"☆☆☆☆☆"] action:nil keyEquivalent:@""];
[ratingMenu addItemWithTitle:[NSString stringWithUTF8String:"★☆☆☆☆"] action:nil keyEquivalent:@""];
[ratingMenu addItemWithTitle:[NSString stringWithUTF8String:"★★☆☆☆"] action:nil keyEquivalent:@""];
[ratingMenu addItemWithTitle:[NSString stringWithUTF8String:"☆☆☆☆☆"] action:nil keyEquivalent:@""];
[ratingMenu addItemWithTitle:[NSString stringWithUTF8String:"★☆☆☆☆"] action:nil keyEquivalent:@""];
[ratingMenu addItemWithTitle:[NSString stringWithUTF8String:"★★☆☆☆"] action:nil keyEquivalent:@""];
int numSongs = [currentRemote numberOfSongsInPlaylistAtIndex:_currentPlaylist];
int numSongsInAdvance = [[NSUserDefaults standardUserDefaults] integerForKey:@"SongsInAdvance"];
int numSongs = [currentRemote numberOfSongsInPlaylistAtIndex:_currentPlaylist];
int numSongsInAdvance = [[NSUserDefaults standardUserDefaults] integerForKey:@"SongsInAdvance"];
for (i = _currentTrack + 1; i <= _currentTrack + numSongsInAdvance; i++) {
if (i <= numSongs) {
NSString *curSong = [currentRemote songTitleAtIndex:i];
NSMenuItem *songItem;
for (i = _currentTrack + 1; i <= _currentTrack + numSongsInAdvance; i++) {
if (i <= numSongs) {
NSString *curSong = [currentRemote songTitleAtIndex:i];
NSMenuItem *songItem;
songItem = [upcomingSongsMenu addItemWithTitle:curSong action:@selector(performUpcomingSongsMenuAction:) keyEquivalent:@""];
[songItem setTag:i];
[songItem setTarget:self];
songItem = [upcomingSongsMenu addItemWithTitle:curSong action:@selector(performUpcomingSongsMenuAction:) keyEquivalent:@""];
[songItem setTag:i];
[songItem setTarget:self];
- tempItem = [playlistsMenu addItemWithTitle:[playlists objectAtIndex:i] action:@selector(performPlaylistMenuAction:) keyEquivalent:@""];
+ NSString *curPlaylist = [playlists objectAtIndex:i];
+ ITDebugLog(@"Adding playlist: %@", curPlaylist);
+ tempItem = [playlistsMenu addItemWithTitle:curPlaylist action:@selector(performPlaylistMenuAction:) keyEquivalent:@""];
if (!_playingRadio && _currentPlaylist) {
[[playlistsMenu itemAtIndex:_currentPlaylist - 1] setState:NSOnState];
}
if (!_playingRadio && _currentPlaylist) {
[[playlistsMenu itemAtIndex:_currentPlaylist - 1] setState:NSOnState];
}
- if ( ( name = [eqPresets objectAtIndex:i] ) ) {
- tempItem = [eqMenu addItemWithTitle:name action:@selector(performEqualizerMenuAction:) keyEquivalent:@""];
+ if ( ( name = [eqPresets objectAtIndex:i] ) ) {
+ ITDebugLog(@"Adding EQ Preset: %@", name);
+ tempItem = [eqMenu addItemWithTitle:name
+ action:@selector(performEqualizerMenuAction:)
+ keyEquivalent:@""];
[[MainController sharedController] selectSongRating:[sender tag]];
}
- (void)performPlaylistMenuAction:(id)sender
{
[[MainController sharedController] selectSongRating:[sender tag]];
}
- (void)performPlaylistMenuAction:(id)sender
{
[[MainController sharedController] selectPlaylistAtIndex:[sender tag]];
}
- (void)performEqualizerMenuAction:(id)sender
{
[[MainController sharedController] selectPlaylistAtIndex:[sender tag]];
}
- (void)performEqualizerMenuAction:(id)sender
{
[[MainController sharedController] selectEQPresetAtIndex:[sender tag]];
}
- (void)performUpcomingSongsMenuAction:(id)sender
{
[[MainController sharedController] selectEQPresetAtIndex:[sender tag]];
}
- (void)performUpcomingSongsMenuAction:(id)sender
{
for (i = 0; i < 6; i++) {
if (modifiers & carbonToCocoa[i][0]) {
cocoaModifiers += carbonToCocoa[i][1];
for (i = 0; i < 6; i++) {
if (modifiers & carbonToCocoa[i][0]) {
cocoaModifiers += carbonToCocoa[i][1];
// Haven't tested this, though it should work.
// This doesn't work. :'(
// Haven't tested this, though it should work.
// This doesn't work. :'(
/*MenuRef menuRef = _NSGetCarbonMenu([item menu]);
ITDebugLog(@"%@", menuRef);
SetMenuItemCommandKey(menuRef, 0, NO, 49);
SetMenuItemModifiers(menuRef, 0, kMenuNoCommandModifier);
SetMenuItemKeyGlyph(menuRef, 0, kMenuBlankGlyph);
charcode = 'b';*/
/*MenuRef menuRef = _NSGetCarbonMenu([item menu]);
ITDebugLog(@"%@", menuRef);
SetMenuItemCommandKey(menuRef, 0, NO, 49);
SetMenuItemModifiers(menuRef, 0, kMenuNoCommandModifier);
SetMenuItemKeyGlyph(menuRef, 0, kMenuBlankGlyph);
charcode = 'b';*/
kchr = (Ptr) GetScriptVariable(smCurrentScript, smKCHRCache);
keyTrans = KeyTranslate(kchr, code, &state);
charCode = keyTrans;
kchr = (Ptr) GetScriptVariable(smCurrentScript, smKCHRCache);
keyTrans = KeyTranslate(kchr, code, &state);
charCode = keyTrans;
[item setKeyEquivalent:[NSString stringWithCString:&charCode length:1]];
} else if (charcode != 'b') {
[item setKeyEquivalent:[NSString stringWithCharacters:&charcode length:1]];
}
[item setKeyEquivalent:[NSString stringWithCString:&charCode length:1]];
} else if (charcode != 'b') {
[item setKeyEquivalent:[NSString stringWithCharacters:&charcode length:1]];
}