#import <ITKit/ITHotKeyCenter.h>
#import <ITKit/ITHotKey.h>
#import <ITKit/ITKeyCombo.h>
+#import <ITKit/ITCategory-NSMenu.h>
#import "StatusWindow.h"
#import "StatusWindowController.h"
#import "StatusItemHack.h"
[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.");
}
}
}
- if ( [df boolForKey:@"showPlayCount"] ) {
+ if ( [df boolForKey:@"showPlayCount"] && ![self radioIsPlaying] ) {
NS_DURING
playCount = [[self currentRemote] currentSongPlayCount];
NS_HANDLER
- (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) {
+ NSMenu *menu = [menuController menu];
+ _popped = YES;
+ [(NSCarbonMenuImpl *)[menu _menuImpl] popUpMenu:menu atLocation:[NSEvent mouseLocation] width:1 forView:nil withSelectedItem:-30 withFont:[NSFont menuFontOfSize:32]];
+ _popped = NO;
+ }
}
- (void)incrementVolume
NS_ENDHANDLER
}
+- (void)setRating:(ITHotKey *)sender
+{
+ float rating = ([[sender name] characterAtIndex:9] - 48) / 5.0;
+ [self selectSongRating:rating];
+ [statusWindowController showRatingWindowWithRating:rating];
+}
+
- (void)toggleLoop
{
NS_DURING