-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathyad.lisp
35 lines (31 loc) · 1.59 KB
/
yad.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(in-package #:org.shirakumo.file-select.yad)
(defclass yad (backend)
((program-name :initform "yad" :initarg :program-name :accessor program-name)))
(defun yad (&key title default filter multiple save (program "yad"))
(handler-case
(let ((parts (org.shirakumo.file-select::split
#\Linefeed
(org.shirakumo.file-select::run
program
"--file" ; Identical to zenity, they just decided to call it --file for whatever reason.
"--separator=
"
(format NIL "--title=~a" title)
(when save "--save")
(when multiple "--multiple")
(when (eq filter :directory) "--directory")
(when default (format NIL "--filename=~a" (pathname-utils:native-namestring default)))
(loop for (name . type) in (etypecase filter
((eql :directory))
(string `(("" ,filter)))
(list filter))
collect (format NIL "--file-filter=~a |~{ *.~a~}" name type))))))
(cond ((null parts) (values NIL NIL))
(multiple (values parts T))
(T (values (first parts) T))))
(error ()
(values NIL NIL))))
(defmethod new-with ((backend yad) &rest args)
(apply #'yad :program (program-name backend) :save T args))
(defmethod existing-with ((backend yad) &rest args)
(apply #'yad :program (program-name backend) args))