sant0sk1 (owner)

Revisions

gist: 222616 Download_button fork
public
Public Clone URL: git://gist.github.com/222616.git
Embed All Files: show embed
AppController.j #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
@import <Foundation/CPObject.j>
@import "JSmenu.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()];
    
    var menu = [[JSMenu alloc] init];
    [menu setSessionMenuType:YES];
    [[CPApplication sharedApplication] setMainMenu:menu];
    [CPMenu setMenuBarVisible:YES];
    
}
 
@end
 
JSMenu.j #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
@import <AppKit/CPMenu.j>
 
@implementation JSMenu : CPMenu
{
    CPMenuItem SessionMenuItem;
}
 
- (id)init
{
    self = [super init];
    
    if (self)
    {
        for (i = 0; i < 14; i++)
            [self addItem:[CPMenuItem separatorItem]];
        
        SessionMenuItem = [[CPMenuItem alloc] init];
        
        [SessionMenuItem setFont:[CPFont systemFontOfSize:13]];
        [SessionMenuItem setTarget:[[CPApplication sharedApplication] delegate]];
        
        [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)setSessionMenuType:(BOOL)isLoggedIn
{
    if (isLoggedIn)
    {
        [SessionMenuItem setTitle:@"Logout"];
        [SessionMenuItem setAction:@selector(logoutUser:)];
    }
    else
    {
        [SessionMenuItem setTitle:@"Login"];
        [SessionMenuItem setAction:@selector(showUserWindow:)];
    }
}
 
@end