GtkFileChooser: GTK+ 2 Reference Manual

## GtkFileChooser GtkFileChooser |

## Functions

void | gtk_file_chooser_set_action ()
GtkFileChooserAction | gtk_file_chooser_get_action ()
void | gtk_file_chooser_set_local_only ()
gboolean | gtk_file_chooser_get_local_only ()
void | gtk_file_chooser_set_select_multiple ()
gboolean | gtk_file_chooser_get_select_multiple ()
void | gtk_file_chooser_set_show_hidden ()
gboolean | gtk_file_chooser_get_show_hidden ()
void | gtk_file_chooser_set_do_overwrite_confirmation ()
gboolean | gtk_file_chooser_get_do_overwrite_confirmation ()
void | gtk_file_chooser_set_create_folders ()
gboolean | gtk_file_chooser_get_create_folders ()
void | gtk_file_chooser_set_current_name ()
void | gtk_file_chooser_select_all ()
void | gtk_file_chooser_unselect_all ()
gchar * | gtk_file_chooser_get_uri ()
gboolean | gtk_file_chooser_set_uri ()
gboolean | gtk_file_chooser_select_uri ()
void | gtk_file_chooser_unselect_uri ()
GSList * | gtk_file_chooser_get_uris ()
gboolean | gtk_file_chooser_set_current_folder_uri ()
gchar * | gtk_file_chooser_get_current_folder_uri ()
void | gtk_file_chooser_set_preview_widget ()
GtkWidget * | gtk_file_chooser_get_preview_widget ()
void | gtk_file_chooser_set_preview_widget_active ()
gboolean | gtk_file_chooser_get_preview_widget_active ()
void | gtk_file_chooser_set_use_preview_label ()
gboolean | gtk_file_chooser_get_use_preview_label ()
char * | gtk_file_chooser_get_preview_uri ()
void | gtk_file_chooser_set_extra_widget ()
GtkWidget * | gtk_file_chooser_get_extra_widget ()
void | gtk_file_chooser_add_filter ()
void | gtk_file_chooser_remove_filter ()
GSList * | gtk_file_chooser_list_filters ()
void | gtk_file_chooser_set_filter ()
GtkFileFilter * | gtk_file_chooser_get_filter ()
gboolean | gtk_file_chooser_add_shortcut_folder_uri ()
gboolean | gtk_file_chooser_remove_shortcut_folder_uri ()
GSList * | gtk_file_chooser_list_shortcut_folder_uris ()
GFile * | gtk_file_chooser_get_current_folder_file ()
GFile * | gtk_file_chooser_get_file ()
GSList * | gtk_file_chooser_get_files ()
GFile * | gtk_file_chooser_get_preview_file ()
gboolean | gtk_file_chooser_select_file ()
gboolean | gtk_file_chooser_set_current_folder_file ()
gboolean | gtk_file_chooser_set_file ()
void | gtk_file_chooser_unselect_file ()

## Properties

GtkFileChooserAction | action | Read / Write
gboolean | create-folders | Read / Write
gboolean | do-overwrite-confirmation | Read / Write
GtkWidget * | extra-widget | Read / Write
gchar * | file-system-backend | Write / Construct Only
GtkFileFilter * | filter | Read / Write
gboolean | local-only | Read / Write
GtkWidget * | preview-widget | Read / Write
gboolean | preview-widget-active | Read / Write
gboolean | select-multiple | Read / Write
gboolean | show-hidden | Read / Write
gboolean | use-preview-label | Read / Write

## Signals

GtkFileChooserConfirmation | confirm-overwrite | Run Last
void | current-folder-changed | Run Last
void | file-activated | Run Last
void | selection-changed | Run Last
void | update-preview | Run Last

## Types and Values

| GtkFileChooser
enum | GtkFileChooserAction
enum | GtkFileChooserConfirmation
#define | GTK_FILE_CHOOSER_ERROR
enum | GtkFileChooserError
#define | gtk_file_chooser_get_filename
#define | gtk_file_chooser_set_filename
#define | gtk_file_chooser_select_filename
#define | gtk_file_chooser_unselect_filename
#define | gtk_file_chooser_get_filenames
#define | gtk_file_chooser_set_current_folder
#define | gtk_file_chooser_get_current_folder
#define | gtk_file_chooser_get_preview_filename
#define | gtk_file_chooser_add_shortcut_folder
#define | gtk_file_chooser_remove_shortcut_folder
#define | gtk_file_chooser_list_shortcut_folders

## Object Hierarchy

        GInterface
        ╰── GtkFileChooser

## Prerequisites

GtkFileChooser requires GtkWidget.

