Created
October 22, 2010 12:55
-
-
Save klaaspieter/640489 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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