1.66 <GtkFileDialog>

Class: <GtkFileDialog>

It derives from <GObject>.

Asynchronous API to present a file chooser dialog.

<GtkFileDialog> collects the arguments that are needed to present the dialog to the user, such as a title for the dialog and whether it should be modal.

The dialog is shown with file-dialog:open, file-dialog:save, etc.

Properties

Property: file-dialog:accept-label self

Label for the file chooser’s accept button.

Its value is a string, or #f.

Set it with (set! (file-dialog:accept-label self) value).

Property: file-dialog:default-filter self

The default filter.

This filter is initially active in the file chooser dialog.

If the default filter is NULL, the first filter of file-dialog:filters is used as the default filter. If that property contains no filter, the dialog will be unfiltered.

If file-dialog:filters is not NULL, the default filter should be part of the list. If it is not, the dialog may choose to not make it available.

Its value is a <GtkFileFilter>, or #f.

Set it with (set! (file-dialog:default-filter self) value).

Property: file-dialog:filters self

The list of filters.

See file-dialog:default-filter about how these two properties interact.

Its value is a <GListModel>, or #f.

Set it with (set! (file-dialog:filters self) value).

Property: file-dialog:initial-file self

The initial file.

This file is initially selected in the file chooser dialog

This is a utility property that sets both file-dialog:initial-folder and file-dialog:initial-name.

Its value is a <GFile>, or #f.

Set it with (set! (file-dialog:initial-file self) value).

Property: file-dialog:initial-folder self

The initial folder.

This is the directory that is initially opened in the file chooser dialog.

Its value is a <GFile>, or #f.

Set it with (set! (file-dialog:initial-folder self) value).

Property: file-dialog:initial-name self

The initial name.

This is the name of the file that is initially selected in the file chooser dialog.

Its value is a string, or #f.

Set it with (set! (file-dialog:initial-name self) value).

Property: file-dialog:modal self

Whether the file chooser dialog is modal.

Its value is a boolean.

Set it with (set! (file-dialog:modal self) value).

Property: file-dialog:title self

A title that may be shown on the file chooser dialog.

Its value is a string, or #f.

Set it with (set! (file-dialog:title self) value).

Procedures

Method: file-dialog:get-accept-label self ⇒ %return
Method: get-accept-label self ⇒ %return

Retrieves the text used by the dialog on its accept button.

self

Passed: a <GtkFileDialog>.

a file dialog

%return

Returned: a string, or #f.

the label shown on the file chooser’s accept button

Method: file-dialog:get-default-filter self ⇒ %return
Method: get-default-filter self ⇒ %return

Gets the filter that will be selected by default in the file chooser dialog.

self

Passed: a <GtkFileDialog>.

a file dialog

%return

Returned: a <GtkFileFilter>, or #f.

the default filter

Method: file-dialog:get-filters self ⇒ %return
Method: get-filters self ⇒ %return

Gets the filters that will be offered to the user in the file chooser dialog.

self

Passed: a <GtkFileDialog>.

a file dialog

%return

Returned: a <GListModel>, or #f.

the filters, as a list model of <GtkFileFilter>

Method: file-dialog:get-initial-file self ⇒ %return
Method: get-initial-file self ⇒ %return

Gets the file that will be initially selected in the file chooser dialog.

self

Passed: a <GtkFileDialog>.

a file dialog

%return

Returned: a <GFile>, or #f.

the file

Method: file-dialog:get-initial-folder self ⇒ %return
Method: get-initial-folder self ⇒ %return

Gets the folder that will be set as the initial folder in the file chooser dialog.

self

Passed: a <GtkFileDialog>.

a file dialog

%return

Returned: a <GFile>, or #f.

the folder

Method: file-dialog:get-initial-name self ⇒ %return
Method: get-initial-name self ⇒ %return

Gets the filename that will be initially selected.

self

Passed: a <GtkFileDialog>.

a file dialog

%return

Returned: a string, or #f.

the name

Method: file-dialog:get-modal? self ⇒ %return
Method: get-modal? self ⇒ %return

Returns whether the file chooser dialog blocks interaction with the parent window while it is presented.

self

Passed: a <GtkFileDialog>.

a file dialog

%return

Returned: a boolean.

true if the file chooser dialog is modal

Method: file-dialog:get-title self ⇒ %return
Method: get-title self ⇒ %return

