From 42f65cfcf53770a93d21ff969916875f26262d2d Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 22 May 2021 16:12:22 +0300 Subject: [PATCH 48/48] gtk: 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.22/unitselunitdlg.c | 4 ++++ client/gui-gtk-4.0/unitselunitdlg.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/client/gui-gtk-3.22/unitselunitdlg.c b/client/gui-gtk-3.22/unitselunitdlg.c index 7ea8f3de75..c2bbc30726 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; const 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, @@ -143,6 +144,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. */ @@ -158,6 +160,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); @@ -186,6 +189,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-4.0/unitselunitdlg.c b/client/gui-gtk-4.0/unitselunitdlg.c index bbc80b7d1f..1d6f78ee1d 100644 --- a/client/gui-gtk-4.0/unitselunitdlg.c +++ b/client/gui-gtk-4.0/unitselunitdlg.c @@ -88,6 +88,7 @@ bool select_tgt_unit(struct unit *actor, struct tile *ptile, struct sprite *spr; const 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, @@ -143,6 +144,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. */ @@ -158,6 +160,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); @@ -186,6 +189,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