Package: gtk

Function gtk-file-chooser-file

Lambda List

gtk-file-chooser-file (chooser)

Syntax

(gtk-file-chooser-file chooser) => file
(setf (gtk-file-chooser-file chooser) file)

Arguments

chooser -- a gtk-file-chooser widget
file -- a g-file object for the file

Details

Accessor of the file of the file chooser.

The function gtk-file-choose-file gets the g-file object for the currently selected file in the file selector. If multiple files are selected, one of the files will be returned at random. If the file chooser is in folder mode, this function returns the selected folder.

The function gtk-file-chooser-file sets file as the current filename for the file chooser, by changing to the file's parent folder and actually selecting the file in list. If the chooser is in :save mode, the file's base name will also appear in the dialog's file name entry.

If the file name is not in the current folder of the file chooser, then the current folder of the file chooser will be changed to the folder containing file. This is equivalent to a sequence of the function gtk-file-chooser-unselect-all followed by the function gtk-file-chooser-select-filename.

Note that the file must exist, or nothing will be done except for the directory change.

If you are implementing a File/Save As... dialog, you should use this function if you already have a file name to which the user may save. For example, when the user opens an existing file and then does File/Save As... on it. If you do not have a file name already - for example, if the user just created a new file and is saving it for the first time, do not call this function. Instead, use something similar to this:
(if document-is-new
    (progn
      ;; the user just created a new document
      (setf (gtk-file-chooser-current-folder-file chooser)
            default-file-for-saving)
      (setf (gtk-file-chooser-current-name chooser "Untitled document")))
      (progn
        ;; the user edited an existing document
        (setf (gtk-file-chooser-file chooser) existing-file)))  
 

See also

2021-2-5