Skip to content

Instantly share code, notes, and snippets.

@jerodsanto
Created December 8, 2009 22:05
Show Gist options
  • Save jerodsanto/252038 to your computer and use it in GitHub Desktop.
Save jerodsanto/252038 to your computer and use it in GitHub Desktop.
@import <AppKit/CPMenu.j>
@implementation JSMenu : CPMenu
{
CPMenuItem SessionMenuItem;
}
- (id)init
{
if (self = [super init])
{
for (i = 0; i < 14; i++)
[self addItem:[CPMenuItem separatorItem]];
SessionMenuItem = [[CPMenuItem alloc] init];
[SessionMenuItem setFont:[CPFont systemFontOfSize:13]];
[SessionMenuItem setTarget:[[[CPApplication sharedApplication] delegate] userController]];
[self insertItem:SessionMenuItem atIndex:13];
var menuAttributes = [CPDictionary dictionaryWithObjects:
[[CPColor colorWithPatternImage:[[CPImage alloc] initByReferencingFile:@"Resources/Menu.png"
size:CGSizeMake(5,29)]],
[CPColor whiteColor],
[CPColor blackColor]]
forKeys:[@"CPMenuBarBackgroundColor",@"CPMenuBarTitleColor",@"CPMenuBarTitleShadowColor"]
]
[CPMenu setMenuBarAttributes:menuAttributes];
}
return self;
}
- (void)setSessionMenuItemFor:(BOOL)isLoggedIn
{
if (isLoggedIn)
{
[SessionMenuItem setTitle:@"Logout"];
[SessionMenuItem setAction:@selector(logoutUser:)];
}
else
{
[SessionMenuItem setTitle:@"Login"];
[SessionMenuItem setAction:@selector(showUserWindow:)];
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment