Changeset 4181

Show
Ignore:
Timestamp:
06/02/06 17:30:41 (2 years ago)
Author:
morris
Message:

Do it like WiredClient? does

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WiredServer/trunk/PreferencePane/English.lproj/Wired.nib/classes.nib

    r3946 r4181  
    5454            ACTIONS = { 
    5555                addTracker = id;  
     56                banner = id;  
    5657                clearBanner = id;  
    5758                createCertificate = id;  
    5859                deleteTracker = id;  
    5960                detectURL = id;  
    60                 selectBanner = id;  
    6161                selectFiles = id;  
    6262                selectLogFile = id;  
  • WiredServer/trunk/PreferencePane/French.lproj/Wired.nib/classes.nib

    r4179 r4181  
    5959            ACTIONS = { 
    6060                addTracker = id;  
     61                banner = id;  
    6162                clearBanner = id;  
    6263                createCertificate = id;  
    6364                deleteTracker = id;  
    6465                detectURL = id;  
    65                 selectBanner = id;  
    6666                selectFiles = id;  
    6767                selectLogFile = id;  
  • WiredServer/trunk/PreferencePane/Japanese.lproj/Wired.nib/classes.nib

    r4144 r4181  
    5959            ACTIONS = { 
    6060                addTracker = id;  
     61                banner = id;  
    6162                clearBanner = id;  
    6263                createCertificate = id;  
    6364                deleteTracker = id;  
    6465                detectURL = id;  
    65                 selectBanner = id;  
    6666                selectFiles = id;  
    6767                selectLogFile = id;  
  • WiredServer/trunk/PreferencePane/Japanese.lproj/Wired.nib/info.nib

    r4144 r4181  
    66        <string>46 63 446 363 0 0 1280 832 </string> 
    77        <key>IBFramework Version</key> 
    8         <string>443.0</string> 
     8        <string>446.1</string> 
    99        <key>IBOpenObjects</key> 
    1010        <array> 
  • WiredServer/trunk/WCConfigController.h

    r3950 r4181  
    113113 
    114114- (IBAction)touch:(id)sender; 
     115- (IBAction)banner:(id)sender; 
    115116- (IBAction)setBanner:(id)sender; 
    116 - (IBAction)selectBanner:(id)sender; 
    117117- (IBAction)clearBanner:(id)sender; 
    118118- (IBAction)selectFiles:(id)sender; 
  • WiredServer/trunk/WCConfigController.m

    r4011 r4181  
    4848- (BOOL)_writeFlagsToFile:(NSString *)path; 
    4949 
     50- (void)_setBanner:(NSImage *)banner; 
    5051- (void)_setLaunchesAtBoot:(BOOL)value; 
    5152- (void)_changeOwnerOfPrefixPathToUser:(NSString *)user group:(NSString *)group; 
     
    378379#pragma mark - 
    379380 
     381- (void)_setBanner:(NSImage *)banner { 
     382        NSData                                  *data; 
     383        NSString                                *path, *temp; 
     384        WCDashboardController   *controller; 
     385        BOOL                                    success = NO; 
     386 
     387        banner          = [banner scaledImageWithSize:NSMakeSize(200.0, 32.0)]; 
     388        data            = [[NSBitmapImageRep imageRepWithData:[banner TIFFRepresentation]] representationUsingType:NSPNGFileType properties:NULL]; 
     389        path            = WCExpandWiredPath(@"banner.png"); 
     390        controller      = [WCDashboardController dashboardController]; 
     391        temp            = [NSFileManager temporaryPathWithPrefix:@"banner" suffix:@"png"]; 
     392         
     393        if([data writeToFile:temp atomically:YES]) { 
     394                if([controller movePath:temp toPath:path]) { 
     395                        if([controller changeOwnerOfPath:path 
     396                                                                          toUser:[_config stringForKey:@"user"] 
     397                                                                           group:[_config stringForKey:@"group"]]) { 
     398                                [_config setString:path forKey:@"banner"]; 
     399                                _touched = YES; 
     400                                success = YES; 
     401                        } 
     402                } 
     403        } 
     404         
     405        [_bannerImageView setImage:success ? banner : NULL]; 
     406} 
     407 
     408 
     409 
    380410- (void)_setLaunchesAtBoot:(BOOL)value { 
    381411        NSString                                *path; 
     
    596626 
    597627 
    598 - (void)bannerPanelDidEnd:(NSOpenPanel *)openPanel returnCode:(int)returnCode contextInfo:(void  *)contextInfo { 
    599         if(returnCode == NSOKButton) { 
    600                 [_bannerImageView setImage:[[[NSImage alloc] initWithContentsOfFile: 
    601                         [[openPanel filenames] objectAtIndex:0]] autorelease]]; 
    602                 [self setBanner:self]; 
    603                  
    604                 _touched = YES; 
    605         } 
    606 } 
    607  
    608  
    609  
    610628- (void)filesPanelDidEnd:(NSOpenPanel *)openPanel returnCode:(int)returnCode contextInfo:(void  *)contextInfo { 
    611629        if(returnCode == NSOKButton) { 
     
    650668 
    651669 
     670- (IBAction)banner:(id)sender { 
     671        [self _setBanner:[_bannerImageView image]]; 
     672} 
     673 
     674 
     675 
    652676- (IBAction)setBanner:(id)sender { 
    653         NSImage                                 *image, *banner; 
    654         NSBitmapImageRep                *imageRep; 
    655         NSData                                  *data; 
    656         NSString                                *path, *temp; 
    657         WCDashboardController   *controller; 
    658         NSSize                                  size; 
    659          
    660         image = [_bannerImageView image]; 
    661          
    662     if([image size].width <= 200 && [image size].height <= 32) 
    663         size = [image size]; 
    664     else if([image size].width >= 200 && [image size].height <= 32) 
    665         size = NSMakeSize(200, [image size].height); 
    666     else if([image size].width <= 200 && [image size].height >= 32) 
    667         size = NSMakeSize([image size].height, 32); 
    668     else if([image size].width > [image size].height) 
    669         size = NSMakeSize(200, 32 * ([image size].width / [image size].height)); 
    670     else 
    671         size = NSMakeSize(200 * ([image size].width / [image size].height), 32); 
    672          
    673         if(!NSEqualSizes([image size], size)) { 
    674         banner = [[NSImage alloc] initWithSize:size]; 
    675         [banner lockFocus]; 
    676         [image setSize:size]; 
    677         [image drawAtPoint:NSZeroPoint 
    678                   fromRect:NSMakeRect(0, 0, size.width, size.height) 
    679                  operation:NSCompositeCopy 
    680                   fraction:1.0]; 
    681         [banner unlockFocus]; 
    682                  
    683         [_bannerImageView setImage:banner]; 
    684         [banner release]; 
    685     } 
    686          
    687         imageRep        = [NSBitmapImageRep imageRepWithData:[[_bannerImageView image] TIFFRepresentation]]; 
    688         data            = [imageRep representationUsingType:NSPNGFileType properties:NULL]; 
    689         path            = WCExpandWiredPath(@"banner.png"); 
    690         controller      = [WCDashboardController dashboardController]; 
    691         temp            = [NSFileManager temporaryPathWithPrefix:@"banner" suffix:@"png"]; 
    692          
    693         if([data writeToFile:temp atomically:YES]) { 
    694                 if([controller movePath:temp toPath:path]) { 
    695                         if([controller changeOwnerOfPath:path 
    696                                                                           toUser:[_config stringForKey:@"user"] 
    697                                                                            group:[_config stringForKey:@"group"]]) { 
    698                                 [_config setString:path forKey:@"banner"]; 
    699                                 _touched = YES; 
    700                         } 
    701                 } 
    702         } 
    703 } 
    704  
    705  
    706  
    707 - (IBAction)selectBanner:(id)sender { 
    708677        NSOpenPanel             *openPanel; 
    709678         
     
    718687                                           didEndSelector:@selector(bannerPanelDidEnd:returnCode:contextInfo:) 
    719688                                                  contextInfo:NULL]; 
     689} 
     690 
     691 
     692 
     693- (void)bannerPanelDidEnd:(NSOpenPanel *)openPanel returnCode:(int)returnCode contextInfo:(void  *)contextInfo { 
     694        NSData          *data; 
     695        NSImage         *image; 
     696 
     697        if(returnCode == NSOKButton) { 
     698                data = [NSData dataWithContentsOfFile:[openPanel filename]]; 
     699                image = [NSImage imageWithData:data]; 
     700                 
     701                if(image) 
     702                        [self _setBanner:image]; 
     703        } 
    720704} 
    721705