diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-07-20 12:09:42 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-07-20 12:09:42 (GMT) |
commit | 1b73d4228fc3269284427ed574b9f35775315488 (patch) | |
tree | e70bd2e70c75ae1b8282ce320d830284156cd5a7 /Slimber/Cocoa | |
parent | 6c181e11f30cfb58688f327326a03f268ee3790a (diff) | |
download | swift-1b73d4228fc3269284427ed574b9f35775315488.zip swift-1b73d4228fc3269284427ed574b9f35775315488.tar.bz2 |
Use icon in menulet.
Diffstat (limited to 'Slimber/Cocoa')
-rw-r--r-- | Slimber/Cocoa/Makefile.inc | 17 | ||||
-rw-r--r-- | Slimber/Cocoa/Menulet.h | 5 | ||||
-rw-r--r-- | Slimber/Cocoa/Menulet.m | 9 |
3 files changed, 21 insertions, 10 deletions
diff --git a/Slimber/Cocoa/Makefile.inc b/Slimber/Cocoa/Makefile.inc index e457b7a..d07e0d7 100644 --- a/Slimber/Cocoa/Makefile.inc +++ b/Slimber/Cocoa/Makefile.inc @@ -6,6 +6,9 @@ SLIMBER_COCOA_SOURCES = \ Slimber/Cocoa/Menulet.m SLIMBER_COCOA_XIBS = \ Slimber/Cocoa/MainMenu.xib +SLIMBER_COCOA_RESOURCES = \ + Slimber/Resources/Online.png \ + Slimber/Resources/Offline.png SLIMBER_COCOA_NIBS = \ $(SLIMBER_COCOA_XIBS:.xib=.nib) @@ -24,12 +27,14 @@ DEPS += \ slimber-cocoa: $(SLIMBER_COCOA_TARGET) $(SLIMBER_COCOA_TARGET): $(SLIMBER_COCOA_BINARY) $(SLIMBER_COCOA_NIBS) Slimber/Cocoa/Info.plist Slimber/Cocoa/PkgInfo - mkdir -p $(SLIMBER_COCOA_TARGET)/Resources - mkdir -p $(SLIMBER_COCOA_TARGET)/MacOS - cp -r Slimber/Cocoa/Info.plist $(SLIMBER_COCOA_TARGET) - cp -r Slimber/Cocoa/PkgInfo $(SLIMBER_COCOA_TARGET) - cp $(SLIMBER_COCOA_BINARY) $(SLIMBER_COCOA_TARGET)/MacOS - cp $(SLIMBER_COCOA_NIBS) $(SLIMBER_COCOA_TARGET)/Resources + -rm -rf $(SLIMBER_COCOA_TARGET) + mkdir -p $(SLIMBER_COCOA_TARGET)/Contents/Resources + mkdir -p $(SLIMBER_COCOA_TARGET)/Contents/MacOS + cp -r Slimber/Cocoa/Info.plist $(SLIMBER_COCOA_TARGET)/Contents + cp -r Slimber/Cocoa/PkgInfo $(SLIMBER_COCOA_TARGET)/Contents + cp $(SLIMBER_COCOA_BINARY) $(SLIMBER_COCOA_TARGET)/Contents/MacOS + cp $(SLIMBER_COCOA_NIBS) $(SLIMBER_COCOA_TARGET)/Contents/Resources + cp $(SLIMBER_COCOA_RESOURCES) $(SLIMBER_COCOA_TARGET)/Contents/Resources $(SLIMBER_COCOA_BINARY): $(SLIMBER_COCOA_OBJECTS) $(QUIET_LINK)$(CXX) -o $@ $(SLIMBER_COCOA_OBJECTS) $(LDFLAGS) $(SWIFTEN_TARGET) $(LIBS) -framework Cocoa diff --git a/Slimber/Cocoa/Menulet.h b/Slimber/Cocoa/Menulet.h index 0993547..c676630 100644 --- a/Slimber/Cocoa/Menulet.h +++ b/Slimber/Cocoa/Menulet.h @@ -3,9 +3,10 @@ @interface Menulet : NSObject { NSStatusItem* statusItem; - IBOutlet NSMenu *statusMenu; + IBOutlet NSMenu* statusMenu; + NSImage* menuIcon; } -(IBAction) updateStatus: (id) sender; -@end
\ No newline at end of file +@end diff --git a/Slimber/Cocoa/Menulet.m b/Slimber/Cocoa/Menulet.m index 02615ac..2f0f465 100644 --- a/Slimber/Cocoa/Menulet.m +++ b/Slimber/Cocoa/Menulet.m @@ -4,17 +4,22 @@ - (void) dealloc { [statusItem release]; + [menuIcon 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]; + 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]]; @@ -29,4 +34,4 @@ [statusMenu insertItem: statusMenuItem atIndex:1]; } -@end
\ No newline at end of file +@end |