gtkmm: Gtk::FileDialog Class Reference

gtkmm 4.14.0

Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Symbols | List of all members
Gtk::FileDialog Class Reference
Dialogs

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>`

Inheritance diagram for Gtk::FileDialog:
[legend]

## 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
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.

## Detailed Description

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().

Since gtkmm 4.10

## Constructor & Destructor Documentation

## ◆ FileDialog() [1/2]

Gtk::FileDialog::FileDialog | ( | FileDialog && | src | ) |
| noexcept

## ◆ ~FileDialog()

Gtk::FileDialog::~FileDialog | ( |  | ) |
| overridenoexcept

## ◆ FileDialog() [2/2]

Gtk::FileDialog::FileDialog | ( |  | ) |
| protected

## Member Function Documentation

## ◆ create()

static Glib::RefPtr< FileDialog > Gtk::FileDialog::create | ( |  | ) |
| static

## ◆ get_accept_label()

Glib::ustring Gtk::FileDialog::get_accept_label | ( |  | ) | const

Since gtkmm 4.10

Returns
  The label shown on the file chooser's accept button.

## ◆ get_default_filter() [1/2]

Glib::RefPtr< FileFilter > Gtk::FileDialog::get_default_filter | ( |  | ) |

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

Since gtkmm 4.10

Returns
  The current filter.

## ◆ get_default_filter() [2/2]

Glib::RefPtr< const FileFilter > Gtk::FileDialog::get_default_filter | ( |  | ) | const

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

Since gtkmm 4.10

Returns
  The current filter.

## ◆ get_filters() [1/2]

Glib::RefPtr< Gio::ListModel > Gtk::FileDialog::get_filters | ( |  | ) |

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

Since gtkmm 4.10

Returns
  The filters, as a `Gio::ListModel` of `Gtk::FileFilters`.

## ◆ get_filters() [2/2]

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.

Since gtkmm 4.10

Returns
  The filters, as a `Gio::ListModel` of `Gtk::FileFilters`.

## ◆ get_initial_file() [1/2]

Glib::RefPtr< Gio::File > Gtk::FileDialog::get_initial_file | ( |  | ) |

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

Since gtkmm 4.10

Returns
  The file.

## ◆ get_initial_file() [2/2]

Glib::RefPtr< const Gio::File > Gtk::FileDialog::get_initial_file | ( |  | ) | const

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

Since gtkmm 4.10

Returns
  The file.

## ◆ get_initial_folder() [1/2]

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.

Since gtkmm 4.10

Returns
  The folder.

## ◆ get_initial_folder() [2/2]

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.

Since gtkmm 4.10

Returns
  The folder.

## ◆ get_initial_name()

std::string Gtk::FileDialog::get_initial_name | ( |  | ) | const

Gets the name for the file that should be initially set.

Since gtkmm 4.10

Returns
  The name.

## ◆ get_modal()

bool Gtk::FileDialog::get_modal | ( |  | ) | const

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

Since gtkmm 4.10

Returns
  `true` if the file chooser dialog is modal.

## ◆ get_title()

Glib::ustring Gtk::FileDialog::get_title | ( |  | ) | const

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

Since gtkmm 4.10

Returns
  The title.

## ◆ get_type()

static GType Gtk::FileDialog::get_type | ( |  | ) |
| static

Get the GType for this class, for use with the underlying GObject type system.

## ◆ gobj() [1/2]

GtkFileDialog * Gtk::FileDialog::gobj | ( |  | ) |
| inline

Provides access to the underlying C GObject.

## ◆ gobj() [2/2]

const GtkFileDialog * Gtk::FileDialog::gobj | ( |  | ) | const
| inline

Provides access to the underlying C GObject.

## ◆ gobj_copy()

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.

## ◆ open() [1/2]

void Gtk::FileDialog::open | ( | const Gio::SlotAsyncReady & | slot,
|  | const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} )

A open() convenience overload.

## ◆ open() [2/2]

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. It should call open_finish() to obtain the result.

Since gtkmm 4.10

Parameters

  parent | The parent `Gtk::Window`.
  cancellable | A `Cancellable` to cancel the operation.
  slot | A callback to call when the operation is complete.

## ◆ open_finish()

Glib::RefPtr< Gio::File > Gtk::FileDialog::open_finish | ( | const Glib::RefPtr< Gio::AsyncResult > & | result | ) |

Finishes the open() call and returns the resulting file.

Since gtkmm 4.10

Parameters

  result | A `Gio::AsyncResult`.

Returns
  The file that was selected. Otherwise, `nullptr` is returned and error is set.

Exceptions

  Gtk::DialogError |

## ◆ open_multiple() [1/2]

void Gtk::FileDialog::open_multiple | ( | const Gio::SlotAsyncReady & | slot,
|  | const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} )

A open_multiple() convenience overload.

## ◆ open_multiple() [2/2]

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. It should call open_multiple_finish() to obtain the result.

Since gtkmm 4.10

Parameters

  parent | The parent `Gtk::Window`.
  cancellable | A `Cancellable` to cancel the operation.
  slot | A callback to call when the operation is complete.

## ◆ open_multiple_finish()

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.

Since gtkmm 4.10

Parameters

  result | A `Gio::AsyncResult`.

Returns
  The files that were selected, as a vector of `Gio::File`s. Otherwise, an exception is thrown.

Exceptions

  Gtk::DialogError |

## ◆ operator=()

FileDialog & Gtk::FileDialog::operator= | ( | FileDialog && | src | ) |
| noexcept

## ◆ property_accept_label() [1/2]

Glib::PropertyProxy< Glib::ustring > Gtk::FileDialog::property_accept_label | ( |  | ) |

Label for the file chooser's accept button.

Since gtkmm 4.10

Default value: ""

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_accept_label() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::FileDialog::property_accept_label | ( |  | ) | const

Label for the file chooser's accept button.

Since gtkmm 4.10

Default value: ""

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_default_filter() [1/2]

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.

Since gtkmm 4.10

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_default_filter() [2/2]

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.

Since gtkmm 4.10

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_filters() [1/2]

Glib::PropertyProxy< Glib::RefPtr< Gio::ListModel > > Gtk::FileDialog::property_filters | ( |  | ) |

The list of filters.

See property_default_filter() about how those two properties interact.

Since gtkmm 4.10

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_filters() [2/2]

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.

Since gtkmm 4.10

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_initial_file() [1/2]

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().

Since gtkmm 4.10

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_initial_file() [2/2]

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().

Since gtkmm 4.10

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_initial_folder() [1/2]

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.

Since gtkmm 4.10

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_initial_folder() [2/2]

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.

Since gtkmm 4.10

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_initial_name() [1/2]

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.

Since gtkmm 4.10

Default value: ""

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_initial_name() [2/2]

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.

Since gtkmm 4.10

Default value: ""

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_modal() [1/2]

Glib::PropertyProxy< bool > Gtk::FileDialog::property_modal | ( |  | ) |

Whether the file chooser dialog is modal.

Since gtkmm 4.10

Default value: `true`

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_modal() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gtk::FileDialog::property_modal | ( |  | ) | const

Whether the file chooser dialog is modal.

Since gtkmm 4.10

Default value: `true`

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_title() [1/2]

Glib::PropertyProxy< Glib::ustring > Gtk::FileDialog::property_title | ( |  | ) |

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

Since gtkmm 4.10

Default value: ""

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_title() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::FileDialog::property_title | ( |  | ) | const

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

Since gtkmm 4.10

Default value: ""

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ save() [1/2]

void Gtk::FileDialog::save | ( | const Gio::SlotAsyncReady & | slot,
|  | const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} )

A save() convenience overload.

## ◆ save() [2/2]

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. It should call save_finish() to obtain the result.

Since gtkmm 4.10

Parameters

  parent | The parent `Gtk::Window`.
  cancellable | A `Cancellable` to cancel the operation.
  slot | A callback to call when the operation is complete.

## ◆ save_finish()

Glib::RefPtr< Gio::File > Gtk::FileDialog::save_finish | ( | const Glib::RefPtr< Gio::AsyncResult > & | result | ) |

Finishes the save() call and returns the resulting file.

Since gtkmm 4.10

Parameters

  result | A `Gio::AsyncResult`.

Returns
  The file that was selected. Otherwise, `nullptr` is returned and error is set.

Exceptions

  Gtk::DialogError |

## ◆ select_folder() [1/2]

void Gtk::FileDialog::select_folder | ( | const Gio::SlotAsyncReady & | slot,
|  | const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} )

A select_folder() convenience overload.

## ◆ select_folder() [2/2]

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. It should call select_folder_finish() to obtain the result.

Since gtkmm 4.10

Parameters

  parent | The parent `Gtk::Window`.
  cancellable | A `Cancellable` to cancel the operation.
  slot | A callback to call when the operation is complete.

## ◆ select_folder_finish()

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.

Since gtkmm 4.10

Parameters

  result | A `Gio::AsyncResult`.

Returns
  The file that was selected. Otherwise, `nullptr` is returned and error is set.

Exceptions

  Gtk::DialogError |

## ◆ select_multiple_folders() [1/2]

void Gtk::FileDialog::select_multiple_folders | ( | const Gio::SlotAsyncReady & | slot,
|  | const Glib::RefPtr< Gio::Cancellable > & | cancellable = {} )

A select_multiple_folders() convenience overload.

## ◆ select_multiple_folders() [2/2]

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. It should call select_multiple_folders_finish() to obtain the result.

Since gtkmm 4.10

Parameters

  parent | The parent `Gtk::Window`.
  cancellable | A `Cancellable` to cancel the operation.
  slot | A callback to call when the operation is complete.

## ◆ select_multiple_folders_finish()

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.

Since gtkmm 4.10

Parameters

  result | A Gio::AsyncResult.

Returns
  The files that were selected, as a vector of `Gio::File`s. Otherwise, an exception is thrown.

Exceptions

  Gtk::DialogError |

## ◆ set_accept_label()

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.

Since gtkmm 4.10

Parameters

  accept_label | The new accept label.

## ◆ set_default_filter()

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.

Since gtkmm 4.10

Parameters

  filter | A `Gtk::FileFilter`.

## ◆ set_filters()

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.

Since gtkmm 4.10

Parameters

  filters | A `Gio::ListModel` of `Gtk::FileFilters`.

## ◆ set_initial_file()

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.

Since gtkmm 4.10

Parameters

  file | A `Gio::File`.

## ◆ set_initial_folder()

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.

Since gtkmm 4.10

Parameters

  folder | A `Gio::File`.

## ◆ set_initial_name()

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.

Since gtkmm 4.10

Parameters

  name | A UTF8 string.

## ◆ set_modal()

void Gtk::FileDialog::set_modal | ( | bool | modal = true | ) |

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

Since gtkmm 4.10

Parameters

  modal | The new value.

## ◆ set_title()

void Gtk::FileDialog::set_title | ( | const Glib::ustring & | title | ) |

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

Since gtkmm 4.10

Parameters

  title | The new title.

## Friends And Related Symbol Documentation

## ◆ wrap()

Glib::RefPtr< Gtk::FileDialog > wrap | ( | GtkFileDialog * | object,
|  | bool | take_copy = false )
| related

A Glib::wrap() method for this object.

Parameters

  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.

Returns
  A C++ instance that wraps this C instance.