Gtk.FileDialog¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Gtk.FileDialog(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A
GtkFileDialog
object collects the arguments that are needed to present a file chooser dialog to the user, such as a title for the dialog and whether it should be modal.The dialog is shown with [method`Gtk`.FileDialog.open], [method`Gtk`.FileDialog.save], etc. These APIs follow the GIO async pattern, and the result can be obtained by calling the corresponding finish function, for example [method`Gtk`.FileDialog.open_finish].
New in version 4.10.
- classmethod new()[source]¶
- Returns:
the new
GtkFileDialog
- Return type:
Creates a new
GtkFileDialog
object.New in version 4.10.
- get_default_filter()[source]¶
- Returns:
the current filter
- Return type:
Gets the filter that will be selected by default in the file chooser dialog.
New in version 4.10.
- get_filters()[source]¶
- Returns:
the filters, as a
GListModel
ofGtkFileFilters
- Return type:
Gets the filters that will be offered to the user in the file chooser dialog.
New in version 4.10.
- get_initial_file()[source]¶
-
Gets the file that will be initially selected in the file chooser dialog.
New in version 4.10.
- get_initial_folder()[source]¶
-
Gets the folder that will be set as the initial folder in the file chooser dialog.
New in version 4.10.
- get_initial_name()[source]¶
-
Gets the name for the file that should be initially set.
New in version 4.10.
- get_modal()[source]¶
- Returns:
TRUE
if the file chooser dialog is modal- Return type:
Returns whether the file chooser dialog blocks interaction with the parent window while it is presented.
New in version 4.10.
- get_title()[source]¶
- Returns:
the title
- Return type:
Returns the title that will be shown on the file chooser dialog.
New in version 4.10.
- open(parent, cancellable, callback, *user_data)[source]¶
- Parameters:
parent (
Gtk.Window
orNone
) – the parentGtkWindow
cancellable (
Gio.Cancellable
orNone
) – aGCancellable
to cancel the operationcallback (
Gio.AsyncReadyCallback
orNone
) – a callback to call when the operation is complete
This function initiates a file selection operation by presenting a file chooser dialog to the user.
The callback will be called when the dialog is dismissed. It should call [method`Gtk`.FileDialog.open_finish] to obtain the result.
New in version 4.10.
- open_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – aGAsyncResult
- Raises:
- Returns:
the file that was selected. Otherwise,
NULL
is returned and error is set- Return type:
Finishes the [method`Gtk`.FileDialog.open] call and returns the resulting file.
New in version 4.10.
- open_multiple(parent, cancellable, callback, *user_data)[source]¶
- Parameters:
parent (
Gtk.Window
orNone
) – the parentGtkWindow
cancellable (
Gio.Cancellable
orNone
) – aGCancellable
to cancel the operationcallback (
Gio.AsyncReadyCallback
orNone
) – a callback to call when the operation is complete
This function initiates a multi-file selection operation by presenting a file chooser dialog to the user.
The file chooser will initially be opened in the directory [property`Gtk`.FileDialog:initial-folder].
The callback will be called when the dialog is dismissed. It should call [method`Gtk`.FileDialog.open_multiple_finish] to obtain the result.
New in version 4.10.
- open_multiple_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – aGAsyncResult
- Raises:
- Returns:
the file that was selected, as a
GListModel
ofGFiles
. Otherwise,NULL
is returned and error is set- Return type:
Finishes the [method`Gtk`.FileDialog.open] call and returns the resulting files in a
GListModel
.New in version 4.10.
- save(parent, cancellable, callback, *user_data)[source]¶
- Parameters:
parent (
Gtk.Window
orNone
) – the parentGtkWindow
cancellable (
Gio.Cancellable
orNone
) – aGCancellable
to cancel the operationcallback (
Gio.AsyncReadyCallback
orNone
) – a callback to call when the operation is complete
This function initiates a file save operation by presenting a file chooser dialog to the user.
The callback will be called when the dialog is dismissed. It should call [method`Gtk`.FileDialog.save_finish] to obtain the result.
New in version 4.10.
- save_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – aGAsyncResult
- Raises:
- Returns:
the file that was selected. Otherwise,
NULL
is returned and error is set- Return type:
Finishes the [method`Gtk`.FileDialog.save] call and returns the resulting file.
New in version 4.10.
- select_folder(parent, cancellable, callback, *user_data)[source]¶
- Parameters:
parent (
Gtk.Window
orNone
) – the parentGtkWindow
cancellable (
Gio.Cancellable
orNone
) – aGCancellable
to cancel the operationcallback (
Gio.AsyncReadyCallback
orNone
) – a callback to call when the operation is complete
This function initiates a directory selection operation by presenting a file chooser dialog to the user.
If you pass initial_folder, the file chooser will initially be opened in the parent directory of that folder, otherwise, it will be in the directory [property`Gtk`.FileDialog:initial-folder].
The callback will be called when the dialog is dismissed. It should call [method`Gtk`.FileDialog.select_folder_finish] to obtain the result.
New in version 4.10.
- select_folder_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – aGAsyncResult
- Raises:
- Returns:
the file that was selected. Otherwise,
NULL
is returned and error is set- Return type:
Finishes the [method`Gtk`.FileDialog.select_folder] call and returns the resulting file.
New in version 4.10.
- select_multiple_folders(parent, cancellable, callback, *user_data)[source]¶
- Parameters:
parent (
Gtk.Window
orNone
) – the parentGtkWindow
cancellable (
Gio.Cancellable
orNone
) – aGCancellable
to cancel the operationcallback (
Gio.AsyncReadyCallback
orNone
) – a callback to call when the operation is complete
This function initiates a multi-directory selection operation by presenting a file chooser dialog to the user.
The file chooser will initially be opened in the directory [property`Gtk`.FileDialog:initial-folder].
The callback will be called when the dialog is dismissed. It should call [method`Gtk`.FileDialog.select_multiple_folders_finish] to obtain the result.
New in version 4.10.
- select_multiple_folders_finish(result)[source]¶
- Parameters:
result (
Gio.AsyncResult
) – aGAsyncResult
- Raises:
- Returns:
the file that was selected, as a
GListModel
ofGFiles
. Otherwise,NULL
is returned and error is set- Return type:
Finishes the [method`Gtk`.FileDialog.select_multiple_folders] call and returns the resulting files in a
GListModel
.New in version 4.10.
- set_accept_label(accept_label)[source]¶
-
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.New in version 4.10.
- set_default_filter(filter)[source]¶
- Parameters:
filter (
Gtk.FileFilter
orNone
) – aGtkFileFilter
Sets the filter that will be selected by default in the file chooser dialog.
If set to
None
, the first item in [property`Gtk`.FileDialog:filters] will be used as the default filter. If that list is empty, the dialog will be unfiltered.New in version 4.10.
- set_filters(filters)[source]¶
- Parameters:
filters (
Gio.ListModel
orNone
) – aGListModel
ofGtkFileFilters
Sets the filters that will be offered to the user in the file chooser dialog.
New in version 4.10.
- set_initial_file(file)[source]¶
-
Sets the file that will be initially selected in the file chooser dialog.
This function is a shortcut for calling both
Gtk.FileDialog.set_initial_folder
() andGtk.FileDialog.set_initial_name
() with the directory and name of file respectively.New in version 4.10.
- set_initial_folder(folder)[source]¶
-
Sets the folder that will be set as the initial folder in the file chooser dialog.
New in version 4.10.
- set_initial_name(name)[source]¶
-
Sets the name for the file that should be initially set. For saving dialogs, this will usually be pre-entered into the name field.
If a file with this name already exists in the directory set via [property`Gtk`.FileDialog:initial-folder], the dialog should preselect it.
New in version 4.10.
Property Details¶
- Gtk.FileDialog.props.accept_label¶
- Name:
accept-label
- Type:
- Default Value:
- Flags:
Label for the file chooser’s accept button.
New in version 4.10.
- Gtk.FileDialog.props.default_filter¶
- Name:
default-filter
- Type:
- Default Value:
- Flags:
The default filter, that is, the filter that is initially active in the file chooser dialog.
If the default filter is
None
, the first filter of [property`Gtk`.FileDialog:filters] is used as the default filter. If that property contains no filter, the dialog will be unfiltered.If [property`Gtk`.FileDialog:filters] is not
None
, the default filter should be part of the list. If it is not, the dialog may choose to not make it available.New in version 4.10.
- Gtk.FileDialog.props.filters¶
- Name:
filters
- Type:
- Default Value:
- Flags:
The list of filters.
See [property`Gtk`.FileDialog:default-filter] about how those two properties interact.
New in version 4.10.
- Gtk.FileDialog.props.initial_file¶
- Name:
initial-file
- Type:
- Default Value:
- Flags:
The initial file, that is, the file that is initially selected in the file chooser dialog
This is a utility property that sets both [property`Gtk`.FileDialog:initial-folder] and [property`Gtk`.FileDialog:initial-name].
New in version 4.10.
- Gtk.FileDialog.props.initial_folder¶
- Name:
initial-folder
- Type:
- Default Value:
- Flags:
The initial folder, that is, the directory that is initially opened in the file chooser dialog
New in version 4.10.
- Gtk.FileDialog.props.initial_name¶
- Name:
initial-name
- Type:
- Default Value:
- Flags:
The initial name, that is, the filename that is initially selected in the file chooser dialog.
New in version 4.10.
- Gtk.FileDialog.props.modal¶
- Name:
modal
- Type:
- Default Value:
- Flags:
Whether the file chooser dialog is modal.
New in version 4.10.