diff options
author | Benjamin Otte <otte@redhat.com> | 2022-11-23 23:43:36 +0100 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-12-24 07:56:57 -0500 |
commit | 381bb84f3dcf799c4ca1d450707e5aecbe804415 (patch) | |
tree | 73947994e79481489f29ea25eb82734a5d2ebcf0 | |
parent | 977fedfdf1e15bdfb90423e52d07eb1babcf5d6d (diff) | |
download | gtk+-381bb84f3dcf799c4ca1d450707e5aecbe804415.tar.gz |
alertdialog: Bring the GError back
Make sure we have a GError, so that dismissing and cancelling can be
separated.
-rw-r--r-- | gtk/gtkalertdialog.c | 12 | ||||
-rw-r--r-- | gtk/gtkalertdialog.h | 3 | ||||
-rw-r--r-- | gtk/gtkfilechooserwidget.c | 12 | ||||
-rw-r--r-- | gtk/gtkmountoperation.c | 6 |
4 files changed, 20 insertions, 13 deletions
diff --git a/gtk/gtkalertdialog.c b/gtk/gtkalertdialog.c index 645ab6d829..d4e0512a16 100644 --- a/gtk/gtkalertdialog.c +++ b/gtk/gtkalertdialog.c @@ -22,6 +22,7 @@ #include "gtkalertdialog.h" #include "gtkbutton.h" +#include "gtkdialogerror.h" #include "deprecated/gtkmessagedialog.h" #include <glib/gi18n-lib.h> @@ -618,7 +619,10 @@ response_cb (GTask *task, { GtkAlertDialog *self = GTK_ALERT_DIALOG (g_task_get_source_object (task)); - g_task_return_int (task, self->cancel_return); + if (self->cancel_return >= 0) + g_task_return_int (task, self->cancel_return); + else + g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_DISMISSED, "Dismissed by user"); } g_object_unref (task); @@ -723,6 +727,7 @@ gtk_alert_dialog_choose (GtkAlertDialog *self, * gtk_alert_dialog_choose_finish: * @self: a `GtkAlertDialog` * @result: a `GAsyncResult` + * @error: return location for a [enum@Gtk.DialogError] error * * Finishes the [method@Gtk.AlertDialog.choose] call * and returns the index of the button that was clicked. @@ -735,13 +740,14 @@ gtk_alert_dialog_choose (GtkAlertDialog *self, */ int gtk_alert_dialog_choose_finish (GtkAlertDialog *self, - GAsyncResult *result) + GAsyncResult *result, + GError **error) { g_return_val_if_fail (GTK_IS_ALERT_DIALOG (self), -1); g_return_val_if_fail (g_task_is_valid (result, self), -1); g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_alert_dialog_choose, -1); - return (int) g_task_propagate_int (G_TASK (result), NULL); + return (int) g_task_propagate_int (G_TASK (result), error); } /** diff --git a/gtk/gtkalertdialog.h b/gtk/gtkalertdialog.h index 4263eb9c92..a5a8412a5a 100644 --- a/gtk/gtkalertdialog.h +++ b/gtk/gtkalertdialog.h @@ -87,7 +87,8 @@ void gtk_alert_dialog_choose (GtkAlertDialog *self, GDK_AVAILABLE_IN_4_10 int gtk_alert_dialog_choose_finish (GtkAlertDialog *self, - GAsyncResult *result); + GAsyncResult *result, + GError **error); GDK_AVAILABLE_IN_4_10 void gtk_alert_dialog_show (GtkAlertDialog *self, diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index ed85b0eb9e..ca1aa426b4 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -1125,14 +1125,14 @@ typedef struct { } ConfirmDeleteData; static void -on_confirm_delete_response (GObject *source, +on_confirm_delete_response (GObject *source, GAsyncResult *result, - void *user_data) + void *user_data) { ConfirmDeleteData *data = user_data; int button; - button = gtk_alert_dialog_choose_finish (GTK_ALERT_DIALOG (source), result); + button = gtk_alert_dialog_choose_finish (GTK_ALERT_DIALOG (source), result, NULL); if (button == 1) { @@ -4955,14 +4955,14 @@ request_response_and_add_to_recent_list (GtkFileChooserWidget *impl) } static void -on_confirm_overwrite_response (GObject *source, +on_confirm_overwrite_response (GObject *source, GAsyncResult *result, - void *user_data) + void *user_data) { GtkFileChooserWidget *impl = user_data; int button; - button = gtk_alert_dialog_choose_finish (GTK_ALERT_DIALOG (source), result); + button = gtk_alert_dialog_choose_finish (GTK_ALERT_DIALOG (source), result, NULL); if (button == 1) { diff --git a/gtk/gtkmountoperation.c b/gtk/gtkmountoperation.c index 8d7d3046ef..d94a28fcc9 100644 --- a/gtk/gtkmountoperation.c +++ b/gtk/gtkmountoperation.c @@ -914,9 +914,9 @@ gtk_mount_operation_ask_password (GMountOperation *mount_op, } static void -question_dialog_button_clicked (GObject *source, +question_dialog_button_clicked (GObject *source, GAsyncResult *result, - void *user_data) + void *user_data) { GtkAlertDialog *dialog = GTK_ALERT_DIALOG (source); GMountOperation *op = user_data; @@ -925,7 +925,7 @@ question_dialog_button_clicked (GObject *source, operation = GTK_MOUNT_OPERATION (op); - button = gtk_alert_dialog_choose_finish (dialog, result); + button = gtk_alert_dialog_choose_finish (dialog, result, NULL); if (button >= 0) { g_mount_operation_set_choice (op, button); |