From 1b73d4228fc3269284427ed574b9f35775315488 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Mon, 20 Jul 2009 14:09:42 +0200
Subject: Use icon in menulet.


diff --git a/Makefile b/Makefile
index fe9602a..f5bab96 100644
--- a/Makefile
+++ b/Makefile
@@ -87,7 +87,7 @@ endif
 endif
 
 %/PkgInfo:
-	echo -n -e "APPL\x3f\x3f\x3f\x3f" > $@
+	printf "APPL\77\77\77\77" > $@
 
 %.dep: %.cpp
 	$(QUIET_MM)$(MM) -MM -MG -MT $(basename $@).o $(CPPFLAGS) $(filter-out -arch armv6 -arch i386 -arch ppc,$(CXXFLAGS)) $< > $@
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
diff --git a/Slimber/Resources/Offline.png b/Slimber/Resources/Offline.png
new file mode 100644
index 0000000..08a183a
Binary files /dev/null and b/Slimber/Resources/Offline.png differ
diff --git a/Slimber/Resources/Online.png b/Slimber/Resources/Online.png
new file mode 100644
index 0000000..0ea9a2d
Binary files /dev/null and b/Slimber/Resources/Online.png differ
-- 
cgit v0.10.2-6-g49f6