Changeset 6252


Ignore:
Timestamp:
Jun 25, 2008, 5:01:04 AM (13 years ago)
Author:
livings124
Message:

store progress gradients in the gradient class; miscellaneous cleanup

Location:
trunk/macosx
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/CTGradient/CTGradientAdditions.m

    r6250 r6252  
    6666}
    6767
     68CTGradient * fProgressWhiteGradient = nil;
    6869+ (CTGradient *)progressWhiteGradient
    6970{
    70     return [[self class] progressGradientForRed: 0.95 green: 0.95 blue: 0.95];
     71    if (!fProgressWhiteGradient)
     72        fProgressWhiteGradient = [[[self class] progressGradientForRed: 0.95 green: 0.95 blue: 0.95] retain];
     73    return fProgressWhiteGradient;
    7174}
    7275
     76CTGradient * fProgressGrayGradient = nil;
    7377+ (CTGradient *)progressGrayGradient
    7478{
    75     return [[self class] progressGradientForRed: 0.7 green: 0.7 blue: 0.7];
     79    if (!fProgressGrayGradient)
     80        fProgressGrayGradient = [[[self class] progressGradientForRed: 0.7 green: 0.7 blue: 0.7] retain];
     81    return fProgressGrayGradient;
    7682}
    7783
     84CTGradient * fProgressLightGrayGradient = nil;
    7885+ (CTGradient *)progressLightGrayGradient
    7986{
    80     return [[self class] progressGradientForRed: 0.87 green: 0.87 blue: 0.87];
     87    if (!fProgressLightGrayGradient)
     88        fProgressLightGrayGradient = [[[self class] progressGradientForRed: 0.87 green: 0.87 blue: 0.87] retain];
     89    return fProgressLightGrayGradient;
    8190}
    8291
     92CTGradient * fProgressBlueGradient = nil;
    8393+ (CTGradient *)progressBlueGradient
    8494{
    85     return [[self class] progressGradientForRed: 0.373 green: 0.698 blue: 0.972];
     95    if (!fProgressBlueGradient)
     96        fProgressBlueGradient = [[[self class] progressGradientForRed: 0.373 green: 0.698 blue: 0.972] retain];
     97    return fProgressBlueGradient;
    8698}
    8799
     100CTGradient * fProgressDarkBlueGradient = nil;
    88101+ (CTGradient *)progressDarkBlueGradient
    89102{
    90     return [[self class] progressGradientForRed: 0.616 green: 0.722 blue: 0.776];
     103    if (!fProgressDarkBlueGradient)
     104        fProgressDarkBlueGradient = [[[self class] progressGradientForRed: 0.616 green: 0.722 blue: 0.776] retain];
     105    return fProgressDarkBlueGradient;
    91106}
    92107
     108CTGradient * fProgressGreenGradient = nil;
    93109+ (CTGradient *)progressGreenGradient
    94110{
    95     return [[self class] progressGradientForRed: 0.384 green: 0.847 blue: 0.310];
     111    if (!fProgressGreenGradient)
     112        fProgressGreenGradient = [[[self class] progressGradientForRed: 0.384 green: 0.847 blue: 0.310] retain];
     113    return fProgressGreenGradient;
    96114}
    97115
     116CTGradient * fProgressLightGreenGradient = nil;
    98117+ (CTGradient *)progressLightGreenGradient
    99118{
    100     return [[self class] progressGradientForRed: 0.780 green: 0.894 blue: 0.729];
     119    if (!fProgressLightGreenGradient)
     120        fProgressLightGreenGradient = [[[self class] progressGradientForRed: 0.780 green: 0.894 blue: 0.729] retain];
     121    return fProgressLightGreenGradient;
    101122}
    102123
     124CTGradient * fProgressDarkGreenGradient = nil;
    103125+ (CTGradient *)progressDarkGreenGradient
    104126{
    105     return [[self class] progressGradientForRed: 0.627 green: 0.714 blue: 0.639];
     127    if (!fProgressDarkGreenGradient)
     128        fProgressDarkGreenGradient = [[[self class] progressGradientForRed: 0.627 green: 0.714 blue: 0.639] retain];
     129    return fProgressDarkGreenGradient;
    106130}
    107131
     132CTGradient * fProgressRedGradient = nil;
    108133+ (CTGradient *)progressRedGradient
    109134{
    110     return [[self class] progressGradientForRed: 0.902 green: 0.439 blue: 0.451];
     135    if (!fProgressRedGradient)
     136        fProgressRedGradient = [[[self class] progressGradientForRed: 0.902 green: 0.439 blue: 0.451] retain];
     137    return fProgressRedGradient;
    111138}
    112139
     140CTGradient * fProgressYellowGradient = nil;
    113141+ (CTGradient *)progressYellowGradient
    114142{
    115     return [[self class] progressGradientForRed: 0.933 green: 0.890 blue: 0.243];
     143    if (!fProgressYellowGradient)
     144        fProgressYellowGradient = [[[self class] progressGradientForRed: 0.933 green: 0.890 blue: 0.243] retain];
     145    return fProgressYellowGradient;
    116146}
    117147
  • trunk/macosx/English.lproj/Localizable.strings

    r6150 r6252  
    126126/* Folder cannot be used alert -> message */
    127127"\"%@\" cannot be used. The transfer will be paused." = "\"%@\" cannot be used. The transfer will be paused.";
     128
     129/* Open invalid alert -> title */
     130"\"%@\" is not a valid torrent file." = "\"%@\" is not a valid torrent file.";
    128131
    129132/* Prefs -> blocklist -> message */
     
    263266"Create a Torrent File" = "Create a Torrent File";
    264267
    265 /* Create toolbar item -> tooltip */
    266 "Create torrent file" = "Create torrent file";
    267 
    268268/* Create torrent -> select file
    269269   Create toolbar item -> palette label */
    270270"Create Torrent File" = "Create Torrent File";
     271
     272/* Create toolbar item -> tooltip */
     273"Create torrent file" = "Create torrent file";
    271274
    272275/* Create torrent -> failed -> title */
     
    490493   Create torrent -> no files -> button
    491494   Download not a torrent -> button
     495   Open invalid alert -> button
    492496   About window -> license close button
    493497   Blocklist -> button
     
    513517"Open Torrent Address" = "Open Torrent Address";
    514518
     519/* Open toolbar item -> tooltip */
     520"Open torrent files" = "Open torrent files";
     521
    515522/* Open toolbar item -> palette label */
    516523"Open Torrent Files" = "Open Torrent Files";
    517 
    518 /* Open toolbar item -> tooltip */
    519 "Open torrent files" = "Open torrent files";
    520524
    521525/* Open address toolbar item -> tooltip */
     
    784788"The torrent file (%@) cannot be found." = "The torrent file (%@) cannot be found.";
    785789
     790/* Open invalid alert -> message */
     791"The torrent file cannot be opened because it contains invalid data." = "The torrent file cannot be opened because it contains invalid data.";
     792
    786793/* Open duplicate alert -> message */
    787794"The torrent file cannot be opened because it is a duplicate of an already added transfer." = "The torrent file cannot be opened because it is a duplicate of an already added transfer.";
     
    881888"Transmission is already running." = "Transmission is already running.";
    882889
    883 /* Torrent -> location when deleting original */
     890/* Inspector -> torrent location */
    884891"Transmission Support Folder" = "Transmission Support Folder";
    885892
  • trunk/macosx/InfoWindowController.m

    r6246 r6252  
    11031103{
    11041104    FileOutlineView * fileOutlineView = [fFileController outlineView];
    1105     Torrent * torrent = [fTorrents objectAtIndex: 0];
    11061105    NSIndexSet * indexes = [fileOutlineView selectedRowIndexes];
    1107 
     1106   
    11081107    int i;
    11091108    for (i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
  • trunk/macosx/NSStringAdditions.h

    r5117 r6252  
    3737
    3838+ (NSString *) timeString: (uint64_t) seconds showSeconds: (BOOL) showSeconds;
    39 + (NSString *) timeString: (NSUInteger) seconds showSeconds: (BOOL) showSeconds maxDigits: (NSUInteger) max;
     39+ (NSString *) timeString: (NSUInteger) seconds showSeconds: (BOOL) showSeconds maxFields: (NSUInteger) max;
    4040
    4141- (NSComparisonResult) compareIP: (NSString *) string;
  • trunk/macosx/NSStringAdditions.m

    r5556 r6252  
    109109+ (NSString *) timeString: (uint64_t) seconds showSeconds: (BOOL) showSeconds
    110110{
    111     return [NSString timeString: seconds showSeconds: showSeconds maxDigits: UINT_MAX];
     111    return [NSString timeString: seconds showSeconds: showSeconds maxFields: UINT_MAX];
    112112}
    113113
    114 + (NSString *) timeString: (NSUInteger) seconds showSeconds: (BOOL) showSeconds maxDigits: (NSUInteger) max
     114+ (NSString *) timeString: (NSUInteger) seconds showSeconds: (BOOL) showSeconds maxFields: (NSUInteger) max
    115115{
    116116    NSMutableArray * timeArray = [NSMutableArray arrayWithCapacity: MIN(max, 4)];
  • trunk/macosx/PortChecker.m

    r4423 r6252  
    4141       
    4242        fTimer = [NSTimer scheduledTimerWithTimeInterval: CHECK_FIRE target: self selector: @selector(startProbe)
    43                         userInfo: nil repeats: NO];
     43                    userInfo: nil repeats: NO];
    4444    }
    4545   
     
    125125        {
    126126            NSString * portStatus = [[[[nodes objectAtIndex: 0] stringValue] stringByTrimmingCharactersInSet:
    127                                                 [[NSCharacterSet letterCharacterSet] invertedSet]] lowercaseString];
     127                                        [[NSCharacterSet letterCharacterSet] invertedSet]] lowercaseString];
    128128           
    129129            if ([portStatus isEqualToString: @"open"])
     
    141141        else
    142142        {
    143                 NSLog(@"Unable to get port status: invalid response");
    144                 [self callBackWithStatus: PORT_STATUS_ERROR];
     143            NSLog(@"Unable to get port status: invalid response");
     144            [self callBackWithStatus: PORT_STATUS_ERROR];
    145145        }
    146146        [shieldsUpProbe release];
  • trunk/macosx/Torrent.m

    r6247 r6252  
    19231923        default:
    19241924            return [NSString stringWithFormat: NSLocalizedString(@"%@ remaining", "Torrent -> eta string"),
    1925                         [NSString timeString: eta showSeconds: YES maxDigits: 2]];
     1925                        [NSString timeString: eta showSeconds: YES maxFields: 2]];
    19261926    }
    19271927}
  • trunk/macosx/TorrentCell.h

    r6125 r6252  
    3535            fHoverControl, fHoverReveal, fHoverAction;
    3636   
    37     NSColor * fBarBorderColor;
    38     CTGradient * fWhiteGradient, * fGrayGradient, * fLightGrayGradient, * fBlueGradient, * fDarkBlueGradient,
    39                 * fGreenGradient, * fLightGreenGradient, * fDarkGreenGradient, * fYellowGradient, * fRedGradient;
    40    
    41     NSColor * fBluePieceColor;
     37    NSColor * fBarBorderColor, * fBluePieceColor;
    4238}
    4339
  • trunk/macosx/TorrentCell.m

    r6248 r6252  
    105105}
    106106
    107 - (id) copyWithZone: (NSZone *) zone
    108 {
    109     TorrentCell * copy = [super copyWithZone: zone];
    110    
    111     copy->fGrayGradient = [fGrayGradient retain];
    112     copy->fLightGrayGradient = [fLightGrayGradient retain];
    113     copy->fBlueGradient = [fBlueGradient retain];
    114     copy->fDarkBlueGradient = [fDarkBlueGradient retain];
    115     copy->fGreenGradient = [fGreenGradient retain];
    116     copy->fLightGreenGradient = [fLightGreenGradient retain];
    117     copy->fDarkGreenGradient = [fDarkGreenGradient retain];
    118     copy->fYellowGradient = [fYellowGradient retain];
    119     copy->fRedGradient = [fRedGradient retain];
    120    
    121     return copy;
    122 }
    123 
    124 - (void) dealloc
    125 {
    126     [fGrayGradient release];
    127     [fLightGrayGradient release];
    128     [fBlueGradient release];
    129     [fDarkBlueGradient release];
    130     [fGreenGradient release];
    131     [fLightGreenGradient release];
    132     [fDarkGreenGradient release];
    133     [fYellowGradient release];
    134     [fRedGradient release];
    135    
    136     [super dealloc];
    137 }
    138 
    139107- (NSRect) iconRectForBounds: (NSRect) bounds
    140108{
     
    621589            noIncludeRect.size.width = rightNoIncludeWidth;
    622590           
    623             if (!fLightGrayGradient)
    624                 fLightGrayGradient = [[CTGradient progressLightGrayGradient] retain];
    625             [fLightGrayGradient fillRect: noIncludeRect angle: 90];
     591            [[CTGradient progressLightGrayGradient] fillRect: noIncludeRect angle: 90];
    626592        }
    627593       
     
    640606                    notAvailableRect.size.width = notAvailableWidth;
    641607                   
    642                     if (!fRedGradient)
    643                         fRedGradient = [[CTGradient progressRedGradient] retain];
    644                     [fRedGradient fillRect: notAvailableRect angle: 90];
     608                    [[CTGradient progressRedGradient] fillRect: notAvailableRect angle: 90];
    645609                }
    646610            }
     
    652616                includeRect.size.width = rightWidth;
    653617               
    654                 if (!fWhiteGradient)
    655                     fWhiteGradient = [[CTGradient progressWhiteGradient] retain];
    656                 [fWhiteGradient fillRect: includeRect angle: 90];
     618                [[CTGradient progressWhiteGradient] fillRect: includeRect angle: 90];
    657619            }
    658620        }
     
    667629        {
    668630            if ([torrent isChecking])
    669             {
    670                 if (!fYellowGradient)
    671                     fYellowGradient = [[CTGradient progressYellowGradient] retain];
    672                 [fYellowGradient fillRect: completeRect angle: 90];
    673             }
     631                [[CTGradient progressYellowGradient] fillRect: completeRect angle: 90];
    674632            else if ([torrent isSeeding])
    675633            {
     
    683641                    ratioLeftRect.size.width = ratioLeftWidth;
    684642                   
    685                     if (!fLightGreenGradient)
    686                         fLightGreenGradient = [[CTGradient progressLightGreenGradient] retain];
    687                     [fLightGreenGradient fillRect: ratioLeftRect angle: 90];
     643                    [[CTGradient progressLightGreenGradient] fillRect: ratioLeftRect angle: 90];
    688644                }
    689645               
     
    692648                    completeRect.size.width = leftWidth;
    693649                   
    694                     if (!fGreenGradient)
    695                         fGreenGradient = [[CTGradient progressGreenGradient] retain];
    696                     [fGreenGradient fillRect: completeRect angle: 90];
     650                    [[CTGradient progressGreenGradient] fillRect: completeRect angle: 90];
    697651                }
    698652            }
    699653            else
    700             {
    701                 if (!fBlueGradient)
    702                     fBlueGradient = [[CTGradient progressBlueGradient] retain];
    703                 [fBlueGradient fillRect: completeRect angle: 90];
    704             }
     654                [[CTGradient progressBlueGradient] fillRect: completeRect angle: 90];
    705655        }
    706656        else
     
    709659            {
    710660                if ([torrent progressLeft] <= 0.0)
    711                 {
    712                     if (!fDarkGreenGradient)
    713                         fDarkGreenGradient = [[CTGradient progressDarkGreenGradient] retain];
    714                     [fDarkGreenGradient fillRect: completeRect angle: 90];
    715                 }
     661                    [[CTGradient progressDarkGreenGradient] fillRect: completeRect angle: 90];
    716662                else
    717                 {
    718                     if (!fDarkBlueGradient)
    719                         fDarkBlueGradient = [[CTGradient progressDarkBlueGradient] retain];
    720                     [fDarkBlueGradient fillRect: completeRect angle: 90];
    721                 }
     663                    [[CTGradient progressDarkBlueGradient] fillRect: completeRect angle: 90];
    722664            }
    723665            else
    724             {
    725                 if (!fGrayGradient)
    726                     fGrayGradient = [[CTGradient progressGrayGradient] retain];
    727                 [fGrayGradient fillRect: completeRect angle: 90];
    728             }
     666                [[CTGradient progressGrayGradient] fillRect: completeRect angle: 90];
    729667        }
    730668    }
Note: See TracChangeset for help on using the changeset viewer.