Package: gtk

Interface gtk:file-chooser

Superclasses

gobject:object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

Direct Slots

action
The action property of type gtk:file-chooser-action (Read / Write)
The type of operation that the file selector is performing.
Default value: :open
create-folders
The create-folders property of type :boolean (Read / Write)
Whether a file chooser not in :open mode will offer the user to create new folders.
Default value: true
filter
The filter property of type gtk:file-filter (Read / Write)
The current filter for selecting which files are displayed.
filters
The filters property of type g:list-model (Read)
The list model containing the filters that have been added with the gtk:file-chooser-add-filter function.
select-multiple
The select-multiple property of type :boolean (Read / Write)
Whether to allow multiple files to be selected.
Default value: false
shortcut-folders
The shortcut-folders property of type g:list-model (Read)
The list model containing the shortcut folders that have been added with the gtk:file-chooser-add-shortcut-folder function.

Details

The gtk:file-chooser interface is an interface that can be implemented by file selection widgets. The main widgets that implement this interface are the gtk:file-chooser-widget and gtk:file-chooser-dialog widgets. You do not need to write a widget that implements the gtk:file-chooser interface unless you are trying to adapt an existing file selector to expose a standard programming interface.

The gtk:file-chooser interface allows for shortcuts to various places in the filesystem. In the default implementation these are displayed in the left pane. It may be a bit confusing at first that these shortcuts come from various sources and in various flavours, so lets explain the terminology here:
Bookmarks
are created by the user, by dragging folders from the right pane to the left pane, or by using the "Add". Bookmarks can be renamed and deleted by the user.
Shortcuts
can be provided by the application or by the underlying filesystem abstraction, for example, both the gnome-vfs and the Windows filesystems provide "Desktop" shortcuts. Shortcuts cannot be modified by the user.
Volumes
are provided by the underlying filesystem abstraction. Volumes are the "roots" of the filesystem.
File Names and Encodings
When the user is finished selecting files in a gtk:file-chooser widget, the program can get the selected filenames as g:file objects.

Examples

Sample usage with a gtk:file-chooser-dialog widget.
(defun create-file-chooser-dialog (parent)
  (let ((filter-all (gtk:file-filter-new))
        (filter-picture (gtk:file-filter-new))
        (dialog (gtk:file-chooser-dialog-new "File Chooser Dialog"
                                             parent
                                             :open
                                             "Open" 100
                                             "Cancel" :cancel)))
    (setf (gtk:window-modal dialog) t)
    (g:signal-connect dialog "response"
                      (lambda (dialog response)
                        (format t "  Response is ~a~%" response)
                        (unless (eq :cancel
                                    (gtk:response-type-keyword response))
                          (format t "Selected file is ~a~%"
                                  (gtk:file-chooser-namestring dialog)))
                        (gtk:window-destroy dialog)))
    ;; Add a file filter
    (setf (gtk:file-filter-name filter-all) "All Files")
    (gtk:file-filter-add-pattern filter-all "*")
    (gtk:file-chooser-add-filter dialog filter-all)
    ;; Add a second file filter for pictures
    (setf (gtk:file-filter-name filter-picture) "All Pictures")
    (gtk:file-filter-add-pixbuf-formats filter-picture)
    (gtk:file-chooser-add-filter dialog filter-picture)
    ;; Present the dialog
    (gtk:window-present dialog)))    

Warning

The gtk:file-chooser implementation is deprecated since 4.10. Use the gtk:file-dialog object instead.
 

Slot Access Functions

Inherited Slot Access Functions

See also

2024-5-20