1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-30 19:03:04 +00:00

don't redraw the dock tile if there is no change

This commit is contained in:
Mitchell Livingston 2008-04-24 21:24:42 +00:00
parent 169e717474
commit eaf4ecc37a
5 changed files with 59 additions and 27 deletions

View file

@ -91,6 +91,10 @@
A22A8D560AEEAFA5007E9CB9 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = A22A8D540AEEAFA5007E9CB9 /* Localizable.strings */; };
A22D3AA60D00D1790079CFED /* Turtle.png in Resources */ = {isa = PBXBuildFile; fileRef = A22D3AA30D00D1790079CFED /* Turtle.png */; };
A22D3AA70D00D1790079CFED /* TurtleBlue.png in Resources */ = {isa = PBXBuildFile; fileRef = A22D3AA40D00D1790079CFED /* TurtleBlue.png */; };
A22E59A70DC11A1D00F4BE15 /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A29EBE700DC06068006CEE80 /* libcurl.dylib */; };
A22E59A80DC11A1F00F4BE15 /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A29EBE700DC06068006CEE80 /* libcurl.dylib */; };
A22E59A90DC11A2000F4BE15 /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A29EBE700DC06068006CEE80 /* libcurl.dylib */; };
A22E59AA0DC11A2000F4BE15 /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A29EBE700DC06068006CEE80 /* libcurl.dylib */; };
A231274C0D11D0B7003F9AFF /* AboutWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = A231274B0D11D0B7003F9AFF /* AboutWindow.xib */; };
A232D29E0A70903E00973B12 /* Filter.png in Resources */ = {isa = PBXBuildFile; fileRef = A232D29D0A70903E00973B12 /* Filter.png */; };
A233BD330D8C6585007EE7B4 /* MessageWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = A233BD320D8C6585007EE7B4 /* MessageWindow.xib */; };
@ -766,6 +770,7 @@
files = (
4D9A2BF009E16D21002D0FF9 /* libtransmission.a in Frameworks */,
4D9A2BF909E16D4F002D0FF9 /* libcrypto.0.9.7.dylib in Frameworks */,
A22E59A70DC11A1D00F4BE15 /* libcurl.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -813,6 +818,7 @@
files = (
BEFC1C040C07753100B0BB3C /* libcrypto.0.9.7.dylib in Frameworks */,
BEFC1C050C07753500B0BB3C /* libtransmission.a in Frameworks */,
A22E59A80DC11A1F00F4BE15 /* libcurl.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -822,6 +828,7 @@
files = (
BEFC1CF40C07822400B0BB3C /* libcrypto.0.9.7.dylib in Frameworks */,
BEFC1D2D0C0783D900B0BB3C /* libtransmission.a in Frameworks */,
A22E59A90DC11A2000F4BE15 /* libcurl.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -831,6 +838,7 @@
files = (
BEFC1D3E0C0783EE00B0BB3C /* libcrypto.0.9.7.dylib in Frameworks */,
BEFC1D3F0C0783EE00B0BB3C /* libtransmission.a in Frameworks */,
A22E59AA0DC11A2000F4BE15 /* libcurl.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -2209,6 +2217,7 @@
OTHER_CFLAGS = "$(inherited)";
OTHER_LDFLAGS = "";
PREBINDING = NO;
PRELINK_LIBS = "";
SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
};
name = Development;

View file

@ -31,11 +31,13 @@
NSDictionary * fAttributes;
float fDownloadRate, fUploadRate;
BOOL fQuitting;
}
- (id) initWithFrame: (NSRect) frame lib: (tr_handle *) lib;
- (BOOL) setRatesWithDownload: (float) downloadRate upload: (float) uploadRate;
- (void) setQuitting;
@end

View file

@ -40,22 +40,39 @@
if ((self = [super initWithFrame: frame]))
{
fLib = lib;
fDownloadRate = 0.0;
fUploadRate = 0.0;
fQuitting = NO;
}
return self;
}
- (void) setQuitting
{
fQuitting = YES;
}
- (void) dealloc
{
[fAttributes release];
[super dealloc];
}
- (BOOL) setRatesWithDownload: (float) downloadRate upload: (float) uploadRate
{
//only needs update if the badges were displayed or are displayed now
BOOL needsUpdate = fDownloadRate != downloadRate || fUploadRate != uploadRate;
if (needsUpdate)
{
fDownloadRate = downloadRate;
fUploadRate = uploadRate;
}
return needsUpdate;
}
- (void) setQuitting
{
fQuitting = YES;
[self display];
}
- (void) drawRect: (NSRect) rect
{
[[NSImage imageNamed: @"NSApplicationIcon"] drawInRect: rect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
@ -68,27 +85,19 @@
return;
}
BOOL checkDownload = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeDownloadRate"],
checkUpload = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeUploadRate"];
if (checkDownload || checkUpload)
BOOL upload = fUploadRate >= 0.1,
download = fDownloadRate >= 0.1;
float bottom = 0.0;
if (upload)
{
float downloadRate, uploadRate;
tr_torrentRates(fLib, &downloadRate, &uploadRate);
BOOL upload = checkUpload && uploadRate >= 0.1,
download = checkDownload && downloadRate >= 0.1;
float bottom = 0.0;
if (upload)
{
NSImage * uploadBadge = [NSImage imageNamed: @"UploadBadge.png"];
[self badge: uploadBadge string: [NSString stringForSpeedAbbrev: uploadRate] atHeight: bottom adjustForQuit: NO];
if (download)
bottom += [uploadBadge size].height + BETWEEN_PADDING; //download rate above upload rate
}
NSImage * uploadBadge = [NSImage imageNamed: @"UploadBadge.png"];
[self badge: uploadBadge string: [NSString stringForSpeedAbbrev: fUploadRate] atHeight: bottom adjustForQuit: NO];
if (download)
[self badge: [NSImage imageNamed: @"DownloadBadge.png"] string: [NSString stringForSpeedAbbrev: downloadRate]
atHeight: bottom adjustForQuit: NO];
bottom += [uploadBadge size].height + BETWEEN_PADDING; //download rate above upload rate
}
if (download)
[self badge: [NSImage imageNamed: @"DownloadBadge.png"] string: [NSString stringForSpeedAbbrev: fDownloadRate]
atHeight: bottom adjustForQuit: NO];
}
@end

View file

@ -85,8 +85,21 @@
{
if ([NSApp isOnLeopardOrBetter])
{
#warning only update if change to values
[[NSApp dockTile] display];
float downloadRate = 0.0, uploadRate = 0.0;
BOOL checkDownload = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeDownloadRate"],
checkUpload = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeUploadRate"];
if (checkDownload || checkUpload)
{
tr_torrentRates(fLib, &downloadRate, &uploadRate);
downloadRate = checkDownload ? downloadRate : 0.0;
uploadRate = checkUpload ? uploadRate : 0.0;
}
//only update if the badged values change
if ([(BadgeView *)[[NSApp dockTile] contentView] setRatesWithDownload: downloadRate upload: uploadRate])
[[NSApp dockTile] display];
return;
}
else if (fQuittingTiger)
@ -235,7 +248,7 @@
{
[self clearCompleted];
[(BadgeView *)[[NSApp dockTile] contentView] setQuitting];
[self updateBadge];
[[NSApp dockTile] display];
}
else
{

View file

@ -770,7 +770,6 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
return [NSString stringWithUTF8String: fStat->tracker_stat.scrapeResponse];
}
#warning removes separators?
- (NSArray *) allTrackers: (BOOL) separators
{
int count = fInfo->trackerCount, capacity = count;