2008-02-13 16:10:59 +00:00
|
|
|
//
|
|
|
|
// SpotlightPlaylistController.m
|
|
|
|
// Cog
|
|
|
|
//
|
|
|
|
// Created by Matthew Grinshpun on 13/02/08.
|
2008-02-14 14:07:10 +00:00
|
|
|
// Copyright 2008 Matthew Leon Grinshpun. All rights reserved.
|
2008-02-13 16:10:59 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#import "SpotlightPlaylistController.h"
|
2008-02-16 16:13:21 +00:00
|
|
|
#import "SpotlightWindowController.h"
|
2008-02-13 16:10:59 +00:00
|
|
|
|
|
|
|
@implementation SpotlightPlaylistController
|
|
|
|
|
|
|
|
// Allow drag and drop from Spotlight into main playlist
|
|
|
|
- (BOOL)tableView:(NSTableView *)tv
|
|
|
|
writeRowsWithIndexes:(NSIndexSet *)rowIndexes
|
|
|
|
toPasteboard:(NSPasteboard*)pboard
|
|
|
|
{
|
2008-02-13 23:51:36 +00:00
|
|
|
[spotlightWindowController.query disableUpdates];
|
2008-02-13 16:10:59 +00:00
|
|
|
|
2008-02-20 00:44:40 +00:00
|
|
|
NSArray *urls = [[self selectedObjects]valueForKey:@"URL"];
|
2021-04-30 01:16:24 +00:00
|
|
|
NSError *error = nil;
|
2021-09-23 07:49:51 +00:00
|
|
|
NSData *data;
|
|
|
|
if (@available(macOS 10.13, *))
|
|
|
|
{
|
|
|
|
data = [NSKeyedArchiver archivedDataWithRootObject:urls
|
|
|
|
requiringSecureCoding:YES
|
|
|
|
error:&error];
|
|
|
|
if (error) return NO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
data = [NSArchiver archivedDataWithRootObject:urls];
|
|
|
|
}
|
2008-02-13 17:14:19 +00:00
|
|
|
[pboard declareTypes:[NSArray arrayWithObjects:CogUrlsPboardType,nil] owner:nil]; //add it to pboard
|
2021-04-30 01:16:24 +00:00
|
|
|
[pboard setData:data forType:CogUrlsPboardType];
|
2008-02-13 16:10:59 +00:00
|
|
|
|
2008-02-13 23:51:36 +00:00
|
|
|
[spotlightWindowController.query enableUpdates];
|
2008-02-13 16:10:59 +00:00
|
|
|
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do not accept drag operations, necessary as long as this class inherits from PlaylistController
|
|
|
|
- (NSDragOperation)tableView:(NSTableView*)tv
|
|
|
|
validateDrop:(id <NSDraggingInfo>)info
|
2021-04-30 01:16:24 +00:00
|
|
|
proposedRow:(NSInteger)row
|
2008-02-13 16:10:59 +00:00
|
|
|
proposedDropOperation:(NSTableViewDropOperation)op
|
|
|
|
{
|
|
|
|
return NSDragOperationNone;
|
|
|
|
}
|
|
|
|
|
2021-04-30 01:16:24 +00:00
|
|
|
@end
|