gtkmm 3.24.7
|
Gtk::FileChooser is an interface that can be implemented by file selection widgets. More...
#include <gtkmm/filechooser.h>
Public Member Functions | |
FileChooser (FileChooser && src) noexcept | |
FileChooser & | operator= (FileChooser && src) noexcept |
~FileChooser () noexcept override | |
GtkFileChooser * | gobj () |
Provides access to the underlying C GObject. More... | |
const GtkFileChooser * | gobj () const |
Provides access to the underlying C GObject. More... | |
void | set_action (FileChooserAction action) |
Sets the type of operation that the chooser is performing; the user interface is adapted to suit the selected action. More... | |
FileChooserAction | get_action () const |
Gets the type of operation that the file chooser is performing; see set_action(). More... | |
void | set_local_only (bool local_only=true) |
Sets whether only local files can be selected in the file selector. More... | |
bool | get_local_only () const |
Gets whether only local files can be selected in the file selector. More... | |
void | set_select_multiple (bool select_multiple=true) |
Sets whether multiple files can be selected in the file selector. More... | |
bool | get_select_multiple () const |
Gets whether multiple files can be selected in the file selector. More... | |
void | set_show_hidden (bool show_hidden=true) |
Sets whether hidden files and folders are displayed in the file selector. More... | |
bool | get_show_hidden () const |
Gets whether hidden files and folders are displayed in the file selector. More... | |
void | set_do_overwrite_confirmation (bool do_overwrite_confirmation=true) |
Sets whether a file chooser in Gtk::FILE_CHOOSER_ACTION_SAVE mode will present a confirmation dialog if the user types a file name that already exists. More... | |
bool | get_do_overwrite_confirmation () const |
Queries whether a file chooser is set to confirm for overwriting when the user types a file name that already exists. More... | |
void | set_create_folders (bool create_folders=true) |
Sets whether file choser will offer to create new folders. More... | |
bool | get_create_folders () const |
Gets whether file choser will offer to create new folders. More... | |
void | set_current_name (const Glib::ustring & name) |
Sets the current name in the file selector, as if entered by the user. More... | |
Glib::ustring | get_current_name () const |
Gets the current name in the file selector, as entered by the user in the text entry for “Name”. More... | |
std::string | get_filename () const |
Gets the filename for the currently selected file in the file selector. More... | |
bool | set_filename (const std::string & filename) |
Sets filename as the current filename for the file chooser, by changing to the file’s parent folder and actually selecting the file in list; all other files will be unselected. More... | |
bool | select_filename (const std::string & filename) |
Selects a filename. More... | |
void | unselect_filename (const std::string & filename) |
Unselects a currently selected filename. More... | |
void | select_all () |
Selects all the files in the current folder of a file chooser. More... | |
void | unselect_all () |
Unselects all the files in the current folder of a file chooser. More... | |
std::vector< std::string > | get_filenames () const |
Lists all the selected files and subfolders in the current folder of chooser. More... | |
bool | set_current_folder (const std::string & filename) |
Sets the current folder for chooser from a local filename. More... | |
std::string | get_current_folder () const |
Gets the current folder of chooser as a local filename. More... | |
Glib::ustring | get_uri () const |
Gets the URI for the currently selected file in the file selector. More... | |
bool | set_uri (const Glib::ustring & uri) |
Sets the file referred to by uri as the current file for the file chooser, by changing to the URI’s parent folder and actually selecting the URI in the list. More... | |
bool | select_uri (const Glib::ustring & uri) |
Selects the file to by uri. More... | |
void | unselect_uri (const Glib::ustring & uri) |
Unselects the file referred to by uri. More... | |
std::vector< Glib::ustring > | get_uris () const |
Lists all the selected files and subfolders in the current folder of chooser. More... | |
bool | set_current_folder_uri (const Glib::ustring & uri) |
Sets the current folder for chooser from an URI. More... | |
Glib::ustring | get_current_folder_uri () const |
Gets the current folder of chooser as an URI. More... | |
bool | set_file (const Glib::RefPtr< const Gio::File > & file) |
Sets file as the current filename for the file chooser, by changing to the file’s parent folder and actually selecting the file in list. More... | |
bool | select_file (const Glib::RefPtr< const Gio::File > & file) |
Selects the file referred to by file. More... | |
void | unselect_file (const Glib::RefPtr< const Gio::File > & file) |
Unselects the file referred to by file. More... | |
std::vector< Glib::RefPtr< Gio::File > > | get_files () |
Lists all the selected files and subfolders in the current folder of chooser as Gio::File. More... | |
bool | set_current_folder_file (const Glib::RefPtr< const Gio::File > & file) |
Sets the current folder for chooser from a Gio::File. More... | |
Glib::RefPtr< Gio::File > | get_current_folder_file () |
Gets the current folder of chooser as Gio::File. More... | |
Glib::RefPtr< Gio::File > | get_file () |
Gets the Gio::File for the currently selected file in the file selector. More... | |
Glib::RefPtr< const Gio::File > | get_file () const |
Gets the Gio::File for the currently selected file in the file selector. More... | |
void | set_preview_widget (Gtk::Widget & preview_widget) |
Sets an application-supplied widget to use to display a custom preview of the currently selected file. More... | |
Gtk::Widget * | get_preview_widget () |
Gets the current preview widget; see set_preview_widget(). More... | |
const Gtk::Widget * | get_preview_widget () const |
Gets the current preview widget; see set_preview_widget(). More... | |
void | set_preview_widget_active (bool active=true) |
Sets whether the preview widget set by set_preview_widget() should be shown for the current filename. More... | |
bool | get_preview_widget_active () const |
Gets whether the preview widget set by set_preview_widget() should be shown for the current filename. More... | |
void | set_use_preview_label (bool use_label=true) |
Sets whether the file chooser should display a stock label with the name of the file that is being previewed; the default is true . More... | |
bool | get_use_preview_label () const |
Gets whether a stock label should be drawn with the name of the previewed file. More... | |
std::string | get_preview_filename () const |
Gets the filename that should be previewed in a custom preview widget. More... | |
Glib::ustring | get_preview_uri () const |
Gets the URI that should be previewed in a custom preview widget. More... | |
Glib::RefPtr< Gio::File > | get_preview_file () |
Gets the Gio::File that should be previewed in a custom preview Internal function, see get_preview_uri(). More... | |
Glib::RefPtr< const Gio::File > | get_preview_file () const |
Gets the Gio::File that should be previewed in a custom preview Internal function, see get_preview_uri(). More... | |
void | set_extra_widget (Gtk::Widget & extra_widget) |
Sets an application-supplied widget to provide extra options to the user. More... | |
Gtk::Widget * | get_extra_widget () |
Gets the current extra widget; see set_extra_widget(). More... | |
const Gtk::Widget * | get_extra_widget () const |
Gets the current extra widget; see set_extra_widget(). More... | |
void | add_filter (const Glib::RefPtr< FileFilter > & filter) |
Adds filter to the list of filters that the user can select between. More... | |
void | remove_filter (const Glib::RefPtr< FileFilter > & filter) |
Removes filter from the list of filters that the user can select between. More... | |
std::vector< Glib::RefPtr< FileFilter > > | list_filters () |
Lists the current set of user-selectable filters; see add_filter(), remove_filter(). More... | |
std::vector< Glib::RefPtr< const FileFilter > > | list_filters () const |
Lists the current set of user-selectable filters; see add_filter(), remove_filter(). More... | |
void | set_filter (const Glib::RefPtr< FileFilter > & filter) |
Sets the current filter; only the files that pass the filter will be displayed. More... | |
Glib::RefPtr< FileFilter > | get_filter () |
Gets the current filter; see set_filter(). More... | |
Glib::RefPtr< const FileFilter > | get_filter () const |
Gets the current filter; see set_filter(). More... | |
bool | add_shortcut_folder (const std::string & folder) |
Adds a folder to be displayed with the shortcut folders in a file chooser. More... | |
bool | remove_shortcut_folder (const std::string & folder) |
Removes a folder from a file chooser’s list of shortcut folders. More... | |
std::vector< std::string > | list_shortcut_folders () const |
Queries the list of shortcut folders in the file chooser, as set by add_shortcut_folder(). More... | |
bool | add_shortcut_folder_uri (const Glib::ustring & uri) |
Adds a folder URI to be displayed with the shortcut folders in a file chooser. More... | |
bool | remove_shortcut_folder_uri (const Glib::ustring & uri) |
Removes a folder URI from a file chooser’s list of shortcut folders. More... | |
std::vector< Glib::ustring > | list_shortcut_folder_uris () const |
Queries the list of shortcut folders in the file chooser, as set by add_shortcut_folder_uri(). More... | |
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. More... | |
void | add_choice (const Glib::ustring & id, const Glib::ustring & label) |
Adds a boolean 'choice' to the file chooser. More... | |
void | remove_choice (const Glib::ustring & id) |
Removes a 'choice' that has been added with add_choice(). More... | |
void | set_choice (const Glib::ustring & id, const Glib::ustring & option) |
Selects an option in a 'choice' that has been added with add_choice(). More... | |
Glib::ustring | get_choice (const Glib::ustring & id) const |
Gets the currently selected option in the 'choice' with the given ID. More... | |
Glib::SignalProxy< void > | signal_current_folder_changed () |
Glib::SignalProxy< void > | signal_selection_changed () |
Glib::SignalProxy< void > | signal_update_preview () |
Glib::SignalProxy< void > | signal_file_activated () |
Glib::SignalProxy< FileChooserConfirmation > | signal_confirm_overwrite () |
Glib::PropertyProxy< FileChooserAction > | property_action () |
The type of operation that the file selector is performing. More... | |
Glib::PropertyProxy_ReadOnly< FileChooserAction > | property_action () const |
The type of operation that the file selector is performing. More... | |
Glib::PropertyProxy< Glib::RefPtr< FileFilter > > | property_filter () |
The current filter for selecting which files are displayed. More... | |
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< FileFilter > > | property_filter () const |
The current filter for selecting which files are displayed. More... | |
Glib::PropertyProxy< bool > | property_local_only () |
Whether the selected file(s) should be limited to local file: URLs. More... | |
Glib::PropertyProxy_ReadOnly< bool > | property_local_only () const |
Whether the selected file(s) should be limited to local file: URLs. More... | |
Glib::PropertyProxy< Widget * > | property_preview_widget () |
Application supplied widget for custom previews. More... | |
Glib::PropertyProxy_ReadOnly< Widget * > | property_preview_widget () const |
Application supplied widget for custom previews. More... | |
Glib::PropertyProxy< bool > | property_preview_widget_active () |
Whether the application supplied widget for custom previews should be shown. More... | |
Glib::PropertyProxy_ReadOnly< bool > | property_preview_widget_active () const |
Whether the application supplied widget for custom previews should be shown. More... | |
Glib::PropertyProxy< bool > | property_use_preview_label () |
Whether to display a stock label with the name of the previewed file. More... | |
Glib::PropertyProxy_ReadOnly< bool > | property_use_preview_label () const |
Whether to display a stock label with the name of the previewed file. More... | |
Glib::PropertyProxy< Widget * > | property_extra_widget () |
Application supplied widget for extra options. More... | |
Glib::PropertyProxy_ReadOnly< Widget * > | property_extra_widget () const |
Application supplied widget for extra options. More... | |
Glib::PropertyProxy< bool > | property_select_multiple () |
Whether to allow multiple files to be selected. More... | |
Glib::PropertyProxy_ReadOnly< bool > | property_select_multiple () const |
Whether to allow multiple files to be selected. More... | |
Glib::PropertyProxy< bool > | property_show_hidden () |
Whether the hidden files and folders should be displayed. More... | |
Glib::PropertyProxy_ReadOnly< bool > | property_show_hidden () const |
Whether the hidden files and folders should be displayed. More... | |
Glib::PropertyProxy< bool > | property_do_overwrite_confirmation () |
Whether a file chooser in Gtk::FILE_CHOOSER_ACTION_SAVE mode will present an overwrite confirmation dialog if the user selects a file name that already exists. More... | |
Glib::PropertyProxy_ReadOnly< bool > | property_do_overwrite_confirmation () const |
Whether a file chooser in Gtk::FILE_CHOOSER_ACTION_SAVE mode will present an overwrite confirmation dialog if the user selects a file name that already exists. More... | |
Glib::PropertyProxy< bool > | property_create_folders () |
Whether a file chooser not in Gtk::FILE_CHOOSER_ACTION_OPEN mode will offer the user to create new folders. More... | |
Glib::PropertyProxy_ReadOnly< bool > | property_create_folders () const |
Whether a file chooser not in Gtk::FILE_CHOOSER_ACTION_OPEN mode will offer the user to create new folders. More... | |
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. More... | |
Protected Member Functions | |
FileChooser () | |
You should derive from this class to use it. More... | |
Related Functions | |
(Note that these are not member functions.) | |
Glib::RefPtr< Gtk::FileChooser > | wrap (GtkFileChooser * object, bool take_copy=false) |
A Glib::wrap() method for this object. More... | |
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.
open(2)
or fopen(3)
, you may not be able to directly set it as the text of a Gtk::Label widget unless you convert it first to UTF-8, which all gtkmm widgets expect. You should use Glib::filename_to_utf8() to convert filenames into strings that can be passed to gtkmm widgets.
|
protected |
You should derive from this class to use it.
|
noexcept |
|
overridenoexcept |
void Gtk::FileChooser::add_choice | ( | const Glib::ustring & | id, |
const Glib::ustring & | label | ||
) |
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 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. |
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, so you have to ref and sink it if you want to keep a reference.
filter | A Gtk::FileFilter. |
|
static |
bool Gtk::FileChooser::add_shortcut_folder | ( | const std::string & | folder | ) |
Adds a folder to be displayed with the shortcut folders in a file chooser.
Note that shortcut folders do not get saved, as they are provided by the application. For example, you can use this to add a “/usr/share/mydrawprogram/Clipart” folder to the volume list.
folder | Filename of the folder to add. |
true
if the folder could be added successfully, false
otherwise. In the latter case, the error will be set as appropriate.Glib::Error |
bool Gtk::FileChooser::add_shortcut_folder_uri | ( | const Glib::ustring & | uri | ) |
Adds a folder URI to be displayed with the shortcut folders in a file chooser.
Note that shortcut folders do not get saved, as they are provided by the application. For example, you can use this to add a “file:///usr/share/mydrawprogram/Clipart” folder to the volume list.
uri | URI of the folder to add. |
true
if the folder could be added successfully, false
otherwise. In the latter case, the error will be set as appropriate.Glib::Error |
FileChooserAction Gtk::FileChooser::get_action | ( | ) | const |
Gets the type of operation that the file chooser is performing; see set_action().
Glib::ustring Gtk::FileChooser::get_choice | ( | const Glib::ustring & | id | ) | const |
Gets the currently selected option in the 'choice' with the given ID.
id | The ID of the choice to get. |
bool Gtk::FileChooser::get_create_folders | ( | ) | const |
Gets whether file choser will offer to create new folders.
See set_create_folders().
true
if the Create Folder button should be displayed. std::string Gtk::FileChooser::get_current_folder | ( | ) | const |
Gets the current folder of chooser as a local filename.
See set_current_folder().
Note that this is the folder that the file chooser is currently displaying (e.g. "/home/username/Documents"), which is not the same as the currently-selected folder if the chooser is in Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER mode (e.g. "/home/username/Documents/selected-folder/". To get the currently-selected folder in that mode, use get_uri() as the usual way to get the selection.
Glib::RefPtr< Gio::File > Gtk::FileChooser::get_current_folder_file | ( | ) |
Gets the current folder of chooser as Gio::File.
Glib::ustring Gtk::FileChooser::get_current_folder_uri | ( | ) | const |
Gets the current folder of chooser as an URI.
Note that this is the folder that the file chooser is currently displaying (e.g. "file:///home/username/Documents"), which is not the same as the currently-selected folder if the chooser is in Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER mode (e.g. "file:///home/username/Documents/selected-folder/". To get the currently-selected folder in that mode, use get_uri() as the usual way to get the selection.
Glib::ustring Gtk::FileChooser::get_current_name | ( | ) | const |
Gets the current name in the file selector, as entered by the user in the text entry for “Name”.
This is meant to be used in save dialogs, to get the currently typed filename when the file itself does not exist yet. For example, an application that adds a custom extra widget to the file chooser for “file format” may want to change the extension of the typed filename based on the chosen format, say, from “.jpg” to “.png”.
bool Gtk::FileChooser::get_do_overwrite_confirmation | ( | ) | const |
Queries whether a file chooser is set to confirm for overwriting when the user types a file name that already exists.
true
if the file chooser will present a confirmation dialog; false
otherwise. Gtk::Widget * Gtk::FileChooser::get_extra_widget | ( | ) |
Gets the current extra widget; see set_extra_widget().
nullptr
. const Gtk::Widget * Gtk::FileChooser::get_extra_widget | ( | ) | const |
Gets the current extra widget; see set_extra_widget().
nullptr
. 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.
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.
std::string Gtk::FileChooser::get_filename | ( | ) | const |
Gets the filename for the currently selected file in the file selector.
The filename is returned as an absolute path. If multiple files are selected, one of the filenames will be returned at random.
If the file chooser is in folder mode, this function returns the selected folder.
std::vector< std::string > Gtk::FileChooser::get_filenames | ( | ) | const |
Lists all the selected files and subfolders in the current folder of chooser.
The returned names are full absolute paths. If files in the current folder cannot be represented as local filenames they will be ignored. (See get_uris())
std::vector< Glib::RefPtr< Gio::File > > Gtk::FileChooser::get_files | ( | ) |
Lists all the selected files and subfolders in the current folder of chooser as Gio::File.
An internal function, see get_uris().
Glib::RefPtr< FileFilter > Gtk::FileChooser::get_filter | ( | ) |
Glib::RefPtr< const FileFilter > Gtk::FileChooser::get_filter | ( | ) | const |
bool Gtk::FileChooser::get_local_only | ( | ) | const |
Gets whether only local files can be selected in the file selector.
See set_local_only()
true
if only local files can be selected. Glib::RefPtr< Gio::File > Gtk::FileChooser::get_preview_file | ( | ) |
Gets the Gio::File that should be previewed in a custom preview Internal function, see get_preview_uri().
nullptr
if no file is selected. Free with Glib::object_unref(). Glib::RefPtr< const Gio::File > Gtk::FileChooser::get_preview_file | ( | ) | const |
Gets the Gio::File that should be previewed in a custom preview Internal function, see get_preview_uri().
nullptr
if no file is selected. Free with Glib::object_unref(). std::string Gtk::FileChooser::get_preview_filename | ( | ) | const |
Gets the filename that should be previewed in a custom preview widget.
See set_preview_widget().
Glib::ustring Gtk::FileChooser::get_preview_uri | ( | ) | const |
Gets the URI that should be previewed in a custom preview widget.
See set_preview_widget().
Gtk::Widget * Gtk::FileChooser::get_preview_widget | ( | ) |
Gets the current preview widget; see set_preview_widget().
nullptr
. const Gtk::Widget * Gtk::FileChooser::get_preview_widget | ( | ) | const |
Gets the current preview widget; see set_preview_widget().
nullptr
. bool Gtk::FileChooser::get_preview_widget_active | ( | ) | const |
Gets whether the preview widget set by set_preview_widget() should be shown for the current filename.
See set_preview_widget_active().
true
if the preview widget is active for the current filename. bool Gtk::FileChooser::get_select_multiple | ( | ) | const |
Gets whether multiple files can be selected in the file selector.
true
if multiple files can be selected. bool Gtk::FileChooser::get_show_hidden | ( | ) | const |
Gets whether hidden files and folders are displayed in the file selector.
See set_show_hidden().
true
if hidden files and folders are displayed.
|
static |
Get the GType for this class, for use with the underlying GObject type system.
Glib::ustring Gtk::FileChooser::get_uri | ( | ) | const |
Gets the URI for the currently selected file in the file selector.
If multiple files are selected, one of the filenames will be returned at random.
If the file chooser is in folder mode, this function returns the selected folder.
std::vector< Glib::ustring > Gtk::FileChooser::get_uris | ( | ) | const |
Lists all the selected files and subfolders in the current folder of chooser.
The returned names are full absolute URIs.
bool Gtk::FileChooser::get_use_preview_label | ( | ) | const |
Gets whether a stock label should be drawn with the name of the previewed file.
true
if the file chooser is set to display a label with the name of the previewed file, false
otherwise.
|
inline |
Provides access to the underlying C GObject.
|
inline |
Provides access to the underlying C GObject.
std::vector< Glib::RefPtr< FileFilter > > Gtk::FileChooser::list_filters | ( | ) |
Lists the current set of user-selectable filters; see add_filter(), remove_filter().
std::vector< Glib::RefPtr< const FileFilter > > Gtk::FileChooser::list_filters | ( | ) | const |
Lists the current set of user-selectable filters; see add_filter(), remove_filter().
std::vector< Glib::ustring > Gtk::FileChooser::list_shortcut_folder_uris | ( | ) | const |
Queries the list of shortcut folders in the file chooser, as set by add_shortcut_folder_uri().
std::vector< std::string > Gtk::FileChooser::list_shortcut_folders | ( | ) | const |
Queries the list of shortcut folders in the file chooser, as set by add_shortcut_folder().
|
noexcept |
Glib::PropertyProxy< FileChooserAction > Gtk::FileChooser::property_action | ( | ) |
The type of operation that the file selector is performing.
Default value: Gtk::FILE_CHOOSER_ACTION_OPEN
Glib::PropertyProxy_ReadOnly< FileChooserAction > Gtk::FileChooser::property_action | ( | ) | const |
The type of operation that the file selector is performing.
Default value: Gtk::FILE_CHOOSER_ACTION_OPEN
Glib::PropertyProxy< bool > Gtk::FileChooser::property_create_folders | ( | ) |
Whether a file chooser not in Gtk::FILE_CHOOSER_ACTION_OPEN mode will offer the user to create new folders.
Default value: true
Glib::PropertyProxy_ReadOnly< bool > Gtk::FileChooser::property_create_folders | ( | ) | const |
Whether a file chooser not in Gtk::FILE_CHOOSER_ACTION_OPEN mode will offer the user to create new folders.
Default value: true
Glib::PropertyProxy< bool > Gtk::FileChooser::property_do_overwrite_confirmation | ( | ) |
Whether a file chooser in Gtk::FILE_CHOOSER_ACTION_SAVE mode will present an overwrite confirmation dialog if the user selects a file name that already exists.
Default value: false
Glib::PropertyProxy_ReadOnly< bool > Gtk::FileChooser::property_do_overwrite_confirmation | ( | ) | const |
Whether a file chooser in Gtk::FILE_CHOOSER_ACTION_SAVE mode will present an overwrite confirmation dialog if the user selects a file name that already exists.
Default value: false
Glib::PropertyProxy< Widget * > Gtk::FileChooser::property_extra_widget | ( | ) |
Application supplied widget for extra options.
Glib::PropertyProxy_ReadOnly< Widget * > Gtk::FileChooser::property_extra_widget | ( | ) | const |
Application supplied widget for extra options.
Glib::PropertyProxy< Glib::RefPtr< FileFilter > > Gtk::FileChooser::property_filter | ( | ) |
The current filter for selecting which files are displayed.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< FileFilter > > Gtk::FileChooser::property_filter | ( | ) | const |
The current filter for selecting which files are displayed.
Glib::PropertyProxy< bool > Gtk::FileChooser::property_local_only | ( | ) |
Whether the selected file(s) should be limited to local file: URLs.
Default value: true
Glib::PropertyProxy_ReadOnly< bool > Gtk::FileChooser::property_local_only | ( | ) | const |
Whether the selected file(s) should be limited to local file: URLs.
Default value: true
Glib::PropertyProxy< Widget * > Gtk::FileChooser::property_preview_widget | ( | ) |
Application supplied widget for custom previews.
Glib::PropertyProxy_ReadOnly< Widget * > Gtk::FileChooser::property_preview_widget | ( | ) | const |
Application supplied widget for custom previews.
Glib::PropertyProxy< bool > Gtk::FileChooser::property_preview_widget_active | ( | ) |
Whether the application supplied widget for custom previews should be shown.
Default value: true
Glib::PropertyProxy_ReadOnly< bool > Gtk::FileChooser::property_preview_widget_active | ( | ) | const |
Whether the application supplied widget for custom previews should be shown.
Default value: true
Glib::PropertyProxy< bool > Gtk::FileChooser::property_select_multiple | ( | ) |
Whether to allow multiple files to be selected.
Default value: false
Glib::PropertyProxy_ReadOnly< bool > Gtk::FileChooser::property_select_multiple | ( | ) | const |
Whether to allow multiple files to be selected.
Default value: false
Glib::PropertyProxy< bool > Gtk::FileChooser::property_show_hidden | ( | ) |
Whether the hidden files and folders should be displayed.
Default value: false
Glib::PropertyProxy_ReadOnly< bool > Gtk::FileChooser::property_show_hidden | ( | ) | const |
Whether the hidden files and folders should be displayed.
Default value: false
Glib::PropertyProxy< bool > Gtk::FileChooser::property_use_preview_label | ( | ) |
Whether to display a stock label with the name of the previewed file.
Default value: true
Glib::PropertyProxy_ReadOnly< bool > Gtk::FileChooser::property_use_preview_label | ( | ) | const |
Whether to display a stock label with the name of the previewed file.
Default value: true
void Gtk::FileChooser::remove_choice | ( | const Glib::ustring & | id | ) |
Removes a 'choice' that has been added with add_choice().
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.
filter | A Gtk::FileFilter. |
bool Gtk::FileChooser::remove_shortcut_folder | ( | const std::string & | folder | ) |
Removes a folder from a file chooser’s list of shortcut folders.
folder | Filename of the folder to remove. |
true
if the operation succeeds, false
otherwise. See also: add_shortcut_folder().
Glib::Error |
bool Gtk::FileChooser::remove_shortcut_folder_uri | ( | const Glib::ustring & | uri | ) |
Removes a folder URI from a file chooser’s list of shortcut folders.
uri | URI of the folder to remove. |
true
if the operation succeeds, false
otherwise. See also: add_shortcut_folder_uri().
Glib::Error |
void Gtk::FileChooser::select_all | ( | ) |
Selects all the files in the current folder of a file chooser.
bool Gtk::FileChooser::select_file | ( | const Glib::RefPtr< const Gio::File > & | file | ) |
Selects the file referred to by file.
An internal function. See _gtk_file_chooser_select_uri().
file | The file to select. |
Glib::Error |
bool Gtk::FileChooser::select_filename | ( | const std::string & | filename | ) |
Selects a filename.
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 filename.
filename | The filename to select. |
See also: set_filename().
bool Gtk::FileChooser::select_uri | ( | const Glib::ustring & | uri | ) |
Selects the file to by uri.
If the URI doesn’t refer to a file in the current folder of chooser, then the current folder of chooser will be changed to the folder containing filename.
uri | The URI to select. |
void Gtk::FileChooser::set_action | ( | FileChooserAction | action | ) |
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::FILE_CHOOSER_ACTION_SAVE but not if the action is Gtk::FILE_CHOOSER_ACTION_OPEN.
action | The action that the file selector is performing. |
void Gtk::FileChooser::set_choice | ( | const Glib::ustring & | id, |
const Glib::ustring & | option | ||
) |
Selects an option in a 'choice' that has been added with add_choice().
For a boolean choice, the possible options are "true" and "false".
id | The ID of the choice to set. |
option | The ID of the option to select. |
void Gtk::FileChooser::set_create_folders | ( | bool | create_folders = true | ) |
Sets whether file choser will offer to create new folders.
This is only relevant if the action is not set to be Gtk::FILE_CHOOSER_ACTION_OPEN.
create_folders | true if the Create Folder button should be displayed. |
bool Gtk::FileChooser::set_current_folder | ( | const std::string & | filename | ) |
Sets the current folder for chooser from a local filename.
The user will be shown the full contents of the current folder, plus user interface elements for navigating to other folders.
In general, you should not use this function. See the [section on setting up a file chooser dialog][gtkfilechooserdialog-setting-up] for the rationale behind this.
filename | The full path of the new current folder. |
bool Gtk::FileChooser::set_current_folder_file | ( | const Glib::RefPtr< const Gio::File > & | file | ) |
Sets the current folder for chooser from a Gio::File.
Internal function, see set_current_folder_uri().
file | The Gio::File for the new folder. |
true
if the folder could be changed successfully, false
otherwise.Glib::Error |
bool Gtk::FileChooser::set_current_folder_uri | ( | const Glib::ustring & | uri | ) |
Sets the current folder for chooser from an URI.
The user will be shown the full contents of the current folder, plus user interface elements for navigating to other folders.
In general, you should not use this function. See the [section on setting up a file chooser dialog][gtkfilechooserdialog-setting-up] for the rationale behind this.
uri | The URI for the new current folder. |
true
if the folder could be changed successfully, false
otherwise. void Gtk::FileChooser::set_current_name | ( | const Glib::ustring & | name | ) |
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_filename() or set_uri() instead. Please see the documentation for those functions for an example of using set_current_name() as well.
name | The filename to use, as a UTF-8 string. |
void Gtk::FileChooser::set_do_overwrite_confirmation | ( | bool | do_overwrite_confirmation = true | ) |
Sets whether a file chooser in Gtk::FILE_CHOOSER_ACTION_SAVE mode will present a confirmation dialog if the user types a file name that already exists.
This is false
by default.
If set to true
, the chooser will emit the Gtk::FileChooser::signal_confirm_overwrite() signal when appropriate.
If all you need is the stock confirmation dialog, set this property to true
. You can override the way confirmation is done by actually handling the Gtk::FileChooser::signal_confirm_overwrite() signal; please refer to its documentation for the details.
do_overwrite_confirmation | Whether to confirm overwriting in save mode. |
void Gtk::FileChooser::set_extra_widget | ( | Gtk::Widget & | extra_widget | ) |
Sets an application-supplied widget to provide extra options to the user.
extra_widget | Widget for extra options. |
bool Gtk::FileChooser::set_file | ( | const Glib::RefPtr< const Gio::File > & | file | ) |
Sets file as the current filename for the file chooser, by changing to the file’s parent folder and actually selecting the file in list.
If the chooser is in Gtk::FILE_CHOOSER_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 filename. This is equivalent to a sequence of unselect_all() followed by select_filename().
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]
file | The Gio::File to set as current. |
Glib::Error |
bool Gtk::FileChooser::set_filename | ( | const std::string & | filename | ) |
Sets filename as the current filename for the file chooser, by changing to the file’s parent folder and actually selecting the file in list; all other files will be unselected.
If the chooser is in Gtk::FILE_CHOOSER_ACTION_SAVE mode, the file’s base name will also appear in the dialog’s file name entry.
Note that the file must exist, or nothing will be done except for the directory change.
You should use this function only when implementing a save dialog for which 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... to save a copy or a modified version. 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]
In the first case, the file chooser will present the user with useful suggestions as to where to save his new file. In the second case, the file’s existing location is already known, so the file chooser will use it.
filename | The filename to set as current. |
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.
filter | A Gtk::FileFilter. |
void Gtk::FileChooser::set_local_only | ( | bool | local_only = true | ) |
Sets whether only local files can be selected in the file selector.
If local_only is true
(the default), then the selected file or files are guaranteed to be accessible through the operating systems native file system and therefore the application only needs to worry about the filename functions in Gtk::FileChooser, like get_filename(), rather than the URI functions like get_uri(),
On some systems non-native files may still be available using the native filesystem via a userspace filesystem (FUSE).
local_only | true if only local files can be selected. |
void Gtk::FileChooser::set_preview_widget | ( | Gtk::Widget & | preview_widget | ) |
Sets an application-supplied widget to use to display a custom preview of the currently selected file.
To implement a preview, after setting the preview widget, you connect to the Gtk::FileChooser::signal_update_preview() signal, and call get_preview_filename() or get_preview_uri() on each change. If you can display a preview of the new file, update your widget and set the preview active using set_preview_widget_active(). Otherwise, set the preview inactive.
When there is no application-supplied preview widget, or the application-supplied preview widget is not active, the file chooser will display no preview at all.
preview_widget | Widget for displaying preview. |
void Gtk::FileChooser::set_preview_widget_active | ( | bool | active = true | ) |
Sets whether the preview widget set by set_preview_widget() should be shown for the current filename.
When active is set to false, the file chooser may display an internally generated preview of the current file or it may display no preview at all. See set_preview_widget() for more details.
active | Whether to display the user-specified preview widget. |
void Gtk::FileChooser::set_select_multiple | ( | bool | select_multiple = true | ) |
Sets whether multiple files can be selected in the file selector.
This is only relevant if the action is set to be Gtk::FILE_CHOOSER_ACTION_OPEN or Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER.
select_multiple | true if multiple files can be selected. |
void Gtk::FileChooser::set_show_hidden | ( | bool | show_hidden = true | ) |
Sets whether hidden files and folders are displayed in the file selector.
show_hidden | true if hidden files and folders should be displayed. |
bool Gtk::FileChooser::set_uri | ( | const Glib::ustring & | uri | ) |
Sets the file referred to by uri as the current file for the file chooser, by changing to the URI’s parent folder and actually selecting the URI in the list.
If the chooser is Gtk::FILE_CHOOSER_ACTION_SAVE mode, the URI’s base name will also appear in the dialog’s file name entry.
Note that the URI must exist, or nothing will be done except for the directory change.
You should use this function only when implementing a save dialog for which 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... to save a copy or a modified version. 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]
In the first case, the file chooser will present the user with useful suggestions as to where to save his new file. In the second case, the file’s existing location is already known, so the file chooser will use it.
uri | The URI to set as current. |
void Gtk::FileChooser::set_use_preview_label | ( | bool | use_label = true | ) |
Sets whether the file chooser should display a stock label with the name of the file that is being previewed; the default is true
.
Applications that want to draw the whole preview area themselves should set this to false
and display the name themselves in their preview widget.
See also: set_preview_widget()
use_label | Whether to display a stock label with the name of the previewed file. |
Glib::SignalProxy< FileChooserConfirmation > Gtk::FileChooser::signal_confirm_overwrite | ( | ) |
FileChooserConfirmation on_my_confirm_overwrite()
Flags: Run Last
This signal gets emitted whenever it is appropriate to present a confirmation dialog when the user has selected a file name that already exists. The signal only gets emitted when the file chooser is in Gtk::FILE_CHOOSER_ACTION_SAVE mode.
Most applications just need to turn on the Gtk::FileChooser::property_do_overwrite_confirmation() property (or call the Gtk::FileChooser::set_do_overwrite_confirmation() function), and they will automatically get a stock confirmation dialog. Applications which need to customize this behavior should do that, and also connect to the Gtk::FileChooser::signal_confirm_overwrite() signal.
A signal handler for this signal must return a Gtk::FileChooserConfirmation value, which indicates the action to take. If the handler determines that the user wants to select a different filename, it should return Gtk::FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN. If it determines that the user is satisfied with his choice of file name, it should return Gtk::FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME. On the other hand, if it determines that the stock confirmation dialog should be used, it should return Gtk::FILE_CHOOSER_CONFIRMATION_CONFIRM. The following example illustrates this.
[C example ellipted]
Glib::SignalProxy< void > Gtk::FileChooser::signal_current_folder_changed | ( | ) |
void on_my_current_folder_changed()
Flags: Run Last
This signal is emitted when the current folder in a Gtk::FileChooser changes. This can happen due to the user performing some action that changes folders, such as selecting a bookmark or visiting a folder on the file list. It can also happen as a result of calling a function to explicitly change the current folder in a file chooser.
Normally you do not need to connect to this signal, unless you need to keep track of which folder a file chooser is showing.
See also: Gtk::FileChooser::set_current_folder(), Gtk::FileChooser::get_current_folder(), Gtk::FileChooser::set_current_folder_uri(), Gtk::FileChooser::get_current_folder_uri().
Glib::SignalProxy< void > Gtk::FileChooser::signal_file_activated | ( | ) |
void on_my_file_activated()
Flags: Run Last
This signal is emitted when the user "activates" a file in the file chooser. This can happen by double-clicking on a file in the file list, or by pressing Enter
.
Normally you do not need to connect to this signal. It is used internally by Gtk::FileChooserDialog to know when to activate the default button in the dialog.
See also: Gtk::FileChooser::get_filename(), Gtk::FileChooser::get_filenames(), Gtk::FileChooser::get_uri(), Gtk::FileChooser::get_uris().
Glib::SignalProxy< void > Gtk::FileChooser::signal_selection_changed | ( | ) |
void on_my_selection_changed()
Flags: Run Last
This signal is emitted when there is a change in the set of selected files in a Gtk::FileChooser. This can happen when the user modifies the selection with the mouse or the keyboard, or when explicitly calling functions to change the selection.
Normally you do not need to connect to this signal, as it is easier to wait for the file chooser to finish running, and then to get the list of selected files using the functions mentioned below.
See also: Gtk::FileChooser::select_filename(), Gtk::FileChooser::unselect_filename(), Gtk::FileChooser::get_filename(), Gtk::FileChooser::get_filenames(), Gtk::FileChooser::select_uri(), Gtk::FileChooser::unselect_uri(), Gtk::FileChooser::get_uri(), Gtk::FileChooser::get_uris().
Glib::SignalProxy< void > Gtk::FileChooser::signal_update_preview | ( | ) |
void on_my_update_preview()
Flags: Run Last
This signal is emitted when the preview in a file chooser should be regenerated. For example, this can happen when the currently selected file changes. You should use this signal if you want your file chooser to have a preview widget.
Once you have installed a preview widget with Gtk::FileChooser::set_preview_widget(), you should update it when this signal is emitted. You can use the functions Gtk::FileChooser::get_preview_filename() or Gtk::FileChooser::get_preview_uri() to get the name of the file to preview. Your widget may not be able to preview all kinds of files; your callback must call Gtk::FileChooser::set_preview_widget_active() to inform the file chooser about whether the preview was generated successfully or not.
Please see the example code in [Using a Preview Widget][gtkfilechooser-preview].
See also: Gtk::FileChooser::set_preview_widget(), Gtk::FileChooser::set_preview_widget_active(), Gtk::FileChooser::set_use_preview_label(), Gtk::FileChooser::get_preview_filename(), Gtk::FileChooser::get_preview_uri().
void Gtk::FileChooser::unselect_all | ( | ) |
Unselects all the files in the current folder of a file chooser.
void Gtk::FileChooser::unselect_file | ( | const Glib::RefPtr< const Gio::File > & | file | ) |
Unselects the file referred to by file.
If the file is not in the current directory, does not exist, or is otherwise not currently selected, does nothing.
file | A Gio::File. |
void Gtk::FileChooser::unselect_filename | ( | const std::string & | filename | ) |
Unselects a currently selected filename.
If the filename is not in the current directory, does not exist, or is otherwise not currently selected, does nothing.
filename | The filename to unselect. |
void Gtk::FileChooser::unselect_uri | ( | const Glib::ustring & | uri | ) |
Unselects the file referred to by uri.
If the file is not in the current directory, does not exist, or is otherwise not currently selected, does nothing.
uri | The URI to unselect. |
|
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. |