Created
April 13, 2012 09:39
-
-
Save runeb/2375444 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void) play:(NSMenuItem*) menuItem | |
{ | |
for(NSMenuItem *i in menuItems) { | |
[i setState:NSOffState]; | |
} | |
[menuItem setState:NSOnState]; | |
NSDictionary *station = [stations objectAtIndex:menuItem.tag]; | |
NSString *name = [station valueForKey:@"name"]; | |
[systemStatusItem setTitle:name]; | |
NSLog(@"Spiller %@ fra %@", name, [station valueForKey:@"url"]); | |
} | |
- (void) createMenu | |
{ | |
NSStatusBar *bar = [NSStatusBar systemStatusBar]; | |
systemStatusItem = [bar statusItemWithLength:NSVariableStatusItemLength]; | |
[systemStatusItem setTitle:@"Radio"]; | |
[systemStatusItem setHighlightMode:YES]; | |
[systemStatusItem retain]; | |
NSMenu *appMenu = [[NSMenu alloc] init]; | |
NSString *stationsPath = [[NSBundle mainBundle] | |
pathForResource:@"stations" | |
ofType:@"plist"]; | |
stations = [NSArray arrayWithContentsOfFile:stationsPath]; | |
[stations retain]; | |
for(NSDictionary *station in stations) { | |
NSMenuItem *mi = [[NSMenuItem alloc] initWithTitle:[station valueForKey:@"name"] | |
action:@selector(play:) | |
keyEquivalent:@""]; | |
[mi setTag:[menuItems count]]; | |
[menuItems addObject:mi]; | |
[appMenu addItem:mi]; | |
[mi release]; | |
} | |
[appMenu addItem:[NSMenuItem separatorItem]]; | |
[appMenu addItemWithTitle:@"Avslutt" action:@selector(quit) keyEquivalent:@""]; | |
[systemStatusItem setMenu:appMenu]; | |
[appMenu release]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment