blob: 02615ac07a599dcfe1f39de3878cec3fc57f025d (
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
|
#import "Menulet.h"
@implementation Menulet
- (void) dealloc {
[statusItem release];
[super dealloc];
}
- (void) awakeFromNib {
statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength: NSVariableStatusItemLength] retain];
[statusItem setHighlightMode: YES];
[statusItem setTitle: [NSString stringWithFormat:@"%C",0x2295]];
[statusItem setEnabled: YES];
[statusItem setToolTip: @"Slimber"];
[statusItem setMenu: statusMenu];
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
|