Returns the title that will be shown on the file chooser dialog.

self

Passed: a <GtkFileDialog>.

a file dialog

%return

Returned: a string.

the title

Procedure: file-dialog:new ⇒ %return

Creates a new <GtkFileDialog> object.

%return

Returned: a <GtkFileDialog>.

the new <GtkFileDialog>

Method: file-dialog:open self [parent] [cancellable] [callback]
Method: open self [parent] [cancellable] [callback]

Presents a file chooser dialog to the user.

The file chooser dialog will be set up to select a single file.

The callback will be called when the dialog is closed.

self

Passed: a <GtkFileDialog>.

a file dialog

parent

Passed, or left out: a <GtkWindow>, or #f.

the parent window

cancellable

Passed, or left out: a <GCancellable>, or #f.

a cancellable to cancel the operation

callback

Passed, or left out: a procedure, or #f.

a callback to call when the operation is complete

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

data to pass to callback

Method: file-dialog:open-finish self result ⇒ %return
Method: open-finish self result ⇒ %return

Finishes the file-dialog:open call.

Note that this function returns a Gtk.DialogError.DISMISSED error if the user cancels the dialog.

self

Passed: a <GtkFileDialog>.

a file dialog

result

Passed: a <GAsyncResult>.

the result

%return

Returned: a <GFile>.

the file that was selected

Method: file-dialog:open-multiple self [parent] [cancellable] [callback]
Method: open-multiple self [parent] [cancellable] [callback]

Presents a file chooser dialog to the user.

The file chooser dialog will be set up to select multiple files.

The file chooser dialog will initially be opened in the directory file-dialog:initial-folder.

The callback will be called when the dialog is closed.

self

Passed: a <GtkFileDialog>.

a file dialog

parent

Passed, or left out: a <GtkWindow>, or #f.

the parent window

cancellable

Passed, or left out: a <GCancellable>, or #f.

a cancellable to cancel the operation

callback

Passed, or left out: a procedure, or #f.

a callback to call when the operation is complete

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

data to pass to callback

Method: file-dialog:open-multiple-finish self result ⇒ %return
Method: open-multiple-finish self result ⇒ %return

Finishes the file-dialog:open call.

Note that this function returns a Gtk.DialogError.DISMISSED error if the user cancels the dialog.

self

Passed: a <GtkFileDialog>.

a file dialog

result

Passed: a <GAsyncResult>.

the result

%return

Returned: a <GListModel>.

the files that were selected, as a list model of <GFile>

Method: file-dialog:open-multiple-text-files self [parent] [cancellable] [callback]
Method: open-multiple-text-files self [parent] [cancellable] [callback]

Presents a file chooser dialog to the user.

The file chooser dialog will be set up to select multiple files.

The file chooser dialog will initially be opened in the directory file-dialog:initial-folder.

In contrast to file-dialog:open, this function lets the user select the text encoding for the files, if possible.

The callback will be called when the dialog is closed.

self

Passed: a <GtkFileDialog>.

a file dialog

parent

Passed, or left out: a <GtkWindow>, or #f.

the parent window

cancellable

Passed, or left out: a <GCancellable>, or #f.

a cancellable to cancel the operation

callback

Passed, or left out: a procedure, or #f.

a callback to call when the operation is complete

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

data to pass to callback

Method: file-dialog:open-multiple-text-files-finish self result ⇒ %return encoding
Method: open-multiple-text-files-finish self result ⇒ %return encoding

Finishes the file-dialog:open call.

Note that this function returns a Gtk.DialogError.DISMISSED error if the user cancels the dialog.

self

Passed: a <GtkFileDialog>.

a file dialog

result

Passed: a <GAsyncResult>.

the result

%return

Returned: a <GListModel>.

the files that were selected, as a list model of <GFile>

encoding

Returned: a string.

return location for the text encoding to use

Method: file-dialog:open-text-file self [parent] [cancellable] [callback]
Method: open-text-file self [parent] [cancellable] [callback]

Initiates a file selection operation by presenting a file chooser dialog to the user.

In contrast to file-dialog:open, this function lets the user select the text encoding for the file, if possible.

The callback will be called when the dialog is closed.

self

Passed: a <GtkFileDialog>.

a <GtkFileDialog>

parent

Passed, or left out: a <GtkWindow>, or #f.

the parent <GtkWindow>

cancellable

Passed, or left out: a <GCancellable>, or #f.

