- (NSMenu *)upcomingSongsMenu;
- (NSMenu *)playlistsMenu;
- (NSMenu *)eqMenu;
+- (NSMenu *)artistsMenu;
- (void)setKeyEquivalentForCode:(short)code andModifiers:(long)modifiers
onItem:(id <NSMenuItem>)item;
- (BOOL)iPodWithNameAutomaticallyUpdates:(NSString *)name;
[tempItem setSubmenu:nil];
}
+ if ( (tempItem = [_currentMenu itemWithTag:5]) ) {
+ ITDebugLog(@"Removing \"Artists\" submenu.");
+ [tempItem setSubmenu:nil];
+ }
+
ITDebugLog(@"Begin building menu.");
//create our menu
if (!_playingRadio) {
NS_DURING
+ if ([defaults boolForKey:@"showPlayCount"] && [mtr currentSource] == ITMTRemoteLibrarySource) {
+ [menu indentItem:[menu addItemWithTitle:[NSString stringWithFormat:@"Play Count: %i", [mtr currentSongPlayCount]] action:nil keyEquivalent:@""]];
+ }
if ([defaults boolForKey:@"showTrackRating"] && ( [mtr currentSongRating] != -1.0 )) {
NSString *string = nil;
switch ((int)([mtr currentSongRating] * 5)) {
[tempItem setState:NSOffState];
}
NS_DURING
+ [[_eqMenu itemAtIndex:0] setState:[mtr equalizerEnabled] ? NSOnState : NSOffState];
+ [[_eqMenu itemAtIndex:([mtr currentEQPresetIndex] + 1)] setState:NSOnState];
[[_eqMenu itemAtIndex:([mtr currentEQPresetIndex] - 1)] setState:NSOnState];
NS_HANDLER
[[MainController sharedController] networkError:localException];
NS_ENDHANDLER
} else if ([nextObject isEqualToString:@"songRating"] && currentSongRating) {
- ITDebugLog(@"Add \"Song Rating\" submenu.");
- tempItem = [menu addItemWithTitle:NSLocalizedString(@"songRating", @"Song Rating")
- action:nil
- keyEquivalent:@""];
- [tempItem setSubmenu:_ratingMenu];
- [tempItem setTag:1];
- if (_playingRadio || !_currentPlaylist) {
- [tempItem setEnabled:NO];
- }
-
- itemEnum = [[_ratingMenu itemArray] objectEnumerator];
- while ( (tempItem = [itemEnum nextObject]) ) {
- [tempItem setState:NSOffState];
- }
-
- NS_DURING
- [[_ratingMenu itemAtIndex:([mtr currentSongRating] * 5)] setState:NSOnState];
- NS_HANDLER
- [[MainController sharedController] networkError:localException];
- NS_ENDHANDLER
- } else if ([nextObject isEqualToString:@"upcomingSongs"]) {
- ITDebugLog(@"Add \"Upcoming Songs\" submenu.");
- tempItem = [menu addItemWithTitle:NSLocalizedString(@"upcomingSongs", @"Upcoming Songs")
- action:nil
- keyEquivalent:@""];
- [tempItem setSubmenu:_upcomingSongsMenu];
- [tempItem setTag:2];
- if (_playingRadio || !_currentPlaylist) {
- [tempItem setEnabled:NO];
- }
+ ITDebugLog(@"Add \"Song Rating\" submenu.");
+ tempItem = [menu addItemWithTitle:NSLocalizedString(@"songRating", @"Song Rating")
+ action:nil
+ keyEquivalent:@""];
+ [tempItem setSubmenu:_ratingMenu];
+ [tempItem setTag:1];
+ if (_playingRadio || !_currentPlaylist) {
+ [tempItem setEnabled:NO];
+ }
+
+ itemEnum = [[_ratingMenu itemArray] objectEnumerator];
+ while ( (tempItem = [itemEnum nextObject]) ) {
+ [tempItem setState:NSOffState];
+ }
+
+ NS_DURING
+ [[_ratingMenu itemAtIndex:([mtr currentSongRating] * 5)] setState:NSOnState];
+ NS_HANDLER
+ [[MainController sharedController] networkError:localException];
+ NS_ENDHANDLER
+ } else if ([nextObject isEqualToString:@"upcomingSongs"]) {
+ ITDebugLog(@"Add \"Upcoming Songs\" submenu.");
+ tempItem = [menu addItemWithTitle:NSLocalizedString(@"upcomingSongs", @"Upcoming Songs")
+ action:nil
+ keyEquivalent:@""];
+ [tempItem setSubmenu:_upcomingSongsMenu];
+ [tempItem setTag:2];
+ if (_playingRadio || !_currentPlaylist) {
+ [tempItem setEnabled:NO];
+ }
+ } else if ([nextObject isEqualToString:@"artists"]) {
+ ITDebugLog(@"Add \"Artists\" submenu.");
+ tempItem = [menu addItemWithTitle:NSLocalizedString(@"artists", @"Artists")
+ action:nil
+ keyEquivalent:@""];
+ [tempItem setSubmenu:_artistsMenu];
+ [tempItem setTag:5];
+
+ itemEnum = [[_eqMenu itemArray] objectEnumerator];
+ while ( (tempItem = [itemEnum nextObject]) ) {
+ [tempItem setState:NSOffState];
}
}
+ }
ITDebugLog(@"Finished building menu.");
[_currentMenu release];
_currentMenu = menu;
- (void)rebuildSubmenus
{
+ NSArray *menu = [[NSUserDefaults standardUserDefaults] arrayForKey:@"menu"];
ITDebugLog(@"Rebuilding all of the submenus.");
NS_DURING
_currentPlaylist = [[[MainController sharedController] currentRemote] currentPlaylistIndex];
[_playlistsMenu release];
ITDebugLog(@" - EQ menu");
[_eqMenu release];
+
ITDebugLog(@"Beginning Rebuild of \"Song Rating\" submenu.");
_ratingMenu = [self ratingMenu];
ITDebugLog(@"Beginning Rebuild of \"Upcoming Songs\" submenu.");
_playlistsMenu = [self playlistsMenu];
ITDebugLog(@"Beginning Rebuild of \"EQ Presets\" submenu.");
_eqMenu = [self eqMenu];
+
+ if ([menu containsObject:@"artists"]) {
+ ITDebugLog(@"Releasing artists menu");
+ [_artistsMenu release];
+ ITDebugLog(@"Beginning Rebuild of \"Artists\" submenu.");
+ _artistsMenu = [self artistsMenu];
+ }
ITDebugLog(@"Done rebuilding all of the submenus.");
}
[[playlistsMenu itemAtIndex:_currentPlaylist - 1] setState:NSOnState];
}
[indices release];
+ tempItem = [playlistsMenu addItemWithTitle:NSLocalizedString(@"refresh", @"Refresh") action:@selector(rebuildSubmenus) keyEquivalent:@""];
+ [tempItem setTarget:self];
+ [tempItem setImage:[NSImage imageNamed:@"ChasingArrow"]];
ITDebugLog(@"Done Building \"Playlists\" menu");
return playlistsMenu;
}
ITDebugLog(@"Building \"EQ Presets\" menu.");
+ tempItem = [eqMenu addItemWithTitle:@"Enabled" action:@selector(performEqualizerMenuAction:) keyEquivalent:@""];
+ [tempItem setTag:-1];
+ [tempItem setTarget:self];
+ NS_DURING
+ [tempItem setState:[[[MainController sharedController] currentRemote] equalizerEnabled] ? NSOnState : NSOffState];
+ NS_HANDLER
+ [[MainController sharedController] networkError:localException];
+ NS_ENDHANDLER
+ [eqMenu addItem:[NSMenuItem separatorItem]];
+
for (i = 0; i < [eqPresets count]; i++) {
NSString *name;
if ( ( name = [eqPresets objectAtIndex:i] ) ) {
return eqMenu;
}
+- (NSMenu *)artistsMenu
+{
+ NSMenu *artistsMenu = [[NSMenu alloc] initWithTitle:@""];
+ NSEnumerator *artistsEnumerator;
+ NSString *nextArtist;
+ id <NSMenuItem> tempItem;
+ ITDebugLog(@"Building \"Artists\" menu.");
+ NS_DURING
+ artistsEnumerator = [[[[MainController sharedController] currentRemote] artists] objectEnumerator];
+ while ( (nextArtist = [artistsEnumerator nextObject]) ) {
+ tempItem = [artistsMenu addItemWithTitle:nextArtist action:@selector(performArtistsMenuAction:) keyEquivalent:@""];
+ [tempItem setRepresentedObject:nextArtist];
+ [tempItem setTarget:self];
+ }
+ NS_HANDLER
+ [[MainController sharedController] networkError:localException];
+ NS_ENDHANDLER
+ ITDebugLog(@"Done Building \"Artists\" menu");
+ return artistsMenu;
+}
+
- (void)performMainMenuAction:(id)sender
{
switch ( [sender tag] )
[[MainController sharedController] selectSongAtIndex:[sender tag]];
}
+- (void)performArtistsMenuAction:(id)sender
+{
+ ITDebugLog(@"Artist action selected on item with object %i", [sender representedObject]);
+ /*
+ ** 1 - Artist
+ ** 2 - Album
+ ** 3 - Genre?
+ */
+ //[[MainController sharedController] createAndPlayPlaylistWithTerm:[sender representedObject] ofType:1];
+}
+
- (void)updateMenu
{
ITDebugLog(@"Update Menu");