Changeset 36


Ignore:
Timestamp:
Jan 20, 2006, 1:51:07 AM (15 years ago)
Author:
titer
Message:

This adds badging

Location:
trunk/macosx
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.h

    r34 r36  
    2727#import <transmission.h>
    2828#import "PrefsController.h"
     29#import "Badger.h"
    2930
    3031@class TorrentTableView;
     
    3334{
    3435    tr_handle_t                 * fHandle;
    35     int                         fCount;
     36    int                         fCount, fCompleted;
    3637    tr_stat_t                   * fStat;
    3738    int                         fResumeOnWake[TR_MAX_TORRENT_COUNT];
     
    7576   
    7677    BOOL                        fHasGrowl;
     78    Badger                      * fBadger;
    7779}
    7880
  • trunk/macosx/Controller.m

    r34 r36  
    134134                GROWL_PATH] stringByExpandingTildeInPath]];
    135135    [self growlRegister: self];
     136
     137    //initialize badging
     138    fBadger = [[Badger alloc] init];
     139    fCompleted = 0;
    136140   
    137141    //update the interface every 500 ms
     
    142146    [[NSRunLoop currentRunLoop] addTimer: fTimer
    143147        forMode: NSEventTrackingRunLoopMode];
     148}
     149
     150- (void) windowDidBecomeKey: (NSNotification *) n
     151{
     152    /* Reset the number of recently completed downloads */
     153    fCompleted = 0;
    144154}
    145155
     
    558568    //Update the global DL/UL rates
    559569    tr_torrentRates( fHandle, &dl, &ul );
    560     [fTotalDLField setStringValue: [NSString stringForSpeed: dl]];
    561     [fTotalULField setStringValue: [NSString stringForSpeed: ul]];
     570    NSString * downloadRate = [NSString stringForSpeed: dl];
     571    NSString * uploadRate = [NSString stringForSpeed: ul];
     572    [fTotalDLField setStringValue: downloadRate];
     573    [fTotalULField setStringValue: uploadRate];
    562574
    563575    //Update DL/UL totals in the Info panel
     
    576588        if( !tr_getFinished( fHandle, i ) )
    577589            continue;
    578            
     590
     591        fCompleted++;
    579592        [self notifyGrowl: [NSString stringWithUTF8String:
    580593            fStat[i].info.name]];
    581594        tr_setFinished( fHandle, i, 0 );
    582595    }
     596
     597    //badge dock
     598    NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
     599    [fBadger updateBadgeWithCompleted: [defaults boolForKey: @"BadgeCompleted"] ? fCompleted : 0
     600                    uploadRate: ul >= 0.1 && [defaults boolForKey: @"BadgeUploadRate"] ? uploadRate : nil
     601                    downloadRate: dl >= 0.1 && [defaults boolForKey: @"BadgeDownloadRate"] ? downloadRate : nil];
    583602}
    584603
  • trunk/macosx/Transmission.xcodeproj/project.pbxproj

    r34 r36  
    2525                4DA6FDC6091141AD00450CB1 /* ResumeOn.png in Resources */ = {isa = PBXBuildFile; fileRef = 4DA6FDC4091141AD00450CB1 /* ResumeOn.png */; };
    2626                4DE5CC9D0980656F00BE280E /* StringAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4DE5CC9C0980656F00BE280E /* StringAdditions.m */; };
     27                4DE5CCA70980735700BE280E /* Badger.m in Sources */ = {isa = PBXBuildFile; fileRef = 4DE5CCA60980735700BE280E /* Badger.m */; };
     28                4DE5CCA90980739100BE280E /* Badge.png in Resources */ = {isa = PBXBuildFile; fileRef = 4DE5CCA80980739100BE280E /* Badge.png */; };
    2729                4DF0C5AB0899190500DD8943 /* Controller.m in Sources */ = {isa = PBXBuildFile; fileRef = 4DF0C5A90899190500DD8943 /* Controller.m */; };
    2830                4DF0C5AE08991C1600DD8943 /* libtransmission.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4DF0C5AD08991C1600DD8943 /* libtransmission.a */; };
     
    9496                4DE5CC9B0980656F00BE280E /* StringAdditions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = StringAdditions.h; sourceTree = "<group>"; };
    9597                4DE5CC9C0980656F00BE280E /* StringAdditions.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = StringAdditions.m; sourceTree = "<group>"; };
     98                4DE5CCA50980735700BE280E /* Badger.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Badger.h; sourceTree = "<group>"; };
     99                4DE5CCA60980735700BE280E /* Badger.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = Badger.m; sourceTree = "<group>"; };
     100                4DE5CCA80980739100BE280E /* Badge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Badge.png; path = Images/Badge.png; sourceTree = "<group>"; };
    96101                4DF0C5A90899190500DD8943 /* Controller.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = Controller.m; sourceTree = "<group>"; };
    97102                4DF0C5AA0899190500DD8943 /* Controller.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Controller.h; sourceTree = "<group>"; };
     
    133138                                4DE5CC9B0980656F00BE280E /* StringAdditions.h */,
    134139                                4DE5CC9C0980656F00BE280E /* StringAdditions.m */,
     140                                4DE5CCA50980735700BE280E /* Badger.h */,
     141                                4DE5CCA60980735700BE280E /* Badger.m */,
    135142                        );
    136143                        name = Classes;
     
    203210                                4D752E920913C949008EAAD4 /* Preferences.png */,
    204211                                4D8CEF90095870E00063BAEA /* Network.png */,
     212                                4DE5CCA80980739100BE280E /* Badge.png */,
    205213                                8D1107310486CEB800E47090 /* Info.plist */,
    206214                                089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
     
    293301                                4D752E930913C949008EAAD4 /* Preferences.png in Resources */,
    294302                                4D8CEF91095870E00063BAEA /* Network.png in Resources */,
     303                                4DE5CCA90980739100BE280E /* Badge.png in Resources */,
    295304                        );
    296305                        runOnlyForDeploymentPostprocessing = 0;
     
    310319                                4D364DA0091FBB2C00377D12 /* TorrentTableView.m in Sources */,
    311320                                4DE5CC9D0980656F00BE280E /* StringAdditions.m in Sources */,
     321                                4DE5CCA70980735700BE280E /* Badger.m in Sources */,
    312322                        );
    313323                        runOnlyForDeploymentPostprocessing = 0;
Note: See TracChangeset for help on using the changeset viewer.