CommitView: Allow drag and drop to external applications

This allows you to drag a changed file to for example XCode,
so you can edit it.
This commit is contained in:
Pieter de Bie
2008-11-19 15:06:13 +01:00
parent b0caa349ae
commit e76d483180
2 changed files with 21 additions and 2 deletions
+6
View File
@@ -18,4 +18,10 @@
return nil;
}
- (NSDragOperation) draggingSourceOperationMaskForLocal:(BOOL) local
{
return NSDragOperationEvery;
}
@end
+15 -2
View File
@@ -206,9 +206,22 @@ writeRowsWithIndexes:(NSIndexSet *)rowIndexes
toPasteboard:(NSPasteboard*)pboard
{
// Copy the row numbers to the pasteboard.
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
[pboard declareTypes:[NSArray arrayWithObject:FileChangesTableViewType] owner:self];
[pboard declareTypes:[NSArray arrayWithObjects:FileChangesTableViewType, NSFilenamesPboardType, nil] owner:self];
// Internal, for dragging from one tableview to the other
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
[pboard setData:data forType:FileChangesTableViewType];
// External, to drag them to for example XCode or Textmate
NSArrayController *controller = [tv tag] == 0 ? unstagedFilesController : stagedFilesController;
NSArray *files = [[controller arrangedObjects] objectsAtIndexes:rowIndexes];
NSString *workingDirectory = [commitController.repository workingDirectory];
NSMutableArray *filenames = [NSMutableArray arrayWithCapacity:[rowIndexes count]];
for (PBChangedFile *file in files)
[filenames addObject:[workingDirectory stringByAppendingPathComponent:[file path]]];
[pboard setPropertyList:filenames forType:NSFilenamesPboardType];
return YES;
}