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 | |
parent | 052f685338462a8c0c6d9785864e7549290d7037 (diff) | |
download | swift-contrib-0c44bb6fa24900acef40dffdc65c8aecd3ee48ca.zip swift-contrib-0c44bb6fa24900acef40dffdc65c8aecd3ee48ca.tar.bz2 |
Add an online/offline icon.
-rw-r--r-- | Slimber/Cocoa/Makefile.inc | 4 | ||||
-rw-r--r-- | Slimber/Cocoa/Menulet.m | 16 | ||||
-rwxr-xr-x[-rw-r--r--] | Slimber/Resources/Offline.png | bin | 1115 -> 3411 bytes | |||
-rwxr-xr-x[-rw-r--r--] | Slimber/Resources/Online.png | bin | 1217 -> 3427 bytes | |||
-rw-r--r-- | Slimber/Resources/UsersOffline.png | bin | 0 -> 1115 bytes | |||
-rw-r--r-- | Slimber/Resources/UsersOnline.png | bin | 0 -> 1217 bytes |
6 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]; diff --git a/Slimber/Resources/Offline.png b/Slimber/Resources/Offline.png Binary files differindex 08a183a..5b4fe01 100644..100755 --- a/Slimber/Resources/Offline.png +++ b/Slimber/Resources/Offline.png diff --git a/Slimber/Resources/Online.png b/Slimber/Resources/Online.png Binary files differindex 0ea9a2d..2933460 100644..100755 --- a/Slimber/Resources/Online.png +++ b/Slimber/Resources/Online.png diff --git a/Slimber/Resources/UsersOffline.png b/Slimber/Resources/UsersOffline.png Binary files differnew file mode 100644 index 0000000..08a183a --- /dev/null +++ b/Slimber/Resources/UsersOffline.png diff --git a/Slimber/Resources/UsersOnline.png b/Slimber/Resources/UsersOnline.png Binary files differnew file mode 100644 index 0000000..0ea9a2d --- /dev/null +++ b/Slimber/Resources/UsersOnline.png |