"The local value of the special `XdndSelection' selection.")
(defvar haiku-dnd-selection-converters '((STRING . haiku-dnd-convert-string)
- (FILE_NAME . haiku-dnd-convert-file-name))
+ (FILE_NAME . haiku-dnd-convert-file-name)
+ (text/uri-list . haiku-dnd-convert-text-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
(file-exists-p value))
(list "refs" (propertize (expand-file-name value) 'type 'ref))))
+(defun haiku-dnd-convert-text-uri-list (value)
+ "Convert VALUE to a list of URLs."
+ (cond
+ ((stringp value) (list "text/uri-list"
+ (concat (url-encode-url value) "\n")))
+ ((vectorp value) (list "text/uri-list"
+ (with-temp-buffer
+ (cl-loop for tem across value
+ do (progn
+ (insert (url-encode-url tem))
+ (insert "\n")))
+ (buffer-string))))))
+
(declare-function x-open-connection "haikufns.c")
(declare-function x-handle-args "common-win")
(declare-function haiku-selection-data "haikuselect.c")
(mouse-highlight nil)
(haiku-signal-invalid-refs nil))
(dolist (target targets)
- (let ((selection-converter (cdr (assoc (intern target)
- haiku-dnd-selection-converters))))
+ (let* ((target-atom (intern target))
+ (selection-converter (cdr (assoc target-atom
+ haiku-dnd-selection-converters))))
(when selection-converter
(let ((selection-result
(funcall selection-converter
- haiku-dnd-selection-value)))
+ (if (stringp haiku-dnd-selection-value)
+ (or (get-text-property 0 target-atom
+ haiku-dnd-selection-value)
+ haiku-dnd-selection-value)
+ haiku-dnd-selection-value))))
(when selection-result
(let ((field (cdr (assoc (car selection-result) message))))
(unless (cadr field)