-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try to figure out preview image data and overlay the images on the view after they are loaded.
- Loading branch information
Showing
9 changed files
with
168 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// CTFKillerImageLoader.h | ||
// ClickToFlash | ||
// | ||
// Created by Sven on 04.10.09. | ||
// Copyright 2009 earthlingsoft. All rights reserved. | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
@class CTFClickToFlashPlugin; | ||
|
||
@interface CTFImageLoader : NSObject { | ||
NSMutableData * data; | ||
CTFClickToFlashPlugin * plugin; | ||
} | ||
|
||
- (id) initWithURL: (NSURL *) theURL forPlugin: (CTFClickToFlashPlugin *) thePlugin; | ||
- (void) cleanup; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// CTFKillerImageLoader.m | ||
// ClickToFlash | ||
// | ||
// Created by Sven on 04.10.09. | ||
// Copyright 2009 earthlingsoft. All rights reserved. | ||
// | ||
|
||
#import "CTFImageLoader.h" | ||
#import "Plugin.h" | ||
|
||
|
||
@implementation CTFImageLoader | ||
|
||
- (id) initWithURL: (NSURL *) theURL forPlugin: (CTFClickToFlashPlugin *) thePlugin { | ||
self = [super init]; | ||
|
||
if (self != nil) { | ||
data = [[NSMutableData alloc] initWithCapacity:125000]; | ||
plugin = [thePlugin retain]; | ||
|
||
NSURLRequest * request = [NSURLRequest requestWithURL: theURL]; | ||
[[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease]; | ||
[self retain]; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
|
||
- (void) dealloc { | ||
[data release]; | ||
[plugin release]; | ||
[super dealloc]; | ||
} | ||
|
||
|
||
|
||
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *) newData { | ||
[data appendData: newData]; | ||
} | ||
|
||
|
||
- (void)connectionDidFinishLoading:(NSURLConnection *)connection { | ||
NSImage * image = [[[NSImage alloc] initWithData: data] autorelease]; | ||
if (image != nil) { | ||
[plugin setPreviewImage: image ]; | ||
} | ||
|
||
[self cleanup]; | ||
} | ||
|
||
|
||
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { | ||
NSLog(@"ClickToFlash couldn't download preview image: %@", [error description]); | ||
[self cleanup]; | ||
} | ||
|
||
|
||
- (void) cleanup { | ||
[self autorelease]; | ||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters