Trait gtk::prelude::FileChooserExt [−][src]
pub trait FileChooserExt: 'static {}Show methods
fn add_filter(&self, filter: &FileFilter); fn add_shortcut_folder<P: AsRef<Path>>(
&self,
folder: P
) -> Result<(), Error>; fn add_shortcut_folder_uri(&self, uri: &str) -> Result<(), Error>; fn action(&self) -> FileChooserAction; fn choice(&self, id: &str) -> Option<GString>; fn creates_folders(&self) -> bool; fn current_folder(&self) -> Option<PathBuf>; fn current_folder_file(&self) -> Option<File>; fn current_folder_uri(&self) -> Option<GString>; fn current_name(&self) -> Option<GString>; fn does_overwrite_confirmation(&self) -> bool; fn extra_widget(&self) -> Option<Widget>; fn file(&self) -> Option<File>; fn filename(&self) -> Option<PathBuf>; fn filenames(&self) -> Vec<PathBuf>; fn files(&self) -> Vec<File>; fn filter(&self) -> Option<FileFilter>; fn is_local_only(&self) -> bool; fn preview_file(&self) -> Option<File>; fn preview_filename(&self) -> Option<PathBuf>; fn preview_uri(&self) -> Option<GString>; fn preview_widget(&self) -> Option<Widget>; fn is_preview_widget_active(&self) -> bool; fn selects_multiple(&self) -> bool; fn shows_hidden(&self) -> bool; fn uri(&self) -> Option<GString>; fn uris(&self) -> Vec<GString>; fn uses_preview_label(&self) -> bool; fn list_filters(&self) -> Vec<FileFilter>; fn list_shortcut_folder_uris(&self) -> Vec<GString>; fn list_shortcut_folders(&self) -> Vec<PathBuf>; fn remove_choice(&self, id: &str); fn remove_filter(&self, filter: &FileFilter); fn remove_shortcut_folder<P: AsRef<Path>>(
&self,
folder: P
) -> Result<(), Error>; fn remove_shortcut_folder_uri(&self, uri: &str) -> Result<(), Error>; fn select_all(&self); fn select_file<P: IsA<File>>(&self, file: &P) -> Result<(), Error>; fn select_filename<P: AsRef<Path>>(&self, filename: P) -> bool; fn select_uri(&self, uri: &str) -> bool; fn set_action(&self, action: FileChooserAction); fn set_choice(&self, id: &str, option: &str); fn set_create_folders(&self, create_folders: bool); fn set_current_folder<P: AsRef<Path>>(&self, filename: P) -> bool; fn set_current_folder_file<P: IsA<File>>(
&self,
file: &P
) -> Result<(), Error>; fn set_current_folder_uri(&self, uri: &str) -> bool; fn set_current_name(&self, name: &str); fn set_do_overwrite_confirmation(&self, do_overwrite_confirmation: bool); fn set_extra_widget<P: IsA<Widget>>(&self, extra_widget: &P); fn set_file<P: IsA<File>>(&self, file: &P) -> Result<(), Error>; fn set_filename<P: AsRef<Path>>(&self, filename: P) -> bool; fn set_filter(&self, filter: &FileFilter); fn set_local_only(&self, local_only: bool); fn set_preview_widget<P: IsA<Widget>>(&self, preview_widget: &P); fn set_preview_widget_active(&self, active: bool); fn set_select_multiple(&self, select_multiple: bool); fn set_show_hidden(&self, show_hidden: bool); fn set_uri(&self, uri: &str) -> bool; fn set_use_preview_label(&self, use_label: bool); fn unselect_all(&self); fn unselect_file<P: IsA<File>>(&self, file: &P); fn unselect_filename<P: AsRef<Path>>(&self, filename: P); fn unselect_uri(&self, uri: &str); fn connect_confirm_overwrite<F: Fn(&Self) -> FileChooserConfirmation + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_current_folder_changed<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_file_activated<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_selection_changed<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_update_preview<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_action_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_create_folders_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_do_overwrite_confirmation_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_extra_widget_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_filter_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_local_only_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_preview_widget_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_preview_widget_active_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_select_multiple_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_show_hidden_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_use_preview_label_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
Expand description
Trait containing all FileChooser
methods.
Implementors
FileChooserButton
, FileChooserDialog
, FileChooserNative
, FileChooserWidget
, FileChooser
Required methods
fn add_filter(&self, filter: &FileFilter)
fn add_filter(&self, filter: &FileFilter)
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 self
takes ownership of the filter, so you have to
ref and sink it if you want to keep a reference.
filter
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
Returns
true
if the folder could be added successfully, false
otherwise. In the latter case, the error
will be set as appropriate.
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
Returns
true
if the folder could be added successfully, false
otherwise. In the latter case, the error
will be set as appropriate.
fn action(&self) -> FileChooserAction
fn action(&self) -> FileChooserAction
Gets the type of operation that the file chooser is performing; see
set_action()
.
Returns
the action that the file selector is performing
v3_22
only.fn creates_folders(&self) -> bool
fn creates_folders(&self) -> bool
Gets whether file choser will offer to create new folders.
See set_create_folders()
.
Returns
true
if the Create Folder button should be displayed.
fn current_folder(&self) -> Option<PathBuf>
fn current_folder(&self) -> Option<PathBuf>
Gets the current folder of self
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
FileChooserAction::SelectFolder
mode
(e.g. “/home/username/Documents/selected-folder/”. To get the
currently-selected folder in that mode, use uri()
as the
usual way to get the selection.
Returns
the full path of the current
folder, or None
if the current path cannot be represented as a local
filename. Free with g_free()
. This function will also return
None
if the file chooser was unable to load the last folder that
was requested from it; for example, as would be for calling
set_current_folder()
on a nonexistent folder.
fn current_folder_file(&self) -> Option<File>
fn current_folder_file(&self) -> Option<File>
Gets the current folder of self
as gio::File
.
See current_folder_uri()
.
Returns
the gio::File
for the current folder.
fn current_folder_uri(&self) -> Option<GString>
fn current_folder_uri(&self) -> Option<GString>
Gets the current folder of self
as an URI.
See set_current_folder_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
FileChooserAction::SelectFolder
mode
(e.g. “file:///home/username/Documents/selected-folder/”. To get the
currently-selected folder in that mode, use uri()
as the
usual way to get the selection.
Returns
the URI for the current folder.
Free with g_free()
. This function will also return None
if the file chooser
was unable to load the last folder that was requested from it; for example,
as would be for calling set_current_folder_uri()
on a
nonexistent folder.
fn current_name(&self) -> Option<GString>
fn current_name(&self) -> Option<GString>
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”.
Returns
The raw text from the file chooser’s “Name” entry. Free this with
g_free()
. Note that this string is not a full pathname or URI; it is
whatever the contents of the entry are. Note also that this string is in
UTF-8 encoding, which is not necessarily the system’s encoding for filenames.
fn does_overwrite_confirmation(&self) -> bool
fn does_overwrite_confirmation(&self) -> bool
fn extra_widget(&self) -> Option<Widget>
fn extra_widget(&self) -> Option<Widget>
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.
Returns
a selected gio::File
. You own the returned file;
use g_object_unref()
to release it.
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.
Returns
The currently selected filename,
or None
if no file is selected, or the selected file can’t
be represented with a local filename. Free with g_free()
.
Lists all the selected files and subfolders in the current folder of
self
. The returned names are full absolute paths. If files in the current
folder cannot be represented as local filenames they will be ignored. (See
uris()
)
Returns
a GSList
containing the filenames of all selected files and subfolders in
the current folder. Free the returned list with g_slist_free()
,
and the filenames with g_free()
.
Lists all the selected files and subfolders in the current folder of self
as gio::File
. An internal function, see uris()
.
Returns
a GSList
containing a gio::File
for each selected file and subfolder in the
current folder. Free the returned list with g_slist_free()
, and
the files with g_object_unref()
.
fn filter(&self) -> Option<FileFilter>
fn filter(&self) -> Option<FileFilter>
fn is_local_only(&self) -> bool
fn is_local_only(&self) -> bool
Gets whether only local files can be selected in the
file selector. See set_local_only()
Returns
true
if only local files can be selected.
fn preview_file(&self) -> Option<File>
fn preview_file(&self) -> Option<File>
Gets the gio::File
that should be previewed in a custom preview
Internal function, see preview_uri()
.
Returns
the gio::File
for the file to preview,
or None
if no file is selected. Free with g_object_unref()
.
fn preview_filename(&self) -> Option<PathBuf>
fn preview_filename(&self) -> Option<PathBuf>
Gets the filename that should be previewed in a custom preview
widget. See set_preview_widget()
.
Returns
the filename to preview, or None
if
no file is selected, or if the selected file cannot be represented
as a local filename. Free with g_free()
fn preview_uri(&self) -> Option<GString>
fn preview_uri(&self) -> Option<GString>
Gets the URI that should be previewed in a custom preview
widget. See set_preview_widget()
.
Returns
the URI for the file to preview,
or None
if no file is selected. Free with g_free()
.
fn preview_widget(&self) -> Option<Widget>
fn preview_widget(&self) -> Option<Widget>
Gets the current preview widget; see
set_preview_widget()
.
Returns
the current preview widget, or None
fn is_preview_widget_active(&self) -> bool
fn is_preview_widget_active(&self) -> bool
Gets whether the preview widget set by set_preview_widget()
should be shown for the current filename. See
set_preview_widget_active()
.
Returns
true
if the preview widget is active for the current filename.
fn selects_multiple(&self) -> bool
fn selects_multiple(&self) -> bool
Gets whether multiple files can be selected in the file
selector. See set_select_multiple()
.
Returns
true
if multiple files can be selected.
Gets whether hidden files and folders are displayed in the file selector.
See set_show_hidden()
.
Returns
true
if hidden files and folders are displayed.
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.
Returns
The currently selected URI, or None
if no file is selected. If set_local_only()
is set to
true
(the default) a local URI will be returned for any FUSE locations.
Free with g_free()
Lists all the selected files and subfolders in the current folder of
self
. The returned names are full absolute URIs.
Returns
a GSList
containing the URIs of all selected
files and subfolders in the current folder. Free the returned list
with g_slist_free()
, and the filenames with g_free()
.
fn uses_preview_label(&self) -> bool
fn uses_preview_label(&self) -> bool
Gets whether a stock label should be drawn with the name of the previewed
file. See set_use_preview_label()
.
Returns
true
if the file chooser is set to display a label with the
name of the previewed file, false
otherwise.
fn list_filters(&self) -> Vec<FileFilter>
fn list_filters(&self) -> Vec<FileFilter>
Lists the current set of user-selectable filters; see
add_filter()
, remove_filter()
.
Returns
a
GSList
containing the current set of user selectable filters. The
contents of the list are owned by GTK+, but you must free the list
itself with g_slist_free()
when you are done with it.
fn list_shortcut_folder_uris(&self) -> Vec<GString>
fn list_shortcut_folder_uris(&self) -> Vec<GString>
Queries the list of shortcut folders in the file chooser, as set by
add_shortcut_folder_uri()
.
Returns
A list of
folder URIs, or None
if there are no shortcut folders. Free the
returned list with g_slist_free()
, and the URIs with g_free()
.
fn list_shortcut_folders(&self) -> Vec<PathBuf>
fn list_shortcut_folders(&self) -> Vec<PathBuf>
Queries the list of shortcut folders in the file chooser, as set by
add_shortcut_folder()
.
Returns
A list
of folder filenames, or None
if there are no shortcut folders.
Free the returned list with g_slist_free()
, and the filenames with
g_free()
.
fn remove_choice(&self, id: &str)
fn remove_choice(&self, id: &str)
v3_22
only.Removes a ‘choice’ that has been added with gtk_file_chooser_add_choice()
.
id
the ID of the choice to remove
fn remove_filter(&self, filter: &FileFilter)
fn remove_filter(&self, filter: &FileFilter)
Removes a folder from a file chooser’s list of shortcut folders.
folder
filename of the folder to remove
Returns
true
if the operation succeeds, false
otherwise.
In the latter case, the error
will be set as appropriate.
See also: add_shortcut_folder()
Removes a folder URI from a file chooser’s list of shortcut folders.
uri
URI of the folder to remove
Returns
true
if the operation succeeds, false
otherwise.
In the latter case, the error
will be set as appropriate.
See also: add_shortcut_folder_uri()
fn select_all(&self)
fn select_all(&self)
Selects all the files in the current folder of a file chooser.
fn select_filename<P: AsRef<Path>>(&self, filename: P) -> bool
fn select_filename<P: AsRef<Path>>(&self, filename: P) -> bool
Selects a filename. If the file name isn’t in the current
folder of self
, then the current folder of self
will
be changed to the folder containing filename
.
filename
the filename to select
Returns
Not useful.
See also: set_filename()
fn select_uri(&self, uri: &str) -> bool
fn select_uri(&self, uri: &str) -> bool
fn set_action(&self, action: FileChooserAction)
fn set_action(&self, action: FileChooserAction)
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
FileChooserAction::Save
but not if the action is
FileChooserAction::Open
.
action
the action that the file selector is performing
fn set_choice(&self, id: &str, option: &str)
fn set_choice(&self, id: &str, option: &str)
v3_22
only.fn set_create_folders(&self, create_folders: bool)
fn set_create_folders(&self, create_folders: bool)
Sets whether file choser will offer to create new folders.
This is only relevant if the action is not set to be
FileChooserAction::Open
.
create_folders
true
if the Create Folder button should be displayed
fn set_current_folder<P: AsRef<Path>>(&self, filename: P) -> bool
fn set_current_folder<P: AsRef<Path>>(&self, filename: P) -> bool
Sets the current folder for self
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
Returns
Not useful.
fn set_current_folder_uri(&self, uri: &str) -> bool
fn set_current_folder_uri(&self, uri: &str) -> bool
Sets the current folder for self
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
Returns
true
if the folder could be changed successfully, false
otherwise.
fn set_current_name(&self, name: &str)
fn set_current_name(&self, name: &str)
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
fn set_do_overwrite_confirmation(&self, do_overwrite_confirmation: bool)
fn set_do_overwrite_confirmation(&self, do_overwrite_confirmation: bool)
Sets whether a file chooser in FileChooserAction::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 self
will emit the
signal::FileChooser::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
signal::FileChooser::confirm-overwrite
signal; please refer to its documentation
for the details.
do_overwrite_confirmation
whether to confirm overwriting in save mode
fn set_extra_widget<P: IsA<Widget>>(&self, extra_widget: &P)
fn set_extra_widget<P: IsA<Widget>>(&self, extra_widget: &P)
Sets an application-supplied widget to provide extra options to the user.
extra_widget
widget for extra options
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 self
is in FileChooserAction::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 self
, then the current
folder of self
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:
⚠️ The following code is in C ⚠️
if (document_is_new)
{
// the user just created a new document
gtk_file_chooser_set_current_folder_file (chooser, default_file_for_saving);
gtk_file_chooser_set_current_name (chooser, "Untitled document");
}
else
{
// the user edited an existing document
gtk_file_chooser_set_file (chooser, existing_file);
}
file
the gio::File
to set as current
Returns
Not useful.
fn set_filename<P: AsRef<Path>>(&self, filename: P) -> bool
fn set_filename<P: AsRef<Path>>(&self, filename: P) -> bool
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 self
is in
FileChooserAction::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:
⚠️ The following code is in C ⚠️
if (document_is_new)
{
// the user just created a new document
gtk_file_chooser_set_current_name (chooser, "Untitled document");
}
else
{
// the user edited an existing document
gtk_file_chooser_set_filename (chooser, existing_filename);
}
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
Returns
Not useful.
fn set_filter(&self, filter: &FileFilter)
fn set_filter(&self, filter: &FileFilter)
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
fn set_local_only(&self, local_only: bool)
fn set_local_only(&self, local_only: bool)
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
FileChooser
, like filename()
,
rather than the URI functions like
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
fn set_preview_widget<P: IsA<Widget>>(&self, preview_widget: &P)
fn set_preview_widget<P: IsA<Widget>>(&self, preview_widget: &P)
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 signal::FileChooser::update-preview
signal, and call preview_filename()
or
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.
fn set_preview_widget_active(&self, active: bool)
fn set_preview_widget_active(&self, active: bool)
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
fn set_select_multiple(&self, select_multiple: bool)
fn set_select_multiple(&self, select_multiple: bool)
Sets whether multiple files can be selected in the file selector. This is
only relevant if the action is set to be FileChooserAction::Open
or
FileChooserAction::SelectFolder
.
select_multiple
true
if multiple files can be selected.
Sets whether hidden files and folders are displayed in the file selector.
show_hidden
true
if hidden files and folders should be displayed.
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 self
is FileChooserAction::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:
⚠️ The following code is in C ⚠️
if (document_is_new)
{
// the user just created a new document
gtk_file_chooser_set_current_name (chooser, "Untitled document");
}
else
{
// the user edited an existing document
gtk_file_chooser_set_uri (chooser, existing_uri);
}
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
Returns
Not useful.
fn set_use_preview_label(&self, use_label: bool)
fn set_use_preview_label(&self, use_label: bool)
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
fn unselect_all(&self)
fn unselect_all(&self)
Unselects all the files in the current folder of a file chooser.
fn unselect_file<P: IsA<File>>(&self, file: &P)
fn unselect_file<P: IsA<File>>(&self, file: &P)
fn unselect_filename<P: AsRef<Path>>(&self, filename: P)
fn unselect_filename<P: AsRef<Path>>(&self, filename: P)
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
fn unselect_uri(&self, uri: &str)
fn unselect_uri(&self, uri: &str)
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
fn connect_confirm_overwrite<F: Fn(&Self) -> FileChooserConfirmation + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_confirm_overwrite<F: Fn(&Self) -> FileChooserConfirmation + 'static>(
&self,
f: F
) -> SignalHandlerId
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 FileChooserAction::Save
mode.
Most applications just need to turn on the
property::FileChooser::do-overwrite-confirmation
property (or call the
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 signal::FileChooser::confirm-overwrite
signal.
A signal handler for this signal must return a
FileChooserConfirmation
value, which indicates the action to
take. If the handler determines that the user wants to select a
different filename, it should return
FileChooserConfirmation::SelectAgain
. If it determines
that the user is satisfied with his choice of file name, it
should return FileChooserConfirmation::AcceptFilename
.
On the other hand, if it determines that the stock confirmation
dialog should be used, it should return
FileChooserConfirmation::Confirm
. The following example
illustrates this.
Custom confirmation ## {gtkfilechooser
-confirmation}
⚠️ The following code is in C ⚠️
static GtkFileChooserConfirmation
confirm_overwrite_callback (GtkFileChooser *chooser, gpointer data)
{
char *uri;
uri = gtk_file_chooser_get_uri (chooser);
if (is_uri_read_only (uri))
{
if (user_wants_to_replace_read_only_file (uri))
return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME;
else
return GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN;
} else
return GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM; // fall back to the default dialog
}
...
chooser = gtk_file_chooser_dialog_new (...);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
g_signal_connect (chooser, "confirm-overwrite",
G_CALLBACK (confirm_overwrite_callback), NULL);
if (gtk_dialog_run (chooser) == GTK_RESPONSE_ACCEPT)
save_to_file (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
gtk_widget_destroy (chooser);
Returns
a FileChooserConfirmation
value that indicates which
action to take after emitting the signal.
fn connect_current_folder_changed<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_current_folder_changed<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
This signal is emitted when the current folder in a 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: set_current_folder()
,
current_folder()
,
set_current_folder_uri()
,
current_folder_uri()
.
fn connect_file_activated<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_file_activated<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
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 FileChooserDialog
to know when to activate the default button in the
dialog.
See also: filename()
,
filenames()
, uri()
,
uris()
.
fn connect_selection_changed<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_selection_changed<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
This signal is emitted when there is a change in the set of selected files
in a 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: select_filename()
,
unselect_filename()
, filename()
,
filenames()
, select_uri()
,
unselect_uri()
, uri()
,
uris()
.
fn connect_update_preview<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_update_preview<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
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
set_preview_widget()
, you should update it when this
signal is emitted. You can use the functions
preview_filename()
or
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 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: set_preview_widget()
,
set_preview_widget_active()
,
set_use_preview_label()
,
preview_filename()
,
preview_uri()
.
fn connect_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_create_folders_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_do_overwrite_confirmation_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_extra_widget_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_filter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_local_only_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_preview_widget_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_preview_widget_active_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_select_multiple_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_use_preview_label_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId