Package: gtk

Function gtk-file-chooser-filename

Lambda List

gtk-file-chooser-filename (chooser)

Syntax

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

Arguments

chooser -- a gtk-file-chooser widget
filename -- a string with the filename to set as current

Details

Accessor of the filename of a file chooser widget.

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

The function (gtk-file-chooser-filename) sets filename as the current filename for the file chooser, by changing to the file's parent folder and actually selecting the file in the list. All other files will be unselected. If the chooser is in :save mode, the file's base name will also appear in the dialog's file name entry. Note that the file must exist, or nothing will be done except for the directory change.

You should use this function only when implementing a "File/Save As..." dialog for which 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 to save a copy or a modified version. 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)
    ;; the user just created a new document
    (setf (gtk-file-chooser-current-name chooser) "Untitled document")
    ;; the user edited an existing document
    (setf (gtk-file-chooser-filename chooser) existing-filename))  
In the first case, the file chooser will present the user with useful suggestions as to where to save his new file. In the second case, the file's existing location is already known, so the file chooser will use it.
 

See also

*2021-2-4