gtkmm 4.18.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>
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 () | |
![]() | |
Object () | |
Object (const Glib::ConstructParams &construct_params) | |
Object (GObject *castitem) | |
~Object () noexcept override | |
![]() | |
ObjectBase () | |
ObjectBase (const char *custom_type_name) | |
ObjectBase (const std::type_info &custom_type_info) | |
ObjectBase (ObjectBase &&src) noexcept | |
ObjectBase & | operator= (ObjectBase &&src) noexcept |
virtual | ~ObjectBase () noexcept=0 |
void | initialize (GObject *castitem) |
void | initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper) |
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. | |
Additional Inherited Members | |
![]() | |
typedef void(*)(gpointer data | DestroyNotify) |
![]() | |
typedef internal::func_destroy_notify | func_destroy_notify |
![]() | |
typedef internal::func_destroy_notify | func_destroy_notify |
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.
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.
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.
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 = {} |
||
) |
Presents a file chooser dialog to the user.
The file chooser dialog will be set up to select a single file.
The slot will be called when the dialog is dismissed.
parent | The parent 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.
result | The result. |
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 = {} |
||
) |
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 property_initial_folder().
The slot will be called when the dialog is dismissed.
parent | The parent 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 |
void Gtk::FileDialog::open_multiple_text_files | ( | const Gio::SlotAsyncReady & | slot, |
const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} |
||
) |
A open_multiple_text_files() convenience overload.
void Gtk::FileDialog::open_multiple_text_files | ( | Window & | parent, |
const Gio::SlotAsyncReady & | slot, | ||
const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} |
||
) |
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 property_initial_folder().
In contrast to open(), this function lets the user select the text encoding for the files, if possible.
The slot will be called when the dialog is dismissed.
parent | The parent window. |
cancellable | A cancellable to cancel the operation. |
slot | A callback to call when the operation is complete. |
std::tuple< std::vector< Glib::RefPtr< Gio::File > >, Glib::ustring > Gtk::FileDialog::open_multiple_text_files_finish | ( | const Glib::RefPtr< Gio::AsyncResult > & | result | ) |
Finishes the open_multiple_text_files() call.
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 an empty string.
result | A Gio::AsyncResult . |
Gio::File
s, and the text encoding to use. Gtk::DialogError |
void Gtk::FileDialog::open_text_file | ( | const Gio::SlotAsyncReady & | slot, |
const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} |
||
) |
A open_text_file() convenience overload.
void Gtk::FileDialog::open_text_file | ( | Window & | parent, |
const Gio::SlotAsyncReady & | slot, | ||
const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} |
||
) |
Initiates a file selection operation by presenting a file chooser dialog to the user.
In contrast to open(), this function lets the user select the text encoding for the file, if possible.
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::tuple< Glib::RefPtr< Gio::File >, Glib::ustring > Gtk::FileDialog::open_text_file_finish | ( | const Glib::RefPtr< Gio::AsyncResult > & | result | ) |
Finishes the 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 an empty string.
result | A Gio::AsyncResult . |
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.
This filter 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.
This filter 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 these 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 these two properties interact.
Glib::PropertyProxy< Glib::RefPtr< Gio::File > > Gtk::FileDialog::property_initial_file | ( | ) |
The initial file.
This file 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.
This file 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.
This 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.
This is the directory that is initially opened in the file chooser dialog.
Glib::PropertyProxy< std::string > Gtk::FileDialog::property_initial_name | ( | ) |
The initial name.
This is the name of the file 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.
This is the name of the file 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 = {} |
||
) |
Presents a file chooser dialog to the user.
The file chooser dialog will be save mode.
The slot will be called when the dialog is dismissed.
parent | The parent 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.
result | The result. |
Gtk::DialogError |
void Gtk::FileDialog::save_text_file | ( | const Gio::SlotAsyncReady & | slot, |
const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} |
||
) |
A save_text_file() convenience overload.
void Gtk::FileDialog::save_text_file | ( | Window & | parent, |
const Gio::SlotAsyncReady & | slot, | ||
const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} |
||
) |
Initiates a file save operation by presenting a file chooser dialog to the user.
In contrast to save(), this function lets the user select the text encoding and line endings for the text file, if possible.
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::tuple< Glib::RefPtr< Gio::File >, Glib::ustring, Glib::ustring > Gtk::FileDialog::save_text_file_finish | ( | const Glib::RefPtr< Gio::AsyncResult > & | result | ) |
Finishes the 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 an empty string.
The line_ending will be set to one of "\\n", "\\r\\n", "\\r" or "", where the latter means to preserve existing line endings.
result | A Gio::AsyncResult . |
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 = {} |
||
) |
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 property_initial_folder().
The slot will be called when the dialog is dismissed.
parent | The parent 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.
result | The result. |
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 = {} |
||
) |
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 property_initial_folder().
The slot will be called when the dialog is dismissed.
parent | The parent 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 |
void Gtk::FileDialog::set_accept_label | ( | const Glib::ustring & | accept_label | ) |
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 | The file filter. |
void Gtk::FileDialog::set_filters | ( | const Glib::RefPtr< Gio::ListModel > & | filters | ) |
Sets the filters that will be offered to the user in the file chooser dialog.
filters | A list model of Gtk::FileFilter. |
void Gtk::FileDialog::set_initial_file | ( | const Glib::RefPtr< Gio::File > & | file | ) |
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 file. |
void Gtk::FileDialog::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.
folder | A file. |
void Gtk::FileDialog::set_initial_name | ( | const std::string & | 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 property_initial_folder(), the dialog will preselect it.
name | A string. |
Sets whether the file chooser dialog blocks interaction with the parent window while it is presented.
modal | The new value. |
void Gtk::FileDialog::set_title | ( | const Glib::ustring & | title | ) |
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. |