Drop from iTunes support, thanks to Aaron VonderHaar
parent
dfe73fd554
commit
eb47e318f3
|
@ -1,3 +1,7 @@
|
|||
0.06
|
||||
----
|
||||
Drag from iTunes support. (Aaron VonderHaar)
|
||||
|
||||
0.05
|
||||
----
|
||||
Wavpack length should be reported correctly.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
extern NSString *MovedRowsType;
|
||||
extern NSString *iTunesDropType;
|
||||
|
||||
@interface DNDArrayController : NSArrayController
|
||||
{
|
||||
|
|
|
@ -5,12 +5,17 @@
|
|||
|
||||
NSString *MovedRowsType = @"MOVED_ROWS_TYPE";
|
||||
|
||||
// @"CorePasteboardFlavorType 0x6974756E" is the "itun" type representing an iTunes plist
|
||||
NSString *iTunesDropType = @"CorePasteboardFlavorType 0x6974756E";
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
// register for drag and drop
|
||||
NSLog(@"AWOKE");
|
||||
[tableView registerForDraggedTypes:[NSArray arrayWithObjects:MovedRowsType, NSFilenamesPboardType, nil]];
|
||||
|
||||
[tableView registerForDraggedTypes:[NSArray arrayWithObjects:MovedRowsType, NSFilenamesPboardType,
|
||||
iTunesDropType, nil]];
|
||||
|
||||
// [tableView setVerticalMotionCanBeginDrag:YES];
|
||||
// [tableView setAllowsMultipleSelection:NO];
|
||||
// [super awakeFromNib];
|
||||
|
|
|
@ -229,11 +229,44 @@
|
|||
|
||||
if (row < 0)
|
||||
row = 0;
|
||||
|
||||
// Determine the type of object that was dropped
|
||||
NSArray *supportedtypes = [NSArray arrayWithObjects:NSFilenamesPboardType, iTunesDropType, nil];
|
||||
NSPasteboard *pboard = [info draggingPasteboard];
|
||||
NSString *bestType = [pboard availableTypeFromArray:supportedtypes];
|
||||
|
||||
// Get files from a normal file drop (such as from Finder)
|
||||
if ([bestType isEqualToString:NSFilenamesPboardType]) {
|
||||
NSArray *files = [[info draggingPasteboard] propertyListForType:NSFilenamesPboardType];
|
||||
|
||||
NSLog(@"INSERTING PATHS: %@", files);
|
||||
[self insertPaths:files atIndex:row sort:YES];
|
||||
}
|
||||
|
||||
// Get files from an iTunes drop
|
||||
if ([bestType isEqualToString:iTunesDropType]) {
|
||||
NSDictionary *iTunesDict = [pboard propertyListForType:iTunesDropType];
|
||||
NSDictionary *tracks = [iTunesDict valueForKey:@"Tracks"];
|
||||
|
||||
NSArray *files = [[info draggingPasteboard] propertyListForType:NSFilenamesPboardType];
|
||||
NSLog(@"INSERTING PATHS: %@", files);
|
||||
[self insertPaths:files atIndex:row sort:YES];
|
||||
|
||||
// Convert the iTunes URLs to filenames
|
||||
NSMutableArray *files = [[NSMutableArray alloc] init];
|
||||
NSEnumerator *e = [[tracks allValues] objectEnumerator];
|
||||
NSDictionary *trackInfo;
|
||||
NSURL *url;
|
||||
while (trackInfo = [e nextObject]) {
|
||||
url = [[NSURL alloc] initWithString:[trackInfo valueForKey:@"Location"]];
|
||||
if ([url isFileURL]) {
|
||||
[files addObject:[url path]];
|
||||
}
|
||||
|
||||
[url release];
|
||||
}
|
||||
|
||||
NSLog(@"INSERTING ITUNES PATHS: %@", files);
|
||||
[self insertPaths:files atIndex:row sort:YES];
|
||||
[files release];
|
||||
}
|
||||
|
||||
NSLog(@"UPDATING");
|
||||
[self updateIndexesFromRow:row];
|
||||
[self updateTotalTime];
|
||||
|
|
Loading…
Reference in New Issue