[cells-gtk-devel] How do I get file-chooser's result as a pathname

wagwilk at telusplanet.net wagwilk at telusplanet.net
Sat May 12 16:46:13 UTC 2007


I'm trying to use a file-chooser to select mp3 files in this code:

(defmodel audio-panel (vbox)
  ((audio :accessor audio :initform (c-in (make-array 1024 :element-type
'(signed-byte 16) :adjustable t)))
   (filename :accessor filename :initform (c-in nil)))
  (:default-initargs
      :kids (list
             (mk-label :text (c? (format nil "~:[No Data Loaded~;~:*~a~]"
(filename (upper self audio-panel)))))
             (make-instance 'mp3-file-selector))))


(defmodel mp3-file-selector (button)
  ()
  (:default-initargs
   :stock (c? :open)
;   :label (c? "Load Mp3")
   :on-clicked (callback (widget signal data)
                  (setf (filename (upper self audio-panel))
                        (format nil "Set to: ~a"
                               (gtk-file-chooser-get-filenames-strs
(file-chooser :title "Load Mp3"
                                                               :select-multiple 0
                                                               :action :open)))))))


I want the callback (reprinted here) to set the string "filename" in the
audio-panel object

(callback (widget signal data)
  (setf (filename (upper self audio-panel))
        (format nil "Set to: ~a"
           (file-chooser :title "Load Mp3"
                         :select-multiple 0
                         :action :open))))


However, when I run the code, Filename gets set to "Set to (#.(SB-SYS:INT-SAP
#X0817CF28))" (the pointer address changes)

I've also tried using the method "gtk-file-chooser-get-filenames-strs" from
gtk-ffi, but it expects a SB-SYS:SYSTEM-AREA-POINTER:

The value (#.(SB-SYS:INT-SAP #X0817CF28))                                      
                                                                               
         
is not of type                                                                 
                                                                               
         
  SB-SYS:SYSTEM-AREA-POINTER.
   [Condition of type TYPE-ERROR]

I've also poured through the test-gtk example code, but I'm not sure how they're
doing it, and I'm not certain that the result name ever gets fully translated on
the lisp side. Here is the code from test-gtk:

(callback (widget signal data)
    (setf (text (fm^ :file-chooser-response))
          (file-chooser :title (format nil "~a dialog" (action self))
                        :select-multiple (md-value (fm^ :select-multiple-files))
                        :action (action self)))

Where :file-chooser-response is the 'md-name' of a text label elsewhere in the
program.


Cheers,
Warren Wilkinson




More information about the cells-gtk-devel mailing list