]> granicus.if.org Git - transmission/commitdiff
fix dock badging
authorMitchell Livingston <livings124@transmissionbt.com>
Sat, 3 Jan 2009 06:06:21 +0000 (06:06 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Sat, 3 Jan 2009 06:06:21 +0000 (06:06 +0000)
macosx/BadgeView.h
macosx/BadgeView.m
macosx/Badger.m

index 31139db8ab479a9cd5c24cb89e089898e734fdeb..716ac768b2ec73fa84b37b4e11e5e24611c3b90c 100644 (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
index 0953d43721bd9e5de978a7d006f8ea9c6b50f35d..e1c57ec986f6221f8df59768c937c283e01b1412 100644 (file)
     [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)
     {
index 8d2ae415ea458ba409ce4d9182d343ad07d49113..b5ed48fcee85e5607cac9509db153482791bf4e1 100644 (file)
 
 - (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