mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Allow dragging of files out of tree view
This uses the promisedfile protocol, which means that dragging to e.g. FileMerge won't work.
This commit is contained in:
+1270
-1270
File diff suppressed because it is too large
Load Diff
@@ -23,6 +23,7 @@
|
||||
|
||||
+ (PBGitTree*) rootForCommit: (id) commit;
|
||||
+ (PBGitTree*) treeForTree: (PBGitTree*) tree andPath: (NSString*) path;
|
||||
- (void) saveToFolder: (NSString *) directory;
|
||||
|
||||
- (NSString*) tmpFileNameForContents;
|
||||
|
||||
|
||||
@@ -11,6 +11,20 @@
|
||||
|
||||
@implementation PBQLOutlineView
|
||||
|
||||
- initWithCoder: (NSCoder *) coder
|
||||
{
|
||||
id a = [super initWithCoder:coder];
|
||||
[a setDataSource: a];
|
||||
[a registerForDraggedTypes: [NSArray arrayWithObject:NSFilesPromisePboardType]];
|
||||
return a;
|
||||
}
|
||||
|
||||
/* Needed to drag outside application */
|
||||
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL) local
|
||||
{
|
||||
return NSDragOperationCopy;
|
||||
}
|
||||
|
||||
- (void) keyDown: (NSEvent *) event
|
||||
{
|
||||
if ([[event characters] isEqualToString:@" "]) {
|
||||
@@ -20,4 +34,42 @@
|
||||
|
||||
[super keyDown:event];
|
||||
}
|
||||
|
||||
- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *) pb
|
||||
{
|
||||
NSMutableArray* fileNames = [NSMutableArray array];
|
||||
for (id tree in items)
|
||||
[fileNames addObject: [[[tree representedObject] path] pathExtension]];
|
||||
|
||||
[pb declareTypes:[NSArray arrayWithObject:NSFilesPromisePboardType] owner:self];
|
||||
[pb setPropertyList:fileNames forType:NSFilesPromisePboardType];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSArray *)outlineView:(NSOutlineView *)outlineView namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination forDraggedItems:(NSArray *)items
|
||||
{
|
||||
NSMutableArray* fileNames = [NSMutableArray array];
|
||||
for (id obj in items) {
|
||||
PBGitTree* tree = [obj representedObject];
|
||||
[fileNames addObject: [tree path]];
|
||||
[tree saveToFolder:[dropDestination path]];
|
||||
}
|
||||
return fileNames;
|
||||
}
|
||||
|
||||
/* Implemented to satisfy datasourcee protocol */
|
||||
- (BOOL) outlineView: (NSOutlineView *)ov
|
||||
isItemExpandable: (id)item { return NO; }
|
||||
|
||||
- (int) outlineView: (NSOutlineView *)ov
|
||||
numberOfChildrenOfItem:(id)item { return 0; }
|
||||
|
||||
- (id) outlineView: (NSOutlineView *)ov
|
||||
child:(int)index
|
||||
ofItem:(id)item { return nil; }
|
||||
|
||||
- (id) outlineView: (NSOutlineView *)ov
|
||||
objectValueForTableColumn:(NSTableColumn*)col
|
||||
byItem:(id)item { return nil; }
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user