From dbfd5abb0f9217900dbf936bbe51f4d435a7aa15 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 4 Dec 2022 19:57:33 +0200 Subject: [PATCH 38/38] gtk3.22: Add action confirmation dialog See osdn #46163 Signed-off-by: Marko Lindqvist --- client/gui-gtk-3.22/dialogs.c | 37 +++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/client/gui-gtk-3.22/dialogs.c b/client/gui-gtk-3.22/dialogs.c index 2238f33c09..d372c9257f 100644 --- a/client/gui-gtk-3.22/dialogs.c +++ b/client/gui-gtk-3.22/dialogs.c @@ -1573,13 +1573,46 @@ void popup_combat_info(int attacker_unit_id, int defender_unit_id, { } +/**********************************************************************//** + This is the response callback for the action confirmation dialog. +**************************************************************************/ +static void act_conf_response(GtkWidget *dialog, gint response, + gpointer data) +{ + gtk_widget_destroy(dialog); + + if (response == GTK_RESPONSE_YES) { + action_confirmation(data, TRUE); + } else { + action_confirmation(data, FALSE); + } +} + /**********************************************************************//** Common code wants confirmation for an action. **************************************************************************/ void request_action_confirmation(const char *expl, struct act_confirmation_data *data) { - log_normal("Got to confirm, because %s", expl); + GtkWidget *dialog; + char buf[1024]; + + if (expl != NULL) { + fc_snprintf(buf, sizeof(buf), _("Are you sure you want to do %s?\n%s"), + action_id_name_translation(data->act), expl); + } else { + fc_snprintf(buf, sizeof(buf), _("Are you sure you want to do %s?"), + action_id_name_translation(data->act)); + } + + dialog = gtk_message_dialog_new(NULL, 0, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_YES_NO, + "%s", buf); + setup_dialog(dialog, toplevel); + + g_signal_connect(dialog, "response", + G_CALLBACK(act_conf_response), data); - action_confirmation(data, TRUE); + gtk_window_present(GTK_WINDOW(dialog)); } -- 2.35.1