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
|
0.05
|
||||||
----
|
----
|
||||||
Wavpack length should be reported correctly.
|
Wavpack length should be reported correctly.
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
extern NSString *MovedRowsType;
|
extern NSString *MovedRowsType;
|
||||||
|
extern NSString *iTunesDropType;
|
||||||
|
|
||||||
@interface DNDArrayController : NSArrayController
|
@interface DNDArrayController : NSArrayController
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,12 +5,17 @@
|
||||||
|
|
||||||
NSString *MovedRowsType = @"MOVED_ROWS_TYPE";
|
NSString *MovedRowsType = @"MOVED_ROWS_TYPE";
|
||||||
|
|
||||||
|
// @"CorePasteboardFlavorType 0x6974756E" is the "itun" type representing an iTunes plist
|
||||||
|
NSString *iTunesDropType = @"CorePasteboardFlavorType 0x6974756E";
|
||||||
|
|
||||||
- (void)awakeFromNib
|
- (void)awakeFromNib
|
||||||
{
|
{
|
||||||
// register for drag and drop
|
// register for drag and drop
|
||||||
NSLog(@"AWOKE");
|
NSLog(@"AWOKE");
|
||||||
[tableView registerForDraggedTypes:[NSArray arrayWithObjects:MovedRowsType, NSFilenamesPboardType, nil]];
|
|
||||||
|
[tableView registerForDraggedTypes:[NSArray arrayWithObjects:MovedRowsType, NSFilenamesPboardType,
|
||||||
|
iTunesDropType, nil]];
|
||||||
|
|
||||||
// [tableView setVerticalMotionCanBeginDrag:YES];
|
// [tableView setVerticalMotionCanBeginDrag:YES];
|
||||||
// [tableView setAllowsMultipleSelection:NO];
|
// [tableView setAllowsMultipleSelection:NO];
|
||||||
// [super awakeFromNib];
|
// [super awakeFromNib];
|
||||||
|
|
|
@ -230,9 +230,42 @@
|
||||||
if (row < 0)
|
if (row < 0)
|
||||||
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];
|
NSArray *files = [[info draggingPasteboard] propertyListForType:NSFilenamesPboardType];
|
||||||
|
|
||||||
NSLog(@"INSERTING PATHS: %@", files);
|
NSLog(@"INSERTING PATHS: %@", files);
|
||||||
[self insertPaths:files atIndex:row sort:YES];
|
[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"];
|
||||||
|
|
||||||
|
// 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");
|
NSLog(@"UPDATING");
|
||||||
[self updateIndexesFromRow:row];
|
[self updateIndexesFromRow:row];
|
||||||
|
|
Loading…
Reference in New Issue