GNOME Bugzilla – Bug 688519
GtkRadioButton's label style not updated when programmatically toggled
Last modified: 2018-04-15 00:19:36 UTC
The following test case changes the label widget inside a radio button on the fly when the button is toggled: you can see that from time to time the label is white and bold even when the button is not active. Hovering with the mouse refreshes the label properly. Note this is needed to properly imeplement the gnome3 toolbar design (we cannot simply change the label's markup since we need to have two label and put them in a size group to make sure we get the larger width).
Created attachment 229221 [details] test program
This is actually a problem with state flag propagation. When you remove the non-bold widget, it has GTK_STATE_FLAG_ACTIVE set on it (due to the button just having become active). And then when you readd it later, the state flag is still set. There is nothing we can do about it without reorganizing how we handle state flags. The only quickfix I can offer is this: --- test.c.old 2012-11-17 13:01:06.201746549 +0100 +++ test.c 2012-11-17 14:09:46.959591319 +0100 @@ -34,6 +34,7 @@ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio))) { gtk_container_add (GTK_CONTAINER (radio), labels->bold); } else { + gtk_widget_unset_state_flags (labels->plain, GTK_STATE_FLAG_ACTIVE); gtk_container_add (GTK_CONTAINER (radio), labels->plain } gtk_widget_show_all (radio);
Thanks. I have applied the workaround in clocks. I am leaving this open for a real fix as discussed in #gtk+
We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO if they haven't seen activity in more than a year. If this issue is still important to you and still relevant with GTK+ 3.22 or master, please reopen it and we will migrate it to gitlab.
As announced a while ago, we are migrating to gitlab, and bugs that haven't seen activity in the last year or so will be not be migrated, but closed out in bugzilla. If this bug is still relevant to you, you can open a new issue describing the symptoms and how to reproduce it with gtk 3.22.x or master in gitlab: https://gitlab.gnome.org/GNOME/gtk/issues/new