From 16697d8982241bd571f7f21d5b0bb95548b9520d Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 22 May 2021 16:05:35 +0300 Subject: [PATCH 24/24] gtk3.x: Make loading to the default transport to work Option initially selected in the unit load dialog was not really set as loading target, if user did not explicitly rechoose it. Reported by alain_bkr See osdn #42303 Signed-off-by: Marko Lindqvist --- client/gui-gtk-3.0/unitselunitdlg.c | 4 ++++ client/gui-gtk-3.22/unitselunitdlg.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/client/gui-gtk-3.0/unitselunitdlg.c b/client/gui-gtk-3.0/unitselunitdlg.c index 509c19bcab..168fcad84d 100644 --- a/client/gui-gtk-3.0/unitselunitdlg.c +++ b/client/gui-gtk-3.0/unitselunitdlg.c @@ -88,6 +88,7 @@ bool select_tgt_unit(struct unit *actor, struct tile *ptile, struct sprite *spr; struct unit_type *actor_type = unit_type_get(actor); int tcount; + const struct unit *default_unit; dlg = gtk_dialog_new_with_buttons(dlg_title, NULL, 0, _("Close"), GTK_RESPONSE_NO, @@ -144,6 +145,7 @@ bool select_tgt_unit(struct unit *actor, struct tile *ptile, if (first_option == NULL) { first_option = radio; default_option = first_option; + default_unit = ptgt; } /* The lists must be the same length if they contain the same * elements. */ @@ -159,6 +161,7 @@ bool select_tgt_unit(struct unit *actor, struct tile *ptile, G_CALLBACK(unit_sel_unit_destroyed), cbdata); if (ptgt == suggested_tgt_unit) { default_option = radio; + default_unit = suggested_tgt_unit; } gtk_grid_attach(GTK_GRID(box), radio, 0, tcount, 1, 1); @@ -187,6 +190,7 @@ bool select_tgt_unit(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_unit->id)); g_signal_connect(dlg, "response", do_callback, actor); diff --git a/client/gui-gtk-3.22/unitselunitdlg.c b/client/gui-gtk-3.22/unitselunitdlg.c index 07ffcab42c..4d2054848f 100644 --- a/client/gui-gtk-3.22/unitselunitdlg.c +++ b/client/gui-gtk-3.22/unitselunitdlg.c @@ -88,6 +88,7 @@ bool select_tgt_unit(struct unit *actor, struct tile *ptile, struct sprite *spr; struct unit_type *actor_type = unit_type_get(actor); int tcount; + const struct unit *default_unit; dlg = gtk_dialog_new_with_buttons(dlg_title, NULL, 0, _("Close"), GTK_RESPONSE_NO, @@ -144,6 +145,7 @@ bool select_tgt_unit(struct unit *actor, struct tile *ptile, if (first_option == NULL) { first_option = radio; default_option = first_option; + default_unit = ptgt; } /* The lists must be the same length if they contain the same * elements. */ @@ -159,6 +161,7 @@ bool select_tgt_unit(struct unit *actor, struct tile *ptile, G_CALLBACK(unit_sel_unit_destroyed), cbdata); if (ptgt == suggested_tgt_unit) { default_option = radio; + default_unit = suggested_tgt_unit; } gtk_grid_attach(GTK_GRID(box), radio, 0, tcount, 1, 1); @@ -187,6 +190,7 @@ bool select_tgt_unit(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_unit->id)); g_signal_connect(dlg, "response", do_callback, actor); -- 2.30.2