From bdf7d2023efefc1a46fd0ddfa6a9b7c769e56da3 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Tue, 21 Mar 2023 19:32:16 +0200 Subject: [PATCH 38/38] gtk4: Try also to "Clean" nuisances in clean menu Even prefer "Clean" action, just falback to using "Clean Pollution" and "Clean Fallout" when it doesn't work. See osdn #47627 Signed-off-by: Marko Lindqvist --- client/gui-gtk-4.0/menu.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/client/gui-gtk-4.0/menu.c b/client/gui-gtk-4.0/menu.c index 3ceed3d6d0..ad87ae67db 100644 --- a/client/gui-gtk-4.0/menu.c +++ b/client/gui-gtk-4.0/menu.c @@ -2770,7 +2770,10 @@ static void clean_menu_callback(GSimpleAction *action, struct extra_type *pextra = data; unit_list_iterate(get_units_in_focus(), punit) { - if (can_unit_do_activity_targeted(punit, ACTIVITY_POLLUTION, pextra)) { + if (can_unit_do_activity_targeted(punit, ACTIVITY_CLEAN, pextra)) { + request_new_unit_activity_targeted(punit, ACTIVITY_CLEAN, + pextra); + } else if (can_unit_do_activity_targeted(punit, ACTIVITY_POLLUTION, pextra)) { request_new_unit_activity_targeted(punit, ACTIVITY_POLLUTION, pextra); } else { @@ -3662,8 +3665,11 @@ void real_menus_update(void) act = g_simple_action_new(actname, NULL); g_simple_action_set_enabled(act, can_units_do_activity_targeted(punits, - ACTIVITY_POLLUTION, - pextra)); + ACTIVITY_CLEAN, + pextra) + || can_units_do_activity_targeted(punits, + ACTIVITY_POLLUTION, + pextra)); g_action_map_add_action(map, G_ACTION(act)); g_signal_connect(act, "activate", G_CALLBACK(clean_menu_callback), pextra); @@ -3680,8 +3686,11 @@ void real_menus_update(void) act = g_simple_action_new(actname, NULL); g_simple_action_set_enabled(act, can_units_do_activity_targeted(punits, - ACTIVITY_FALLOUT, - pextra)); + ACTIVITY_CLEAN, + pextra) + || can_units_do_activity_targeted(punits, + ACTIVITY_FALLOUT, + pextra)); g_action_map_add_action(map, G_ACTION(act)); g_signal_connect(act, "activate", G_CALLBACK(clean_menu_callback), pextra); -- 2.39.2