(defvar haiku-dnd-selection-value nil
"The local value of the special `XdndSelection' selection.")
-(defvar haiku-dnd-selection-converters '((STRING . haiku-dnd-convert-string))
+(defvar haiku-dnd-selection-converters '((STRING . haiku-dnd-convert-string)
+ (text/uri-list . haiku-dnd-convert-uri-list))
"Alist of X selection types to functions that act as selection converters.
The functions should accept a single argument VALUE, describing
the value of the drag-and-drop selection, and return a list of
two elements TYPE and DATA, where TYPE is a string containing the
MIME type of DATA, and DATA is a unibyte string, or nil if the
-data could not be converted.")
+data could not be converted.
+
+DATA can optionally have a text property `type', which specifies
+the type of DATA inside the system message (see the doc string of
+`haiku-drag-message' for more details).")
(defun haiku-dnd-convert-string (value)
"Convert VALUE to a UTF-8 string and appropriate MIME type.
(list "text/plain" (string-to-unibyte
(encode-coding-string value 'utf-8)))))
+(defun haiku-dnd-convert-uri-list (value)
+ "Convert VALUE to a file system reference if it is a file name."
+ (when (and (stringp value)
+ (file-exists-p value))
+ (list "refs" (propertize (expand-file-name value) 'type 'ref))))
+
(declare-function x-open-connection "haikufns.c")
(declare-function x-handle-args "common-win")
(declare-function haiku-selection-data "haikuselect.c")
(let ((field (cdr (assoc (car selection-result) message))))
(unless (cadr field)
;; Add B_MIME_TYPE to the message if the type was not
- ;; previously defined.
- (push 1296649541 (alist-get (car selection-result) message
- nil nil #'equal))))
+ ;; previously specified, or the type if it was.
+ (push (or (get-text-property 0 'type
+ (cadr selection-result))
+ 1296649541)
+ (alist-get (car selection-result) message
+ nil nil #'equal))))
(push (cadr selection-result)
(cdr (alist-get (car selection-result) message
nil nil #'equal))))))))
int8 char_data;
bool bool_data;
intmax_t t4;
+ int rc;
CHECK_LIST (obj);
for (tem = obj; CONSP (tem); tem = XCDR (tem))
short_data = XFIXNUM (data);
block_input ();
- be_add_message_data (message, SSDATA (name),
- type_code, &short_data,
- sizeof short_data);
+ rc = be_add_message_data (message, SSDATA (name),
+ type_code, &short_data,
+ sizeof short_data);
unblock_input ();
+
+ if (rc)
+ signal_error ("Failed to add short", data);
break;
case 'LONG':
}
block_input ();
- be_add_message_data (message, SSDATA (name),
- type_code, &long_data,
- sizeof long_data);
+ rc = be_add_message_data (message, SSDATA (name),
+ type_code, &long_data,
+ sizeof long_data);
unblock_input ();
+
+ if (rc)
+ signal_error ("Failed to add long", data);
break;
case 'LLNG':
}
block_input ();
- be_add_message_data (message, SSDATA (name),
- type_code, &llong_data,
- sizeof llong_data);
+ rc = be_add_message_data (message, SSDATA (name),
+ type_code, &llong_data,
+ sizeof llong_data);
unblock_input ();
+
+ if (rc)
+ signal_error ("Failed to add llong", data);
break;
case 'CHAR':
char_data = XFIXNUM (data);
block_input ();
- be_add_message_data (message, SSDATA (name),
- type_code, &char_data,
- sizeof char_data);
+ rc = be_add_message_data (message, SSDATA (name),
+ type_code, &char_data,
+ sizeof char_data);
unblock_input ();
+
+ if (rc)
+ signal_error ("Failed to add char", data);
break;
case 'BOOL':
bool_data = !NILP (data);
block_input ();
- be_add_message_data (message, SSDATA (name),
- type_code, &bool_data,
- sizeof bool_data);
+ rc = be_add_message_data (message, SSDATA (name),
+ type_code, &bool_data,
+ sizeof bool_data);
unblock_input ();
+
+ if (rc)
+ signal_error ("Failed to add bool", data);
break;
default:
CHECK_STRING (data);
block_input ();
- be_add_message_data (message, SSDATA (name),
- type_code, SDATA (data),
- SBYTES (data));
+ rc = be_add_message_data (message, SSDATA (name),
+ type_code, SDATA (data),
+ SBYTES (data));
unblock_input ();
+
+ if (rc)
+ signal_error ("Failed to add", data);
}
}
CHECK_LIST_END (t2, t1);