blob: 2f0f465d935e00ad774db34cd890bf0d1aea94d3 (
plain)
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
|
#import "Menulet.h"
@implementation Menulet
- (void) dealloc {
[statusItem release];
[menuIcon release];
[super dealloc];
}
- (void) awakeFromNib {
statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength: NSVariableStatusItemLength] retain];
[statusItem setHighlightMode: YES];
[statusItem setEnabled: YES];
[statusItem setToolTip: @"Slimber"];
[statusItem setMenu: statusMenu];
NSBundle* bundle = [NSBundle bundleForClass: [self class]];
NSString* path = [bundle pathForResource: @"Offline" ofType:@"png"];
menuIcon = [[NSImage alloc] initWithContentsOfFile: path];
[statusItem setImage: menuIcon];
NSMenuItem* statusMenuItem = [[NSMenuItem alloc] initWithTitle: @"Online Users" action: NULL keyEquivalent:@""];
[statusMenu addItem: statusMenuItem];
[statusMenu addItem: [NSMenuItem separatorItem]];
NSMenuItem* loggedInItem = [[NSMenuItem alloc] initWithTitle: @"You are not logged in" action: NULL keyEquivalent:@""];
[statusMenu addItem: loggedInItem];
}
- (IBAction) updateStatus: (id) sender {
[statusItem setTitle: [NSString stringWithString:@"Boo"]];
NSMenuItem* statusMenuItem = [[NSMenuItem alloc] initWithTitle: @"Foo" action: @selector(updateStatus:) keyEquivalent:@""];
[statusMenuItem setTitle:[NSString stringWithString:@"Boo"]];
[statusMenu insertItem: statusMenuItem atIndex:1];
}
@end
|