Created
January 31, 2016 06:32
-
-
Save festivia/55641144129863f53452 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
// | |
// main.m | |
// Simple iTunes | |
// | |
// Created by Colt on 4/13/13. | |
// Copyright 2013 __colt__. All rights reserved. | |
// | |
#import <Cocoa/Cocoa.h> | |
int main(int argc, char *argv[]) | |
{ | |
return NSApplicationMain(argc, (const char **) argv); | |
} |
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
// | |
// Simple iTunes.h | |
// Simple iTunes | |
// | |
// Created by Colt on 4/13/13. | |
// Copyright 2013 __colt__. All rights reserved. | |
// | |
#import <Cocoa/Cocoa.h> | |
@interface Simple_iTunes : NSObject { | |
NSStatusItem *statusItem; | |
IBOutlet NSMenu *statusMenu; | |
} | |
@end |
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
// | |
// Simple iTunes.m | |
// Simple iTunes | |
// | |
// Created by Colt on 4/13/13. | |
// Copyright 2013 __colt__. All rights reserved. | |
// | |
#import "Simple iTunes.h" | |
@implementation Simple_iTunes | |
-(void)awakeFromNib { | |
statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain]; | |
[statusItem setHighlightMode:YES]; | |
[statusItem setTitle:@"iTunes"]; | |
[statusItem setMenu:statusMenu]; | |
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(updateTrackInfo:) name:@"com.apple.iTunes.playerInfo" object:nil]; | |
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(iTunesTerminated:) name:NSWorkspaceDidTerminateApplicationNotification object:nil]; | |
} | |
-(void)updateTrackInfo:(NSNotification *)notification { | |
NSDictionary *information = [notification userInfo]; | |
NSLog(@"track information: %@", information); | |
if ([information valueForKey:@"Display Line 2"]) { | |
[statusItem setTitle: [NSString stringWithFormat:@"%@", [information valueForKey:@"Display Line 1"]]]; | |
} | |
if ([information valueForKey:@"Artist"] && | |
[information valueForKey:@"Name"]) { | |
[statusItem setTitle: [NSString stringWithFormat:@"%@ - %@", [information valueForKey:@"Name"], [information valueForKey:@"Artist"]]]; | |
}} | |
-(void)iTunesTerminated:(NSNotification *)notification { | |
NSRunningApplication *runApp = [[notification userInfo] valueForKey:@"NSWorkspaceApplicationKey"]; | |
if ([runApp.bundleIdentifier isEqualToString:@"com.apple.iTunes"]) { | |
[statusItem setTitle:@"iTunes"]; | |
}} | |
-(void)dealloc { | |
[statusItem release]; | |
[super dealloc]; | |
} | |
@end |
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
// | |
// Prefix header for all source files of the 'Simple iTunes' target in the 'Simple iTunes' project | |
// | |
#ifdef __OBJC__ | |
#import <Cocoa/Cocoa.h> | |
#endif |
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
// | |
// Simple_iTunesAppDelegate.h | |
// Simple iTunes | |
// | |
// Created by Colt on 4/13/13. | |
// Copyright 2013 __colt__. All rights reserved. | |
// | |
#import <Cocoa/Cocoa.h> | |
@interface Simple_iTunesAppDelegate : NSObject <NSApplicationDelegate> { | |
NSWindow *window; | |
} | |
@property (assign) IBOutlet NSWindow *window; | |
@end |
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
// | |
// Simple_iTunesAppDelegate.m | |
// Simple iTunes | |
// | |
// Created by Colt on 4/13/13. | |
// Copyright 2013 __colt__. All rights reserved. | |
// | |
#import "Simple_iTunesAppDelegate.h" | |
@implementation Simple_iTunesAppDelegate | |
@synthesize window; | |
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { | |
// Insert code here to initialize your application | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment