Interface

Gtk-3.0GtkFileChooserNativeSignalSignatures

interface SignalSignatures {
    "confirm-overwrite": () => Gtk.FileChooserConfirmation;
    "current-folder-changed": () => void;
    "file-activated": () => void;
    notify: (pspec: GObject.ParamSpec) => void;
    "notify::accept-label": (pspec: GObject.ParamSpec) => void;
    "notify::action": (pspec: GObject.ParamSpec) => void;
    "notify::cancel-label": (pspec: GObject.ParamSpec) => void;
    "notify::create-folders": (pspec: GObject.ParamSpec) => void;
    "notify::do-overwrite-confirmation": (pspec: GObject.ParamSpec) => void;
    "notify::extra-widget": (pspec: GObject.ParamSpec) => void;
    "notify::filter": (pspec: GObject.ParamSpec) => void;
    "notify::local-only": (pspec: GObject.ParamSpec) => void;
    "notify::modal": (pspec: GObject.ParamSpec) => void;
    "notify::preview-widget": (pspec: GObject.ParamSpec) => void;
    "notify::preview-widget-active": (pspec: GObject.ParamSpec) => void;
    "notify::select-multiple": (pspec: GObject.ParamSpec) => void;
    "notify::show-hidden": (pspec: GObject.ParamSpec) => void;
    "notify::title": (pspec: GObject.ParamSpec) => void;
    "notify::transient-for": (pspec: GObject.ParamSpec) => void;
    "notify::use-preview-label": (pspec: GObject.ParamSpec) => void;
    "notify::visible": (pspec: GObject.ParamSpec) => void;
    response: (response_id: number) => void;
    "selection-changed": () => void;
    "update-preview": () => void;
    [key: `notify::${string}`]: (pspec: GObject.ParamSpec) => void;
}

Hierarchy (View Summary)

Indexable

Index
"notify::accept-label": (pspec: GObject.ParamSpec) => void
"notify::action": (pspec: GObject.ParamSpec) => void
"notify::cancel-label": (pspec: GObject.ParamSpec) => void
"notify::create-folders": (pspec: GObject.ParamSpec) => void
"notify::do-overwrite-confirmation": (pspec: GObject.ParamSpec) => void
"notify::extra-widget": (pspec: GObject.ParamSpec) => void
"notify::filter": (pspec: GObject.ParamSpec) => void
"notify::local-only": (pspec: GObject.ParamSpec) => void
"notify::modal": (pspec: GObject.ParamSpec) => void
"notify::preview-widget": (pspec: GObject.ParamSpec) => void
"notify::preview-widget-active": (pspec: GObject.ParamSpec) => void
"notify::select-multiple": (pspec: GObject.ParamSpec) => void
"notify::show-hidden": (pspec: GObject.ParamSpec) => void
"notify::title": (pspec: GObject.ParamSpec) => void
"notify::transient-for": (pspec: GObject.ParamSpec) => void
"notify::use-preview-label": (pspec: GObject.ParamSpec) => void
"notify::visible": (pspec: GObject.ParamSpec) => void
"confirm-overwrite": () => Gtk.FileChooserConfirmation

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 Gtk.FileChooserAction.SAVE mode.

Most applications just need to turn on the Gtk.FileChooser.do_overwrite_confirmation property (or call the gtk_file_chooser_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 Gtk.FileChooser.SignalSignatures.confirm_overwrite | Gtk.FileChooser::confirm-overwrite signal.

A signal handler for this signal must return a Gtk.FileChooserConfirmation value, which indicates the action to take. If the handler determines that the user wants to select a different filename, it should return Gtk.FileChooserConfirmation.SELECT_AGAIN. If it determines that the user is satisfied with his choice of file name, it should return Gtk.FileChooserConfirmation.ACCEPT_FILENAME. On the other hand, if it determines that the stock confirmation dialog should be used, it should return Gtk.FileChooserConfirmation.CONFIRM. The following example illustrates this.

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);

2.8

"current-folder-changed": () => void

This signal is emitted when the current folder in a Gtk.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: gtk_file_chooser_set_current_folder(), gtk_file_chooser_get_current_folder(), gtk_file_chooser_set_current_folder_uri(), gtk_file_chooser_get_current_folder_uri().

"file-activated": () => void

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 Gtk.FileChooserDialog to know when to activate the default button in the dialog.

See also: gtk_file_chooser_get_filename(), gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(), gtk_file_chooser_get_uris().

"selection-changed": () => void

This signal is emitted when there is a change in the set of selected files in a Gtk.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: gtk_file_chooser_select_filename(), gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(), gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(), gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(), gtk_file_chooser_get_uris().

"update-preview": () => void

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 gtk_file_chooser_set_preview_widget(), you should update it when this signal is emitted. You can use the functions gtk_file_chooser_get_preview_filename() or gtk_file_chooser_get_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 gtk_file_chooser_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: gtk_file_chooser_set_preview_widget(), gtk_file_chooser_set_preview_widget_active(), gtk_file_chooser_set_use_preview_label(), gtk_file_chooser_get_preview_filename(), gtk_file_chooser_get_preview_uri().

notify: (pspec: GObject.ParamSpec) => void

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with GObject.ParamFlags.EXPLICIT_NOTIFY, then any call to g_object_set_property() results in ::notify being emitted, even if the new value is the same as the old. If they did pass GObject.ParamFlags.EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this:

g_signal_connect (text_view->buffer, "notify::paste-target-list",
G_CALLBACK (gtk_text_view_target_list_notify),
text_view)

It is important to note that you must use [canonical parameter names][class@GObject.ParamSpec#parameter-names] as detail strings for the notify signal.

response: (response_id: number) => void

Emitted when the user responds to the dialog.

When this is called the dialog has been hidden.

If you call gtk_native_dialog_hide() before the user responds to the dialog this signal will not be emitted.

3.20