X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/6162e11fb9ec9ca0f4add4d5838e98a31ead4a21..f259f879db5bb904afca6f0fa31effa5511c476e:/MainController.m diff --git a/MainController.m b/MainController.m index 8cb2643..40f50ce 100755 --- a/MainController.m +++ b/MainController.m @@ -6,6 +6,7 @@ #import #import #import +#import #import "StatusWindow.h" #import "StatusWindowController.h" #import "StatusItemHack.h" @@ -358,7 +359,6 @@ static MainController *sharedController; { if ( [self songChanged] && (timerUpdating != YES) && (playerRunningState == ITMTRemotePlayerRunning) ) { ITDebugLog(@"The song changed."); - if ([df boolForKey:@"runScripts"]) { NSArray *scripts = [[NSFileManager defaultManager] directoryContentsAtPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"]]; NSEnumerator *scriptsEnum = [scripts objectEnumerator]; @@ -556,6 +556,17 @@ static MainController *sharedController; [self timerUpdate]; } +- (void)makePlaylistWithTerm:(NSString *)term ofType:(int)type +{ + ITDebugLog(@"Making playlist with term %@, type %i", term, type); + NS_DURING + [[self currentRemote] makePlaylistWithTerm:term ofType:type]; + NS_HANDLER + [self networkError:localException]; + NS_ENDHANDLER + ITDebugLog(@"Done making playlist"); +} + - (void)showPlayer { ITDebugLog(@"Beginning show player."); @@ -810,6 +821,20 @@ static MainController *sharedController; [hotKey setAction:@selector(popupMenu)]; [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]]; } + + int i; + for (i = 0; i <= 5; i++) { + NSString *curName = [NSString stringWithFormat:@"SetRating%i", i]; + if ([df objectForKey:curName] != nil) { + ITDebugLog(@"Setting up set rating %i hot key.", i); + hotKey = [[ITHotKey alloc] init]; + [hotKey setName:curName]; + [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:curName]]]; + [hotKey setTarget:self]; + [hotKey setAction:@selector(setRating:)]; + [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]]; + } + } ITDebugLog(@"Finished setting up hot keys."); } @@ -876,7 +901,7 @@ static MainController *sharedController; if ( [df boolForKey:@"showTime"] ) { NS_DURING time = [NSString stringWithFormat:@"%@: %@ / %@", - @"Time", + NSLocalizedString(@"time", @"Time"), [[self currentRemote] currentSongElapsed], [[self currentRemote] currentSongLength]]; NS_HANDLER @@ -915,7 +940,7 @@ static MainController *sharedController; } } - if ( [df boolForKey:@"showPlayCount"] ) { + if ( [df boolForKey:@"showPlayCount"] && ![self radioIsPlaying] && [[self currentRemote] currentSource] == ITMTRemoteLibrarySource ) { NS_DURING playCount = [[self currentRemote] currentSongPlayCount]; NS_HANDLER @@ -976,8 +1001,13 @@ static MainController *sharedController; - (void)popupMenu { - NSMenu *menu = [menuController menu]; - [(NSCarbonMenuImpl *)[menu _menuImpl] popUpMenu:menu atLocation:[NSEvent mouseLocation] width:1 forView:nil withSelectedItem:-30 withFont:[NSFont menuFontOfSize:32]]; + if (!_popped) { + _popped = YES; + [self menuClicked]; + NSMenu *menu = [statusItem menu]; + [(NSCarbonMenuImpl *)[menu _menuImpl] popUpMenu:menu atLocation:[NSEvent mouseLocation] width:1 forView:nil withSelectedItem:-30 withFont:[NSFont menuFontOfSize:32]]; + _popped = NO; + } } - (void)incrementVolume @@ -1078,6 +1108,13 @@ static MainController *sharedController; NS_ENDHANDLER } +- (void)setRating:(ITHotKey *)sender +{ + int stars = [[sender name] characterAtIndex:9] - 48; + [self selectSongRating:stars * 20]; + [statusWindowController showRatingWindowWithRating:(float)stars / 5.0]; +} + - (void)toggleLoop { NS_DURING