diff --git a/macosx/Controller.m b/macosx/Controller.m index 61af50fd3..fdc3ec740 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -1676,11 +1676,17 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy [tempTorrents setArray: fTorrents]; //set buttons with counts - [fNoFilterButton setCount: [fTorrents count]]; - [fDownloadFilterButton setCount: downloading]; - [fSeedFilterButton setCount: seeding]; - [fPauseFilterButton setCount: paused]; - [fFilterBar replaceButtons]; + BOOL change = NO; + if ([fNoFilterButton setCount: [fTorrents count]]) + change = YES; + if ([fDownloadFilterButton setCount: downloading]) + change = YES; + if ([fSeedFilterButton setCount: seeding]) + change = YES; + if ([fPauseFilterButton setCount: paused]) + change = YES; + if (change) + [fFilterBar replaceButtons]; NSString * searchString = [fSearchFilterField stringValue]; if ([searchString length] > 0) diff --git a/macosx/FilterBarButton.h b/macosx/FilterBarButton.h index b92049db0..f0f53db9c 100644 --- a/macosx/FilterBarButton.h +++ b/macosx/FilterBarButton.h @@ -34,7 +34,7 @@ NSTrackingRectTag fTrackingTag; } -- (void) setCount: (int) count; +- (BOOL) setCount: (int) count; - (void) setEnabled: (BOOL) enable; - (void) resetBounds: (NSNotification *) notification; diff --git a/macosx/FilterBarButton.m b/macosx/FilterBarButton.m index 15e251917..ee7e4681a 100644 --- a/macosx/FilterBarButton.m +++ b/macosx/FilterBarButton.m @@ -25,6 +25,12 @@ #import "FilterBarButton.h" #import "StringAdditions.h" +@interface FilterBarButton (Private) + +- (NSImage *) badgeCount: (int) count color: (NSColor *) color; + +@end + @implementation FilterBarButton - (id) initWithCoder: (NSCoder *) coder @@ -64,46 +70,10 @@ [super dealloc]; } -- (NSImage *) badgeCount: (int) count color: (NSColor *) color -{ - NSDictionary * attributes = [[NSDictionary alloc] initWithObjectsAndKeys: - [[NSFontManager sharedFontManager] convertFont: [NSFont fontWithName: @"Lucida Grande" size: 10.0] - toHaveTrait: NSBoldFontMask], NSFontAttributeName, nil]; - - NSString * string = [NSString stringWithInt: count]; - NSSize stringSize = [string sizeWithAttributes: attributes]; - NSRect badgeRect = NSMakeRect(0, 0, stringSize.width + 6.0, stringSize.height); - - //create badge part - NSImage * tempBadge = [[NSImage alloc] initWithSize: badgeRect.size]; - NSBezierPath * bp = [NSBezierPath bezierPathWithOvalInRect: badgeRect]; - [tempBadge lockFocus]; - - [color set]; - [bp fill]; - - [tempBadge unlockFocus]; - - //create string part - NSImage * badge = [[NSImage alloc] initWithSize: badgeRect.size]; - [badge lockFocus]; - - [string drawAtPoint: NSMakePoint((badgeRect.size.width - stringSize.width) * 0.5, - (badgeRect.size.height - stringSize.height) * 0.5) withAttributes: attributes]; - [tempBadge compositeToPoint: badgeRect.origin operation: NSCompositeSourceOut]; - - [badge unlockFocus]; - - [tempBadge release]; - [attributes release]; - - return [badge autorelease]; -} - -- (void) setCount: (int) count +- (BOOL) setCount: (int) count { if (fCount == count) - return; + return NO; fCount = count; if (fButtonNormal) @@ -333,6 +303,8 @@ [self setImage: fEnabled ? fButtonSelected : fButtonNormal]; else [self setImage: fEnabled ? fButtonSelectedDim : fButtonNormalDim]; + + return YES; } - (void) mouseEntered: (NSEvent *) event @@ -382,3 +354,43 @@ } @end + +@implementation FilterBarButton (Private) + +- (NSImage *) badgeCount: (int) count color: (NSColor *) color +{ + NSDictionary * attributes = [[NSDictionary alloc] initWithObjectsAndKeys: + [[NSFontManager sharedFontManager] convertFont: [NSFont fontWithName: @"Lucida Grande" size: 10.0] + toHaveTrait: NSBoldFontMask], NSFontAttributeName, nil]; + + NSString * string = [NSString stringWithInt: count]; + NSSize stringSize = [string sizeWithAttributes: attributes]; + NSRect badgeRect = NSMakeRect(0, 0, stringSize.width + 6.0, stringSize.height); + + //create badge part + NSImage * tempBadge = [[NSImage alloc] initWithSize: badgeRect.size]; + NSBezierPath * bp = [NSBezierPath bezierPathWithOvalInRect: badgeRect]; + [tempBadge lockFocus]; + + [color set]; + [bp fill]; + + [tempBadge unlockFocus]; + + //create string part + NSImage * badge = [[NSImage alloc] initWithSize: badgeRect.size]; + [badge lockFocus]; + + [string drawAtPoint: NSMakePoint((badgeRect.size.width - stringSize.width) * 0.5, + (badgeRect.size.height - stringSize.height) * 0.5) withAttributes: attributes]; + [tempBadge compositeToPoint: badgeRect.origin operation: NSCompositeSourceOut]; + + [badge unlockFocus]; + + [tempBadge release]; + [attributes release]; + + return [badge autorelease]; +} + +@end diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 6050cb1cf..9e65095c3 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -381,6 +381,8 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80 [shortStatusString setString: tempString]; [remainingTimeString setString: tempString]; + fChecking = YES; + break; case TR_STATUS_CHECK: