forked from orta/tumblrclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageImagekitView.m
38 lines (32 loc) · 1.08 KB
/
ImageImagekitView.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// ImageImagekitView.m
// Tumblg
//
// Created by orta on 21/09/2008.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "ImageImagekitView.h"
@implementation ImageImagekitView
- (void) awakeFromNib{
[self registerForDraggedTypes:[NSArray arrayWithObjects: NSFilenamesPboardType, nil]];
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender{
NSPasteboard *pboard = [sender draggingPasteboard];
NSString *fileName = [[pboard propertyListForType:NSFilenamesPboardType] objectAtIndex: 0];
NSString *extension = [fileName pathExtension];
NSLog(@"ext = %@", extension);
NSString *filetype;
for ( filetype in [NSImage imageFileTypes] ) {
if([extension caseInsensitiveCompare: filetype] == NSOrderedSame){
return NSDragOperationCopy;
}
}
return NSDragOperationNone;
}
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender{
NSPasteboard *pboard = [sender draggingPasteboard];
NSString *fileName = [[pboard propertyListForType:NSFilenamesPboardType] objectAtIndex: 0];
[imageController setSource:fileName];
return YES;
}
@end