Skip to content

Instantly share code, notes, and snippets.

@bpowers
Created November 23, 2011 13:03
Show Gist options
  • Save bpowers/1388617 to your computer and use it in GitHub Desktop.
Save bpowers/1388617 to your computer and use it in GitHub Desktop.
@import <Foundation/CPObject.j>
@import <AppKit/CPToolbar.j>
@import <AppKit/CPToolbarItem.j>
var LogoToolbarItemIdentifier = "LogoToolbarItemIdentifier";
@implementation AppController : CPObject {
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification {
CPLogRegister(CPLogPopup);
var theWindow = [[CPWindow alloc]
initWithContentRect:CGRectMakeZero()
styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView];
[contentView setBackgroundColor:[CPColor whiteColor]];
[theWindow orderFront:self];
var toolbar = [[CPToolbar alloc] init];
[toolbar setDelegate:self];
[toolbar setVisible:YES];
[theWindow setToolbar:toolbar];
[theWindow orderFront:self];
}
- (CPArray)toolbarAllowedIdentifiers:(CPToolbar)aToolbar {
return [LogoToolbarItemIdentifier];
}
- (CPArray)toolbarDefaultItemIdentifiers:(CPToolbar)aToolbar {
return [LogoToolbarItemIdentifier];
}
- (CPToolbarItem)toolbar:(CPToolbar)aToolbar itemForItemIdentifier:(CPString)anIdentifier willBeInsertedIntoToolbar:(CPBOOL)aFlag {
var item = [[CPToolbarItem alloc] initWithItemIdentifier:anIdentifier];
if (anIdentifier == LogoToolbarItemIdentifier) {
var image = [[CPImage alloc]
initWithContentsOfFile:[[CPBundle mainBundle]
pathForResource:@"logo.png"]
size:CPSizeMake(214, 59)];
[item setImage:image];
[item setLabel:""];
[item setMinSize:CGSizeMake(20, 48)];
[item setMaxSize:CGSizeMake(174, 80)];
[item setTarget:self];
[item setAction:@selector(logoClick)];
}
return item;
}
- (void)logoClick {
// when we click on the logo, simply go back to the manager.
window.location = "/";
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment