gtkmm 4.16.0
|
A native file chooser dialog, suitable for “File/Open” or “File/Save” commands. More...
#include <gtkmm/filechoosernative.h>
Public Member Functions | |
FileChooserNative (FileChooserNative &&src) noexcept | |
FileChooserNative & | operator= (FileChooserNative &&src) noexcept |
~FileChooserNative () noexcept override | |
GtkFileChooserNative * | gobj () |
Provides access to the underlying C GObject. | |
const GtkFileChooserNative * | gobj () const |
Provides access to the underlying C GObject. | |
GtkFileChooserNative * | 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_accept_label () const |
Retrieves the custom label text for the accept button. | |
void | set_accept_label (const Glib::ustring &accept_label={}) |
Sets the custom label text for the accept button. | |
Glib::ustring | get_cancel_label () const |
Retrieves the custom label text for the cancel button. | |
void | set_cancel_label (const Glib::ustring &cancel_label={}) |
Sets the custom label text for the cancel button. | |
Glib::PropertyProxy< Glib::ustring > | property_accept_label () |
The text used for the label on the accept button in the dialog, or nullptr to use the default text. | |
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_accept_label () const |
The text used for the label on the accept button in the dialog, or nullptr to use the default text. | |
Glib::PropertyProxy< Glib::ustring > | property_cancel_label () |
The text used for the label on the cancel button in the dialog, or nullptr to use the default text. | |
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_cancel_label () const |
The text used for the label on the cancel button in the dialog, or nullptr to use the default text. | |
Public Member Functions inherited from Gtk::NativeDialog | |
NativeDialog (NativeDialog &&src) noexcept | |
NativeDialog & | operator= (NativeDialog &&src) noexcept |
~NativeDialog () noexcept override | |
GtkNativeDialog * | gobj () |
Provides access to the underlying C GObject. | |
const GtkNativeDialog * | gobj () const |
Provides access to the underlying C GObject. | |
GtkNativeDialog * | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
void | show () |
Shows the dialog on the display. | |
void | hide () |
Hides the dialog if it is visible, aborting any interaction. | |
bool | get_visible () const |
Determines whether the dialog is visible. | |
void | set_modal (bool modal=true) |
Sets a dialog modal or non-modal. | |
bool | get_modal () const |
Returns whether the dialog is modal. | |
void | set_title (const Glib::ustring &title) |
Sets the title of the GtkNativeDialog. | |
Glib::ustring | get_title () const |
Gets the title of the Gtk::NativeDialog . | |
void | set_transient_for (Window & parent) |
Dialog windows should be set transient for the main application window they were spawned from. | |
void | unset_transient_for () |
Unsets the current transient window. | |
Window * | get_transient_for () |
Fetches the transient parent for this window. | |
const Window * | get_transient_for () const |
Fetches the transient parent for this window. | |
Glib::PropertyProxy< Glib::ustring > | property_title () |
The title of the dialog window. | |
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_title () const |
The title of the dialog window. | |
Glib::PropertyProxy< bool > | property_modal () |
Whether the window should be modal with respect to its transient parent. | |
Glib::PropertyProxy_ReadOnly< bool > | property_modal () const |
Whether the window should be modal with respect to its transient parent. | |
Glib::PropertyProxy< bool > | property_visible () |
Whether the window is currently visible. | |
Glib::PropertyProxy_ReadOnly< bool > | property_visible () const |
Whether the window is currently visible. | |
Glib::PropertyProxy< Window * > | property_transient_for () |
The transient parent of the dialog, or nullptr for none. | |
Glib::PropertyProxy_ReadOnly< Window * > | property_transient_for () const |
The transient parent of the dialog, or nullptr for none. | |
Glib::SignalProxy< void(int)> | signal_response () |
Public Member Functions inherited from Gtk::FileChooser | |
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 GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
static Glib::RefPtr< FileChooserNative > | create (const Glib::ustring &title, Window & parent, FileChooser::Action action, const Glib::ustring &accept_label={}, const Glib::ustring &cancel_label={}) |
Creates a FileChooserNative. | |
static Glib::RefPtr< FileChooserNative > | create (const Glib::ustring &title, FileChooser::Action action, const Glib::ustring &accept_label={}, const Glib::ustring &cancel_label={}) |
A create() convenience overload. | |
Static Public Member Functions inherited from Gtk::NativeDialog | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
Static Public Member Functions inherited from Gtk::FileChooser | |
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 | |
FileChooserNative () | |
There is no create() method that corresponds to this constructor, because this constructor shall only be used by derived classes. | |
FileChooserNative (const Glib::ustring &title, Window & parent, FileChooser::Action action, const Glib::ustring &accept_label, const Glib::ustring &cancel_label) | |
Constructs a FileChooserNative. | |
FileChooserNative (const Glib::ustring &title, FileChooser::Action action, const Glib::ustring &accept_label, const Glib::ustring &cancel_label) | |
Constructs a FileChooserNative. | |
Protected Member Functions inherited from Gtk::NativeDialog | |
NativeDialog () | |
There is no create() method that corresponds to this constructor, because only derived classes shall be created. | |
virtual void | on_response (int response_id) |
This is a default handler for the signal signal_response(). | |
Protected Member Functions inherited from Gtk::FileChooser | |
FileChooser () | |
You should derive from this class to use it. | |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Gtk::FileChooserNative > | wrap (GtkFileChooserNative *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
Related Symbols inherited from Gtk::NativeDialog | |
Glib::RefPtr< Gtk::NativeDialog > | wrap (GtkNativeDialog *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
Related Symbols inherited from Gtk::FileChooser | |
Glib::RefPtr< Gtk::FileChooser > | wrap (GtkFileChooser *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
Additional Inherited Members | |
Public Types inherited from Gtk::FileChooser | |
enum class | Action { Action::OPEN , Action::SAVE , Action::SELECT_FOLDER } |
Describes whether a Gtk::FileChooser is being used to open existing files or to save to a possibly new file. More... | |
A native file chooser dialog, suitable for “File/Open” or “File/Save” commands.
FileChooserNative is an abstraction of a dialog box suitable for use with “File/Open” or “File/Save as” commands. By default, this just uses a Gtk::FileChooserDialog to implement the actual dialog. However, on certain platforms, such as Windows, the native platform file chooser is used instead. When the application is running in a sandboxed environment without direct filesystem access (such as Flatpak), FileChooserNative may call the proper APIs (portals) to let the user choose a file and make it available to the application.
While the API of FileChooserNative closely mirrors FileChooserDialog, the main difference is that there is no access to any Gtk::Window or Gtk::Widget for the dialog. This is required, as there may not be one in the case of a platform native dialog. Showing, hiding and running the dialog is handled by the NativeDialog functions.
FileChooserNative inherits from NativeDialog, which means it will return Gtk::ResponseType::ACCEPT if the user accepted, and Gtk::ResponseType::CANCEL if he pressed cancel. It can also return Gtk::ResponseType::DELETE_EVENT if the window was unexpectedly closed.
There are a few things in the FileChooser API that are not possible to use with FileChooserNative, as such use would prohibit the use of a native dialog.
There is no support for the signals that are emitted when the user navigates in the dialog, including:
You can also not use the methods that directly control user navigation:
If you need any of the above you will have to use FileChooserDialog directly.
No operations that change the dialog work while the dialog is visible. Set all the properties that are required before showing the dialog.
On windows the IFileDialog implementation (added in Windows Vista) is used. It supports many of the features that FileChooserDialog does, but there are some things it does not handle:
If any of these features are used the regular FileChooserDialog will be used in place of the native one.
When the org.freedesktop.portal.FileChooser portal is available on the session bus, it is used to bring up an out-of-process file chooser. Depending on the kind of session the application is running in, this may or may not be a GTK+ file chooser. In this situation, the following things are not supported and will be silently ignored:
|
noexcept |
|
overridenoexcept |
|
protected |
There is no create() method that corresponds to this constructor, because this constructor shall only be used by derived classes.
|
protected |
Constructs a FileChooserNative.
|
protected |
Constructs a FileChooserNative.
|
static |
A create() convenience overload.
|
static |
Creates a FileChooserNative.
title | Title of the native. |
parent | Transient parent of the native. |
action | Open or save mode for the dialog. |
accept_label | Text to go in the accept button, or empty string for the default. |
cancel_label | Text to go in the cancel button, or empty string for the default. |
Glib::ustring Gtk::FileChooserNative::get_accept_label | ( | ) | const |
Retrieves the custom label text for the accept button.
Deprecated: 4.10: Use Gtk::FileDialog instead
Glib::ustring Gtk::FileChooserNative::get_cancel_label | ( | ) | const |
Retrieves the custom label text for the cancel button.
Deprecated: 4.10: Use Gtk::FileDialog instead
|
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.
GtkFileChooserNative * Gtk::FileChooserNative::gobj_copy | ( | ) |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
|
noexcept |
Glib::PropertyProxy< Glib::ustring > Gtk::FileChooserNative::property_accept_label | ( | ) |
The text used for the label on the accept button in the dialog, or nullptr
to use the default text.
Default value: ""
Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::FileChooserNative::property_accept_label | ( | ) | const |
The text used for the label on the accept button in the dialog, or nullptr
to use the default text.
Default value: ""
Glib::PropertyProxy< Glib::ustring > Gtk::FileChooserNative::property_cancel_label | ( | ) |
The text used for the label on the cancel button in the dialog, or nullptr
to use the default text.
Default value: ""
Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::FileChooserNative::property_cancel_label | ( | ) | const |
The text used for the label on the cancel button in the dialog, or nullptr
to use the default text.
Default value: ""
Sets the custom label text for the accept button.
If characters in label are preceded by an underscore, they are underlined. If you need a literal underscore character in a label, use “__” (two underscores). The first underlined character represents a keyboard accelerator called a mnemonic.
Pressing Alt and that key should activate the button.
Deprecated: 4.10: Use Gtk::FileDialog instead
accept_label | Custom label. |
Sets the custom label text for the cancel button.
If characters in label are preceded by an underscore, they are underlined. If you need a literal underscore character in a label, use “__” (two underscores). The first underlined character represents a keyboard accelerator called a mnemonic.
Pressing Alt and that key should activate the button.
Deprecated: 4.10: Use Gtk::FileDialog instead
cancel_label | Custom label. |
|
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. |