From c50475de34f66a97ea8fb57c722d7290b9f60d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 30 Jul 2021 07:40:48 +0200 Subject: [PATCH 1/2] checkbutton: Delegate ::activate to the helper if appropriate If the button is associated with an action, the action is currently only activated when the button is clicked, not when it is activated. --- gtk/gtkcheckbutton.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c index 9860641ac6..9471f6d3c6 100644 --- a/gtk/gtkcheckbutton.c +++ b/gtk/gtkcheckbutton.c @@ -498,7 +498,10 @@ gtk_check_button_real_activate (GtkCheckButton *self) if (priv->active && (priv->group_prev || priv->group_next)) return; - gtk_check_button_set_active (self, !gtk_check_button_get_active (self)); + if (priv->action_helper) + gtk_action_helper_activate (priv->action_helper); + else + gtk_check_button_set_active (self, !gtk_check_button_get_active (self)); } static void From 1728aa581c19dc70e05aae59bf9b82ac87ed7c74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 30 Jul 2021 20:18:36 +0200 Subject: [PATCH 2/2] checkbutton: Activate when moving focus Currently we update the :active property on both the previous and new focus button. That "visually activate" the button and will emit ::toggled, but if the button is associated with an action, the action state won't change. Fix that by activating the new focus instead of explicitly fiddling with the :active property. --- gtk/gtkcheckbutton.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c index 9471f6d3c6..4357a10010 100644 --- a/gtk/gtkcheckbutton.c +++ b/gtk/gtkcheckbutton.c @@ -420,9 +420,6 @@ gtk_check_button_focus (GtkWidget *widget, GtkDirectionType direction) { GtkCheckButton *self = GTK_CHECK_BUTTON (widget); - GtkCheckButton *active_button; - - active_button = get_group_active_button (self); if (gtk_widget_is_focus (widget)) { @@ -471,9 +468,7 @@ gtk_check_button_focus (GtkWidget *widget, if (new_focus) { gtk_widget_grab_focus (new_focus); - gtk_check_button_set_active (GTK_CHECK_BUTTON (new_focus), TRUE); - if (active_button && active_button != (GtkCheckButton *)new_focus) - gtk_check_button_set_active (GTK_CHECK_BUTTON (active_button), FALSE); + gtk_widget_activate (new_focus); } g_ptr_array_free (child_array, TRUE); @@ -482,6 +477,9 @@ gtk_check_button_focus (GtkWidget *widget, } else { + GtkCheckButton *active_button; + + active_button = get_group_active_button (self); if (active_button && active_button != self) return FALSE;