gtkmm 4.16.0
|
File chooser interface used by Gtk::FileChooserWidget and Gtk::FileChooserDialog. More...
#include <gtkmm/filechooser.h>
Public Types | |
enum class | Action { OPEN , SAVE , SELECT_FOLDER } |
Public Member Functions | |
FileChooser (FileChooser &&src) noexcept | |
FileChooser & | operator= (FileChooser &&src) noexcept |
~FileChooser () noexcept override | |
GtkFileChooser * | gobj () |
Provides access to the underlying C GObject. | |
const GtkFileChooser * | gobj () const |
Provides access to the underlying C GObject. | |
void | set_action (Action action) |
Sets the type of operation that the chooser is performing. | |
Action | get_action () const |
Gets the type of operation that the file chooser is performing. | |
void | set_select_multiple (bool select_multiple=true) |
Sets whether multiple files can be selected in the file chooser. | |
bool | get_select_multiple () const |
Gets whether multiple files can be selected in the file chooser. | |
void | set_create_folders (bool create_folders=true) |
Sets whether file chooser will offer to create new folders. | |
bool | get_create_folders () const |
Gets whether file chooser will offer to create new folders. | |
void | set_current_name (const Glib::ustring & name) |
Sets the current name in the file selector, as if entered by the user. | |
Glib::ustring | get_current_name () const |
Gets the current name in the file selector, as entered by the user. | |
bool | set_file (const Glib::RefPtr< const Gio::File > & file) |
Sets file as the current filename for the file chooser. | |
Glib::RefPtr< Gio::ListModel > | get_files () |
Lists all the selected files and subfolders in the current folder of chooser as Gio::File . | |
Glib::RefPtr< const Gio::ListModel > | get_files () const |
Lists all the selected files and subfolders in the current folder of chooser as Gio::File . | |
std::vector< Glib::RefPtr< Gio::File > > | get_files2 () |
Lists all the selected files and subfolders in the current folder of chooser as Gio::File. | |
std::vector< Glib::RefPtr< const Gio::File > > | get_files2 () const |
Lists all the selected files and subfolders in the current folder of chooser as Gio::File. | |
bool | set_current_folder (const Glib::RefPtr< const Gio::File > & file) |
Sets the current folder for chooser from a Gio::File . | |
Glib::RefPtr< Gio::File > | get_current_folder () |
Gets the current folder of chooser as Gio::File . | |
Glib::RefPtr< const Gio::File > | get_current_folder () const |
Gets the current folder of chooser as Gio::File . | |
Glib::RefPtr< Gio::File > | get_file () |
Gets the Gio::File for the currently selected file in the file selector. | |
Glib::RefPtr< const Gio::File > | get_file () const |
Gets the Gio::File for the currently selected file in the file selector. | |
void | add_filter (const Glib::RefPtr< FileFilter > &filter) |
Adds filter to the list of filters that the user can select between. | |
void | remove_filter (const Glib::RefPtr< FileFilter > &filter) |
Removes filter from the list of filters that the user can select between. | |
Glib::RefPtr< const Gio::ListModel > | get_filters () const |
Gets the current set of user-selectable filters, as a list model. | |
void | set_filter (const Glib::RefPtr< FileFilter > &filter) |
Sets the current filter. | |
Glib::RefPtr< FileFilter > | get_filter () |
Gets the current filter. | |
Glib::RefPtr< const FileFilter > | get_filter () const |
Gets the current filter. | |
bool | add_shortcut_folder (const Glib::RefPtr< Gio::File > &folder) |
Adds a folder to be displayed with the shortcut folders in a file chooser. | |
bool | remove_shortcut_folder (const Glib::RefPtr< Gio::File > &folder) |
Removes a folder from the shortcut folders in a file chooser. | |
Glib::RefPtr< const Gio::ListModel > | get_shortcut_folders () const |
Queries the list of shortcut folders in the file chooser. | |
std::vector< Glib::RefPtr< Gio::File > > | get_shortcut_folders2 () |
Queries the list of shortcut folders in the file chooser. | |
void | add_choice (const Glib::ustring & id, const Glib::ustring &label, const std::vector< Glib::ustring > &options, const std::vector< Glib::ustring > &option_labels) |
Adds a 'choice' to the file chooser. | |
void | add_choice (const Glib::ustring & id, const Glib::ustring &label) |
Adds a boolean 'choice' to the file chooser. | |
void | remove_choice (const Glib::ustring & id) |
Removes a 'choice' that has been added with add_choice(). | |
void | set_choice (const Glib::ustring & id, const Glib::ustring &option) |
Selects an option in a 'choice' that has been added with add_choice(). | |
Glib::ustring | get_choice (const Glib::ustring & id) const |
Gets the currently selected option in the 'choice' with the given ID. | |
Glib::PropertyProxy< Action > | property_action () |
The type of operation that the file chooser is performing. | |
Glib::PropertyProxy_ReadOnly< Action > | property_action () const |
The type of operation that the file chooser is performing. | |
Glib::PropertyProxy< Glib::RefPtr< FileFilter > > | property_filter () |
The current filter for selecting files that are displayed. | |
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< FileFilter > > | property_filter () const |
The current filter for selecting files that are displayed. | |
Glib::PropertyProxy< bool > | property_select_multiple () |
Whether to allow multiple files to be selected. | |
Glib::PropertyProxy_ReadOnly< bool > | property_select_multiple () const |
Whether to allow multiple files to be selected. | |
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gio::ListModel > > | property_filters () const |
A Gio::ListModel containing the filters that have been added with Gtk::FileChooser::add_filter(). | |
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gio::ListModel > > | property_shortcut_folders () const |
A Gio::ListModel containing the shortcut folders that have been added with Gtk::FileChooser::add_shortcut_folder(). | |
Glib::PropertyProxy< bool > | property_create_folders () |
Whether a file chooser not in Gtk::FileChooser::Action::OPEN mode will offer the user to create new folders. | |
Glib::PropertyProxy_ReadOnly< bool > | property_create_folders () const |
Whether a file chooser not in Gtk::FileChooser::Action::OPEN mode will offer the user to create new folders. | |
Static Public Member Functions | |
static void | add_interface (GType gtype_implementer) |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
Protected Member Functions | |
FileChooser () | |
You should derive from this class to use it. | |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Gtk::FileChooser > | wrap (GtkFileChooser *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
File chooser interface used by Gtk::FileChooserWidget and Gtk::FileChooserDialog.
Gtk::FileChooser is an interface that can be implemented by file selection widgets. In gtkmm, the main objects that implement this interface are FileChooserWidget and FileChooserDialog. You do not need to write an object that implements the FileChooser interface unless you are trying to adapt an existing file selector to expose a standard programming interface.
Gtk::FileChooser allows for shortcuts to various places in the filesystem. In the default implementation these are displayed in the left pane. It may be a bit confusing at first that these shortcuts come from various sources and in various flavours, so lets explain the terminology here:
|
strong |
|
protected |
You should derive from this class to use it.
|
noexcept |
|
overridenoexcept |
Adds a boolean 'choice' to the file chooser.
This is typically implemented as a checkbutton. You can select a value using set_boolean_choice() before the dialog is shown, and you can obtain the user-selected value in the signal_response() signal handler using get_choice().
Compare set_extra_widget().
id | Id for the added choice. |
label | User-visible label for the added choice. |
void Gtk::FileChooser::add_choice | ( | const Glib::ustring & | id, |
const Glib::ustring & | label, | ||
const std::vector< Glib::ustring > & | options, | ||
const std::vector< Glib::ustring > & | option_labels | ||
) |
Adds a 'choice' to the file chooser.
This is typically implemented as a combobox or, for boolean choices, as a checkbutton. You can select a value using set_choice() before the dialog is shown, and you can obtain the user-selected value in the Gtk::Dialog::signal_response() signal handler using get_choice().
Deprecated: 4.10: Use Gtk::FileDialog instead
id | Id for the added choice. |
label | User-visible label for the added choice. |
options | Ids for the options of the choice, or nullptr for a boolean choice. |
option_labels | User-visible labels for the options, must be the same length as options. |
void Gtk::FileChooser::add_filter | ( | const Glib::RefPtr< FileFilter > & | filter | ) |
Adds filter to the list of filters that the user can select between.
When a filter is selected, only files that are passed by that filter are displayed.
Note that the chooser takes ownership of the filter if it is floating, so you have to ref and sink it if you want to keep a reference.
Deprecated: 4.10: Use Gtk::FileDialog instead
filter | A Gtk::FileFilter . |
bool Gtk::FileChooser::add_shortcut_folder | ( | const Glib::RefPtr< Gio::File > & | folder | ) |
Adds a folder to be displayed with the shortcut folders in a file chooser.
Deprecated: 4.10: Use Gtk::FileDialog instead
folder | A Gio::File for the folder to add. |
true
if the folder could be added successfully, false
otherwise.Glib::Error |
Action Gtk::FileChooser::get_action | ( | ) | const |
Gets the type of operation that the file chooser is performing.
Deprecated: 4.10: Use Gtk::FileDialog instead
Glib::ustring Gtk::FileChooser::get_choice | ( | const Glib::ustring & | id | ) | const |
Gets the currently selected option in the 'choice' with the given ID.
Deprecated: 4.10: Use Gtk::FileDialog instead
id | The ID of the choice to get. |
bool Gtk::FileChooser::get_create_folders | ( | ) | const |
Gets whether file chooser will offer to create new folders.
Deprecated: 4.10: Use Gtk::FileDialog instead
true
if the Create Folder button should be displayed. Glib::RefPtr< Gio::File > Gtk::FileChooser::get_current_folder | ( | ) |
Gets the current folder of chooser as Gio::File
.
Deprecated: 4.10: Use Gtk::FileDialog instead
Glib::RefPtr< const Gio::File > Gtk::FileChooser::get_current_folder | ( | ) | const |
Gets the current folder of chooser as Gio::File
.
Deprecated: 4.10: Use Gtk::FileDialog instead
Glib::ustring Gtk::FileChooser::get_current_name | ( | ) | const |
Gets the current name in the file selector, as entered by the user.
This is meant to be used in save dialogs, to get the currently typed filename when the file itself does not exist yet.
Deprecated: 4.10: Use Gtk::FileDialog instead
Glib::RefPtr< Gio::File > Gtk::FileChooser::get_file | ( | ) |
Gets the Gio::File
for the currently selected file in the file selector.
If multiple files are selected, one of the files will be returned at random.
If the file chooser is in folder mode, this function returns the selected folder.
Deprecated: 4.10: Use Gtk::FileDialog instead
Gio::File
. You own the returned file; use Glib::object_unref() to release it. Glib::RefPtr< const Gio::File > Gtk::FileChooser::get_file | ( | ) | const |
Gets the Gio::File
for the currently selected file in the file selector.
If multiple files are selected, one of the files will be returned at random.
If the file chooser is in folder mode, this function returns the selected folder.
Deprecated: 4.10: Use Gtk::FileDialog instead
Gio::File
. You own the returned file; use Glib::object_unref() to release it. Glib::RefPtr< Gio::ListModel > Gtk::FileChooser::get_files | ( | ) |
Lists all the selected files and subfolders in the current folder of chooser as Gio::File
.
Deprecated: 4.10: Use Gtk::FileDialog instead
Gio::File
for each selected file and subfolder in the current folder. Free the returned list with Glib::object_unref(). Glib::RefPtr< const Gio::ListModel > Gtk::FileChooser::get_files | ( | ) | const |
Lists all the selected files and subfolders in the current folder of chooser as Gio::File
.
Deprecated: 4.10: Use Gtk::FileDialog instead
Gio::File
for each selected file and subfolder in the current folder. Free the returned list with Glib::object_unref(). std::vector< Glib::RefPtr< Gio::File > > Gtk::FileChooser::get_files2 | ( | ) |
Lists all the selected files and subfolders in the current folder of chooser as Gio::File.
Deprecated: 4.10: Use Gtk::FileDialog instead
std::vector< Glib::RefPtr< const Gio::File > > Gtk::FileChooser::get_files2 | ( | ) | const |
Lists all the selected files and subfolders in the current folder of chooser as Gio::File.
Deprecated: 4.10: Use Gtk::FileDialog instead
Glib::RefPtr< FileFilter > Gtk::FileChooser::get_filter | ( | ) |
Glib::RefPtr< const FileFilter > Gtk::FileChooser::get_filter | ( | ) | const |
Glib::RefPtr< const Gio::ListModel > Gtk::FileChooser::get_filters | ( | ) | const |
Gets the current set of user-selectable filters, as a list model.
See add_filter() and remove_filter() for changing individual filters.
You should not modify the returned list model. Future changes to chooser may or may not affect the returned model.
Deprecated: 4.10: Use Gtk::FileDialog instead
Gio::ListModel
containing the current set of user-selectable filters. bool Gtk::FileChooser::get_select_multiple | ( | ) | const |
Gets whether multiple files can be selected in the file chooser.
Deprecated: 4.10: Use Gtk::FileDialog instead
true
if multiple files can be selected. Glib::RefPtr< const Gio::ListModel > Gtk::FileChooser::get_shortcut_folders | ( | ) | const |
Queries the list of shortcut folders in the file chooser.
You should not modify the returned list model. Future changes to chooser may or may not affect the returned model.
Deprecated: 4.10: Use Gtk::FileDialog instead
Gio::File
s. std::vector< Glib::RefPtr< Gio::File > > Gtk::FileChooser::get_shortcut_folders2 | ( | ) |
Queries the list of shortcut folders in the file chooser.
You should not modify the returned list model. Future changes to chooser may or may not affect the returned model.
Deprecated: 4.10: Use Gtk::FileDialog instead
Gio::File
s.
|
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.
|
noexcept |
Glib::PropertyProxy< Action > Gtk::FileChooser::property_action | ( | ) |
The type of operation that the file chooser is performing.
Deprecated: 4.10: Use Gtk::FileDialog instead
Default value: Gtk::FileChooser::Action::OPEN
Glib::PropertyProxy_ReadOnly< Action > Gtk::FileChooser::property_action | ( | ) | const |
The type of operation that the file chooser is performing.
Deprecated: 4.10: Use Gtk::FileDialog instead
Default value: Gtk::FileChooser::Action::OPEN
Glib::PropertyProxy< bool > Gtk::FileChooser::property_create_folders | ( | ) |
Whether a file chooser not in Gtk::FileChooser::Action::OPEN mode will offer the user to create new folders.
Deprecated: 4.10: Use Gtk::FileDialog instead
Default value: true
Glib::PropertyProxy_ReadOnly< bool > Gtk::FileChooser::property_create_folders | ( | ) | const |
Whether a file chooser not in Gtk::FileChooser::Action::OPEN mode will offer the user to create new folders.
Deprecated: 4.10: Use Gtk::FileDialog instead
Default value: true
Glib::PropertyProxy< Glib::RefPtr< FileFilter > > Gtk::FileChooser::property_filter | ( | ) |
The current filter for selecting files that are displayed.
Deprecated: 4.10: Use Gtk::FileDialog instead
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< FileFilter > > Gtk::FileChooser::property_filter | ( | ) | const |
The current filter for selecting files that are displayed.
Deprecated: 4.10: Use Gtk::FileDialog instead
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gio::ListModel > > Gtk::FileChooser::property_filters | ( | ) | const |
A Gio::ListModel
containing the filters that have been added with Gtk::FileChooser::add_filter().
The returned object should not be modified. It may or may not be updated for later changes.
Deprecated: 4.10: Use Gtk::FileDialog instead
Glib::PropertyProxy< bool > Gtk::FileChooser::property_select_multiple | ( | ) |
Whether to allow multiple files to be selected.
Deprecated: 4.10: Use Gtk::FileDialog instead
Default value: false
Glib::PropertyProxy_ReadOnly< bool > Gtk::FileChooser::property_select_multiple | ( | ) | const |
Whether to allow multiple files to be selected.
Deprecated: 4.10: Use Gtk::FileDialog instead
Default value: false
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gio::ListModel > > Gtk::FileChooser::property_shortcut_folders | ( | ) | const |
A Gio::ListModel
containing the shortcut folders that have been added with Gtk::FileChooser::add_shortcut_folder().
The returned object should not be modified. It may or may not be updated for later changes.
Deprecated: 4.10: Use Gtk::FileDialog instead
Removes a 'choice' that has been added with add_choice().
Deprecated: 4.10: Use Gtk::FileDialog instead
id | The ID of the choice to remove. |
void Gtk::FileChooser::remove_filter | ( | const Glib::RefPtr< FileFilter > & | filter | ) |
Removes filter from the list of filters that the user can select between.
Deprecated: 4.10: Use Gtk::FileDialog instead
filter | A Gtk::FileFilter . |
bool Gtk::FileChooser::remove_shortcut_folder | ( | const Glib::RefPtr< Gio::File > & | folder | ) |
Removes a folder from the shortcut folders in a file chooser.
Deprecated: 4.10: Use Gtk::FileDialog instead
folder | A Gio::File for the folder to remove. |
true
if the folder could be removed successfully, false
otherwise.Glib::Error |
Sets the type of operation that the chooser is performing.
The user interface is adapted to suit the selected action.
For example, an option to create a new folder might be shown if the action is Gtk::FileChooser::Action::SAVE but not if the action is Gtk::FileChooser::Action::OPEN.
Deprecated: 4.10: Use Gtk::FileDialog instead
action | The action that the file selector is performing. |
Selects an option in a 'choice' that has been added with add_choice().
For a boolean choice, the possible options are "true" and "false".
Deprecated: 4.10: Use Gtk::FileDialog instead
id | The ID of the choice to set. |
option | The ID of the option to select. |
Sets whether file chooser will offer to create new folders.
This is only relevant if the action is not set to be Gtk::FileChooser::Action::OPEN.
Deprecated: 4.10: Use Gtk::FileDialog instead
create_folders | true if the Create Folder button should be displayed. |
Sets the current folder for chooser from a Gio::File
.
Deprecated: 4.10: Use Gtk::FileDialog instead
file | The Gio::File for the new folder. |
true
if the folder could be changed successfully, false
otherwise.Glib::Error |
Sets the current name in the file selector, as if entered by the user.
Note that the name passed in here is a UTF-8 string rather than a filename. This function is meant for such uses as a suggested name in a “Save As...” dialog. You can pass “Untitled.doc” or a similarly suitable suggestion for the name.
If you want to preselect a particular existing file, you should use set_file() instead.
Please see the documentation for those functions for an example of using set_current_name() as well.
Deprecated: 4.10: Use Gtk::FileDialog instead
name | The filename to use, as a UTF-8 string. |
Sets file as the current filename for the file chooser.
This includes changing to the file’s parent folder and actually selecting the file in list. If the chooser is in Gtk::FileChooser::Action::SAVE mode, the file’s base name will also appear in the dialog’s file name entry.
If the file name isn’t in the current folder of chooser, then the current folder of chooser will be changed to the folder containing file.
Note that the file must exist, or nothing will be done except for the directory change.
If you are implementing a save dialog, you should use this function if you already have a file name to which the user may save; for example, when the user opens an existing file and then does “Save As…”. If you don’t have a file name already — for example, if the user just created a new file and is saving it for the first time, do not call this function.
Instead, use something similar to this:
[C example ellipted]
Deprecated: 4.10: Use Gtk::FileDialog instead
file | The Gio::File to set as current. |
Glib::Error |
void Gtk::FileChooser::set_filter | ( | const Glib::RefPtr< FileFilter > & | filter | ) |
Sets the current filter.
Only the files that pass the filter will be displayed. If the user-selectable list of filters is non-empty, then the filter should be one of the filters in that list.
Setting the current filter when the list of filters is empty is useful if you want to restrict the displayed set of files without letting the user change it.
Deprecated: 4.10: Use Gtk::FileDialog instead
filter | A Gtk::FileFilter . |
Sets whether multiple files can be selected in the file chooser.
This is only relevant if the action is set to be Gtk::FileChooser::Action::OPEN or Gtk::FileChooser::Action::SELECT_FOLDER.
Deprecated: 4.10: Use Gtk::FileDialog instead
select_multiple | true if multiple files can be selected. |
|
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. |