A simple aggretrees demo

Sean Champ <[email protected]> Tue, 2 Aug 2005 20:36:18 -0700
Newsgroups gmane.lisp.garnet.user
Message-ID <[email protected]>
--envbJBWh7q8WU6mo
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline


* Background

The file aggretrees.lisp is contained within the Garnet src/contrib/
directory. The file contains some demos of the aggretree schemas, and
is documented, within the file's comments.


aggretrees.lisp may  be loaded, upon execution of the form:

   (garnet-load  "contrib-src:aggretrees")


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* A minor demo

In some re-application of one of the aggretree demos, I'd made a
simple filesystem directory tree, based upon the aggretree-2
schema. While it is simple and not very new (it is just a revised
aggretree demo, essentially) yet it seemed that it might bear
mentioning, at least as anything of a discussion-starter.


The code for the demo is attached.

The primary motive of the attached code is: To list a rudimentary
tree of filesystem objects, given a single directory as the "root" of
the tree. 


 Usage example:

   (defparameter *w* (file-tree.show "/"))
   ;; e.g left-click on some directories, then left-click again
   ;; eventually:
  (file-tree.stop *w*)




THere are some issues that could be resolved about the code, in
revision. For example:

  1) Using a fancier :NODE-PROTOTYPE label (e.g depending upon
     properties of the identified file/directory)

  2) Setting the INTERACTOR-WINDOW height, based upon the minimum
     value of: 
       (A) the "root" aggretree's height and
       (B) an establisehd "maximum-height" value

  3) Adding scroll-bars

  4) Activating a property-list upon selection (e.g. with middle mouse
     button) selection of one of the nodes  

  6) Adding a TAB-INTER

  5) Using it for something more than filesytem-tree-display

However, it seems doable, as it is, as a very simple example.


I mean not to waste time on the list, certainly. I know this is
nothing expressedly significant, about Garnet. It seemed worth 
mentioning, however, as one simple example, and (possibly) towards
discussion.


Luego

----
Sean Champ
[email protected]

--envbJBWh7q8WU6mo
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="aggretree-fsdirectory.lisp"


(in-package #:cl-user)

(garnet-load  "contrib-src:aggretrees")

(defun file-tree.create (pathname)
  (create-instance nil gg:aggretree-2
    (:expansion-level 1)
    (:tree pathname)
    (:children-function
     #'(lambda (node)
	 (unless (pathname-name node)
	   (directory node
		      #+cmu :follow-links #+cmu nil
		      #+cmu :truenamep #+cmu nil))))
    
    (:node-prototype
     (create-instance nil opal:text
       (:string (o-formula (namestring (gvl :tree))))))
    
    (:interactors
     `((:selection-inter ,inter:button-interactor
	(:window ,(o-formula (gv-local :self :operates-on :window)))
	(:start-where ,(o-formula (list :element-of
					(gvl :operates-on
					     :nodes-aggregate))))
	(:start-event :leftdown)
	(:final-function
	 ,#'(lambda (inter ob)
	      (let ((level (g-value ob :expansion-level)))
		(s-value ob :expansion-level
			 (if (> level 0) 0 1))
		(gg:revert-aggretree-node
		 (g-value ob :parent :parent) ob)
		(opal:update (g-value ob :window) t)))))))))


(defun file-tree.show (pathname)
  (let* ((aggretree (file-tree.create pathname))
	 (window (create-instance nil inter:interactor-window
		   (:aggregate aggretree))))
    (opal:update window)
    (inter:main-event-loop)
    (values window)))

;; (defparameter *w* (file-tree.show "/"))

(defun file-tree.stop (window)
  (opal:destroy window))

;; (file-tree.stop *w*)

--envbJBWh7q8WU6mo--