FileChooser
Object Hierarchy:
Gtk.FileChooser
Gtk.FileChooser
Gtk.FileChooser
GLib.Object
GLib.Object
GLib.Object->Gtk.FileChooser
Description:
[ CCode ( type_id = "gtk_file_chooser_get_type ()" ) ]public interface FileChooser : Object
`GtkFileChooser` is an interface that can be implemented by file selection widgets.
In GTK, the main objects that implement this interface are [[email protected] ] and [[email protected] ].
You do not need to write an object that implements the `GtkFileChooser` interface unless you are trying to adapt an existing file
selector to expose a standard programming interface.
`GtkFileChooser` allows for shortcuts to various places in the filesystem. In the default implementation these are displayed in the left
pane. It may be a bit confusing at first that these shortcuts come from various sources and in various flavours, so lets explain the
terminology here:
Bookmarks: are created by the user, by dragging folders from the right pane to the left pane, or by using the “Add”. Bookmarks
can be renamed and deleted by the user.
Shortcuts: can be provided by the application. For example, a Paint program may want to add a shortcut for a Clipart folder.
Shortcuts cannot be modified by the user.
Volumes: are provided by the underlying filesystem abstraction. They are the “roots” of the filesystem.
File Names and Encodings
When the user is finished selecting files in a `GtkFileChooser`, your program can get the selected filenames as `GFile`s.
Adding options
You can add extra widgets to a file chooser to provide options that are not present in the default design, by using [
[email protected] _choice]. Each choice has an identifier and a user visible label; additionally, each choice can have multiple
options. If a choice has no option, it will be rendered as a check button with the given label; if a choice has options, it will be
rendered as a combo box.
All known implementing classes:
Content:
Properties:
public abstract FileChooserAction action { get ; set ; }
The type of operation that the file chooser is performing.
public abstract bool create_folders { get ; set ; }
Whether a file chooser not in
gtk_file_chooser_action_open mode will offer the user to create new folders.
public abstract FileFilter filter { get ; set ; }
The current filter for selecting files that are displayed.
public abstract ListModel filters { owned get ; }
A `GListModel` containing the filters that have been added with
add_filter .
public abstract bool select_multiple { get ; set ; }
Whether to allow multiple files to be selected.
public abstract ListModel shortcut_folders { owned get ; }
Methods:
public void add_choice (string id, string label, string []? options, string []? option_labels)
Adds a 'choice' to the file chooser.
public void add_filter (FileFilter filter)
Adds filter
to the list of filters that the user can
select between.
public bool add_shortcut_folder (File folder) throws Error
Adds a folder to be displayed with the shortcut folders in a file
chooser.
public FileChooserAction get_action ()
Gets the type of operation that the file chooser is performing.
public unowned string ? get_choice (string id)
Gets the currently selected option in the 'choice' with the given ID.
public bool get_create_folders ()
Gets whether file chooser will offer to create new folders.
public File ? get_current_folder ()
Gets the current folder of this as
`GFile`.
public string ? get_current_name ()
Gets the current name in the file selector, as entered by the user.
public File ? get_file ()
Gets the `GFile` for the currently selected file in the file selector.
public ListModel get_files ()
Lists all the selected files and subfolders in the current folder of
this as `GFile`.
public unowned FileFilter ? get_filter ()
Gets the current filter.
public ListModel get_filters ()
Gets the current set of user-selectable filters, as a list model.
public bool get_select_multiple ()
Gets whether multiple files can be selected in the file chooser.
public ListModel get_shortcut_folders ()
Queries the list of shortcut folders in the file chooser.
public void remove_choice (string id)
Removes a 'choice' that has been added with
add_choice .
public void remove_filter (FileFilter filter)
Removes filter
from the list of filters that the user can
select between.
public bool remove_shortcut_folder (File folder) throws Error
Removes a folder from the shortcut folders in a file chooser.
public void set_action (FileChooserAction action)
Sets the type of operation that the chooser is performing.
public void set_choice (string id, string option)
Selects an option in a 'choice' that has been added with
add_choice .
public void set_create_folders (bool create_folders)
Sets whether file chooser will offer to create new folders.
public bool set_current_folder (File ? file) throws Error
Sets the current folder for this
from a `GFile`.
public void set_current_name (string name)
Sets the current name in the file selector, as if entered by the user.
public bool set_file (File file) throws Error
Sets file
as the current filename for the file chooser.
public void set_filter (FileFilter filter)
Sets the current filter.
public void set_select_multiple (bool select_multiple)
Sets whether multiple files can be selected in the file chooser.
Inherited Members:
All known members inherited from class GLib.Object
@get
@new
@ref
@set
add_toggle_ref
add_weak_pointer
bind_property
connect
constructed
disconnect
dispose
dup_data
dup_qdata
force_floating
freeze_notify
get_class
get_data
get_property
get_qdata
get_type
getv
interface_find_property
interface_install_property
interface_list_properties
is_floating
new_valist
new_with_properties
newv
notify
notify_property
ref_count
ref_sink
remove_toggle_ref
remove_weak_pointer
replace_data
replace_qdata
set_data
set_data_full
set_property
set_qdata
set_qdata_full
set_valist
setv
steal_data
steal_qdata
thaw_notify
unref
watch_closure
weak_ref
weak_unref