## Known Implementations

GtkFileChooser is implemented by GtkFileChooserButton, GtkFileChooserDialog and GtkFileChooserWidget.

## Includes

    #include <gtk/gtk.h>

## Description

## Functions

### gtk_file_chooser_set_action ()

    void
    gtk_file_chooser_set_action (GtkFileChooser *chooser,
                                 GtkFileChooserAction action);

Since: 2.4

### gtk_file_chooser_get_action ()

    GtkFileChooserAction
    gtk_file_chooser_get_action (GtkFileChooser *chooser);

Since: 2.4

### gtk_file_chooser_set_local_only ()

    void
    gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
                                     gboolean local_only);

Since: 2.4

### gtk_file_chooser_get_local_only ()

    gboolean
    gtk_file_chooser_get_local_only (GtkFileChooser *chooser);

Since: 2.4

### gtk_file_chooser_set_select_multiple ()

    void
    gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
                                          gboolean select_multiple);

Since: 2.4

### gtk_file_chooser_get_select_multiple ()

    gboolean
    gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser);

Since: 2.4

### gtk_file_chooser_set_show_hidden ()

    void
    gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
                                      gboolean show_hidden);

Since: 2.6

### gtk_file_chooser_get_show_hidden ()

    gboolean
    gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser);

Since: 2.6

### gtk_file_chooser_set_do_overwrite_confirmation ()

    void
    gtk_file_chooser_set_do_overwrite_confirmation
                                   (GtkFileChooser *chooser,
                                    gboolean do_overwrite_confirmation);

Since: 2.8

### gtk_file_chooser_get_do_overwrite_confirmation ()

    gboolean
    gtk_file_chooser_get_do_overwrite_confirmation
                                   (GtkFileChooser *chooser);

Since: 2.8

### gtk_file_chooser_set_create_folders ()

    void
    gtk_file_chooser_set_create_folders (GtkFileChooser *chooser,
                                         gboolean create_folders);

Since: 2.18

### gtk_file_chooser_get_create_folders ()

    gboolean
    gtk_file_chooser_get_create_folders (GtkFileChooser *chooser);

Since: 2.18

### gtk_file_chooser_set_current_name ()

    void
    gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
                                       const gchar *name);

Since: 2.4

### gtk_file_chooser_select_all ()

    void
    gtk_file_chooser_select_all (GtkFileChooser *chooser);

Since: 2.4

### gtk_file_chooser_unselect_all ()

    void
    gtk_file_chooser_unselect_all (GtkFileChooser *chooser);

Since: 2.4

### gtk_file_chooser_get_uri ()

    gchar *
    gtk_file_chooser_get_uri (GtkFileChooser *chooser);

Since: 2.4

### gtk_file_chooser_set_uri ()

    gboolean
    gtk_file_chooser_set_uri (GtkFileChooser *chooser,
                              const char *uri);

Since: 2.4

### gtk_file_chooser_select_uri ()

    gboolean
    gtk_file_chooser_select_uri (GtkFileChooser *chooser,
                                 const char *uri);

Since: 2.4

### gtk_file_chooser_unselect_uri ()

    void
    gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
                                   const char *uri);

Since: 2.4

### gtk_file_chooser_get_uris ()

    GSList *
    gtk_file_chooser_get_uris (GtkFileChooser *chooser);

Since: 2.4

### gtk_file_chooser_set_current_folder_uri ()

    gboolean
    gtk_file_chooser_set_current_folder_uri
                                   (GtkFileChooser *chooser,
                                    const gchar *uri);

Since: 2.4

### gtk_file_chooser_get_current_folder_uri ()

    gchar *
    gtk_file_chooser_get_current_folder_uri
                                   (GtkFileChooser *chooser);

Since: 2.4

### gtk_file_chooser_set_preview_widget ()

    void
    gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
                                         GtkWidget *preview_widget);

Since: 2.4

### gtk_file_chooser_get_preview_widget ()

    GtkWidget *
    gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser);

Since: 2.4

### gtk_file_chooser_set_preview_widget_active ()

    void
    gtk_file_chooser_set_preview_widget_active
                                   (GtkFileChooser *chooser,
                                    gboolean active);

Since: 2.4

### gtk_file_chooser_get_preview_widget_active ()

    gboolean
    gtk_file_chooser_get_preview_widget_active
                                   (GtkFileChooser *chooser);

Since: 2.4

### gtk_file_chooser_set_use_preview_label ()

    void
    gtk_file_chooser_set_use_preview_label
                                   (GtkFileChooser *chooser,
                                    gboolean use_label);

Since: 2.4

### gtk_file_chooser_get_use_preview_label ()

    gboolean
    gtk_file_chooser_get_use_preview_label
                                   (GtkFileChooser *chooser);

### gtk_file_chooser_get_preview_uri ()

    char *
    gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser);

Since: 2.4

### gtk_file_chooser_set_extra_widget ()

    void
    gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
                                       GtkWidget *extra_widget);

Since: 2.4

### gtk_file_chooser_get_extra_widget ()

    GtkWidget *
    gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser);

Since: 2.4

### gtk_file_chooser_add_filter ()

    void
    gtk_file_chooser_add_filter (GtkFileChooser *chooser,
                                 GtkFileFilter *filter);

Since: 2.4

### gtk_file_chooser_remove_filter ()

    void
    gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
                                    GtkFileFilter *filter);

Since: 2.4

### gtk_file_chooser_list_filters ()

    GSList *
    gtk_file_chooser_list_filters (GtkFileChooser *chooser);

Since: 2.4

### gtk_file_chooser_set_filter ()

    void
    gtk_file_chooser_set_filter (GtkFileChooser *chooser,
                                 GtkFileFilter *filter);

Since: 2.4

### gtk_file_chooser_get_filter ()

    GtkFileFilter *
    gtk_file_chooser_get_filter (GtkFileChooser *chooser);

Since: 2.4

### gtk_file_chooser_add_shortcut_folder_uri ()

    gboolean
    gtk_file_chooser_add_shortcut_folder_uri
                                   (GtkFileChooser *chooser,
                                    const char *uri,
                                    GError **error);

Since: 2.4

### gtk_file_chooser_remove_shortcut_folder_uri ()

    gboolean
    gtk_file_chooser_remove_shortcut_folder_uri
                                   (GtkFileChooser *chooser,
                                    const char *uri,
                                    GError **error);

Since: 2.4

### gtk_file_chooser_list_shortcut_folder_uris ()

    GSList *
    gtk_file_chooser_list_shortcut_folder_uris
                                   (GtkFileChooser *chooser);

Since: 2.4

### gtk_file_chooser_get_current_folder_file ()

    GFile *
    gtk_file_chooser_get_current_folder_file
                                   (GtkFileChooser *chooser);

Since: 2.14

### gtk_file_chooser_get_file ()

    GFile *
    gtk_file_chooser_get_file (GtkFileChooser *chooser);

Since: 2.14

### gtk_file_chooser_get_files ()

    GSList *
    gtk_file_chooser_get_files (GtkFileChooser *chooser);

Since: 2.14

### gtk_file_chooser_get_preview_file ()

    GFile *
    gtk_file_chooser_get_preview_file (GtkFileChooser *chooser);

Since: 2.14

### gtk_file_chooser_select_file ()

    gboolean
    gtk_file_chooser_select_file (GtkFileChooser *chooser,
                                  GFile *file,
                                  GError **error);

Since: 2.14

### gtk_file_chooser_set_current_folder_file ()

    gboolean
    gtk_file_chooser_set_current_folder_file
                                   (GtkFileChooser *chooser,
                                    GFile *file,
                                    GError **error);

Since: 2.14

### gtk_file_chooser_set_file ()

    gboolean
    gtk_file_chooser_set_file (GtkFileChooser *chooser,
                               GFile *file,
                               GError **error);

Since: 2.14

### gtk_file_chooser_unselect_file ()

    void
    gtk_file_chooser_unselect_file (GtkFileChooser *chooser,
                                    GFile *file);

Since: 2.14

## Types and Values

### GtkFileChooser

    typedef struct _GtkFileChooser GtkFileChooser;

### enum GtkFileChooserAction

#### Members

GTK_FILE_CHOOSER_ACTION_OPEN |  |
GTK_FILE_CHOOSER_ACTION_SAVE |  |
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER |  |
GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER |  |

### enum GtkFileChooserConfirmation

#### Members

GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM |  |
GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME |  |
GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN |  |

Since: 2.8

### GTK_FILE_CHOOSER_ERROR

    #define GTK_FILE_CHOOSER_ERROR (gtk_file_chooser_error_quark ())

### enum GtkFileChooserError

#### Members

GTK_FILE_CHOOSER_ERROR_NONEXISTENT |  |
GTK_FILE_CHOOSER_ERROR_BAD_FILENAME |  |
GTK_FILE_CHOOSER_ERROR_ALREADY_EXISTS |  |
GTK_FILE_CHOOSER_ERROR_INCOMPLETE_HOSTNAME |  |

### gtk_file_chooser_get_filename

    #define gtk_file_chooser_get_filename gtk_file_chooser_get_filename_utf8

