Changeset 4726
- Timestamp:
- 04/26/07 15:07:53 (1 year ago)
- Files:
-
- Footagehead/trunk/FHApplicationController.m (modified) (1 diff)
- Footagehead/trunk/FHBrowserController.h (modified) (1 diff)
- Footagehead/trunk/FHBrowserController.m (modified) (3 diffs)
- Footagehead/trunk/FHFeedHandler.m (modified) (2 diffs)
- Footagehead/trunk/FHFile.h (modified) (2 diffs)
- Footagehead/trunk/FHFile.m (modified) (3 diffs)
- Footagehead/trunk/FHFileHandler.m (modified) (3 diffs)
- Footagehead/trunk/FHFlickrHandler.m (modified) (3 diffs)
- Footagehead/trunk/FHFutabaHandler.h (deleted)
- Footagehead/trunk/FHFutabaHandler.m (deleted)
- Footagehead/trunk/FHHTMLHandler.h (modified) (1 diff)
- Footagehead/trunk/FHHTMLHandler.m (modified) (3 diffs)
- Footagehead/trunk/FHHTMLParser.m (modified) (4 diffs)
- Footagehead/trunk/FHImageHandler.m (modified) (1 diff)
- Footagehead/trunk/FHImageLoader.h (modified) (1 diff)
- Footagehead/trunk/FHImageLoader.m (modified) (1 diff)
- Footagehead/trunk/FHRangeHandler.m (modified) (2 diffs)
- Footagehead/trunk/FHSlideshowController.m (modified) (1 diff)
- Footagehead/trunk/FHSpotlightHandler.m (modified) (2 diffs)
- Footagehead/trunk/FHURLHandler.m (modified) (2 diffs)
- Footagehead/trunk/FHWindowController.h (modified) (1 diff)
- Footagehead/trunk/FHWindowController.m (modified) (1 diff)
- Footagehead/trunk/Footagehead.xcodeproj/project.pbxproj (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Footagehead/trunk/FHApplicationController.m
r4721 r4726 198 198 addObserver:self 199 199 selector:@selector(windowControllerChangedZoomMode:) 200 name:FH BrowserControllerChangedZoomMode];200 name:FHWindowControllerChangedZoomMode]; 201 201 202 202 [[[NSWorkspace sharedWorkspace] notificationCenter] Footagehead/trunk/FHBrowserController.h
r4717 r4726 73 73 74 74 #define FHBrowserControllerDidLoadHandler @"FHBrowserControllerDidLoadHandler" 75 #define FHBrowserControllerChangedZoomMode @"FHBrowserControllerChangedZoomMode"76 75 77 76 Footagehead/trunk/FHBrowserController.m
r4725 r4726 523 523 selector:@selector(eventFileWrite:) 524 524 name:WIEventFileWriteNotification]; 525 526 [[NSNotificationCenter defaultCenter] 527 addObserver:self 528 selector:@selector(windowControllerChangedZoomMode:) 529 name:FHWindowControllerChangedZoomMode]; 525 530 } 526 531 … … 528 533 529 534 - (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 530 546 [self _updateRightStatus]; 531 547 } … … 1005 1021 #pragma mark - 1006 1022 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 1019 1023 - (void)rotateRight:(id)sender { 1020 1024 [super rotateRight:sender]; Footagehead/trunk/FHFeedHandler.m
r4723 r4726 315 315 NSArray *links; 316 316 NSString *content; 317 FHFile *file;318 317 NSUInteger i, index, count, j, linkCount; 319 318 … … 328 327 329 328 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]]; 333 330 334 331 _numberOfFiles++; Footagehead/trunk/FHFile.h
r4725 r4726 40 40 double _percentReceived; 41 41 BOOL _directory; 42 NSUInteger _index;43 42 } 44 43 45 44 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; 48 50 49 51 - (void)setImage:(FHImage *)image; … … 62 64 - (FHImage *)icon; 63 65 - (BOOL)isDirectory; 64 - (NSUInteger)index;65 66 66 67 @end Footagehead/trunk/FHFile.m
r4725 r4726 33 33 @implementation FHFile 34 34 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]; 37 37 } 38 38 39 39 40 40 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 { 42 54 NSImage *icon; 43 55 … … 49 61 _extension = [[[self path] pathExtension] retain]; 50 62 _directory = isDirectory; 51 _index = index;52 63 53 64 if(!_directory) { … … 174 185 } 175 186 176 177 178 - (NSUInteger)index {179 return _index;180 }181 182 187 @end Footagehead/trunk/FHFileHandler.m
r4723 r4726 126 126 NSArray *files; 127 127 NSString *name, *path, *extension; 128 FHFile *file;129 128 WIURL *url; 130 129 LSItemInfoRecord itemInfoRecord; 131 130 OSStatus err; 132 131 BOOL isDirectory; 133 NSUInteger i, count , index;132 NSUInteger i, count; 134 133 135 134 if(!_files) { … … 140 139 _files = [[NSMutableArray alloc] initWithCapacity:count]; 141 140 142 for(i = index =0; i < count; i++) {141 for(i = 0; i < count; i++) { 143 142 name = [files objectAtIndex:i]; 144 143 path = [_rootPath stringByAppendingPathComponent:name]; … … 169 168 } 170 169 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]]; 174 171 175 172 _numberOfFiles++; Footagehead/trunk/FHFlickrHandler.m
r4723 r4726 38 38 NSArray *links; 39 39 NSString *content; 40 FHFile *file;41 40 WIURL *url; 42 41 NSRange range; 43 NSUInteger i, index,count;42 NSUInteger i, count; 44 43 45 44 if(!_files) { … … 47 46 _files = [[NSMutableArray alloc] initWithCapacity:count]; 48 47 49 for(i = index =0; i < count; i++) {48 for(i = 0; i < count; i++) { 50 49 item = [_items objectAtIndex:i]; 51 50 content = [item objectForKey:[self itemContentKey]]; … … 63 62 [path release]; 64 63 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]]; 68 65 69 66 _numberOfFiles++; Footagehead/trunk/FHHTMLHandler.h
r4706 r4726 29 29 #import "FHURLHandler.h" 30 30 31 enum _FHHTMLHandlerType { 32 FHHTMLHandlerGeneric, 33 FHHTMLHandler4chan 34 }; 35 typedef enum _FHHTMLHandlerType FHHTMLHandlerType; 36 37 31 38 @interface FHHTMLHandler : FHURLHandler { 32 NSString *_html; 39 NSString *_html; 40 41 FHHTMLHandlerType _type; 33 42 } 34 43 Footagehead/trunk/FHHTMLHandler.m
r4724 r4726 29 29 #import "NSImage-FHAdditions.h" 30 30 #import "FHFile.h" 31 #import "FHFutabaHandler.h"32 31 #import "FHHTMLHandler.h" 33 32 #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 34 64 35 65 @implementation FHHTMLHandler 36 66 37 67 + (Class)handlerForURL:(WIURL *)url { 38 NSString *host;39 40 host = [url host];41 42 if([host hasSuffix:@"4chan.org"])43 return [FHFutabaHandler class];44 45 68 return self; 46 69 } … … 51 74 52 75 - (id)initHandlerWithURL:(WIURL *)url HTML:(NSString *)html { 76 NSString *host; 53 77 self = [super initHandlerWithURL:url]; 54 78 55 79 _html = [html retain]; 80 81 host = [url host]; 82 83 if([host hasSuffix:@"4chan.org"]) 84 _type = FHHTMLHandler4chan; 85 else 86 _type = FHHTMLHandlerGeneric; 56 87 57 88 return self; … … 72 103 - (NSArray *)files { 73 104 NSArray *links; 74 FHFile *file;75 NSUInteger i, index,count;105 WIURL *url; 106 NSUInteger i, count; 76 107 77 108 if(!_files) { 78 links = [FHHTMLParser imageLinksInHTML:_html baseURL:[self URL] ];109 links = [FHHTMLParser imageLinksInHTML:_html baseURL:[self URL] type:[self _HTMLImageType]]; 79 110 count = [links count]; 80 111 81 112 _files = [[NSMutableArray alloc] initWithCapacity:count]; 82 113 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]; 87 116 88 _numberOfFiles++; 89 _numberOfImages++; 117 if([self _shouldIncludeURL:url]) { 118 [_files addObject:[FHFile fileWithURL:url isDirectory:NO]]; 119 120 _numberOfFiles++; 121 _numberOfImages++; 122 } 90 123 } 91 124 } Footagehead/trunk/FHHTMLParser.m
r4724 r4726 46 46 NSArray *tokens; 47 47 NSSet *types; 48 NSString *token, *link, *path ;48 NSString *token, *link, *path, *extension; 49 49 WIURL *url; 50 50 NSUInteger i, count, length; 51 51 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\"\'<>"]; 56 55 57 56 switch(type) { … … 82 81 if([scanner scanUpToString:token intoString:NULL]) { 83 82 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]; 90 85 } 91 86 } … … 95 90 } 96 91 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]]; 100 96 101 97 for(i = 0; i < count; i++) { 102 98 link = [links objectAtIndex:i]; 99 extension = [link pathExtension]; 103 100 104 if(![types containsObject:[link pathExtension]]) 101 if(![types containsObject:extension]) 102 continue; 103 104 if([extension isEqualToString:@"ico"]) 105 105 continue; 106 106 … … 124 124 } 125 125 126 [urls addObject:url]; 126 if(![set containsObject:url]) { 127 [urls addObject:url]; 128 [set addObject:url]; 129 } 127 130 } 128 131 Footagehead/trunk/FHImageHandler.m
r4706 r4726 37 37 self = [super initHandlerWithURL:url]; 38 38 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]; 42 40 [file setImage:image]; 43 41 [file setLoaded:YES]; 44 [_files addObject:file]; 45 [file release];42 43 _files = [[NSMutableArray alloc] initWithObjects:file, NULL]; 46 44 47 _numberOfFiles = 1; 48 _numberOfImages = 1; 45 _numberOfFiles = _numberOfImages = 1; 49 46 50 47 return self; Footagehead/trunk/FHImageLoader.h
r4725 r4726 48 48 NSArray *_files; 49 49 NSUInteger _index; 50 NSUInteger _pixels, _maxPixels; 50 51 unsigned long long _pixels, _maxPixels; 51 52 } 52 53 Footagehead/trunk/FHImageLoader.m
r4725 r4726 46 46 _asynchronousData = [[NSMutableData alloc] init]; 47 47 48 _maxPixels = ((double) [[NSProcessInfo processInfo] amountOfMemory] / 10) / 5; 49 48 50 [NSThread detachNewThreadSelector:@selector(imageThread:) toTarget:self withObject:NULL]; 49 51 [NSThread detachNewThreadSelector:@selector(thumbnailsThread:) toTarget:self withObject:NULL]; 50 52 51 53 [NSThread setThreadPriority:0.75]; 52 53 _maxPixels = 20000000;54 54 55 55 return self; Footagehead/trunk/FHRangeHandler.m
r4723 r4726 135 135 NSEnumerator *enumerator; 136 136 NSString *link; 137 FHFile *file;138 NSUInteger i = 0;139 137 140 138 if(!_files) { … … 144 142 145 143 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]]; 149 145 150 146 _numberOfFiles++; Footagehead/trunk/FHSlideshowController.m
r4725 r4726 139 139 140 140 [_imageView setBackgroundColor:color]; 141 [_imageView setImageScaling:[FHSettings intForKey:FHImageScalingMethod]]; 141 142 142 143 [_imageLoader startLoadingImageAtIndex:[self selectedIndex]]; Footagehead/trunk/FHSpotlightHandler.m
r4725 r4726 78 78 NSMetadataItem *item; 79 79 NSString *path; 80 FHFile *file;81 80 NSUInteger count; 82 81 … … 88 87 89 88 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]]; 93 90 94 91 _numberOfFiles++; Footagehead/trunk/FHURLHandler.m
r4725 r4726 100 100 NSStringEncoding nsEncoding; 101 101 CFStringEncoding cfEncoding; 102 Class class;103 102 104 103 nsEncoding = NSISOLatin1StringEncoding; … … 114 113 text = [NSString stringWithData:data encoding:nsEncoding]; 115 114 116 class = [FHHTMLHandler handlerForURL:url]; 117 118 return [[class allocWithZone:zone] initHandlerWithURL:url HTML:text]; 115 return [[FHHTMLHandler allocWithZone:zone] initHandlerWithURL:url HTML:text]; 119 116 } 120 117 else if([mime containsSubstring:@"xml"]) { Footagehead/trunk/FHWindowController.h
r4725 r4726 38 38 39 39 40 #define FHWindowControllerChangedZoomMode @"FHWindowControllerChangedZoomMode" 41 42 40 43 - (NSArray *)files; 41 44 - (FHFile *)fileAtIndex:(NSUInteger)index; Footagehead/trunk/FHWindowController.m
r4725 r4726 276 276 277 277 [FHSettings setInt:scaling forKey:FHImageScalingMethod]; 278 279 [[NSNotificationCenter defaultCenter] postNotificationName:FHWindowControllerChangedZoomMode object:_imageView]; 278 280 } 279 281 Footagehead/trunk/Footagehead.xcodeproj/project.pbxproj
r4725 r4726 102 102 A58BE56A09BA054F00C3C20D /* White.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A58BE56709BA054F00C3C20D /* White.tiff */; }; 103 103 A58BE56B09BA054F00C3C20D /* Gray.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A58BE56809BA054F00C3C20D /* Gray.tiff */; }; 104 A597A4960BE0889A00C3E4DE /* FHFutabaHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = A597A4940BE0889A00C3E4DE /* FHFutabaHandler.m */; };105 104 A599A110075F94F400A03BA5 /* FHFileCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A599A10E075F94F400A03BA5 /* FHFileCell.m */; }; 106 105 A5A183F00BDD5231004788EF /* FHWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = A5A183EE0BDD5231004788EF /* FHWindowController.m */; }; … … 314 313 A58BE56809BA054F00C3C20D /* Gray.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Gray.tiff; sourceTree = "<group>"; }; 315 314 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>"; };318 315 A599A10D075F94F400A03BA5 /* FHFileCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FHFileCell.h; sourceTree = "<group>"; }; 319 316 A599A10E075F94F400A03BA5 /* FHFileCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FHFileCell.m; sourceTree = "<group>"; }; … … 703 700 A5B1F9AA067BCF0100111D0A /* FHHTMLHandler.m */, 704 701 A5B1F9A9067BCF0100111D0A /* FHHTMLHandler.h */, 705 A597A4740BE0888600C3E4DE /* HTML Handlers */,706 702 A5B1FBC4067D01C200111D0A /* FHImageHandler.m */, 707 703 A5B1FBC5067D01C200111D0A /* FHImageHandler.h */, … … 717 713 ); 718 714 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";728 715 sourceTree = "<group>"; 729 716 }; … … 1135 1122 A5B1F617067B3B7900111D0A /* FHFileHandler.m in Sources */, 1136 1123 77EAC0D5084C6D1F006C9F69 /* FHFlickrHandler.m in Sources */, 1137 A597A4960BE0889A00C3E4DE /* FHFutabaHandler.m in Sources */,1138 1124 A5B1F611067B3AA100111D0A /* FHHandler.m in Sources */, 1139 1125 A5B1F9AC067BCF0200111D0A /* FHHTMLHandler.m in Sources */,
