[mcclim-cvs] CVS mcclim/Doc/Guided-Tour

rgoldman rgoldman at common-lisp.net
Tue Jan 9 03:28:19 UTC 2007


Update of /project/mcclim/cvsroot/mcclim/Doc/Guided-Tour
In directory clnet:/tmp/cvs-serv11339

Added Files:
	file-browser.lisp-type-abbrev 
Log Message:
Alternative version of file-browser, more elegant, but relies on features not working yet in McCLIM.


--- /project/mcclim/cvsroot/mcclim/Doc/Guided-Tour/file-browser.lisp-type-abbrev	2007/01/09 03:28:19	NONE
+++ /project/mcclim/cvsroot/mcclim/Doc/Guided-Tour/file-browser.lisp-type-abbrev	2007/01/09 03:28:19	1.1
(eval-when (:compile-toplevel)
  (asdf:oos 'asdf:load-op :clim)
  (asdf:oos 'asdf:load-op :clim-clx))

(eval-when (:compile-toplevel :load-toplevel :execute)
  (asdf:oos 'asdf:load-op :cl-fad))

(in-package :clim-user)

; LTAG-start:file-browser-all
(define-application-frame file-browser ()
  ((active-files :initform nil :accessor active-files))
  (:panes
   (file-browser :application
		 :display-function '(dirlist-display-files)
		 ;; Call the display-function whenever the command
		 ;; loop makes a ``full-cycle''
		 :display-time :command-loop)
   (interactor :interactor))
  (:layouts (default (vertically ()
				 file-browser
				 interactor))))

(define-presentation-type-abbreviation dir-pathname ()
  '((and pathname (satisfies cl-fad:directory-pathname-p)) :description "Directory"))

(defmethod dirlist-display-files ((frame file-browser) pane)
  ;; Clear old displayed entries
  (clear-output-record (stream-output-history pane))

  (dolist (file (active-files frame))
    ;; Instead of write-string, we use present so that the link to
    ;; object file and the semantic information that file is
    ;; pathname is retained.
    (present file 'pathname
;;	     (if (cl-fad:directory-pathname-p file) 'dir-pathname 'pathname)
	     :stream pane)
    (terpri pane)))

;;; shouldn't this bletch if it is given an argument that is a
;;; well-formed directory name, but for a directory that doesn't
;;; exist? cl-fad:directory-exists-p is relevant
;;; here... [2007/01/07:rpg]
(define-file-browser-command (com-edit-directory :name "Edit Directory")
  ((dir 'dir-pathname))
  ;; the following was a previous attempt to deal with the oddities of
  ;; CL pathnames.  Unfortunately, it does not work properly with all
  ;; lisp implementations.  Because of these oddities, we really need
  ;; a layer like cl-fad to keep things straight. [2007/01/05:rpg]
;;;  (let ((dir (make-pathname :directory (pathname-directory dir)
;;;			    :name :wild :type :wild :version :wild
;;;			    :defaults dir)))
    (setf (active-files *application-frame*)
	  (cl-fad:list-directory dir)))

(define-presentation-to-command-translator pathname-to-edit-command
    ((and pathname (satisfies cl-fad:directory-pathname-p)) ; source presentation-type
     com-edit-directory                 ; target-command
     file-browser                       ; command-table
     :gesture :select                   ; use this translator for pointer clicks
     :documentation "Edit this path")   ; used in context menu
    (object)                            ; argument List
    (list object))                        ; arguments for target-command

(define-file-browser-command (com-quit :name t) ()
  (frame-exit *application-frame*)
  )

(defmethod adopt-frame :after (frame-manager (frame file-browser))
  (declare (ignore frame-manager))
  (execute-frame-command frame
	`(com-edit-directory ,(make-pathname :directory '(:absolute)))))

; LTAG-end



More information about the Mcclim-cvs mailing list