From 0c44bb6fa24900acef40dffdc65c8aecd3ee48ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Tue, 21 Jul 2009 13:42:15 +0200 Subject: Add an online/offline icon. 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]; diff --git a/Slimber/Resources/Offline.png b/Slimber/Resources/Offline.png old mode 100644 new mode 100755 index 08a183a..5b4fe01 Binary files a/Slimber/Resources/Offline.png and b/Slimber/Resources/Offline.png differ diff --git a/Slimber/Resources/Online.png b/Slimber/Resources/Online.png old mode 100644 new mode 100755 index 0ea9a2d..2933460 Binary files a/Slimber/Resources/Online.png and b/Slimber/Resources/Online.png differ diff --git a/Slimber/Resources/UsersOffline.png b/Slimber/Resources/UsersOffline.png new file mode 100644 index 0000000..08a183a Binary files /dev/null and b/Slimber/Resources/UsersOffline.png differ diff --git a/Slimber/Resources/UsersOnline.png b/Slimber/Resources/UsersOnline.png new file mode 100644 index 0000000..0ea9a2d Binary files /dev/null and b/Slimber/Resources/UsersOnline.png differ -- cgit v0.10.2-6-g49f6