CLIM mail archive

[Prev][Next][Index][Thread]

More listener questions



I have tried using the recently posted select-file function in an
application which has its top-level based on the clim lisp-listener
demo.

The following code may be added to the code I posted in my previous
message with questions about the listener.  If you type :Choose File
then a file browser box comes up, but then after you hit OK, a second
file browser appears and the result of that select-file and the first
one appear to be concatenated.  A notification is made about
extraneous characters in the input, and the input is not usable.  I
can reproduce this by typing (accept 'command) at the listener prompt
(implying that the problem is in (accept 'command), not the listener
or (accept 'command-or-form), but when I create a similar command in a
non-listener application, it works fine.

I traced accept and select-file, and it appears that (accept
'command-or-form) calls (accept 'command), which calls (accept
'command-name) and then (accept 'my-pathname) which calls select-file,
select-file returns, (accept 'command) throws.  Then (accept 'command)
is called again, leading to a second select-file.  My guess is that
the way the accept command method is implemented it does one pass
which gets the input and a second which constructs the command object.

I also have a question about programmatic interaction with the
file-browser.  The original post said select-file specializes on
application-frames so that you could customize its behavior.  I would
like to change the default filter (in particular, I'd like to specify
the file type, or filename extension that is acceptable.)  How do I go
about doing that.  There isn't any documentation on how to communicate
to select-file.

;;;-------------------------------------------------------------------
;;; Select-file
;;;-------------------------------------------------------------------

(define-presentation-type my-pathname () :inherit-from '(pathname))

#+clim-2
(define-presentation-method accept ((type my-pathname)
				    (stream t) (view t) &key)
  (let ((pathname (select-file *application-frame*)))
    (presentation-replace-input stream pathname 'pathname view)
    (values pathname 'my-pathname)))

(define-lisp-listener-command (com-choose-file :name t :menu t)
  ((pathname 'my-pathname :prompt #+clim-1 "Pathname" #+clim-2 nil))
  (present pathname 'pathname))

(define-lisp-listener-command (com-another-choose-file :name t :menu t)
  ()
  (let ((pathname (accept 'my-pathname)))
    (terpri)
    (present pathname 'pathname)))


Follow-Ups:

Main Index | Thread Index