gtkmm 4.16.0
|
A Gtk::FileDialog 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. More...
#include <gtkmm/filedialog.h>
Public Member Functions | |
FileDialog (FileDialog &&src) noexcept | |
FileDialog & | operator= (FileDialog &&src) noexcept |
~FileDialog () noexcept override | |
GtkFileDialog * | gobj () |
Provides access to the underlying C GObject. | |
const GtkFileDialog * | gobj () const |
Provides access to the underlying C GObject. | |
GtkFileDialog * | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
Glib::ustring | get_title () const |
Returns the title that will be shown on the file chooser dialog. | |
void | set_title (const Glib::ustring &title) |
Sets the title that will be shown on the file chooser dialog. | |
bool | get_modal () const |
Returns whether the file chooser dialog blocks interaction with the parent window while it is presented. | |
void | set_modal (bool modal=true) |
Sets whether the file chooser dialog blocks interaction with the parent window while it is presented. | |
Glib::RefPtr< Gio::ListModel > | get_filters () |
Gets the filters that will be offered to the user in the file chooser dialog. | |
Glib::RefPtr< const Gio::ListModel > | get_filters () const |
Gets the filters that will be offered to the user in the file chooser dialog. | |
void | set_filters (const Glib::RefPtr< Gio::ListModel > &filters) |
Sets the filters that will be offered to the user in the file chooser dialog. | |
Glib::RefPtr< FileFilter > | get_default_filter () |
Gets the filter that will be selected by default in the file chooser dialog. | |
Glib::RefPtr< const FileFilter > | get_default_filter () const |
Gets the filter that will be selected by default in the file chooser dialog. | |
void | set_default_filter (const Glib::RefPtr< FileFilter > &filter) |
Sets the filter that will be selected by default in the file chooser dialog. | |
Glib::RefPtr< Gio::File > | get_initial_folder () |
Gets the folder that will be set as the initial folder in the file chooser dialog. | |
Glib::RefPtr< const Gio::File > | get_initial_folder () const |
Gets the folder that will be set as the initial folder in the file chooser dialog. | |
void | set_initial_folder (const Glib::RefPtr< Gio::File > &folder) |
Sets the folder that will be set as the initial folder in the file chooser dialog. | |
std::string | get_initial_name () const |
Gets the name for the file that should be initially set. | |
void | set_initial_name (const std::string & name) |
Sets the name for the file that should be initially set. | |
Glib::RefPtr< Gio::File > | get_initial_file () |
Gets the file that will be initially selected in the file chooser dialog. | |
Glib::RefPtr< const Gio::File > | get_initial_file () const |
Gets the file that will be initially selected in the file chooser dialog. | |
void | set_initial_file (const Glib::RefPtr< Gio::File > & file) |
Sets the file that will be initially selected in the file chooser dialog. | |
Glib::ustring | get_accept_label () const |
Retrieves the text used by the dialog on its accept button. | |
void | set_accept_label (const Glib::ustring &accept_label) |
Sets the label shown on the file chooser's accept button. | |
void | open (Window & parent, const Gio::SlotAsyncReady &slot, const Glib::RefPtr< Gio::Cancellable > &cancellable={}) |
This function initiates a file selection operation by presenting a file chooser dialog to the user. | |
void | open (const Gio::SlotAsyncReady &slot, const Glib::RefPtr< Gio::Cancellable > &cancellable={}) |
A open() convenience overload. | |
Glib::RefPtr< Gio::File > | open_finish (const Glib::RefPtr< Gio::AsyncResult > &result) |
Finishes the open() call and returns the resulting file. | |
void | select_folder (Window & parent, const Gio::SlotAsyncReady &slot, const Glib::RefPtr< Gio::Cancellable > &cancellable={}) |
This function initiates a directory selection operation by presenting a file chooser dialog to the user. | |
void | select_folder (const Gio::SlotAsyncReady &slot, const Glib::RefPtr< Gio::Cancellable > &cancellable={}) |
A select_folder() convenience overload. | |
Glib::RefPtr< Gio::File > | select_folder_finish (const Glib::RefPtr< Gio::AsyncResult > &result) |
Finishes the select_folder() call and returns the resulting file. | |
void | save (Window & parent, const Gio::SlotAsyncReady &slot, const Glib::RefPtr< Gio::Cancellable > &cancellable={}) |
This function initiates a file save operation by presenting a file chooser dialog to the user. | |
void | save (const Gio::SlotAsyncReady &slot, const Glib::RefPtr< Gio::Cancellable > &cancellable={}) |
A save() convenience overload. | |
Glib::RefPtr< Gio::File > | save_finish (const Glib::RefPtr< Gio::AsyncResult > &result) |
Finishes the save() call and returns the resulting file. | |
void | open_multiple (Window & parent, const Gio::SlotAsyncReady &slot, const Glib::RefPtr< Gio::Cancellable > &cancellable={}) |
This function initiates a multi-file selection operation by presenting a file chooser dialog to the user. | |
void | open_multiple (const Gio::SlotAsyncReady &slot, const Glib::RefPtr< Gio::Cancellable > &cancellable={}) |
A open_multiple() convenience overload. | |
std::vector< Glib::RefPtr< Gio::File > > | open_multiple_finish (const Glib::RefPtr< Gio::AsyncResult > &result) |
Finishes the open_multiple() call and returns the resulting files in a std::vector. | |
void | select_multiple_folders (Window & parent, const Gio::SlotAsyncReady &slot, const Glib::RefPtr< Gio::Cancellable > &cancellable={}) |
This function initiates a multi-directory selection operation by presenting a file chooser dialog to the user. | |
void | select_multiple_folders (const Gio::SlotAsyncReady &slot, const Glib::RefPtr< Gio::Cancellable > &cancellable={}) |
A select_multiple_folders() convenience overload. | |
std::vector< Glib::RefPtr< Gio::File > > | select_multiple_folders_finish (const Glib::RefPtr< Gio::AsyncResult > &result) |
Finishes the select_multiple_folders() call and returns the resulting files in a std::vector. | |
Glib::PropertyProxy< Glib::ustring > | property_title () |
A title that may be shown on the file chooser dialog. | |
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_title () const |
A title that may be shown on the file chooser dialog. | |
Glib::PropertyProxy< bool > | property_modal () |
Whether the file chooser dialog is modal. | |
Glib::PropertyProxy_ReadOnly< bool > | property_modal () const |
Whether the file chooser dialog is modal. | |
Glib::PropertyProxy< Glib::RefPtr< Gio::ListModel > > | property_filters () |
The list of filters. | |
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gio::ListModel > > | property_filters () const |
The list of filters. | |
Glib::PropertyProxy< Glib::RefPtr< FileFilter > > | property_default_filter () |
The default filter, that is, the filter that is initially active in the file chooser dialog. | |
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< FileFilter > > | property_default_filter () const |
The default filter, that is, the filter that is initially active in the file chooser dialog. | |
Glib::PropertyProxy< Glib::RefPtr< Gio::File > > | property_initial_file () |
The initial file, that is, the file that is initially selected in the file chooser dialog. | |
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gio::File > > | property_initial_file () const |
The initial file, that is, the file that is initially selected in the file chooser dialog. | |
Glib::PropertyProxy< Glib::RefPtr< Gio::File > > | property_initial_folder () |
The initial folder, that is, the directory that is initially opened in the file chooser dialog. | |
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gio::File > > | property_initial_folder () const |
The initial folder, that is, the directory that is initially opened in the file chooser dialog. | |
Glib::PropertyProxy< std::string > | property_initial_name () |
The initial name, that is, the filename that is initially selected in the file chooser dialog. | |
Glib::PropertyProxy_ReadOnly< std::string > | property_initial_name () const |
The initial name, that is, the filename that is initially selected in the file chooser dialog. | |
Glib::PropertyProxy< Glib::ustring > | property_accept_label () |
Label for the file chooser's accept button. | |
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_accept_label () const |
Label for the file chooser's accept button. | |
Static Public Member Functions | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
static Glib::RefPtr< FileDialog > | create () |
Protected Member Functions | |
FileDialog () | |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Gtk::FileDialog > | wrap (GtkFileDialog *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
A Gtk::FileDialog 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 open(), save(), etc. These APIs follow the GIO async pattern, and the result can be obtained by calling the corresponding finish function, for example open_finish().
|
noexcept |
|
overridenoexcept |
|
protected |
|
static |
Glib::ustring Gtk::FileDialog::get_accept_label | ( | ) | const |
Retrieves the text used by the dialog on its accept button.
Glib::RefPtr< FileFilter > Gtk::FileDialog::get_default_filter | ( | ) |
Gets the filter that will be selected by default in the file chooser dialog.
Glib::RefPtr< const FileFilter > Gtk::FileDialog::get_default_filter | ( | ) | const |
Gets the filter that will be selected by default in the file chooser dialog.
Glib::RefPtr< Gio::ListModel > Gtk::FileDialog::get_filters | ( | ) |
Gets the filters that will be offered to the user in the file chooser dialog.
Gio::ListModel
of Gtk::FileFilters
. Glib::RefPtr< const Gio::ListModel > Gtk::FileDialog::get_filters | ( | ) | const |
Gets the filters that will be offered to the user in the file chooser dialog.
Gio::ListModel
of Gtk::FileFilters
. Glib::RefPtr< Gio::File > Gtk::FileDialog::get_initial_file | ( | ) |
Gets the file that will be initially selected in the file chooser dialog.
Glib::RefPtr< const Gio::File > Gtk::FileDialog::get_initial_file | ( | ) | const |
Gets the file that will be initially selected in the file chooser dialog.
Glib::RefPtr< Gio::File > Gtk::FileDialog::get_initial_folder | ( | ) |
Gets the folder that will be set as the initial folder in the file chooser dialog.
Glib::RefPtr< const Gio::File > Gtk::FileDialog::get_initial_folder | ( | ) | const |
Gets the folder that will be set as the initial folder in the file chooser dialog.
std::string Gtk::FileDialog::get_initial_name | ( | ) | const |
bool Gtk::FileDialog::get_modal | ( | ) | const |
Returns whether the file chooser dialog blocks interaction with the parent window while it is presented.
true
if the file chooser dialog is modal. Glib::ustring Gtk::FileDialog::get_title | ( | ) | const |
Returns the title that will be shown on the file chooser dialog.
|
static |
Get the GType for this class, for use with the underlying GObject type system.
|
inline |
Provides access to the underlying C GObject.
|
inline |
Provides access to the underlying C GObject.
GtkFileDialog * Gtk::FileDialog::gobj_copy | ( | ) |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
void Gtk::FileDialog::open | ( | const Gio::SlotAsyncReady & | slot, |
const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} |
||
) |
A open() convenience overload.
void Gtk::FileDialog::open | ( | Window & | parent, |
const Gio::SlotAsyncReady & | slot, | ||
const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} |
||
) |
This function initiates a file selection operation by presenting a file chooser dialog to the user.
The slot will be called when the dialog is dismissed.
parent | The parent Gtk::Window . |
cancellable | A Cancellable to cancel the operation. |
slot | A callback to call when the operation is complete. |
Glib::RefPtr< Gio::File > Gtk::FileDialog::open_finish | ( | const Glib::RefPtr< Gio::AsyncResult > & | result | ) |
Finishes the open() call and returns the resulting file.
result | A Gio::AsyncResult . |
nullptr
is returned and error is set.Gtk::DialogError |
void Gtk::FileDialog::open_multiple | ( | const Gio::SlotAsyncReady & | slot, |
const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} |
||
) |
A open_multiple() convenience overload.
void Gtk::FileDialog::open_multiple | ( | Window & | parent, |
const Gio::SlotAsyncReady & | slot, | ||
const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} |
||
) |
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_initial_folder().
The slot will be called when the dialog is dismissed.
parent | The parent Gtk::Window . |
cancellable | A Cancellable to cancel the operation. |
slot | A callback to call when the operation is complete. |
std::vector< Glib::RefPtr< Gio::File > > Gtk::FileDialog::open_multiple_finish | ( | const Glib::RefPtr< Gio::AsyncResult > & | result | ) |
Finishes the open_multiple() call and returns the resulting files in a std::vector.
result | A Gio::AsyncResult . |
Gio::File
s. Otherwise, an exception is thrown.Gtk::DialogError |
|
noexcept |
Glib::PropertyProxy< Glib::ustring > Gtk::FileDialog::property_accept_label | ( | ) |
Label for the file chooser's accept button.
Default value: ""
Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::FileDialog::property_accept_label | ( | ) | const |
Label for the file chooser's accept button.
Default value: ""
Glib::PropertyProxy< Glib::RefPtr< FileFilter > > Gtk::FileDialog::property_default_filter | ( | ) |
The default filter, that is, the filter that is initially active in the file chooser dialog.
If the default filter is nullptr
, the first filter of property_filters() is used as the default filter. If that property contains no filter, the dialog will be unfiltered.
If property_filters() is not nullptr
, the default filter should be part of the list. If it is not, the dialog may choose to not make it available.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< FileFilter > > Gtk::FileDialog::property_default_filter | ( | ) | const |
The default filter, that is, the filter that is initially active in the file chooser dialog.
If the default filter is nullptr
, the first filter of property_filters() is used as the default filter. If that property contains no filter, the dialog will be unfiltered.
If property_filters() is not nullptr
, the default filter should be part of the list. If it is not, the dialog may choose to not make it available.
Glib::PropertyProxy< Glib::RefPtr< Gio::ListModel > > Gtk::FileDialog::property_filters | ( | ) |
The list of filters.
See property_default_filter() about how those two properties interact.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gio::ListModel > > Gtk::FileDialog::property_filters | ( | ) | const |
The list of filters.
See property_default_filter() about how those two properties interact.
Glib::PropertyProxy< Glib::RefPtr< Gio::File > > Gtk::FileDialog::property_initial_file | ( | ) |
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_initial_folder() and property_initial_name().
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gio::File > > Gtk::FileDialog::property_initial_file | ( | ) | const |
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_initial_folder() and property_initial_name().
Glib::PropertyProxy< Glib::RefPtr< Gio::File > > Gtk::FileDialog::property_initial_folder | ( | ) |
The initial folder, that is, the directory that is initially opened in the file chooser dialog.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gio::File > > Gtk::FileDialog::property_initial_folder | ( | ) | const |
The initial folder, that is, the directory that is initially opened in the file chooser dialog.
Glib::PropertyProxy< std::string > Gtk::FileDialog::property_initial_name | ( | ) |
The initial name, that is, the filename that is initially selected in the file chooser dialog.
Default value: ""
Glib::PropertyProxy_ReadOnly< std::string > Gtk::FileDialog::property_initial_name | ( | ) | const |
The initial name, that is, the filename that is initially selected in the file chooser dialog.
Default value: ""
Glib::PropertyProxy< bool > Gtk::FileDialog::property_modal | ( | ) |
Whether the file chooser dialog is modal.
Default value: true
Glib::PropertyProxy_ReadOnly< bool > Gtk::FileDialog::property_modal | ( | ) | const |
Whether the file chooser dialog is modal.
Default value: true
Glib::PropertyProxy< Glib::ustring > Gtk::FileDialog::property_title | ( | ) |
A title that may be shown on the file chooser dialog.
Default value: ""
Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::FileDialog::property_title | ( | ) | const |
A title that may be shown on the file chooser dialog.
Default value: ""
void Gtk::FileDialog::save | ( | const Gio::SlotAsyncReady & | slot, |
const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} |
||
) |
A save() convenience overload.
void Gtk::FileDialog::save | ( | Window & | parent, |
const Gio::SlotAsyncReady & | slot, | ||
const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} |
||
) |
This function initiates a file save operation by presenting a file chooser dialog to the user.
The slot will be called when the dialog is dismissed.
parent | The parent Gtk::Window . |
cancellable | A Cancellable to cancel the operation. |
slot | A callback to call when the operation is complete. |
Glib::RefPtr< Gio::File > Gtk::FileDialog::save_finish | ( | const Glib::RefPtr< Gio::AsyncResult > & | result | ) |
Finishes the save() call and returns the resulting file.
result | A Gio::AsyncResult . |
nullptr
is returned and error is set.Gtk::DialogError |
void Gtk::FileDialog::select_folder | ( | const Gio::SlotAsyncReady & | slot, |
const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} |
||
) |
A select_folder() convenience overload.
void Gtk::FileDialog::select_folder | ( | Window & | parent, |
const Gio::SlotAsyncReady & | slot, | ||
const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} |
||
) |
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_initial_folder().
The slot will be called when the dialog is dismissed.
parent | The parent Gtk::Window . |
cancellable | A Cancellable to cancel the operation. |
slot | A callback to call when the operation is complete. |
Glib::RefPtr< Gio::File > Gtk::FileDialog::select_folder_finish | ( | const Glib::RefPtr< Gio::AsyncResult > & | result | ) |
Finishes the select_folder() call and returns the resulting file.
result | A Gio::AsyncResult . |
nullptr
is returned and error is set.Gtk::DialogError |
void Gtk::FileDialog::select_multiple_folders | ( | const Gio::SlotAsyncReady & | slot, |
const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} |
||
) |
A select_multiple_folders() convenience overload.
void Gtk::FileDialog::select_multiple_folders | ( | Window & | parent, |
const Gio::SlotAsyncReady & | slot, | ||
const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} |
||
) |
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_initial_folder().
The slot will be called when the dialog is dismissed.
parent | The parent Gtk::Window . |
cancellable | A Cancellable to cancel the operation. |
slot | A callback to call when the operation is complete. |
std::vector< Glib::RefPtr< Gio::File > > Gtk::FileDialog::select_multiple_folders_finish | ( | const Glib::RefPtr< Gio::AsyncResult > & | result | ) |
Finishes the select_multiple_folders() call and returns the resulting files in a std::vector.
result | A Gio::AsyncResult. |
Gio::File
s. Otherwise, an exception is thrown.Gtk::DialogError |
Sets the label shown on the file chooser's accept button.
Leaving the accept label unset or setting it as nullptr
will fall back to a default label, depending on what API is used to launch the file dialog.
accept_label | The new accept label. |
void Gtk::FileDialog::set_default_filter | ( | const Glib::RefPtr< FileFilter > & | filter | ) |
Sets the filter that will be selected by default in the file chooser dialog.
If set to nullptr
, the first item in property_filters() will be used as the default filter. If that list is empty, the dialog will be unfiltered.
filter | A Gtk::FileFilter . |
Sets the filters that will be offered to the user in the file chooser dialog.
filters | A Gio::ListModel of Gtk::FileFilters . |
Sets the file that will be initially selected in the file chooser dialog.
This function is a shortcut for calling both set_initial_folder() and set_initial_name() with the directory and name of file respectively.
file | A Gio::File . |
Sets the folder that will be set as the initial folder in the file chooser dialog.
folder | A Gio::File . |
void Gtk::FileDialog::set_initial_name | ( | const std::string & | name | ) |
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_initial_folder(), the dialog should preselect it.
name | A UTF8 string. |
Sets whether the file chooser dialog blocks interaction with the parent window while it is presented.
modal | The new value. |
Sets the title that will be shown on the file chooser dialog.
title | The new title. |
|
related |
A Glib::wrap() method for this object.
object | The C instance. |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |