- (NSMenu *)playlistsMenu;
- (NSMenu *)eqMenu;
- (NSMenu *)artistsMenu;
+- (NSMenu *)albumsMenu;
- (void)setKeyEquivalentForCode:(short)code andModifiers:(long)modifiers
onItem:(id <NSMenuItem>)item;
- (BOOL)iPodWithNameAutomaticallyUpdates:(NSString *)name;
[tempItem setSubmenu:nil];
}
+ if ( (tempItem = [_currentMenu itemWithTag:6]) ) {
+ ITDebugLog(@"Removing \"Albums\" submenu.");
+ [tempItem setSubmenu:nil];
+ }
+
ITDebugLog(@"Begin building menu.");
//create our menu
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
keyEquivalent:@""];
[tempItem setSubmenu:_artistsMenu];
[tempItem setTag:5];
-
- itemEnum = [[_eqMenu itemArray] objectEnumerator];
- while ( (tempItem = [itemEnum nextObject]) ) {
- [tempItem setState:NSOffState];
- }
+ } else if ([nextObject isEqualToString:@"albums"]) {
+ ITDebugLog(@"Add \"Albums\" submenu.");
+ tempItem = [menu addItemWithTitle:NSLocalizedString(@"albums", @"Albums")
+ action:nil
+ keyEquivalent:@""];
+ [tempItem setSubmenu:_albumsMenu];
+ [tempItem setTag:6];
}
}
ITDebugLog(@"Finished building menu.");
ITDebugLog(@"Beginning Rebuild of \"Artists\" submenu.");
_artistsMenu = [self artistsMenu];
}
+
+ if ([menu containsObject:@"albums"]) {
+ ITDebugLog(@"Releasing albums menu");
+ [_albumsMenu release];
+ ITDebugLog(@"Beginning Rebuild of \"Albums\" submenu.");
+ _albumsMenu = [self albumsMenu];
+ }
ITDebugLog(@"Done rebuilding all of the submenus.");
}
{
NSMenu *upcomingSongsMenu = [[NSMenu alloc] initWithTitle:@""];
int numSongs = 0, numSongsInAdvance = [[NSUserDefaults standardUserDefaults] integerForKey:@"SongsInAdvance"];
-
NS_DURING
numSongs = [[[MainController sharedController] currentRemote] numberOfSongsInPlaylistAtIndex:_currentPlaylist];
NS_HANDLER
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++) {
- (NSMenu *)artistsMenu
{
- NSMenu *artistsMenu = [[NSMenu alloc] initWithTitle:@""];
+ NSMenu *artistsMenu = [[NSMenu alloc] initWithTitle:@"Artists"];
NSEnumerator *artistsEnumerator;
NSString *nextArtist;
id <NSMenuItem> tempItem;
NS_DURING
artistsEnumerator = [[[[MainController sharedController] currentRemote] artists] objectEnumerator];
while ( (nextArtist = [artistsEnumerator nextObject]) ) {
- tempItem = [artistsMenu addItemWithTitle:nextArtist action:@selector(performArtistsMenuAction:) keyEquivalent:@""];
- [tempItem setRepresentedObject:nextArtist];
+ tempItem = [artistsMenu addItemWithTitle:nextArtist action:@selector(performBrowseMenuAction:) keyEquivalent:@""];
[tempItem setTarget:self];
}
NS_HANDLER
return artistsMenu;
}
+- (NSMenu *)albumsMenu
+{
+ NSMenu *albumsMenu = [[NSMenu alloc] initWithTitle:@"Albums"];
+ NSEnumerator *albumsEnumerator;
+ NSString *nextAlbum;
+ id <NSMenuItem> tempItem;
+ ITDebugLog(@"Building \"Albums\" menu.");
+ NS_DURING
+ albumsEnumerator = [[[[MainController sharedController] currentRemote] albums] objectEnumerator];
+ while ( (nextAlbum = [albumsEnumerator nextObject]) ) {
+ tempItem = [albumsMenu addItemWithTitle:nextAlbum action:@selector(performBrowseMenuAction:) keyEquivalent:@""];
+ [tempItem setTarget:self];
+ }
+ NS_HANDLER
+ [[MainController sharedController] networkError:localException];
+ NS_ENDHANDLER
+ ITDebugLog(@"Done Building \"Albums\" menu");
+ return albumsMenu;
+}
+
- (void)performMainMenuAction:(id)sender
{
switch ( [sender tag] )
[[MainController sharedController] selectSongAtIndex:[sender tag]];
}
-- (void)performArtistsMenuAction:(id)sender
+- (void)performBrowseMenuAction:(id)sender
{
- ITDebugLog(@"Artist action selected on item with object %i", [sender representedObject]);
+ ITDebugLog(@"Browse action selected on item named %@", [sender title]);
/*
** 1 - Artist
** 2 - Album
** 3 - Genre?
*/
- //[[MainController sharedController] createAndPlayPlaylistWithTerm:[sender representedObject] ofType:1];
+ [[MainController sharedController] makePlaylistWithTerm:[sender title] ofType:(([[[sender menu] title] isEqualToString:@"Artists"]) ? 1 : 2)];
}
- (void)updateMenu