Since: 2.4

### gtk_file_chooser_set_filename

    #define gtk_file_chooser_set_filename gtk_file_chooser_set_filename_utf8

Since: 2.4

### gtk_file_chooser_select_filename

    #define gtk_file_chooser_select_filename gtk_file_chooser_select_filename_utf8

Since: 2.4

### gtk_file_chooser_unselect_filename

    #define gtk_file_chooser_unselect_filename gtk_file_chooser_unselect_filename_utf8

Since: 2.4

### gtk_file_chooser_get_filenames

    #define gtk_file_chooser_get_filenames gtk_file_chooser_get_filenames_utf8

Since: 2.4

### gtk_file_chooser_set_current_folder

    #define gtk_file_chooser_set_current_folder gtk_file_chooser_set_current_folder_utf8

Since: 2.4

### gtk_file_chooser_get_current_folder

    #define gtk_file_chooser_get_current_folder gtk_file_chooser_get_current_folder_utf8

Since: 2.4

### gtk_file_chooser_get_preview_filename

    #define gtk_file_chooser_get_preview_filename gtk_file_chooser_get_preview_filename_utf8

Since: 2.4

### gtk_file_chooser_add_shortcut_folder

    #define gtk_file_chooser_add_shortcut_folder gtk_file_chooser_add_shortcut_folder_utf8

Since: 2.4

### gtk_file_chooser_remove_shortcut_folder

    #define gtk_file_chooser_remove_shortcut_folder gtk_file_chooser_remove_shortcut_folder_utf8

Since: 2.4

### gtk_file_chooser_list_shortcut_folders

    #define gtk_file_chooser_list_shortcut_folders gtk_file_chooser_list_shortcut_folders_utf8

Since: 2.4

## Property Details

### The `“action”` property

      “action”                   GtkFileChooserAction

The type of operation that the file selector is performing.

Flags: Read / Write

Default value: GTK_FILE_CHOOSER_ACTION_OPEN

### The `“create-folders”` property

      “create-folders”           gboolean

Whether a file chooser not in open mode will offer the user to create new folders.

Flags: Read / Write

Default value: TRUE

Since: 2.18

### The `“do-overwrite-confirmation”` property

      “do-overwrite-confirmation” gboolean

Whether a file chooser in save mode will present an overwrite confirmation dialog if necessary.

Flags: Read / Write

Default value: FALSE

Since: 2.8

### The `“extra-widget”` property

      “extra-widget”             GtkWidget *

Application supplied widget for extra options.

Flags: Read / Write

### The `“file-system-backend”` property

      “file-system-backend”      gchar *

Name of file system backend to use.

Flags: Write / Construct Only

Default value: NULL

### The `“filter”` property

      “filter”                   GtkFileFilter *

The current filter for selecting which files are displayed.

Flags: Read / Write

### The `“local-only”` property

      “local-only”               gboolean

Whether the selected file(s) should be limited to local file: URLs.

Flags: Read / Write

Default value: TRUE

### The `“preview-widget”` property

      “preview-widget”           GtkWidget *

Application supplied widget for custom previews.

Flags: Read / Write

### The `“preview-widget-active”` property

      “preview-widget-active”    gboolean

Whether the application supplied widget for custom previews should be shown.

Flags: Read / Write

Default value: TRUE

### The `“select-multiple”` property

      “select-multiple”          gboolean

Whether to allow multiple files to be selected.

Flags: Read / Write

Default value: FALSE

### The `“show-hidden”` property

      “show-hidden”              gboolean

Whether the hidden files and folders should be displayed.

Flags: Read / Write

Default value: FALSE

### The `“use-preview-label”` property

      “use-preview-label”        gboolean

Whether to display a stock label with the name of the previewed file.

Flags: Read / Write

Default value: TRUE

## Signal Details

### The `“confirm-overwrite”` signal

    GtkFileChooserConfirmation
    user_function (GtkFileChooser *chooser,
                   gpointer        user_data)

Flags: Run Last

Since: 2.8

### The `“current-folder-changed”` signal

    void
    user_function (GtkFileChooser *chooser,
                   gpointer        user_data)

Flags: Run Last

### The `“file-activated”` signal

    void
    user_function (GtkFileChooser *chooser,
                   gpointer        user_data)

Flags: Run Last

### The `“selection-changed”` signal

    void
    user_function (GtkFileChooser *chooser,
                   gpointer        user_data)

Flags: Run Last

### The `“update-preview”` signal

    void
    user_function (GtkFileChooser *chooser,
                   gpointer        user_data)

Flags: Run Last