Changed behaviour of gtk_style_context_get_color
Submitted by Morten Welinder
Link to original bug (#765982)
Description
Gtk+ 3.20 changed behaviour of gtk_style_context_get_color. It used to be correct to have a state argument different from the state of the context; now those have to be the same.
This is unreasonable.
I am sure there are good, internal reasons why the states must match, but gtk+ has all the pieces needed for hiding the change. It makes much more sense to have the work-around in one spot in Gtk+ than having the work-around in 100 places in 100 applications. The pain is 10000 times bigger in the latter case.
The recommended work-around is
save_state
set_state (state)
get_color
restore_state
although as pointed out in bug 765921, that doesn't actually work. Alternatively one can use
old = get_state
if (old != state) set_state (state)
get_color
if (old != state) set_state (old)
I think this work-around should be added to gtk_style_context_get_color or further downstream. That will allow existing code -- including binaries -- to keep working. It will also work with already-changed code.
Version: 3.22.x