FileChooser.connectConfirmOverwrite
gulong connectConfirmOverwrite(T)(T callback, Flag!"After" after = No.After)Connect to ConfirmOverwrite signal.
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.types.FileChooserAction.Save] mode.
Most applications just need to turn on the #GtkFileChooser:do-overwrite-confirmation property (or call the [gtk.file_chooser.FileChooser.setDoOverwriteConfirmation] 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 #GtkFileChooser::confirm-overwrite signal.
A signal handler for this signal must return a #GtkFileChooserConfirmation value, which indicates the action to take. If the handler determines that the user wants to select a different filename, it should return [gtk.types.FileChooserConfirmation.SelectAgain]. If it determines that the user is satisfied with his choice of file name, it should return [gtk.types.FileChooserConfirmation.AcceptFilename]. On the other hand, if it determines that the stock confirmation dialog should be used, it should return [gtk.types.FileChooserConfirmation.Confirm]. The following example illustrates this.
## Custom confirmation ## {#gtkfilechooser-confirmation}
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);Parameters
callback | signal callback delegate or function to connect gtk.types.FileChooserConfirmation callback(gtk.file_chooser.FileChooser fileChooser) fileChooser the instance the signal is connected to (optional) Returns a #GtkFileChooserConfirmation value that indicates which action to take after emitting the signal. |
after | Yes.After to execute callback after default handler, No.After to execute before (default) |