mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 03:21:04 +00:00
Support dropping of filenames onto an appicon
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@9122 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7e0817202e
commit
82da0b3811
2 changed files with 74 additions and 16 deletions
|
@ -1,3 +1,8 @@
|
|||
2001-02-09 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSApplication.m: NSAppIconView modified to support the
|
||||
opening of any documents dropped on the appicon using DnD.
|
||||
|
||||
Fri Feb 9 18:07:13 2001 Nicola Pero <nicola@brainstorm.co.uk>
|
||||
|
||||
* Source/NSTableView.m ([-noteNumberOfRowsChanged]): Fix for nil
|
||||
|
|
|
@ -71,12 +71,6 @@
|
|||
#include <AppKit/NSDataLinkPanel.h>
|
||||
#include <AppKit/NSHelpPanel.h>
|
||||
|
||||
/* Prevent recursion handler */
|
||||
static void
|
||||
_preventRecursion (NSException *exception)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Base library exception handler
|
||||
*/
|
||||
|
@ -141,6 +135,7 @@ struct _NSModalSession {
|
|||
|
||||
@interface NSApplication (Private)
|
||||
- _appIconInit;
|
||||
- (void) _openDocument: (NSString*)name;
|
||||
- (void) _windowDidBecomeKey: (NSNotification*) notification;
|
||||
- (void) _windowDidBecomeMain: (NSNotification*) notification;
|
||||
- (void) _windowDidResignKey: (NSNotification*) notification;
|
||||
|
@ -225,12 +220,38 @@ static NSCell* tileCell = nil;
|
|||
return YES;
|
||||
}
|
||||
|
||||
- (void) concludeDragOperation: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
}
|
||||
|
||||
- (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
return NSDragOperationGeneric;
|
||||
}
|
||||
|
||||
- (void) draggingExited: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
}
|
||||
|
||||
- (unsigned) draggingUpdated: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
return NSDragOperationGeneric;
|
||||
}
|
||||
|
||||
- (void) drawRect: (NSRect)rect
|
||||
{
|
||||
[tileCell drawWithFrame: NSMakeRect(0,0,64,64) inView: self];
|
||||
[dragCell drawWithFrame: NSMakeRect(8,8,48,48) inView: self];
|
||||
}
|
||||
|
||||
- (id) initWithFrame: (NSRect)frame
|
||||
{
|
||||
self = [super initWithFrame: frame];
|
||||
[self registerForDraggedTypes: [NSArray arrayWithObjects:
|
||||
NSFilenamesPboardType, nil]];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) mouseDown: (NSEvent*)theEvent
|
||||
{
|
||||
if ([theEvent clickCount] >= 2)
|
||||
|
@ -284,6 +305,33 @@ static NSCell* tileCell = nil;
|
|||
}
|
||||
}
|
||||
|
||||
- (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) performDragOperation: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSArray *types;
|
||||
NSPasteboard *dragPb;
|
||||
|
||||
dragPb = [sender draggingPasteboard];
|
||||
types = [dragPb types];
|
||||
if ([types containsObject: NSFilenamesPboardType] == YES)
|
||||
{
|
||||
NSArray *names = [dragPb propertyListForType: NSFilenamesPboardType];
|
||||
unsigned index;
|
||||
|
||||
[NSApp activateIgnoringOtherApps: YES];
|
||||
for (index = 0; index < [names count]; index++)
|
||||
{
|
||||
[NSApp _openDocument: [names objectAtIndex: index]];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void) setImage: (NSImage *)anImage
|
||||
{
|
||||
[tileCell drawWithFrame: NSMakeRect(0,0,64,64) inView: self];
|
||||
|
@ -520,15 +568,7 @@ static NSCell* tileCell = nil;
|
|||
if ((filePath = [defs stringForKey: @"GSFilePath"]) != nil ||
|
||||
(filePath = [defs stringForKey: @"NSOpen"]) != nil)
|
||||
{
|
||||
if ([_delegate respondsToSelector: @selector(application:openFile:)])
|
||||
{
|
||||
[_delegate application: self openFile: filePath];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[NSDocumentController sharedDocumentController]
|
||||
openDocumentWithContentsOfFile:filePath display:YES];
|
||||
}
|
||||
[self _openDocument: filePath];
|
||||
}
|
||||
else if ((filePath = [defs stringForKey: @"GSTempPath"]) != nil)
|
||||
{
|
||||
|
@ -539,7 +579,7 @@ static NSCell* tileCell = nil;
|
|||
else
|
||||
{
|
||||
[[NSDocumentController sharedDocumentController]
|
||||
openDocumentWithContentsOfFile:filePath display:YES];
|
||||
openDocumentWithContentsOfFile: filePath display: YES];
|
||||
}
|
||||
}
|
||||
// TODO: Should also support printing of a file here.
|
||||
|
@ -2133,6 +2173,19 @@ IF_NO_GC(NSAssert([event retainCount] > 0, NSInternalInconsistencyException));
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) _openDocument: (NSString*)filePath
|
||||
{
|
||||
if ([_delegate respondsToSelector: @selector(application:openFile:)])
|
||||
{
|
||||
[_delegate application: self openFile: filePath];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[NSDocumentController sharedDocumentController]
|
||||
openDocumentWithContentsOfFile: filePath display: YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) _windowDidBecomeKey: (NSNotification*) notification
|
||||
{
|
||||
id obj = [notification object];
|
||||
|
|
Loading…
Reference in a new issue