From d8f2beb80e153fb1357d750d670d63f8c0ce8b28 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 17 May 2021 07:46:08 +0300 Subject: [PATCH 33/33] gtk3.x: 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 ++++ 2 files changed, 8 insertions(+) diff --git a/client/gui-gtk-3.0/unitselextradlg.c b/client/gui-gtk-3.0/unitselextradlg.c index d8359abf64..acd6fca333 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; 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 e428e0a128..2a503a1c28 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; 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