a <GCancellable> to cancel the operation

callback

Passed, or left out: a procedure, or #f.

a callback to call when the operation is complete

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

data to pass to callback

Method: file-dialog:open-text-file-finish self result ⇒ %return encoding
Method: open-text-file-finish self result ⇒ %return encoding

Finishes the file-dialog:open-text-file call and returns the resulting file and text encoding.

If the user has explicitly selected a text encoding to use for the file, then encoding will be set to a codeset name that is suitable for passing to iconv_open(). Otherwise, it will be NULL.

Note that this function returns a Gtk.DialogError.DISMISSED error if the user cancels the dialog.

self

Passed: a <GtkFileDialog>.

a <GtkFileDialog>

result

Passed: a <GAsyncResult>.

a <GAsyncResult>

%return

Returned: a <GFile>.

the file that was selected

encoding

Returned: a string.

return location for the text encoding to use

Method: file-dialog:save self [parent] [cancellable] [callback]
Method: save self [parent] [cancellable] [callback]

Presents a file chooser dialog to the user.

The file chooser dialog will be save mode.

The callback will be called when the dialog is closed.

self

Passed: a <GtkFileDialog>.

a file dialog

parent

Passed, or left out: a <GtkWindow>, or #f.

the parent window

cancellable

Passed, or left out: a <GCancellable>, or #f.

a cancellable to cancel the operation

callback

Passed, or left out: a procedure, or #f.

a callback to call when the operation is complete

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

data to pass to callback

Method: file-dialog:save-finish self result ⇒ %return
Method: save-finish self result ⇒ %return

Finishes the file-dialog:save call.

Note that this function returns a Gtk.DialogError.DISMISSED error if the user cancels the dialog.

self

Passed: a <GtkFileDialog>.

a file dialog

result

Passed: a <GAsyncResult>.

the result

%return

Returned: a <GFile>.

the file that was selected

Method: file-dialog:save-text-file self [parent] [cancellable] [callback]
Method: save-text-file self [parent] [cancellable] [callback]

Initiates a file save operation by presenting a file chooser dialog to the user.

In contrast to file-dialog:save, this function lets the user select the text encoding and line endings for the text file, if possible.

The callback will be called when the dialog is closed.

self

Passed: a <GtkFileDialog>.

a <GtkFileDialog>

parent

Passed, or left out: a <GtkWindow>, or #f.

the parent <GtkWindow>

cancellable

Passed, or left out: a <GCancellable>, or #f.

a <GCancellable> to cancel the operation

callback

Passed, or left out: a procedure, or #f.

a callback to call when the operation is complete

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

data to pass to callback

Method: file-dialog:save-text-file-finish self result ⇒ %return encoding line-ending
Method: save-text-file-finish self result ⇒ %return encoding line-ending

Finishes the file-dialog:save-text-file call and returns the resulting file, text encoding and line endings.

If the user has explicitly selected a text encoding to use for the file, then encoding will be set to a codeset name that is suitable for passing to iconv_open(). Otherwise, it will be NULL.

The line-ending will be set to one of "\n", "\r\n", "\r" or "", where the latter means to preserve existing line endings.

Note that this function returns a Gtk.DialogError.DISMISSED error if the user cancels the dialog.

self

Passed: a <GtkFileDialog>.

a <GtkFileDialog>

result

Passed: a <GAsyncResult>.

a <GAsyncResult>

%return

Returned: a <GFile>.

the file that was selected.

encoding

Returned: a string.

return location for the text encoding to use

line-ending

Returned: a string.

return location for the line endings to use

Method: file-dialog:select-folder self [parent] [cancellable] [callback]
Method: select-folder self [parent] [cancellable] [callback]

Presents a file chooser dialog to the user.

The file chooser dialog will be set up to select a single folder.

If you pass initial-folder, the file chooser dialog will initially be opened in the parent directory of that folder, otherwise, it will be in the directory file-dialog:initial-folder.

The callback will be called when the dialog is closed.

self

Passed: a <GtkFileDialog>.

a file dialog

parent

Passed, or left out: a <GtkWindow>, or #f.

the parent window

cancellable

Passed, or left out: a <GCancellable>, or #f.

a cancellable to cancel the operation

callback

Passed, or left out: a procedure, or #f.

a callback to call when the operation is complete

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

data to pass to callback

