;;;;
;;;; filechooser.stk    -- GTK File Chooser Demo
;;;;
;;;; Copyright © 2000-2021 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
;;;;
;;;;
;;;; This program is free software; you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
;;;; the Free Software Foundation; either version 2 of the License, or
;;;; (at your option) any later version.
;;;;
;;;; This program is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;;; GNU General Public License for more details.
;;;;
;;;; You should have received a copy of the GNU General Public License
;;;; along with this program; if not, write to the Free Software
;;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
;;;; USA.
;;;;
;;;;           Author: Erick Gallesio [eg@unice.fr]
;;;;    Creation date:  6-Nov-2000 18:59 (eg)
;;;;

(include "demos-utils.stk")

(define file-msg "
A simple demo of the &lt;file-dialog&gt; widget

Since we use the option <b>#:select-multiple</b>, the result 
is the list of selected files.
")


(define (choose-files)
  (let ((dlg (make <file-dialog> #:title "File Chooser demo"
                   #:select-multiple #t)))
    ;; Be modal
    (let ((ans (dialog-run dlg)))
      (if ans
          (begin
            (printf "Files selected:\n")
            (for-each (lambda (x) (printf "  - ~S\n" x)) ans))
          (printf "No File selected\n")))))


(define (main args)
  (let ((win (make <demo-window> :title "File Selector Demo"
                   :#width 400 :file "filechooser" :border-width 5
                   :padding 20 :message file-msg)))
    (make <button> #:text "Open a file chooser dialog" #:parent win
          #:command (lambda _ (choose-files)))
    (gtk-main)))

