X-Git-Url: http://git.ithinksw.org/ITKit.git/blobdiff_plain/7351b185cf3f32e36745ad0107b2e27a4634127c..3263678eef57c78d7017185eaa2efb9e644c7f29:/ITStatusItem.m diff --git a/ITStatusItem.m b/ITStatusItem.m old mode 100755 new mode 100644 index 1b51ca2..561ecf2 --- a/ITStatusItem.m +++ b/ITStatusItem.m @@ -1,58 +1,71 @@ #import "ITStatusItem.h" -/*************************************************************************/ -#pragma mark - -#pragma mark EVIL HACKERY -/*************************************************************************/ +@class NSStatusBarButton; -// This stuff is actually implemented by the AppKit. -// We declare it here to cancel out warnings. - -@interface NSStatusBarButton : NSButton +@interface NSStatusItem (ITStatusItemHacks) +- (id)_initInStatusBar:(NSStatusBar *)statusBar withLength:(float)length withPriority:(int)priority; +- (NSStatusBarButton *)_button; @end -@interface NSStatusItem (HACKHACKHACKHACK) -- (id) _initInStatusBar:(NSStatusBar*)statusBar - withLength:(float)length - withPriority:(int)priority; -- (NSStatusBarButton*) _button; +@protocol _ITStatusItemNSStatusItemPantherCompatability +- (void)setAlternateImage:(NSImage *)image; +- (NSImage *)alternateImage; @end - @implementation ITStatusItem -/*************************************************************************/ -#pragma mark - -#pragma mark INITIALIZATION METHODS -/*************************************************************************/ +static BOOL _ITStatusItemShouldKillShadow = NO; -- (id)initWithStatusBar:(NSStatusBar*)statusBar withLength:(float)length -{ - if ( ( self = [super _initInStatusBar:statusBar - withLength:length - withPriority:1000] ) ) { - - //Eliminate the fucking shadow... - [[[self _button] cell] setType:NSNullCellType]; - - //Be something other than a dumbshit about highlighting... - [self setHighlightMode:YES]; - } - return self; ++ (void)initialize { + if ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_1) && (floor(NSAppKitVersionNumber) <= 663.6)) { + _ITStatusItemShouldKillShadow = YES; + } } +- (id)initWithStatusBar:(NSStatusBar *)statusBar withLength:(float)length { + return [self _initInStatusBar:statusBar withLength:length withPriority:1000]; +} -/*************************************************************************/ -#pragma mark - -#pragma mark ACCESSOR METHODS -/*************************************************************************/ +- (id)_initInStatusBar:(NSStatusBar *)statusBar withLength:(float)length withPriority:(int)priority { + if ((self = [super _initInStatusBar:statusBar withLength:length withPriority:priority])) { + if (_ITStatusItemShouldKillShadow) { + [[(NSButton *)[self _button] cell] setType:NSNullCellType]; + } + [self setHighlightMode:YES]; + } + return self; +} -- (NSImage*) alternateImage { - return [[self _button] alternateImage]; +- (NSImage *)alternateImage { + if ([super respondsToSelector:@selector(alternateImage)]) { + return [(id <_ITStatusItemNSStatusItemPantherCompatability>)super alternateImage]; + } + return [(NSButton *)[self _button] alternateImage]; } -- (void) setAlternateImage:(NSImage*)image { - [[self _button] setAlternateImage:image]; +- (void)setAlternateImage:(NSImage*)image { + if ([super respondsToSelector:@selector(setAlternateImage:)]) { + [(id <_ITStatusItemNSStatusItemPantherCompatability>)super setAlternateImage:image]; + return; + } + [(NSButton *)[self _button] setAlternateImage:image]; } -@end +- (id )menuProvider { + return _menuProvider; +} + +- (void)setMenuProvider:(id )provider { + [_menuProvider autorelease]; + _menuProvider = [provider retain]; +} + +- (NSMenu *)menu { + if (_menuProvider) { + return [_menuProvider menuForStatusItem:self]; + } else { + return [super menu]; + } +} + +@end \ No newline at end of file