fix dock badging

This commit is contained in:
Mitchell Livingston 2009-01-03 06:06:21 +00:00
parent 7fcad8a45b
commit d4010f4abd
3 changed files with 13 additions and 11 deletions

View File

@ -37,7 +37,7 @@
- (id) initWithFrame: (NSRect) frame lib: (tr_session *) lib;
- (void) displayRatesWithDownload: (CGFloat) downloadRate upload: (CGFloat) uploadRate;
- (BOOL) setRatesWithDownload: (CGFloat) downloadRate upload: (CGFloat) uploadRate;
- (void) setQuitting;
@end

View File

@ -54,15 +54,15 @@
[super dealloc];
}
- (void) displayRatesWithDownload: (CGFloat) downloadRate upload: (CGFloat) uploadRate
- (BOOL) setRatesWithDownload: (CGFloat) downloadRate upload: (CGFloat) uploadRate
{
//only needs update if the badges were displayed or are displayed now
if (fDownloadRate == downloadRate && fUploadRate == uploadRate)
return;
return NO;
fDownloadRate = downloadRate;
fUploadRate = uploadRate;
[self display];
return YES;
}
- (void) setQuitting
@ -82,8 +82,8 @@
return;
}
BOOL upload = fUploadRate >= 0.1f,
download = fDownloadRate >= 0.1f;
const BOOL upload = fUploadRate >= 0.1f,
download = fDownloadRate >= 0.1f;
CGFloat bottom = 0.0f;
if (upload)
{

View File

@ -55,12 +55,14 @@
- (void) updateBadge
{
float downloadRate = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeDownloadRate"]
? tr_sessionGetPieceSpeed(fLib, TR_DOWN) : 0.0;
float uploadRate = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeUploadRate"]
? tr_sessionGetPieceSpeed(fLib, TR_UP) : 0.0;
const float downloadRate = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeDownloadRate"]
? tr_sessionGetPieceSpeed(fLib, TR_DOWN) : 0.0;
const float uploadRate = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeUploadRate"]
? tr_sessionGetPieceSpeed(fLib, TR_UP) : 0.0;
[(BadgeView *)[[NSApp dockTile] contentView] displayRatesWithDownload: downloadRate upload: uploadRate];
//only update if the badged values change
if ([(BadgeView *)[[NSApp dockTile] contentView] setRatesWithDownload: downloadRate upload: uploadRate])
[[NSApp dockTile] display];
}
- (void) incrementCompleted