mirror of
https://github.com/transmission/transmission
synced 2024-12-25 01:03:01 +00:00
#4420 The StatusBar updates itself a bit too much
This commit is contained in:
parent
fbfae34837
commit
0e7875848a
2 changed files with 21 additions and 4 deletions
|
@ -33,6 +33,8 @@
|
|||
IBOutlet NSImageView * fTotalDLImageView;
|
||||
|
||||
tr_session * fLib;
|
||||
|
||||
CGFloat fPreviousDownloadRate, fPreviousUploadRate;
|
||||
}
|
||||
|
||||
- (id) initWithLib: (tr_session *) lib;
|
||||
|
|
|
@ -53,6 +53,9 @@ typedef enum
|
|||
if ((self = [super initWithNibName: @"StatusBar" bundle: nil]))
|
||||
{
|
||||
fLib = lib;
|
||||
|
||||
fPreviousDownloadRate = -1.0;
|
||||
fPreviousUploadRate = -1.0;
|
||||
}
|
||||
|
||||
return self;
|
||||
|
@ -93,8 +96,17 @@ typedef enum
|
|||
- (void) updateWithDownload: (CGFloat) dlRate upload: (CGFloat) ulRate
|
||||
{
|
||||
//set rates
|
||||
[fTotalDLField setStringValue: [NSString stringForSpeed: dlRate]];
|
||||
[fTotalULField setStringValue: [NSString stringForSpeed: ulRate]];
|
||||
if (dlRate != fPreviousDownloadRate)
|
||||
{
|
||||
[fTotalDLField setStringValue: [NSString stringForSpeed: dlRate]];
|
||||
fPreviousDownloadRate = dlRate;
|
||||
}
|
||||
|
||||
if (ulRate != fPreviousUploadRate)
|
||||
{
|
||||
[fTotalULField setStringValue: [NSString stringForSpeed: ulRate]];
|
||||
fPreviousUploadRate = ulRate;
|
||||
}
|
||||
|
||||
//set status button text
|
||||
NSString * statusLabel = [[NSUserDefaults standardUserDefaults] stringForKey: @"StatusLabel"], * statusString;
|
||||
|
@ -125,8 +137,11 @@ typedef enum
|
|||
NSLocalizedString(@"UL", "status bar -> status label"), [NSString stringForFileSize: stats.uploadedBytes]];
|
||||
}
|
||||
|
||||
[fStatusButton setTitle: statusString];
|
||||
[self resizeStatusButton];
|
||||
|
||||
if (![[fStatusButton title] isEqualToString:statusString]) {
|
||||
[fStatusButton setTitle: statusString];
|
||||
[self resizeStatusButton];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setStatusLabel: (id) sender
|
||||
|
|
Loading…
Reference in a new issue