#include "gtkalertdialog.h"
#include "gtkbutton.h"
+#include "gtkdialogerror.h"
#include "deprecated/gtkmessagedialog.h"
#include <glib/gi18n-lib.h>
{
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);
* 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.
*/
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);
}
/**
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,
} 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)
{
}
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)
{
}
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;
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);