Skip to content

Instantly share code, notes, and snippets.

@klaaspieter
Created October 22, 2010 12:55
Show Gist options
  • Save klaaspieter/640489 to your computer and use it in GitHub Desktop.
Save klaaspieter/640489 to your computer and use it in GitHub Desktop.
- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pasteBoard
{
[pasteBoard declareTypes:[NSArray arrayWithObjects:
ESTemplateIndexesTableDragType,
NSFilenamesPboardType,
nil] owner:self];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
[pasteBoard setData:data forType:ESTemplateIndexesTableDragType];
NSMutableArray *filenames = [NSMutableArray array];
NSArray *arrangedObjects = [[[self windowController] templateWrappersArrayController] arrangedObjects];
NSUInteger currentIndex = [rowIndexes lastIndex];
while (currentIndex != NSNotFound) {
ESTemplateWrapper *templateWrapper = [arrangedObjects objectAtIndex:currentIndex];
[filenames addObject:[[templateWrapper template] path]];
currentIndex = [rowIndexes indexLessThanIndex:currentIndex];
}
[pasteBoard setPropertyList:filenames forType:NSFilenamesPboardType];
if ([rowIndexes count] == 1) {
ESTemplateWrapper *templateWrapper = [arrangedObjects objectAtIndex:[rowIndexes lastIndex]];
if ([[templateWrapper templateServer] isServing]) {
[pasteBoard addTypes:[NSArray arrayWithObjects:
NSStringPboardType,
NSURLPboardType,
nil] owner:self];
NSURL *url = [[templateWrapper templateServer] currentURL];
[url writeToPasteboard:pasteBoard];
}
}
return YES;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment