X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/a5c365dd668dee7c653dbafee270e5e05025a2ab..8dbd42fb72d80c522809b1a8aeae73ab30dd6c90:/MenuController.m diff --git a/MenuController.m b/MenuController.m index 88a94ba..e65cc1d 100755 --- a/MenuController.m +++ b/MenuController.m @@ -22,6 +22,7 @@ - (NSMenu *)playlistsMenu; - (NSMenu *)eqMenu; - (NSMenu *)artistsMenu; +- (NSMenu *)albumsMenu; - (void)setKeyEquivalentForCode:(short)code andModifiers:(long)modifiers onItem:(id )item; - (BOOL)iPodWithNameAutomaticallyUpdates:(NSString *)name; @@ -88,6 +89,11 @@ [tempItem setSubmenu:nil]; } + if ( (tempItem = [_currentMenu itemWithTag:6]) ) { + ITDebugLog(@"Removing \"Albums\" submenu."); + [tempItem setSubmenu:nil]; + } + ITDebugLog(@"Begin building menu."); //create our menu @@ -439,11 +445,13 @@ 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."); @@ -520,6 +528,13 @@ 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."); } @@ -757,7 +772,7 @@ - (NSMenu *)artistsMenu { - NSMenu *artistsMenu = [[NSMenu alloc] initWithTitle:@""]; + NSMenu *artistsMenu = [[NSMenu alloc] initWithTitle:@"Artists"]; NSEnumerator *artistsEnumerator; NSString *nextArtist; id tempItem; @@ -765,8 +780,7 @@ 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 @@ -776,6 +790,26 @@ return artistsMenu; } +- (NSMenu *)albumsMenu +{ + NSMenu *albumsMenu = [[NSMenu alloc] initWithTitle:@"Albums"]; + NSEnumerator *albumsEnumerator; + NSString *nextAlbum; + id 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] ) @@ -846,15 +880,15 @@ [[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] makePlaylistWithTerm:[sender representedObject] ofType:1]; + [[MainController sharedController] makePlaylistWithTerm:[sender title] ofType:(([[[sender menu] title] isEqualToString:@"Artists"]) ? 1 : 2)]; } - (void)updateMenu