Fix file drag-and-drop on GNUstep
* src/nsselect.m (ns_decode_data_to_pasteboard): Convert URL to path names when we're using NSFilenamesPboardType. * src/nsterm.m: ([EmacsView performDragOperation:]): Handle cases where plist is a string.
This commit is contained in:
parent
2ce686c049
commit
effbd2aeef
2 changed files with 32 additions and 11 deletions
|
@ -565,6 +565,9 @@ Updated by Christian Limpach (chris@nice.ch)
|
|||
NSMutableArray *temp;
|
||||
Lisp_Object tem;
|
||||
specpdl_ref count;
|
||||
#if !NS_USE_NSPasteboardTypeFileURL
|
||||
NSURL *url;
|
||||
#endif
|
||||
|
||||
types = [pasteboard types];
|
||||
count = SPECPDL_INDEX ();
|
||||
|
@ -602,7 +605,12 @@ Updated by Christian Limpach (chris@nice.ch)
|
|||
[pasteboard setString: [NSString stringWithLispString: data]
|
||||
forType: NSPasteboardTypeFileURL];
|
||||
#else
|
||||
[pasteboard setString: [NSString stringWithLispString: data]
|
||||
url = [NSURL URLWithString: [NSString stringWithLispString: data]];
|
||||
|
||||
if (!url)
|
||||
signal_error ("Invalid file URL", data);
|
||||
|
||||
[pasteboard setString: [url path]
|
||||
forType: NSFilenamesPboardType];
|
||||
#endif
|
||||
}
|
||||
|
|
33
src/nsterm.m
33
src/nsterm.m
|
@ -8724,7 +8724,7 @@ - (BOOL) performDragOperation: (id <NSDraggingInfo>) sender
|
|||
Lisp_Object type_sym;
|
||||
struct input_event ie;
|
||||
|
||||
NSTRACE ("[EmacsView performDragOperation:]");
|
||||
NSTRACE (@"[EmacsView performDragOperation:]");
|
||||
|
||||
source = [sender draggingSource];
|
||||
|
||||
|
@ -8752,7 +8752,7 @@ - (BOOL) performDragOperation: (id <NSDraggingInfo>) sender
|
|||
|
||||
if (!type)
|
||||
return NO;
|
||||
#if NS_USE_NSPasteboardTypeFileURL != 0
|
||||
#if NS_USE_NSPasteboardTypeFileURL
|
||||
else if ([type isEqualToString: NSPasteboardTypeFileURL])
|
||||
{
|
||||
type_sym = Qfile;
|
||||
|
@ -8767,18 +8767,29 @@ - (BOOL) performDragOperation: (id <NSDraggingInfo>) sender
|
|||
#else // !NS_USE_NSPasteboardTypeFileURL
|
||||
else if ([type isEqualToString: NSFilenamesPboardType])
|
||||
{
|
||||
NSArray *files;
|
||||
id files;
|
||||
NSEnumerator *fenum;
|
||||
NSString *file;
|
||||
|
||||
if (!(files = [pb propertyListForType: type]))
|
||||
files = [pb propertyListForType: type];
|
||||
|
||||
if (!files)
|
||||
return NO;
|
||||
|
||||
type_sym = Qfile;
|
||||
|
||||
fenum = [files objectEnumerator];
|
||||
while ( (file = [fenum nextObject]) )
|
||||
strings = Fcons ([file lispString], strings);
|
||||
/* On GNUstep, files might be a string. */
|
||||
|
||||
if ([files respondsToSelector: @selector (objectEnumerator:)])
|
||||
{
|
||||
fenum = [files objectEnumerator];
|
||||
|
||||
while ((file = [fenum nextObject]))
|
||||
strings = Fcons ([file lispString], strings);
|
||||
}
|
||||
else
|
||||
/* Then `files' is an NSString. */
|
||||
strings = list1 ([files lispString]);
|
||||
}
|
||||
#endif // !NS_USE_NSPasteboardTypeFileURL
|
||||
else if ([type isEqualToString: NSPasteboardTypeURL])
|
||||
|
@ -8795,11 +8806,12 @@ - (BOOL) performDragOperation: (id <NSDraggingInfo>) sender
|
|||
{
|
||||
NSString *data;
|
||||
|
||||
if (! (data = [pb stringForType: type]))
|
||||
data = [pb stringForType: type];
|
||||
|
||||
if (!data)
|
||||
return NO;
|
||||
|
||||
type_sym = Qnil;
|
||||
|
||||
strings = list1 ([data lispString]);
|
||||
}
|
||||
else
|
||||
|
@ -8807,7 +8819,8 @@ - (BOOL) performDragOperation: (id <NSDraggingInfo>) sender
|
|||
|
||||
EVENT_INIT (ie);
|
||||
ie.kind = DRAG_N_DROP_EVENT;
|
||||
ie.arg = Fcons (type_sym, Fcons (operations, strings));
|
||||
ie.arg = Fcons (type_sym, Fcons (operations,
|
||||
strings));
|
||||
XSETINT (ie.x, x);
|
||||
XSETINT (ie.y, y);
|
||||
XSETFRAME (ie.frame_or_window, emacsframe);
|
||||
|
|
Loading…
Add table
Reference in a new issue