Method: file-dialog:select-folder-finish self result ⇒ %return
Method: select-folder-finish self result ⇒ %return

Finishes the file-dialog:select-folder call.

Note that this function returns a Gtk.DialogError.DISMISSED error if the user cancels the dialog.

self

Passed: a <GtkFileDialog>.

a file dialog

result

Passed: a <GAsyncResult>.

the result

%return

Returned: a <GFile>.

the folder that was selected

Method: file-dialog:select-multiple-folders self [parent] [cancellable] [callback]
Method: select-multiple-folders self [parent] [cancellable] [callback]

Presents a file chooser dialog to the user.

The file chooser dialog will be set up to allow selecting multiple folders.

The file chooser dialog will initially be opened in the directory file-dialog:initial-folder.

The callback will be called when the dialog is closed.

self

Passed: a <GtkFileDialog>.

a file dialog

parent

Passed, or left out: a <GtkWindow>, or #f.

the parent window

cancellable

Passed, or left out: a <GCancellable>, or #f.

a cancellable to cancel the operation

callback

Passed, or left out: a procedure, or #f.

a callback to call when the operation is complete

See GAsyncReadyCallback for how it is called.

user-data

Not passed: guile-gi supplies it.

data to pass to callback

Method: file-dialog:select-multiple-folders-finish self result ⇒ %return
Method: select-multiple-folders-finish self result ⇒ %return

Finishes the file-dialog:select-multiple-folders call.

Note that this function returns a Gtk.DialogError.DISMISSED error if the user cancels the dialog.

self

Passed: a <GtkFileDialog>.

a file dialog

result

Passed: a <GAsyncResult>.

the result

%return

Returned: a <GListModel>.

the folders that were selected, as a list model of <GFile>

Method: file-dialog:set-accept-label self [accept-label]
Method: set-accept-label self [accept-label]

Sets the label shown on the file chooser’s accept button.

Leaving the accept label unset or setting it as NULL will fall back to a default label, depending on what API is used to launch the file dialog.

self

Passed: a <GtkFileDialog>.

a file dialog

accept-label

Passed, or left out: a string, or #f.

the new accept label

Method: file-dialog:set-default-filter self [filter]
Method: set-default-filter self [filter]

Sets the filter that will be selected by default in the file chooser dialog.

If set to NULL, the first item in file-dialog:filters will be used as the default filter. If that list is empty, the dialog will be unfiltered.

self

Passed: a <GtkFileDialog>.

a file dialog

filter

Passed, or left out: a <GtkFileFilter>, or #f.

the file filter

Method: file-dialog:set-filters self [filters]
Method: set-filters self [filters]

Sets the filters that will be offered to the user in the file chooser dialog.

self

Passed: a <GtkFileDialog>.

a file dialog

filters

Passed, or left out: a <GListModel>, or #f.

a list model of <GtkFileFilter>

Method: file-dialog:set-initial-file self [file]
Method: set-initial-file self [file]

Sets the file that will be initially selected in the file chooser dialog.

This function is a shortcut for calling both file-dialog:set-initial-folder and file-dialog:set-initial-name with the directory and name of file, respectively.

self

Passed: a <GtkFileDialog>.

a file dialog

file

Passed, or left out: a <GFile>, or #f.

a file

Method: file-dialog:set-initial-folder self [folder]
Method: set-initial-folder self [folder]

Sets the folder that will be set as the initial folder in the file chooser dialog.

self

Passed: a <GtkFileDialog>.

a file dialog

folder

Passed, or left out: a <GFile>, or #f.

a file

Method: file-dialog:set-initial-name self [name]
Method: set-initial-name self [name]

Sets the filename that will be initially selected.

For save dialogs, name will usually be pre-entered into the name field.

If a file with this name already exists in the directory set via file-dialog:initial-folder, the dialog will preselect it.

self

Passed: a <GtkFileDialog>.

a file dialog

name

Passed, or left out: a string, or #f.

a string

Method: file-dialog:set-modal self modal
Method: set-modal self modal

Sets whether the file chooser dialog blocks interaction with the parent window while it is presented.

self

Passed: a <GtkFileDialog>.

a file dialog

modal

Passed: a boolean.

the new value

Method: file-dialog:set-title self title
Method: set-title self title

Sets the title that will be shown on the file chooser dialog.

self

Passed: a <GtkFileDialog>.

a file dialog

title

Passed: a string.

the new title