Changeset 4726

Show
Ignore:
Timestamp:
04/26/07 15:07:53 (1 year ago)
Author:
morris
Message:

Random stuff

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Footagehead/trunk/FHApplicationController.m

    r4721 r4726  
    198198                addObserver:self 
    199199                   selector:@selector(windowControllerChangedZoomMode:) 
    200                            name:FHBrowserControllerChangedZoomMode]; 
     200                           name:FHWindowControllerChangedZoomMode]; 
    201201         
    202202        [[[NSWorkspace sharedWorkspace] notificationCenter] 
  • Footagehead/trunk/FHBrowserController.h

    r4717 r4726  
    7373 
    7474#define FHBrowserControllerDidLoadHandler       @"FHBrowserControllerDidLoadHandler" 
    75 #define FHBrowserControllerChangedZoomMode      @"FHBrowserControllerChangedZoomMode" 
    7675 
    7776 
  • Footagehead/trunk/FHBrowserController.m

    r4725 r4726  
    523523                   selector:@selector(eventFileWrite:) 
    524524                           name:WIEventFileWriteNotification]; 
     525 
     526        [[NSNotificationCenter defaultCenter] 
     527                addObserver:self 
     528                   selector:@selector(windowControllerChangedZoomMode:) 
     529                           name:FHWindowControllerChangedZoomMode]; 
    525530} 
    526531 
     
    528533 
    529534- (void)windowDidResize:(NSNotification *)notification { 
     535        [self _updateRightStatus]; 
     536} 
     537 
     538 
     539 
     540- (void)windowControllerChangedZoomMode:(NSNotification *)notification { 
     541        if([notification object] != _imageView) 
     542                [_imageView setImageScaling:[FHSettings intForKey:FHImageScalingMethod]]; 
     543         
     544        [self _updateZoomModeToolbarItems]; 
     545 
    530546        [self _updateRightStatus]; 
    531547} 
     
    10051021#pragma mark - 
    10061022 
    1007 - (void)zoomMode:(id)sender { 
    1008         [super zoomMode:sender]; 
    1009          
    1010         [self _updateZoomModeToolbarItems]; 
    1011          
    1012         [[NSNotificationCenter defaultCenter] postNotificationName:FHBrowserControllerChangedZoomMode]; 
    1013  
    1014         [self _updateRightStatus]; 
    1015 } 
    1016  
    1017  
    1018  
    10191023- (void)rotateRight:(id)sender { 
    10201024        [super rotateRight:sender]; 
  • Footagehead/trunk/FHFeedHandler.m

    r4723 r4726  
    315315        NSArray                 *links; 
    316316        NSString                *content; 
    317         FHFile                  *file; 
    318317        NSUInteger              i, index, count, j, linkCount; 
    319318         
     
    328327                         
    329328                        for(j = 0, linkCount = [links count]; j < linkCount; j++) { 
    330                                 file = [[FHFile alloc] initWithURL:[links objectAtIndex:j] isDirectory:NO index:index++]; 
    331                                 [_files addObject:file]; 
    332                                 [file release]; 
     329                                [_files addObject:[FHFile fileWithURL:[links objectAtIndex:j] isDirectory:NO]]; 
    333330                                 
    334331                                _numberOfFiles++; 
  • Footagehead/trunk/FHFile.h

    r4725 r4726  
    4040        double                                  _percentReceived; 
    4141        BOOL                                    _directory; 
    42         NSUInteger                              _index; 
    4342} 
    4443 
    4544 
    46 - (id)initWithURL:(WIURL *)url isDirectory:(BOOL)isDirectory index:(NSUInteger)index; 
    47 - (id)initWithURL:(WIURL *)url name:(NSString *)name isDirectory:(BOOL)isDirectory index:(NSUInteger)index; 
     45+ (id)fileWithURL:(WIURL *)url isDirectory:(BOOL)isDirectory; 
     46+ (id)fileWithURL:(WIURL *)url name:(NSString *)name isDirectory:(BOOL)isDirectory; 
     47 
     48- (id)initWithURL:(WIURL *)url isDirectory:(BOOL)isDirectory; 
     49- (id)initWithURL:(WIURL *)url name:(NSString *)name isDirectory:(BOOL)isDirectory; 
    4850 
    4951- (void)setImage:(FHImage *)image; 
     
    6264- (FHImage *)icon; 
    6365- (BOOL)isDirectory; 
    64 - (NSUInteger)index; 
    6566 
    6667@end 
  • Footagehead/trunk/FHFile.m

    r4725 r4726  
    3333@implementation FHFile 
    3434 
    35 - (id)initWithURL:(WIURL *)url isDirectory:(BOOL)isDirectory index:(NSUInteger)index
    36         return [self initWithURL:url name:NULL isDirectory:isDirectory index:index]; 
     35+ (id)fileWithURL:(WIURL *)url isDirectory:(BOOL)isDirectory
     36        return [[[self alloc] initWithURL:url isDirectory:isDirectory] autorelease]; 
    3737} 
    3838 
    3939 
    4040 
    41 - (id)initWithURL:(WIURL *)url name:(NSString *)name isDirectory:(BOOL)isDirectory index:(NSUInteger)index { 
     41+ (id)fileWithURL:(WIURL *)url name:(NSString *)name isDirectory:(BOOL)isDirectory { 
     42        return [[[self alloc] initWithURL:url name:name isDirectory:isDirectory] autorelease]; 
     43
     44 
     45 
     46 
     47- (id)initWithURL:(WIURL *)url isDirectory:(BOOL)isDirectory { 
     48        return [self initWithURL:url name:NULL isDirectory:isDirectory]; 
     49
     50 
     51 
     52 
     53- (id)initWithURL:(WIURL *)url name:(NSString *)name isDirectory:(BOOL)isDirectory { 
    4254        NSImage         *icon; 
    4355         
     
    4961        _extension = [[[self path] pathExtension] retain]; 
    5062        _directory = isDirectory; 
    51         _index = index; 
    5263         
    5364        if(!_directory) { 
     
    174185} 
    175186 
    176  
    177  
    178 - (NSUInteger)index { 
    179         return _index; 
    180 } 
    181  
    182187@end 
  • Footagehead/trunk/FHFileHandler.m

    r4723 r4726  
    126126        NSArray                         *files; 
    127127        NSString                        *name, *path, *extension; 
    128         FHFile                          *file; 
    129128        WIURL                           *url; 
    130129        LSItemInfoRecord        itemInfoRecord; 
    131130        OSStatus                        err; 
    132131        BOOL                            isDirectory; 
    133         NSUInteger                      i, count, index
     132        NSUInteger                      i, count
    134133 
    135134        if(!_files) { 
     
    140139                _files  = [[NSMutableArray alloc] initWithCapacity:count]; 
    141140                 
    142                 for(i = index = 0; i < count; i++) { 
     141                for(i = 0; i < count; i++) { 
    143142                        name = [files objectAtIndex:i]; 
    144143                        path = [_rootPath stringByAppendingPathComponent:name]; 
     
    169168                        } 
    170169 
    171                         file = [[FHFile alloc] initWithURL:url isDirectory:isDirectory index:index++]; 
    172                         [_files addObject:file]; 
    173                         [file release]; 
     170                        [_files addObject:[FHFile fileWithURL:url isDirectory:isDirectory]]; 
    174171 
    175172                        _numberOfFiles++; 
  • Footagehead/trunk/FHFlickrHandler.m

    r4723 r4726  
    3838        NSArray                 *links; 
    3939        NSString                *content; 
    40         FHFile                  *file; 
    4140        WIURL                   *url; 
    4241        NSRange                 range; 
    43         NSUInteger              i, index, count; 
     42        NSUInteger              i, count; 
    4443         
    4544        if(!_files) { 
     
    4746                _files = [[NSMutableArray alloc] initWithCapacity:count]; 
    4847                 
    49                 for(i = index = 0; i < count; i++) { 
     48                for(i = 0; i < count; i++) { 
    5049                        item = [_items objectAtIndex:i]; 
    5150                        content = [item objectForKey:[self itemContentKey]]; 
     
    6362                                [path release]; 
    6463                                 
    65                                 file = [[FHFile alloc] initWithURL:url name:[item objectForKey:@"title"] isDirectory:NO index:index++]; 
    66                                 [_files addObject:file]; 
    67                                 [file release]; 
     64                                [_files addObject:[FHFile fileWithURL:url name:[item objectForKey:@"title"] isDirectory:NO]]; 
    6865                                 
    6966                                _numberOfFiles++; 
  • Footagehead/trunk/FHHTMLHandler.h

    r4706 r4726  
    2929#import "FHURLHandler.h" 
    3030 
     31enum _FHHTMLHandlerType { 
     32        FHHTMLHandlerGeneric, 
     33        FHHTMLHandler4chan 
     34}; 
     35typedef enum _FHHTMLHandlerType         FHHTMLHandlerType; 
     36 
     37 
    3138@interface FHHTMLHandler : FHURLHandler { 
    32         NSString                                        *_html; 
     39        NSString                                                *_html; 
     40         
     41        FHHTMLHandlerType                               _type; 
    3342} 
    3443 
  • Footagehead/trunk/FHHTMLHandler.m

    r4724 r4726  
    2929#import "NSImage-FHAdditions.h" 
    3030#import "FHFile.h" 
    31 #import "FHFutabaHandler.h" 
    3231#import "FHHTMLHandler.h" 
    3332#import "FHHTMLParser.h" 
     33#import "FHSettings.h" 
     34 
     35@interface FHHTMLHandler(Private) 
     36 
     37- (int)_HTMLImageType; 
     38- (BOOL)_shouldIncludeURL:(WIURL *)url; 
     39 
     40@end 
     41 
     42 
     43@implementation FHHTMLHandler(Private) 
     44 
     45- (int)_HTMLImageType { 
     46        if(_type == FHHTMLHandler4chan) 
     47                return FHHTMLImageOnlyLinks; 
     48         
     49        return [FHSettings intForKey:FHHTMLImageType]; 
     50} 
     51 
     52 
     53 
     54- (BOOL)_shouldIncludeURL:(WIURL *)url { 
     55        if(_type == FHHTMLHandler4chan) 
     56                return ![[url path] containsSubstring:@"src.cgi"]; 
     57         
     58        return YES; 
     59} 
     60 
     61@end 
     62 
     63 
    3464 
    3565@implementation FHHTMLHandler 
    3666 
    3767+ (Class)handlerForURL:(WIURL *)url { 
    38         NSString        *host; 
    39          
    40         host = [url host]; 
    41          
    42         if([host hasSuffix:@"4chan.org"]) 
    43                 return [FHFutabaHandler class]; 
    44          
    4568        return self; 
    4669} 
     
    5174 
    5275- (id)initHandlerWithURL:(WIURL *)url HTML:(NSString *)html { 
     76        NSString        *host; 
    5377        self = [super initHandlerWithURL:url]; 
    5478         
    5579        _html = [html retain]; 
     80         
     81        host = [url host]; 
     82         
     83        if([host hasSuffix:@"4chan.org"]) 
     84                _type = FHHTMLHandler4chan; 
     85        else 
     86                _type = FHHTMLHandlerGeneric; 
    5687         
    5788        return self; 
     
    72103- (NSArray *)files { 
    73104        NSArray                 *links; 
    74         FHFile                 *file
    75         NSUInteger              i, index, count; 
     105        WIURL                  *url
     106        NSUInteger              i, count; 
    76107         
    77108        if(!_files) { 
    78                 links = [FHHTMLParser imageLinksInHTML:_html baseURL:[self URL]]; 
     109                links = [FHHTMLParser imageLinksInHTML:_html baseURL:[self URL] type:[self _HTMLImageType]]; 
    79110                count = [links count]; 
    80111                 
    81112                _files = [[NSMutableArray alloc] initWithCapacity:count]; 
    82113                 
    83                 for(i = index = 0; i < count; i++) { 
    84                         file = [[FHFile alloc] initWithURL:[links objectAtIndex:i] isDirectory:NO index:index++]; 
    85                         [_files addObject:file]; 
    86                         [file release]; 
     114                for(i = 0; i < count; i++) { 
     115                        url = [links objectAtIndex:i]; 
    87116                         
    88                         _numberOfFiles++; 
    89                         _numberOfImages++; 
     117                        if([self _shouldIncludeURL:url]) { 
     118                                [_files addObject:[FHFile fileWithURL:url isDirectory:NO]]; 
     119                                 
     120                                _numberOfFiles++; 
     121                                _numberOfImages++; 
     122                        } 
    90123                } 
    91124        } 
  • Footagehead/trunk/FHHTMLParser.m

    r4724 r4726  
    4646        NSArray                 *tokens; 
    4747        NSSet                   *types; 
    48         NSString                *token, *link, *path
     48        NSString                *token, *link, *path, *extension
    4949        WIURL                   *url; 
    5050        NSUInteger              i, count, length; 
    5151         
    52         links = [NSMutableArray arrayWithCapacity:50]; 
    53         set = [NSMutableSet setWithCapacity:50]; 
    54         length = [html length]; 
    55         skipSet = [NSCharacterSet characterSetWithCharactersInString:@" =\r\n\t\"\'<>"]; 
     52        links   = [NSMutableArray arrayWithCapacity:50]; 
     53        length  = [html length]; 
     54        skipSet = [NSCharacterSet characterSetWithCharactersInString:@" =\r\n\t\"\'<>"]; 
    5655         
    5756        switch(type) { 
     
    8281                        if([scanner scanUpToString:token intoString:NULL]) { 
    8382                                if([scanner scanString:token intoString:NULL]) { 
    84                                         if([scanner scanUpToCharactersFromSet:skipSet intoString:&link]) { 
    85                                                 if(![set containsObject:link]) { 
    86                                                         [links addObject:link]; 
    87                                                         [set addObject:link]; 
    88                                                 } 
    89                                         } 
     83                                        if([scanner scanUpToCharactersFromSet:skipSet intoString:&link]) 
     84                                                [links addObject:link]; 
    9085                                } 
    9186                        } 
     
    9590        } 
    9691         
    97         count = [links count]; 
    98         urls = [NSMutableArray arrayWithCapacity:count]; 
    99         types = [NSSet setWithArray:[NSImage FHImageFileTypes]]; 
     92        count   = [links count]; 
     93        urls    = [NSMutableArray arrayWithCapacity:count]; 
     94        set             = [NSMutableSet setWithCapacity:count]; 
     95        types   = [NSSet setWithArray:[NSImage FHImageFileTypes]]; 
    10096         
    10197        for(i = 0; i < count; i++) { 
    10298                link = [links objectAtIndex:i]; 
     99                extension = [link pathExtension]; 
    103100                 
    104                 if(![types containsObject:[link pathExtension]])  
     101                if(![types containsObject:extension])  
     102                        continue; 
     103                 
     104                if([extension isEqualToString:@"ico"]) 
    105105                        continue; 
    106106                 
     
    124124                } 
    125125                 
    126                 [urls addObject:url]; 
     126                if(![set containsObject:url]) { 
     127                        [urls addObject:url]; 
     128                        [set addObject:url]; 
     129                } 
    127130        } 
    128131                 
  • Footagehead/trunk/FHImageHandler.m

    r4706 r4726  
    3737        self = [super initHandlerWithURL:url]; 
    3838         
    39         _files = [[NSMutableArray alloc] initWithCapacity:1]; 
    40          
    41         file = [[FHFile alloc] initWithURL:[self URL] isDirectory:NO index:0]; 
     39        file = [FHFile fileWithURL:[self URL] isDirectory:NO]; 
    4240        [file setImage:image]; 
    4341        [file setLoaded:YES]; 
    44         [_files addObject:file]; 
    45         [file release]; 
     42 
     43        _files = [[NSMutableArray alloc] initWithObjects:file, NULL]; 
    4644         
    47         _numberOfFiles = 1; 
    48         _numberOfImages = 1; 
     45        _numberOfFiles = _numberOfImages = 1; 
    4946         
    5047        return self; 
  • Footagehead/trunk/FHImageLoader.h

    r4725 r4726  
    4848        NSArray                                 *_files; 
    4949        NSUInteger                              _index; 
    50         NSUInteger                              _pixels, _maxPixels; 
     50         
     51        unsigned long long              _pixels, _maxPixels; 
    5152} 
    5253 
  • Footagehead/trunk/FHImageLoader.m

    r4725 r4726  
    4646        _asynchronousData       = [[NSMutableData alloc] init]; 
    4747 
     48        _maxPixels                      = ((double) [[NSProcessInfo processInfo] amountOfMemory] / 10) / 5; 
     49         
    4850        [NSThread detachNewThreadSelector:@selector(imageThread:) toTarget:self withObject:NULL]; 
    4951        [NSThread detachNewThreadSelector:@selector(thumbnailsThread:) toTarget:self withObject:NULL]; 
    5052 
    5153        [NSThread setThreadPriority:0.75]; 
    52          
    53         _maxPixels = 20000000; 
    5454         
    5555        return self; 
  • Footagehead/trunk/FHRangeHandler.m

    r4723 r4726  
    135135        NSEnumerator    *enumerator; 
    136136        NSString                *link; 
    137         FHFile                  *file; 
    138         NSUInteger              i = 0; 
    139137         
    140138        if(!_files) { 
     
    144142                 
    145143                while((link = [enumerator nextObject])) { 
    146                         file = [[FHFile alloc] initWithURL:[WIURL URLWithString:link] isDirectory:NO index:i++]; 
    147                         [_files addObject:file]; 
    148                         [file release]; 
     144                        [_files addObject:[FHFile fileWithURL:[WIURL URLWithString:link] isDirectory:NO]]; 
    149145                         
    150146                        _numberOfFiles++; 
  • Footagehead/trunk/FHSlideshowController.m

    r4725 r4726  
    139139         
    140140        [_imageView setBackgroundColor:color]; 
     141        [_imageView setImageScaling:[FHSettings intForKey:FHImageScalingMethod]]; 
    141142         
    142143        [_imageLoader startLoadingImageAtIndex:[self selectedIndex]]; 
  • Footagehead/trunk/FHSpotlightHandler.m

    r4725 r4726  
    7878        NSMetadataItem  *item; 
    7979        NSString                *path; 
    80         FHFile                  *file; 
    8180        NSUInteger              count; 
    8281         
     
    8887                 
    8988                if(path) { 
    90                         file = [[FHFile alloc] initWithURL:[WIURL fileURLWithPath:path] isDirectory:NO index:_index]; 
    91                         [_files addObject:file]; 
    92                         [file release]; 
     89                        [_files addObject:[FHFile fileWithURL:[WIURL fileURLWithPath:path] isDirectory:NO]]; 
    9390                         
    9491                        _numberOfFiles++; 
  • Footagehead/trunk/FHURLHandler.m

    r4725 r4726  
    100100                NSStringEncoding        nsEncoding; 
    101101                CFStringEncoding        cfEncoding; 
    102                 Class                           class; 
    103102                 
    104103                nsEncoding = NSISOLatin1StringEncoding; 
     
    114113                text = [NSString stringWithData:data encoding:nsEncoding]; 
    115114 
    116                 class = [FHHTMLHandler handlerForURL:url]; 
    117                  
    118                 return [[class allocWithZone:zone] initHandlerWithURL:url HTML:text]; 
     115                return [[FHHTMLHandler allocWithZone:zone] initHandlerWithURL:url HTML:text]; 
    119116        } 
    120117        else if([mime containsSubstring:@"xml"]) { 
  • Footagehead/trunk/FHWindowController.h

    r4725 r4726  
    3838 
    3939 
     40#define FHWindowControllerChangedZoomMode       @"FHWindowControllerChangedZoomMode" 
     41 
     42 
    4043- (NSArray *)files; 
    4144- (FHFile *)fileAtIndex:(NSUInteger)index; 
  • Footagehead/trunk/FHWindowController.m

    r4725 r4726  
    276276         
    277277        [FHSettings setInt:scaling forKey:FHImageScalingMethod]; 
     278 
     279        [[NSNotificationCenter defaultCenter] postNotificationName:FHWindowControllerChangedZoomMode object:_imageView]; 
    278280} 
    279281 
  • Footagehead/trunk/Footagehead.xcodeproj/project.pbxproj

    r4725 r4726  
    102102                A58BE56A09BA054F00C3C20D /* White.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A58BE56709BA054F00C3C20D /* White.tiff */; }; 
    103103                A58BE56B09BA054F00C3C20D /* Gray.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A58BE56809BA054F00C3C20D /* Gray.tiff */; }; 
    104                 A597A4960BE0889A00C3E4DE /* FHFutabaHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = A597A4940BE0889A00C3E4DE /* FHFutabaHandler.m */; }; 
    105104                A599A110075F94F400A03BA5 /* FHFileCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A599A10E075F94F400A03BA5 /* FHFileCell.m */; }; 
    106105                A5A183F00BDD5231004788EF /* FHWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = A5A183EE0BDD5231004788EF /* FHWindowController.m */; }; 
     
    314313                A58BE56809BA054F00C3C20D /* Gray.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Gray.tiff; sourceTree = "<group>"; }; 
    315314                A591E22C056686CB00215980 /* prefix.pch */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = prefix.pch; sourceTree = "<group>"; }; 
    316                 A597A4940BE0889A00C3E4DE /* FHFutabaHandler.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; path = FHFutabaHandler.m; sourceTree = "<group>"; }; 
    317                 A597A4950BE0889A00C3E4DE /* FHFutabaHandler.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = FHFutabaHandler.h; sourceTree = "<group>"; }; 
    318315                A599A10D075F94F400A03BA5 /* FHFileCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FHFileCell.h; sourceTree = "<group>"; }; 
    319316                A599A10E075F94F400A03BA5 /* FHFileCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FHFileCell.m; sourceTree = "<group>"; }; 
     
    703700                                A5B1F9AA067BCF0100111D0A /* FHHTMLHandler.m */, 
    704701                                A5B1F9A9067BCF0100111D0A /* FHHTMLHandler.h */, 
    705                                 A597A4740BE0888600C3E4DE /* HTML Handlers */, 
    706702                                A5B1FBC4067D01C200111D0A /* FHImageHandler.m */, 
    707703                                A5B1FBC5067D01C200111D0A /* FHImageHandler.h */, 
     
    717713                        ); 
    718714                        name = "Feed Handlers"; 
    719                         sourceTree = "<group>"; 
    720                 }; 
    721                 A597A4740BE0888600C3E4DE /* HTML Handlers */ = { 
    722                         isa = PBXGroup; 
    723                         children = ( 
    724                                 A597A4940BE0889A00C3E4DE /* FHFutabaHandler.m */, 
    725                                 A597A4950BE0889A00C3E4DE /* FHFutabaHandler.h */, 
    726                         ); 
    727                         name = "HTML Handlers"; 
    728715                        sourceTree = "<group>"; 
    729716                }; 
     
    11351122                                A5B1F617067B3B7900111D0A /* FHFileHandler.m in Sources */, 
    11361123                                77EAC0D5084C6D1F006C9F69 /* FHFlickrHandler.m in Sources */, 
    1137                                 A597A4960BE0889A00C3E4DE /* FHFutabaHandler.m in Sources */, 
    11381124                                A5B1F611067B3AA100111D0A /* FHHandler.m in Sources */, 
    11391125                                A5B1F9AC067BCF0200111D0A /* FHHTMLHandler.m in Sources */,