diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-07-21 11:42:15 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-07-21 11:42:15 (GMT) |
commit | 0c44bb6fa24900acef40dffdc65c8aecd3ee48ca (patch) | |
tree | de5384f6e93c5610687ad8167836649f8c136141 /Slimber/Cocoa | |
parent | 052f685338462a8c0c6d9785864e7549290d7037 (diff) | |
download | swift-contrib-0c44bb6fa24900acef40dffdc65c8aecd3ee48ca.zip swift-contrib-0c44bb6fa24900acef40dffdc65c8aecd3ee48ca.tar.bz2 |
Add an online/offline icon.
Diffstat (limited to 'Slimber/Cocoa')
-rw-r--r-- | Slimber/Cocoa/Makefile.inc | 4 | ||||
-rw-r--r-- | Slimber/Cocoa/Menulet.m | 16 |
2 files changed, 15 insertions, 5 deletions
diff --git a/Slimber/Cocoa/Makefile.inc b/Slimber/Cocoa/Makefile.inc index be03429..6658dea 100644 --- a/Slimber/Cocoa/Makefile.inc +++ b/Slimber/Cocoa/Makefile.inc @@ -11,7 +11,9 @@ SLIMBER_COCOA_XIBS = \ Slimber/Cocoa/MainMenu.xib SLIMBER_COCOA_RESOURCES = \ Slimber/Resources/Online.png \ - Slimber/Resources/Offline.png + Slimber/Resources/Offline.png \ + Slimber/Resources/UsersOnline.png \ + Slimber/Resources/UsersOffline.png SLIMBER_COCOA_NIBS = \ $(SLIMBER_COCOA_XIBS:.xib=.nib) diff --git a/Slimber/Cocoa/Menulet.m b/Slimber/Cocoa/Menulet.m index 9eda07c..b2af97f 100644 --- a/Slimber/Cocoa/Menulet.m +++ b/Slimber/Cocoa/Menulet.m @@ -30,20 +30,21 @@ NSBundle* bundle = [NSBundle bundleForClass: [self class]]; NSString* path; if (online) { - path = [bundle pathForResource: @"Online" ofType:@"png"]; + path = [bundle pathForResource: @"UsersOnline" ofType:@"png"]; } else { - path = [bundle pathForResource: @"Offline" ofType:@"png"]; + path = [bundle pathForResource: @"UsersOffline" ofType:@"png"]; } - menuIcon = [[NSImage alloc] initWithContentsOfFile: path]; - [statusItem setImage: menuIcon]; + [statusItem setImage: [[NSImage alloc] initWithContentsOfFile: path]]; } - (void) updateMenu { + // Clear the menu while ([statusMenu numberOfItems] > 0) { [statusMenu removeItemAtIndex: 0]; } + // User items if ([userNames count] > 0) { [statusMenu addItem: [[NSMenuItem alloc] initWithTitle: @"Online users:" action: NULL keyEquivalent: @""]]; int i; @@ -58,16 +59,23 @@ [self updateIcon: [userNames count] > 0]; [statusMenu addItem: [NSMenuItem separatorItem]]; + // Self item NSMenuItem* loggedInItem; + NSBundle* bundle = [NSBundle bundleForClass: [self class]]; + NSString* path; if (selfOnline) { loggedInItem = [[NSMenuItem alloc] initWithTitle: @"You are logged in" action: NULL keyEquivalent: @""]; + path = [bundle pathForResource: @"Online" ofType:@"png"]; } else { loggedInItem = [[NSMenuItem alloc] initWithTitle: @"You are not logged in" action: NULL keyEquivalent: @""]; + path = [bundle pathForResource: @"Offline" ofType:@"png"]; } + [loggedInItem setImage: [[NSImage alloc] initWithContentsOfFile: path]]; [statusMenu addItem: loggedInItem]; [statusMenu addItem: [NSMenuItem separatorItem]]; + // Exit item NSMenuItem* exitMenuItem = [[NSMenuItem alloc] initWithTitle: @"Exit" action: @selector(terminate:) keyEquivalent: @""]; [exitMenuItem setTarget: [NSApplication sharedApplication]]; [statusMenu addItem: exitMenuItem]; |