From 83402dee593f075b9374e413866059309ccf6151 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 17 May 2021 07:33:17 +0300 Subject: [PATCH 42/42] gtk: Make pillaging of the default target to work Option initially selected in the pillage dialog was not really set as pillage target, if user did not explicitly rechoose it. Reported by alain_bkr See osdn #42168 Signed-off-by: Marko Lindqvist --- client/gui-gtk-3.0/unitselextradlg.c | 4 ++++ client/gui-gtk-3.22/unitselextradlg.c | 4 ++++ client/gui-gtk-4.0/unitselextradlg.c | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/client/gui-gtk-3.0/unitselextradlg.c b/client/gui-gtk-3.0/unitselextradlg.c index 8a235751c2..4a7c37ae1f 100644 --- a/client/gui-gtk-3.0/unitselextradlg.c +++ b/client/gui-gtk-3.0/unitselextradlg.c @@ -124,6 +124,7 @@ bool select_tgt_extra(struct unit *actor, struct tile *ptile, struct sprite *spr; const struct unit_type *actor_type = unit_type_get(actor); int tcount; + const struct extra_type *default_extra; dlg = gtk_dialog_new_with_buttons(dlg_title, NULL, 0, _("Close"), GTK_RESPONSE_NO, @@ -183,6 +184,7 @@ bool select_tgt_extra(struct unit *actor, struct tile *ptile, if (first_option == NULL) { first_option = radio; default_option = first_option; + default_extra = ptgt; } /* The lists must be the same length if they contain the same * elements. */ @@ -198,6 +200,7 @@ bool select_tgt_extra(struct unit *actor, struct tile *ptile, G_CALLBACK(unit_sel_extra_destroyed), cbdata); if (ptgt == suggested_tgt_extra) { default_option = radio; + default_extra = suggested_tgt_extra; } gtk_grid_attach(GTK_GRID(box), radio, 0, tcount, 1, 1); @@ -226,6 +229,7 @@ bool select_tgt_extra(struct unit *actor, struct tile *ptile, g_object_set_data(G_OBJECT(dlg), "actor", GINT_TO_POINTER(actor->id)); g_object_set_data(G_OBJECT(dlg), "tile", ptile); + g_object_set_data(G_OBJECT(dlg), "target", GINT_TO_POINTER(default_extra->id)); g_signal_connect(dlg, "response", do_callback, actor); diff --git a/client/gui-gtk-3.22/unitselextradlg.c b/client/gui-gtk-3.22/unitselextradlg.c index 6c9dde4de8..330b8668db 100644 --- a/client/gui-gtk-3.22/unitselextradlg.c +++ b/client/gui-gtk-3.22/unitselextradlg.c @@ -124,6 +124,7 @@ bool select_tgt_extra(struct unit *actor, struct tile *ptile, struct sprite *spr; const struct unit_type *actor_type = unit_type_get(actor); int tcount; + const struct extra_type *default_extra; dlg = gtk_dialog_new_with_buttons(dlg_title, NULL, 0, _("Close"), GTK_RESPONSE_NO, @@ -183,6 +184,7 @@ bool select_tgt_extra(struct unit *actor, struct tile *ptile, if (first_option == NULL) { first_option = radio; default_option = first_option; + default_extra = ptgt; } /* The lists must be the same length if they contain the same * elements. */ @@ -198,6 +200,7 @@ bool select_tgt_extra(struct unit *actor, struct tile *ptile, G_CALLBACK(unit_sel_extra_destroyed), cbdata); if (ptgt == suggested_tgt_extra) { default_option = radio; + default_extra = suggested_tgt_extra; } gtk_grid_attach(GTK_GRID(box), radio, 0, tcount, 1, 1); @@ -226,6 +229,7 @@ bool select_tgt_extra(struct unit *actor, struct tile *ptile, g_object_set_data(G_OBJECT(dlg), "actor", GINT_TO_POINTER(actor->id)); g_object_set_data(G_OBJECT(dlg), "tile", ptile); + g_object_set_data(G_OBJECT(dlg), "target", GINT_TO_POINTER(default_extra->id)); g_signal_connect(dlg, "response", do_callback, actor); diff --git a/client/gui-gtk-4.0/unitselextradlg.c b/client/gui-gtk-4.0/unitselextradlg.c index 8e7c11c50f..19daf9876e 100644 --- a/client/gui-gtk-4.0/unitselextradlg.c +++ b/client/gui-gtk-4.0/unitselextradlg.c @@ -124,6 +124,7 @@ bool select_tgt_extra(struct unit *actor, struct tile *ptile, struct sprite *spr; const struct unit_type *actor_type = unit_type_get(actor); int tcount; + const struct extra_type *default_extra; dlg = gtk_dialog_new_with_buttons(dlg_title, NULL, 0, _("Close"), GTK_RESPONSE_NO, @@ -183,6 +184,7 @@ bool select_tgt_extra(struct unit *actor, struct tile *ptile, if (first_option == NULL) { first_option = radio; default_option = first_option; + default_extra = ptgt; } /* The lists must be the same length if they contain the same * elements. */ @@ -198,6 +200,7 @@ bool select_tgt_extra(struct unit *actor, struct tile *ptile, G_CALLBACK(unit_sel_extra_destroyed), cbdata); if (ptgt == suggested_tgt_extra) { default_option = radio; + default_extra = suggested_tgt_extra; } gtk_grid_attach(GTK_GRID(box), radio, 0, tcount, 1, 1); @@ -226,6 +229,7 @@ bool select_tgt_extra(struct unit *actor, struct tile *ptile, g_object_set_data(G_OBJECT(dlg), "actor", GINT_TO_POINTER(actor->id)); g_object_set_data(G_OBJECT(dlg), "tile", ptile); + g_object_set_data(G_OBJECT(dlg), "target", GINT_TO_POINTER(default_extra->id)); g_signal_connect(dlg, "response", do_callback, actor); -- 2.30.2