diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..b45456e
Binary files /dev/null and b/.DS_Store differ
diff --git a/Base.lproj/MainMenu.nib/designable.nib b/Base.lproj/MainMenu.nib/designable.nib
new file mode 100644
index 0000000..6a2dc79
--- /dev/null
+++ b/Base.lproj/MainMenu.nib/designable.nib
@@ -0,0 +1,371 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Base.lproj/MainMenu.nib/keyedobjects.nib b/Base.lproj/MainMenu.nib/keyedobjects.nib
new file mode 100644
index 0000000..24967d5
Binary files /dev/null and b/Base.lproj/MainMenu.nib/keyedobjects.nib differ
diff --git a/CTBadge.h b/CTBadge.h
index 9d4a329..9f520b3 100644
--- a/CTBadge.h
+++ b/CTBadge.h
@@ -17,13 +17,11 @@ extern const float CTLargeLabelSize;
extern const float CTSmallLabelSize;
@interface CTBadge : NSObject
- {
- NSColor *badgeColor;
- NSColor *labelColor;
- }
+{
+}
+ (CTBadge *)systemBadge; //Classic white on red badge
-+ (CTBadge *)badgeWithColor:(NSColor *)badgeColor labelColor:(NSColor *)labelColor; //Badge of any color scheme
++ (CTBadge *)badgeWithColor:(NSColor *)badgeColor labelColor:(NSColor *)labelColor gradientIntensity:(CGFloat) intensity; //Badge of any color scheme
- (NSImage *)smallBadgeForValue:(unsigned)value; //Image to use during drag operations
- (NSImage *)smallBadgeForString:(NSString *)string;
@@ -31,18 +29,16 @@ extern const float CTSmallLabelSize;
- (NSImage *)largeBadgeForString:(NSString *)string;
- (NSImage *)badgeOfSize:(float)size forValue:(unsigned)value; //A badge of arbitrary size,
- (NSImage *)badgeOfSize:(float)size forString:(NSString *)string; // is the size in pixels of the badge
- // not counting the shadow effect
- // (image returned will be larger than )
+// not counting the shadow effect
+// (image returned will be larger than )
- (NSImage *)badgeOverlayImageForValue:(unsigned)value insetX:(float)dx y:(float)dy; //Returns a transparent 128x128 image
- (NSImage *)badgeOverlayImageForString:(NSString *)string insetX:(float)dx y:(float)dy; // with Large badge inset dx/dy from the upper right
- (void)badgeApplicationDockIconWithValue:(unsigned)value insetX:(float)dx y:(float)dy; //Badges the Application's icon with
- (void)badgeApplicationDockIconWithString:(NSString *)string insetX:(float)dx y:(float)dy; // and puts it on the dock
-- (void)setBadgeColor:(NSColor *)theColor; //Sets the color used on badge
-- (void)setLabelColor:(NSColor *)theColor; //Sets the color of the label
-
-- (NSColor *)badgeColor; //Color currently being used on the badge
-- (NSColor *)labelColor; //Color currently being used on the label
+@property (readwrite) NSColor* badgeColor;
+@property (readwrite) NSColor* labelColor;
+@property (readwrite) CGFloat badgeGradientIntensity;
@end
diff --git a/CTBadge.m b/CTBadge.m
index c491b87..1d8b542 100644
--- a/CTBadge.m
+++ b/CTBadge.m
@@ -25,297 +25,260 @@ - (NSGradient *)badgeGradient; //gradient used to fill badge mask
@implementation CTBadge
-- (id)init
- {
- self = [super init];
-
- if (self != nil)
- {
- badgeColor = nil;
- labelColor = nil;
-
- [self setBadgeColor:[NSColor redColor]];
- [self setLabelColor:[NSColor whiteColor]];
- }
- return self;
- }
+@synthesize badgeColor, labelColor, badgeGradientIntensity;
-- (void)dealloc
- {
- if(badgeColor != nil)
- [badgeColor release];
- if(labelColor != nil)
- [labelColor release];
-
- [super dealloc];
- }
+- (id)init
+{
+ self = [super init];
+
+ if (self != nil)
+ {
+ self.badgeColor = [NSColor redColor];
+ self.labelColor = [NSColor whiteColor];
+ self.badgeGradientIntensity = 1;
+ }
+ return self;
+}
+ (CTBadge *)systemBadge
- {
- id newInstance = [[[self class] alloc] init];
-
- return [newInstance autorelease];
- }
-
-+ (CTBadge *)badgeWithColor:(NSColor *)badgeColor labelColor:(NSColor *)labelColor;
- {
- id newInstance = [[[self class] alloc] init];
-
- [newInstance setBadgeColor:badgeColor];
- [newInstance setLabelColor:labelColor];
-
- return [newInstance autorelease];
- }
-#pragma mark -
-
+{
+ CTBadge* newInstance = [[[self class] alloc] init];
+ return newInstance;
+}
-#pragma mark Appearance
-- (void)setBadgeColor:(NSColor *)theColor;
- {
- if(badgeColor != nil)
- [badgeColor release];
-
- badgeColor = theColor;
- [badgeColor retain];
- }
-- (void)setLabelColor:(NSColor *)theColor;
- {
- if(labelColor != nil)
- [labelColor release];
-
- labelColor = theColor;
- [labelColor retain];
- }
-
-- (NSColor *)badgeColor
- {
- return badgeColor;
- }
-- (NSColor *)labelColor
- {
- return labelColor;
- }
++ (CTBadge *)badgeWithColor:(NSColor *)badgeColor labelColor:(NSColor *)labelColor gradientIntensity:(CGFloat) intensity
+{
+ CTBadge* newInstance = [[[self class] alloc] init];
+
+ newInstance.badgeColor = badgeColor;
+ newInstance.labelColor = labelColor;
+ newInstance.badgeGradientIntensity = intensity;
+
+ return newInstance;
+}
#pragma mark -
-
#pragma mark Drawing
- (NSImage *)smallBadgeForValue:(unsigned)value //does drawing in it's own special way
- {
- return [self badgeOfSize:CTSmallBadgeSize forString:[self stringForValue:value]];
- }
+{
+ return [self badgeOfSize:CTSmallBadgeSize forString:[self stringForValue:value]];
+}
- (NSImage *)smallBadgeForString:(NSString *)string
- {
- return [self badgeOfSize:CTSmallBadgeSize forString:string];
- }
+{
+ return [self badgeOfSize:CTSmallBadgeSize forString:string];
+}
- (NSImage *)largeBadgeForValue:(unsigned)value
- {
- return [self badgeOfSize:CTLargeBadgeSize forString:[self stringForValue:value]];
- }
+{
+ return [self badgeOfSize:CTLargeBadgeSize forString:[self stringForValue:value]];
+}
- (NSImage *)largeBadgeForString:(NSString *)string
- {
- return [self badgeOfSize:CTLargeBadgeSize forString:string];
- }
+{
+ return [self badgeOfSize:CTLargeBadgeSize forString:string];
+}
- (NSImage *)badgeOfSize:(float)size forValue:(unsigned)value
- {
- return [self badgeOfSize:(float)size forString:[self stringForValue:value]];
- }
+{
+ return [self badgeOfSize:(float)size forString:[self stringForValue:value]];
+}
- (NSImage *)badgeOfSize:(float)size forString:(NSString *)string
- {
- float scaleFactor = 1;
-
- if(size <= 0)
- [NSException raise:NSInvalidArgumentException format:@"%@ %@: size (%f) must be positive", [self class], NSStringFromSelector(_cmd), size];
- else if(size <= CTSmallBadgeSize)
- scaleFactor = size/CTSmallBadgeSize;
- else
- scaleFactor = size/CTLargeBadgeSize;
-
- //Label stuff -----------------------------------------------
- NSAttributedString *label;
- NSSize labelSize;
-
- if(size <= CTSmallBadgeSize)
- label = [self labelForString:string size:CTSmallLabelSize*scaleFactor];
- else
- label = [self labelForString:string size:CTLargeLabelSize*scaleFactor];
-
- labelSize = [label size];
-
- //Badge stuff -----------------------------------------------
- NSImage *badgeImage; //this the image with the gradient fill
- NSImage *badgeMask ; //we nock out this mask from the gradient
-
- NSGradient *badgeGradient = [self badgeGradient];
-
- float shadowOpacity,
- shadowOffset,
- shadowBlurRadius;
-
- int angle;
-
- if(size <= CTSmallBadgeSize)
- {
- shadowOpacity = .6;
- shadowOffset = floorf(1*scaleFactor);
- shadowBlurRadius = ceilf(1*scaleFactor);
- }
- else
- {
- shadowOpacity = .8;
- shadowOffset = ceilf(1*scaleFactor);
- shadowBlurRadius = ceilf(2*scaleFactor);
- }
-
- if ([label length] <= 3) //Badges have different gradient angles
- angle = -45;
- else
- angle = -30;
-
- badgeMask = [self badgeMaskOfSize:size length:[label length]];
-
- NSSize badgeSize = [badgeMask size];
- NSPoint origin = NSMakePoint(shadowBlurRadius, shadowBlurRadius+shadowOffset);
-
- badgeImage = [[NSImage alloc] initWithSize:NSMakeSize(badgeSize.width + 2*shadowBlurRadius, //sometimes it needs more
- badgeSize.height + 2*shadowBlurRadius - shadowOffset + (size <= CTSmallBadgeSize))]; //space when small
-
- [badgeImage lockFocus];
- [badgeGradient drawInRect:NSMakeRect(origin.x, origin.y, floorf(badgeSize.width), floorf(badgeSize.height)) angle:angle]; //apply the gradient
- [badgeMask compositeToPoint:origin operation: NSCompositeDestinationAtop]; //knock out the badge area
- [label drawInRect:NSMakeRect(origin.x+floorf((badgeSize.width-labelSize.width)/2), origin.y+floorf((badgeSize.height-labelSize.height)/2), badgeSize.width, labelSize.height)]; //draw label in center
- [badgeImage unlockFocus];
-
-
- //Final stuff -----------------------------------------------
- NSImage *image = [[NSImage alloc] initWithSize:[badgeImage size]];
-
- [image lockFocus];
- [NSGraphicsContext saveGraphicsState];
- NSShadow *theShadow = [[NSShadow alloc] init];
- [theShadow setShadowOffset: NSMakeSize(0,-shadowOffset)];
- [theShadow setShadowBlurRadius:shadowBlurRadius];
- [theShadow setShadowColor:[[NSColor blackColor] colorWithAlphaComponent:shadowOpacity]];
- [theShadow set];
- [theShadow release];
- [badgeImage compositeToPoint:NSZeroPoint operation:NSCompositeSourceOver];
- [NSGraphicsContext restoreGraphicsState];
- [image unlockFocus];
-
- [label release];
- [badgeImage release];
-
- return [image autorelease];
- }
+{
+ float scaleFactor = 1;
+
+ if(size <= 0)
+ [NSException raise:NSInvalidArgumentException format:@"%@ %@: size (%f) must be positive", [self class], NSStringFromSelector(_cmd), size];
+ else if(size <= CTSmallBadgeSize)
+ scaleFactor = size/CTSmallBadgeSize;
+ else
+ scaleFactor = size/CTLargeBadgeSize;
+
+ //Label stuff -----------------------------------------------
+ NSAttributedString *label;
+ NSSize labelSize;
+
+ if(size <= CTSmallBadgeSize)
+ label = [self labelForString:string size:CTSmallLabelSize*scaleFactor];
+ else
+ label = [self labelForString:string size:CTLargeLabelSize*scaleFactor];
+
+ labelSize = [label size];
+
+ //Badge stuff -----------------------------------------------
+ NSImage *badgeImage; //this the image with the gradient fill
+ NSImage *badgeMask ; //we nock out this mask from the gradient
+
+ NSGradient *badgeGradient = [self badgeGradient];
+
+ float shadowOpacity,
+ shadowOffset,
+ shadowBlurRadius;
+
+ int angle;
+
+ if(size <= CTSmallBadgeSize)
+ {
+ shadowOpacity = .6;
+ shadowOffset = floorf(1*scaleFactor);
+ shadowBlurRadius = ceilf(1*scaleFactor);
+ }
+ else
+ {
+ shadowOpacity = .8;
+ shadowOffset = ceilf(1*scaleFactor);
+ shadowBlurRadius = ceilf(2*scaleFactor);
+ }
+
+ if ([label length] <= 3) //Badges have different gradient angles
+ angle = -45;
+ else
+ angle = -30;
+
+ badgeMask = [self badgeMaskOfSize:size length:[label length]];
+
+ NSSize badgeSize = [badgeMask size];
+ NSPoint origin = NSMakePoint(shadowBlurRadius, shadowBlurRadius+shadowOffset);
+
+ badgeImage = [[NSImage alloc] initWithSize:NSMakeSize(badgeSize.width + 2*shadowBlurRadius, //sometimes it needs more
+ badgeSize.height + 2*shadowBlurRadius - shadowOffset + (size <= CTSmallBadgeSize))]; //space when small
+
+ [badgeImage lockFocus];
+ [badgeGradient drawInRect:NSMakeRect(origin.x, origin.y, floorf(badgeSize.width), floorf(badgeSize.height)) angle:angle]; //apply the gradient
+ [badgeMask drawAtPoint:origin fromRect:NSMakeRect(0,0,badgeMask.size.width, badgeMask.size.height) operation:NSCompositingOperationDestinationAtop fraction:1];
+ [label drawInRect:NSMakeRect(origin.x+floorf((badgeSize.width-labelSize.width)/2), origin.y+floorf((badgeSize.height-labelSize.height)/2), badgeSize.width, labelSize.height)]; //draw label in center
+ [badgeImage unlockFocus];
+
+
+ //Final stuff -----------------------------------------------
+ NSImage *image = [[NSImage alloc] initWithSize:[badgeImage size]];
+
+ [image lockFocus];
+ [NSGraphicsContext saveGraphicsState];
+ NSShadow *theShadow = [[NSShadow alloc] init];
+ [theShadow setShadowOffset: NSMakeSize(0,-shadowOffset)];
+ [theShadow setShadowBlurRadius:shadowBlurRadius];
+ [theShadow setShadowColor:[[NSColor blackColor] colorWithAlphaComponent:shadowOpacity]];
+ [theShadow set];
+
+ [badgeImage drawAtPoint:NSZeroPoint fromRect:NSMakeRect(0,0,badgeImage.size.width, badgeImage.size.height) operation:NSCompositingOperationSourceOver fraction:1];
+
+ [NSGraphicsContext restoreGraphicsState];
+ [image unlockFocus];
+ return image;
+}
-- (NSImage *)badgeOverlayImageForString:(NSString *)string insetX:(float)dx y:(float)dy;
- {
- NSImage *badgeImage = [self largeBadgeForString:string];
- NSImage *overlayImage = [[NSImage alloc] initWithSize:NSMakeSize(128,128)];
- //draw large icon in the upper right corner of the overlay image
- [overlayImage lockFocus];
- NSSize badgeSize = [badgeImage size];
- [badgeImage compositeToPoint:NSMakePoint(128-dx-badgeSize.width,128-dy-badgeSize.height) operation:NSCompositeSourceOver];
- [overlayImage unlockFocus];
-
- return [overlayImage autorelease];
- }
+- (NSImage *)badgeOverlayImageForString:(NSString *)string insetX:(float)dx y:(float)dy;
+{
+ NSImage *badgeImage = [self largeBadgeForString:string];
+ NSImage *overlayImage = [[NSImage alloc] initWithSize:NSMakeSize(128,128)];
+
+ //draw large icon in the upper right corner of the overlay image
+ [overlayImage lockFocus];
+ NSSize badgeSize = [badgeImage size];
+
+ [badgeImage drawAtPoint:NSMakePoint(128-dx-badgeSize.width,128-dy-badgeSize.height)
+ fromRect:NSMakeRect(0, 0, badgeImage.size.width, badgeImage.size.height)
+ operation:NSCompositingOperationSourceOver fraction:1];
+
+ [overlayImage unlockFocus];
+
+ return overlayImage;
+}
- (void)badgeApplicationDockIconWithString:(NSString *)string insetX:(float)dx y:(float)dy;
- {
- NSImage *appIcon = [NSImage imageNamed:@"NSApplicationIcon"];
- NSImage *badgeOverlay = [self badgeOverlayImageForString:string insetX:dx y:dy];
-
- //Put the appIcon underneath the badgeOverlay
- [badgeOverlay lockFocus];
- [appIcon compositeToPoint:NSZeroPoint operation:NSCompositeDestinationOver];
- [badgeOverlay unlockFocus];
-
- [NSApp setApplicationIconImage:badgeOverlay];
- }
+{
+ NSImage *appIcon = [NSImage imageNamed:@"NSApplicationIcon"];
+ NSImage *badgeOverlay = [self badgeOverlayImageForString:string insetX:dx y:dy];
+
+ //Put the appIcon underneath the badgeOverlay
+ [badgeOverlay lockFocus];
+
+ [appIcon drawInRect:NSMakeRect(0,0,badgeOverlay.size.width, badgeOverlay.size.height) fromRect:NSMakeRect(0,0,appIcon.size.width, appIcon.size.height) operation:NSCompositingOperationDestinationOver fraction:1];
+
+ [badgeOverlay unlockFocus];
+
+ [NSApp setApplicationIconImage:badgeOverlay];
+}
- (NSImage *)badgeOverlayImageForValue:(unsigned)value insetX:(float)dx y:(float)dy
- {
- return [self badgeOverlayImageForString:[self stringForValue:value] insetX:dx y:dy];
- }
+{
+ return [self badgeOverlayImageForString:[self stringForValue:value] insetX:dx y:dy];
+}
- (void)badgeApplicationDockIconWithValue:(unsigned)value insetX:(float)dx y:(float)dy
- {
- [self badgeApplicationDockIconWithString:[self stringForValue:value] insetX:dx y:dy];
- }
+{
+ [self badgeApplicationDockIconWithString:[self stringForValue:value] insetX:dx y:dy];
+}
#pragma mark -
#pragma mark Misc.
- (NSGradient *)badgeGradient
- {
- NSGradient *aGradient = [[NSGradient alloc] initWithColorsAndLocations:[self badgeColor], 0.0,
- [self badgeColor], 1/3.,
- [[self badgeColor] shadowWithLevel:1/3.], 1.0, nil];
-
- return [aGradient autorelease];
- }
+{
+ CGFloat i = MIN(MAX(self.badgeGradientIntensity, 0.0), 1.0) / 3.0;
+ return [[NSGradient alloc] initWithColorsAndLocations:
+ [self.badgeColor highlightWithLevel:i], 0.0,
+ self.badgeColor, 1/3.,
+ [self.badgeColor shadowWithLevel:i], 1.0, nil];
+}
- (NSAttributedString *)labelForString:(NSString *)label size:(unsigned)size
- {
- //set Attributes to use on String ---------------------------
- NSFont *labelFont;
-
- if(size <= CTSmallLabelSize)
- labelFont = [NSFont boldSystemFontOfSize:size];
- else
- labelFont = [NSFont fontWithName:@"Helvetica-Bold" size:size];
-
- NSMutableParagraphStyle *pStyle = [[NSMutableParagraphStyle alloc] init];[pStyle setAlignment:NSCenterTextAlignment];
- NSDictionary *attributes = [[NSDictionary alloc] initWithObjectsAndKeys:[self labelColor], NSForegroundColorAttributeName,
- labelFont , NSFontAttributeName , nil];
- [pStyle release];
-
- //Label stuff
- if([label length] >= 6) //replace with summarized string - ellipses at end and a zero-width space to trick us into using the 5-wide badge
- label = [NSString stringWithFormat:@"%@%@", [label substringToIndex:3], [NSString stringWithUTF8String:"\xe2\x80\xa6\xe2\x80\x8b"]];
-
- NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:label attributes:attributes];
- [attributes release];
-
- return attributedString;
- }
+{
+ //set Attributes to use on String ---------------------------
+ NSFont *labelFont;
+
+ if(size <= CTSmallLabelSize)
+ labelFont = [NSFont boldSystemFontOfSize:size];
+ else
+ labelFont = [NSFont fontWithName:@"Helvetica-Bold" size:size];
+
+ NSMutableParagraphStyle *pStyle = [[NSMutableParagraphStyle alloc] init];[pStyle setAlignment:NSTextAlignmentCenter];
+
+ NSDictionary *attributes = @{
+ NSForegroundColorAttributeName :[self labelColor],
+ NSFontAttributeName: labelFont
+ };
+
+ //Label stuff
+ if([label length] >= 6) //replace with summarized string - ellipses at end and a zero-width space to trick us into using the 5-wide badge
+ label = [NSString stringWithFormat:@"%@%@", [label substringToIndex:3], [NSString stringWithUTF8String:"\xe2\x80\xa6\xe2\x80\x8b"]];
+
+ NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:label attributes:attributes];
+ return attributedString;
+}
- (NSString *)stringForValue:(unsigned)value
- {
- if(value < 100000)
- return [NSString stringWithFormat:@"%u", value];
- else //give infinity
- return [NSString stringWithUTF8String:"\xe2\x88\x9e"];
- }
+{
+ if(value < 100000)
+ return [NSString stringWithFormat:@"%u", value];
+ else //give infinity
+ return [NSString stringWithUTF8String:"\xe2\x88\x9e"];
+}
- (NSImage *)badgeMaskOfSize:(float)size length:(NSUInteger)length;
- {
- NSImage *badgeMask;
-
- if(length <=2)
- badgeMask = [NSImage imageNamed:@"CTBadge_1.pdf"];
- else if(length <=3)
- badgeMask = [NSImage imageNamed:@"CTBadge_3.pdf"];
- else if(length <=4)
- badgeMask = [NSImage imageNamed:@"CTBadge_4.pdf"];
- else
- badgeMask = [NSImage imageNamed:@"CTBadge_5.pdf"];
-
- if(size > 0 && size != [badgeMask size].height)
- {
- [badgeMask setName:nil];
- [badgeMask setScalesWhenResized:YES];
- [badgeMask setSize:NSMakeSize([badgeMask size].width*(size/[badgeMask size].height), size)];
- }
-
- return badgeMask;
- }
+{
+ NSImage *badgeMask;
+
+ if(length <=2)
+ badgeMask = [NSImage imageNamed:@"CTBadge_1.pdf"];
+ else if(length <=3)
+ badgeMask = [NSImage imageNamed:@"CTBadge_3.pdf"];
+ else if(length <=4)
+ badgeMask = [NSImage imageNamed:@"CTBadge_4.pdf"];
+ else
+ badgeMask = [NSImage imageNamed:@"CTBadge_5.pdf"];
+
+ if(size > 0 && size != [badgeMask size].height)
+ {
+ [badgeMask setName:nil];
+ [badgeMask setSize:NSMakeSize([badgeMask size].width*(size/[badgeMask size].height), size)];
+ }
+
+ return badgeMask;
+}
@end
diff --git a/CTBadge.xcodeproj/project.pbxproj b/CTBadge.xcodeproj/project.pbxproj
index f1ddd62..b008125 100644
--- a/CTBadge.xcodeproj/project.pbxproj
+++ b/CTBadge.xcodeproj/project.pbxproj
@@ -21,13 +21,13 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
- 089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; };
1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; };
13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; };
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
- 29B97319FDCFA39411CA2CEA /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/MainMenu.nib; sourceTree = ""; };
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; };
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; };
+ 63608AFD228B0D090062CD4C /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
+ 63608AFF228B0D0D0062CD4C /* Base */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = Base; path = Base.lproj/MainMenu.nib; sourceTree = ""; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; };
8D1107320486CEB800E47090 /* CTBadge.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CTBadge.app; sourceTree = BUILT_PRODUCTS_DIR; };
A83817A9097E940700EAAB56 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = ""; };
@@ -169,9 +169,17 @@
/* Begin PBXProject section */
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 1020;
+ };
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "CTBadge" */;
compatibilityVersion = "Xcode 2.4";
+ developmentRegion = en;
hasScannedForEncodings = 1;
+ knownRegions = (
+ en,
+ Base,
+ );
mainGroup = 29B97314FDCFA39411CA2CEA /* CTBadge */;
projectDirPath = "";
projectRoot = "";
@@ -214,7 +222,7 @@
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
- 089C165DFE840E0CC02AAC07 /* English */,
+ 63608AFD228B0D090062CD4C /* en */,
);
name = InfoPlist.strings;
sourceTree = "";
@@ -222,7 +230,7 @@
29B97318FDCFA39411CA2CEA /* MainMenu.nib */ = {
isa = PBXVariantGroup;
children = (
- 29B97319FDCFA39411CA2CEA /* English */,
+ 63608AFF228B0D0D0062CD4C /* Base */,
);
name = MainMenu.nib;
sourceTree = "";
@@ -233,13 +241,14 @@
C01FCF4B08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_WEAK = YES;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
- GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Applications";
+ PRODUCT_BUNDLE_IDENTIFIER = com.cotingent.CTBadge;
PRODUCT_NAME = CTBadge;
WRAPPER_EXTENSION = app;
ZERO_LINK = YES;
@@ -249,10 +258,12 @@
C01FCF4C08A954540054247B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ CLANG_ENABLE_OBJC_WEAK = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_MODEL_TUNING = G5;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Applications";
+ PRODUCT_BUNDLE_IDENTIFIER = com.cotingent.CTBadge;
PRODUCT_NAME = CTBadge;
WRAPPER_EXTENSION = app;
};
@@ -261,24 +272,72 @@
C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1)";
- ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386";
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- PREBINDING = NO;
- SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = macosx;
};
name = Debug;
};
C01FCF5008A954540054247B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1)";
- ARCHS_STANDARD_32_BIT_PRE_XCODE_3_1 = "ppc i386";
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- PREBINDING = NO;
- SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
+ SDKROOT = macosx;
};
name = Release;
};
diff --git a/CTBadge.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/CTBadge.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/CTBadge.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/CTBadge.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/CTBadge.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/CTBadge.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/CTBadge.xcodeproj/project.xcworkspace/xcuserdata/shamyl.xcuserdatad/UserInterfaceState.xcuserstate b/CTBadge.xcodeproj/project.xcworkspace/xcuserdata/shamyl.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..155bd1a
Binary files /dev/null and b/CTBadge.xcodeproj/project.xcworkspace/xcuserdata/shamyl.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/CTBadge.xcodeproj/xcuserdata/shamyl.xcuserdatad/xcschemes/xcschememanagement.plist b/CTBadge.xcodeproj/xcuserdata/shamyl.xcuserdatad/xcschemes/xcschememanagement.plist
new file mode 100644
index 0000000..74b576d
--- /dev/null
+++ b/CTBadge.xcodeproj/xcuserdata/shamyl.xcuserdatad/xcschemes/xcschememanagement.plist
@@ -0,0 +1,14 @@
+
+
+
+
+ SchemeUserState
+
+ CTBadge.xcscheme_^#shared#^_
+
+ orderHint
+ 0
+
+
+
+
diff --git a/English.lproj/MainMenu.nib/classes.nib b/English.lproj/MainMenu.nib/classes.nib
deleted file mode 100644
index 4f27d00..0000000
--- a/English.lproj/MainMenu.nib/classes.nib
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- IBClasses = (
- {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
- {
- ACTIONS = {
- setApplicationIcon = id;
- setBadgeColor = id;
- setBadgeValue = id;
- setLabelColor = id;
- };
- CLASS = MainController;
- LANGUAGE = ObjC;
- OUTLETS = {largeBadgeView = id; scroller = id; smallBadgeView = id; };
- SUPERCLASS = NSObject;
- }
- );
- IBVersion = 1;
-}
\ No newline at end of file
diff --git a/English.lproj/MainMenu.nib/info.nib b/English.lproj/MainMenu.nib/info.nib
deleted file mode 100644
index aa3e27c..0000000
--- a/English.lproj/MainMenu.nib/info.nib
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
- IBDocumentLocation
- 180 221 356 240 0 0 1440 878
- IBEditorPositions
-
- 29
- 110 299 291 44 0 0 1440 878
-
- IBFramework Version
- 446.1
- IBOpenObjects
-
- 226
- 29
- 21
-
- IBSystem Version
- 8I1119
-
-
diff --git a/English.lproj/MainMenu.nib/keyedobjects.nib b/English.lproj/MainMenu.nib/keyedobjects.nib
deleted file mode 100644
index 10138c4..0000000
Binary files a/English.lproj/MainMenu.nib/keyedobjects.nib and /dev/null differ
diff --git a/Info.plist b/Info.plist
index 39009f6..598afa8 100644
--- a/Info.plist
+++ b/Info.plist
@@ -1,5 +1,5 @@
-
+
CFBundleDevelopmentRegion
@@ -24,7 +24,7 @@
CFBundleExecutable
${EXECUTABLE_NAME}
CFBundleIdentifier
- com.cotingent.CTBadge
+ $(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleName
diff --git a/MainController.h b/MainController.h
index 937d85d..2c3f492 100644
--- a/MainController.h
+++ b/MainController.h
@@ -5,18 +5,19 @@
#import "CTBadge.h"
@interface MainController : NSObject
- {
- CTBadge *myBadge;
-
- IBOutlet id scroller;
-
- IBOutlet id largeBadgeView;
- IBOutlet id smallBadgeView;
- }
+{
+ CTBadge *myBadge;
+
+ __weak IBOutlet id scroller;
+ __weak IBOutlet id largeBadgeView;
+ __weak IBOutlet id smallBadgeView;
+ __weak IBOutlet NSWindow* settingsWindow;
+}
- (IBAction)setBadgeValue:(id)sender;
- (IBAction)setBadgeColor:(id)sender;
- (IBAction)setLabelColor:(id)sender;
+- (IBAction)setBadgeGradientIntensity:(id)sender;
- (IBAction)setApplicationIcon:(id)sender;
diff --git a/MainController.m b/MainController.m
index 18fb033..d190e01 100644
--- a/MainController.m
+++ b/MainController.m
@@ -3,63 +3,66 @@
@implementation MainController
- (void)awakeFromNib
- {
- myBadge = [[CTBadge alloc] init];
- [self setBadgeValue:scroller];
- [[NSColorPanel sharedColorPanel] setShowsAlpha:YES];
- }
+{
+ myBadge = [[CTBadge alloc] init];
+ [self setBadgeValue:scroller];
+ [[NSColorPanel sharedColorPanel] setShowsAlpha:YES];
+}
- (void)windowWillClose:(NSNotification *)aNotification
- {
- RestoreApplicationDockTileImage();
- [NSApp terminate:self];
- }
+{
+ [NSApp terminate:self];
+}
- (IBAction)setBadgeValue:(id)sender
- {
- int value = [sender intValue];
-
- [largeBadgeView setImage:[myBadge largeBadgeForValue:value]];
- [smallBadgeView setImage:[myBadge smallBadgeForValue:value]];
- [myBadge badgeApplicationDockIconWithValue:value insetX:3 y:0];
-
- //[[[myBadge largeBadgeForValue:value] TIFFRepresentation] writeToFile:@"/tmp/badge.tif" atomically:NO];
- }
+{
+ int value = [sender intValue];
+
+ [largeBadgeView setImage:[myBadge largeBadgeForValue:value]];
+ [smallBadgeView setImage:[myBadge smallBadgeForValue:value]];
+ [myBadge badgeApplicationDockIconWithValue:value insetX:3 y:0];
+}
- (IBAction)setBadgeColor:(id)sender
- {
- [myBadge setBadgeColor:[sender color]];
- [self setBadgeValue:scroller];
- }
+{
+ myBadge.badgeColor = [sender color];
+ [self setBadgeValue:scroller];
+}
- (IBAction)setLabelColor:(id)sender
- {
- [myBadge setLabelColor:[sender color]];
- [self setBadgeValue:scroller];
- }
+{
+ myBadge.labelColor = [sender color];
+ [self setBadgeValue:scroller];
+}
+- (IBAction)setBadgeGradientIntensity:(id)sender
+{
+ myBadge.badgeGradientIntensity = [sender state] == NSControlStateValueOn ? 1 : 0;
+ [self setBadgeValue:scroller];
+}
- (IBAction)setApplicationIcon:(id)sender
- {
- NSOpenPanel *openPanel = [NSOpenPanel openPanel];
-
- int result = [openPanel runModalForDirectory:NSHomeDirectory() file:nil types:[NSArray arrayWithObject:@"icns"]];
-
- if(result == NSOKButton)
- {
- [self application:nil openFile:[openPanel filename]];
- }
- }
+{
+ NSOpenPanel *openPanel = [NSOpenPanel openPanel];
+ openPanel.directoryURL = [NSURL URLWithString:NSHomeDirectory()];
+ openPanel.allowedFileTypes = @[@"icns"];
+ [openPanel beginSheetModalForWindow: settingsWindow completionHandler:^(NSModalResponse result) {
+ if (result == NSModalResponseOK)
+ {
+ [self application:nil openFile:[openPanel URL].path];
+ }
+ }];
+}
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
- {
- NSImage *newAppIcon = [[NSImage alloc] initWithContentsOfFile:filename];
- [(NSImage *)[NSImage imageNamed:@"NSApplicationIcon"] setName:nil];
- [newAppIcon setName:@"NSApplicationIcon"];
-
- [self setBadgeValue:scroller];
- return YES;
- }
+{
+ NSImage *newAppIcon = [[NSImage alloc] initWithContentsOfFile:filename];
+ [(NSImage *)[NSImage imageNamed:@"NSApplicationIcon"] setName:nil];
+ [newAppIcon setName:@"NSApplicationIcon"];
+
+ [self setBadgeValue:scroller];
+ return YES;
+}
@end
diff --git a/English.lproj/InfoPlist.strings b/en.lproj/InfoPlist.strings
similarity index 100%
rename from English.lproj/InfoPlist.strings
rename to en.lproj/InfoPlist.strings