Changeset 5687


Ignore:
Timestamp:
Apr 24, 2008, 9:24:42 PM (14 years ago)
Author:
livings124
Message:

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

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Transmission.xcodeproj/project.pbxproj

    r5677 r5687  
    9292                A22D3AA60D00D1790079CFED /* Turtle.png in Resources */ = {isa = PBXBuildFile; fileRef = A22D3AA30D00D1790079CFED /* Turtle.png */; };
    9393                A22D3AA70D00D1790079CFED /* TurtleBlue.png in Resources */ = {isa = PBXBuildFile; fileRef = A22D3AA40D00D1790079CFED /* TurtleBlue.png */; };
     94                A22E59A70DC11A1D00F4BE15 /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A29EBE700DC06068006CEE80 /* libcurl.dylib */; };
     95                A22E59A80DC11A1F00F4BE15 /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A29EBE700DC06068006CEE80 /* libcurl.dylib */; };
     96                A22E59A90DC11A2000F4BE15 /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A29EBE700DC06068006CEE80 /* libcurl.dylib */; };
     97                A22E59AA0DC11A2000F4BE15 /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A29EBE700DC06068006CEE80 /* libcurl.dylib */; };
    9498                A231274C0D11D0B7003F9AFF /* AboutWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = A231274B0D11D0B7003F9AFF /* AboutWindow.xib */; };
    9599                A232D29E0A70903E00973B12 /* Filter.png in Resources */ = {isa = PBXBuildFile; fileRef = A232D29D0A70903E00973B12 /* Filter.png */; };
     
    767771                                4D9A2BF009E16D21002D0FF9 /* libtransmission.a in Frameworks */,
    768772                                4D9A2BF909E16D4F002D0FF9 /* libcrypto.0.9.7.dylib in Frameworks */,
     773                                A22E59A70DC11A1D00F4BE15 /* libcurl.dylib in Frameworks */,
    769774                        );
    770775                        runOnlyForDeploymentPostprocessing = 0;
     
    814819                                BEFC1C040C07753100B0BB3C /* libcrypto.0.9.7.dylib in Frameworks */,
    815820                                BEFC1C050C07753500B0BB3C /* libtransmission.a in Frameworks */,
     821                                A22E59A80DC11A1F00F4BE15 /* libcurl.dylib in Frameworks */,
    816822                        );
    817823                        runOnlyForDeploymentPostprocessing = 0;
     
    823829                                BEFC1CF40C07822400B0BB3C /* libcrypto.0.9.7.dylib in Frameworks */,
    824830                                BEFC1D2D0C0783D900B0BB3C /* libtransmission.a in Frameworks */,
     831                                A22E59A90DC11A2000F4BE15 /* libcurl.dylib in Frameworks */,
    825832                        );
    826833                        runOnlyForDeploymentPostprocessing = 0;
     
    832839                                BEFC1D3E0C0783EE00B0BB3C /* libcrypto.0.9.7.dylib in Frameworks */,
    833840                                BEFC1D3F0C0783EE00B0BB3C /* libtransmission.a in Frameworks */,
     841                                A22E59AA0DC11A2000F4BE15 /* libcurl.dylib in Frameworks */,
    834842                        );
    835843                        runOnlyForDeploymentPostprocessing = 0;
     
    22102218                                OTHER_LDFLAGS = "";
    22112219                                PREBINDING = NO;
     2220                                PRELINK_LIBS = "";
    22122221                                SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.5.sdk";
    22132222                        };
  • trunk/macosx/BadgeView.h

    r4722 r5687  
    3232    NSDictionary * fAttributes;
    3333   
     34    float fDownloadRate, fUploadRate;
    3435    BOOL fQuitting;
    3536}
     
    3738- (id) initWithFrame: (NSRect) frame lib: (tr_handle *) lib;
    3839
     40- (BOOL) setRatesWithDownload: (float) downloadRate upload: (float) uploadRate;
    3941- (void) setQuitting;
    4042
  • trunk/macosx/BadgeView.m

    r5565 r5687  
    4141    {
    4242        fLib = lib;
     43       
     44        fDownloadRate = 0.0;
     45        fUploadRate = 0.0;
    4346        fQuitting = NO;
    4447    }
    4548    return self;
    46 }
    47 
    48 - (void) setQuitting
    49 {
    50     fQuitting = YES;
    5149}
    5250
     
    5553    [fAttributes release];
    5654    [super dealloc];
     55}
     56
     57- (BOOL) setRatesWithDownload: (float) downloadRate upload: (float) uploadRate
     58{
     59    //only needs update if the badges were displayed or are displayed now
     60    BOOL needsUpdate = fDownloadRate != downloadRate || fUploadRate != uploadRate;
     61    if (needsUpdate)
     62    {
     63        fDownloadRate = downloadRate;
     64        fUploadRate = uploadRate;
     65    }
     66   
     67    return needsUpdate;
     68}
     69
     70- (void) setQuitting
     71{
     72    fQuitting = YES;
     73    [self display];
    5774}
    5875
     
    6986    }
    7087   
    71     BOOL checkDownload = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeDownloadRate"],
    72         checkUpload = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeUploadRate"];
    73     if (checkDownload || checkUpload)
     88    BOOL upload = fUploadRate >= 0.1,
     89        download = fDownloadRate >= 0.1;
     90    float bottom = 0.0;
     91    if (upload)
    7492    {
    75         float downloadRate, uploadRate;
    76         tr_torrentRates(fLib, &downloadRate, &uploadRate);
    77        
    78         BOOL upload = checkUpload && uploadRate >= 0.1,
    79             download = checkDownload && downloadRate >= 0.1;
    80         float bottom = 0.0;
    81         if (upload)
    82         {
    83             NSImage * uploadBadge = [NSImage imageNamed: @"UploadBadge.png"];
    84             [self badge: uploadBadge string: [NSString stringForSpeedAbbrev: uploadRate] atHeight: bottom adjustForQuit: NO];
    85             if (download)
    86                 bottom += [uploadBadge size].height + BETWEEN_PADDING; //download rate above upload rate
    87         }
     93        NSImage * uploadBadge = [NSImage imageNamed: @"UploadBadge.png"];
     94        [self badge: uploadBadge string: [NSString stringForSpeedAbbrev: fUploadRate] atHeight: bottom adjustForQuit: NO];
    8895        if (download)
    89             [self badge: [NSImage imageNamed: @"DownloadBadge.png"] string: [NSString stringForSpeedAbbrev: downloadRate]
    90                     atHeight: bottom adjustForQuit: NO];
     96            bottom += [uploadBadge size].height + BETWEEN_PADDING; //download rate above upload rate
    9197    }
     98    if (download)
     99        [self badge: [NSImage imageNamed: @"DownloadBadge.png"] string: [NSString stringForSpeedAbbrev: fDownloadRate]
     100                atHeight: bottom adjustForQuit: NO];
    92101}
    93102
  • trunk/macosx/Badger.m

    r5677 r5687  
    8686    if ([NSApp isOnLeopardOrBetter])
    8787    {
    88         #warning only update if change to values
    89         [[NSApp dockTile] display];
     88        float downloadRate = 0.0, uploadRate = 0.0;
     89        BOOL checkDownload = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeDownloadRate"],
     90            checkUpload = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeUploadRate"];
     91        if (checkDownload || checkUpload)
     92        {
     93            tr_torrentRates(fLib, &downloadRate, &uploadRate);
     94           
     95            downloadRate = checkDownload ? downloadRate : 0.0;
     96            uploadRate = checkUpload ? uploadRate : 0.0;
     97        }
     98       
     99        //only update if the badged values change
     100        if ([(BadgeView *)[[NSApp dockTile] contentView] setRatesWithDownload: downloadRate upload: uploadRate])
     101            [[NSApp dockTile] display];
     102       
    90103        return;
    91104    }
     
    236249        [self clearCompleted];
    237250        [(BadgeView *)[[NSApp dockTile] contentView] setQuitting];
    238         [self updateBadge];
     251        [[NSApp dockTile] display];
    239252    }
    240253    else
  • trunk/macosx/Torrent.m

    r5681 r5687  
    771771}
    772772
    773 #warning removes separators?
    774773- (NSArray *) allTrackers: (BOOL) separators
    775774{
Note: See TracChangeset for help on using the changeset viewer.