Object Hierarchy:

Object hierarchy for FileChooserButton


[ CCode ( type_id = "gtk_file_chooser_button_get_type ()" ) ]
public class FileChooserButton : Widget, Accessible, Buildable, ConstraintTarget, FileChooser

The FileChooserButton is a widget that lets the user select a file.

It implements the FileChooser interface. Visually, it is a file name with a button to bring up a FileChooserDialog. The user can then use that dialog to change the file associated with that button. This widget does not support setting the select_multiple property to true .

Create a button to let the user select a file in /etc

GtkWidget *button;
GFile *cwd = g_file_new_for_path ("/etc");

button = gtk_file_chooser_button_new (_("Select a file"),
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (button), cwd, NULL);
g_object_unref (cwd);

The FileChooserButton supports the FileChooserActions gtk_file_chooser_action_open and gtk_file_chooser_action_select_folder.


The FileChooserButton will ellipsize the label, and will thus request little horizontal space. To give the button more space, you should call get_preferred_size, set_width_chars, or pack the button in such a way that other interface elements give space to the widget.

CSS nodes

GtkFileChooserButton has a single CSS node with the name “filechooserbutton”.

Namespace: Gtk
Package: gtk4



Creation methods:



Inherited Members:

All known members inherited from class Gtk.Widget