Created
October 10, 2008 06:26
-
-
Save anonymous/16007 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
import <Foundation/CPObject.j> | |
@implementation AppController : CPObject | |
{ | |
} | |
- (void)applicationDidFinishLaunching:(CPNotification)aNotification | |
{ | |
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], | |
contentView = [theWindow contentView]; | |
var label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()]; | |
[label setStringValue:@"Hello World!"]; | |
[label setFont:[CPFont boldSystemFontOfSize:24.0]]; | |
[label sizeToFit]; | |
[label setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin]; | |
[label setFrameOrigin:CGPointMake((CGRectGetWidth([contentView bounds]) - CGRectGetWidth([label frame])) / 2.0, (CGRectGetHeight([contentView bounds]) - CGRectGetHeight([label frame])) / 2.0)]; | |
var request = [CPURLRequest requestWithURL:"http://gignit.com/actions/sessionid.cgi"]; | |
[request setHTTPMethod: "DELETE"]; | |
var connection = [CPURLConnection connectionWithRequest:request delegate:self]; | |
[contentView addSubview:label]; | |
[theWindow orderFront:self]; | |
// Uncomment the following line to turn on the standard menu bar. | |
//[CPMenu setMenuBarVisible:YES]; | |
} | |
- (void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)data | |
{ | |
var result = CPJSObjectCreateWithJSON(data); | |
if (aConnection == connection) | |
[label setStringValue:result]; | |
[self clearConnection:aConnection]; | |
} | |
- (void)clearConnection:(CPURLConnection)aConnection | |
{ | |
if (aConnection == connection) | |
connection = nil; | |
} | |
@end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment