mirror of
https://github.com/gnustep/apps-projectcenter.git
synced 2025-03-17 08:01:24 +00:00
* Framework/PCFileNameIcon.m:
* Headers/ProjectCenter/PCFileNameIcon.h: Implementation of dragging functionality. * Framework/PCProjectBrowser.m: Implement file icon delegate methods. Dragging files to category icon adds files to project. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@27472 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
073b6a650d
commit
cc43e948dc
4 changed files with 65 additions and 3 deletions
|
@ -1,3 +1,12 @@
|
|||
2008-12-31 Sergii Stoian <stoyan255@gmail.com>
|
||||
|
||||
* Framework/PCFileNameIcon.m:
|
||||
* Headers/ProjectCenter/PCFileNameIcon.h:
|
||||
Implementation of dragging functionality.
|
||||
|
||||
* Framework/PCProjectBrowser.m: Implement file icon delegate methods.
|
||||
Dragging files to category icon adds files to project.
|
||||
|
||||
2008-12-30 Richard frith-Macdonald <rfm"gnu.org>
|
||||
|
||||
* PCMenuController.m:
|
||||
|
|
|
@ -122,12 +122,22 @@
|
|||
|
||||
- (void)draggingExited:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
NSLog(@"Dragging exited");
|
||||
}
|
||||
|
||||
// -- After the image is released
|
||||
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
NSPasteboard *pb = [sender draggingPasteboard];
|
||||
NSArray *paths = [pb propertyListForType:NSFilenamesPboardType];
|
||||
|
||||
NSLog(@"Prepare for drag operation");
|
||||
|
||||
if (delegate &&
|
||||
[delegate respondsToSelector:@selector(prepareForDraggingOf:)])
|
||||
{
|
||||
return [delegate prepareForDraggingOf:paths];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
@ -138,11 +148,27 @@
|
|||
|
||||
NSLog(@"performDragOperation: %@", paths);
|
||||
|
||||
return NO;
|
||||
if (delegate &&
|
||||
[delegate respondsToSelector:@selector(performDraggingOf:)])
|
||||
{
|
||||
return [delegate performDraggingOf:paths];
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)concludeDragOperation:(id <NSDraggingInfo>)sendera
|
||||
- (void)concludeDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
NSPasteboard *pb = [sender draggingPasteboard];
|
||||
NSArray *paths = [pb propertyListForType:NSFilenamesPboardType];
|
||||
|
||||
NSLog(@"Conclude drag operation");
|
||||
|
||||
if (delegate &&
|
||||
[delegate respondsToSelector:@selector(concludeDraggingOf:)])
|
||||
{
|
||||
[delegate concludeDraggingOf:paths];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -685,7 +685,7 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification";
|
|||
|
||||
NSLog(@"PCBrowser: canPerformDraggingOf -> %@", category);
|
||||
|
||||
if (!category)
|
||||
if (!category || ([self nameOfSelectedFile] != nil))
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
@ -695,6 +695,7 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification";
|
|||
return NO;
|
||||
}
|
||||
|
||||
// Check if we can accept files of such types
|
||||
while ((s = [e nextObject]))
|
||||
{
|
||||
if (![fileTypes containsObject:[s pathExtension]])
|
||||
|
@ -706,4 +707,27 @@ NSString *PCBrowserDidSetPathNotification = @"PCBrowserDidSetPathNotification";
|
|||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)prepareForDraggingOf:(NSArray *)paths
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)performDraggingOf:(NSArray *)paths
|
||||
{
|
||||
NSString *category = [self nameOfSelectedCategory];
|
||||
NSString *categoryKey = [project keyForCategory:category];
|
||||
NSEnumerator *pathsEnum = [paths objectEnumerator];
|
||||
NSString *file = nil;
|
||||
|
||||
while ((file = [[pathsEnum nextObject] lastPathComponent]))
|
||||
{
|
||||
if (![project doesAcceptFile:file forKey:categoryKey])
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
return [project addAndCopyFiles:paths forKey:categoryKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -46,6 +46,9 @@
|
|||
- (NSImage *)fileNameIconImage;
|
||||
- (NSString *)fileNameIconTitle;
|
||||
- (BOOL)canPerformDraggingOf:(NSArray *)paths;
|
||||
- (BOOL)prepareForDraggingOf:(NSArray *)paths;
|
||||
- (BOOL)performDraggingOf:(NSArray *)paths;
|
||||
- (BOOL)concludeDraggingOf:(NSArray *)paths;
|
||||
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in a new issue