Bug 765982 - Changed behaviour of gtk_style_context_get_color
Changed behaviour of gtk_style_context_get_color
Status: NEW
Product: gtk+
Classification: Platform
Component: Class: GtkStyleContext
3.16.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2016-05-04 12:24 UTC by Morten Welinder
Modified: 2016-05-06 17:20 UTC (History)
2 users (show)

See Also:
GNOME target: ---
GNOME version: ---


Attachments

Description Morten Welinder 2016-05-04 12:24:50 UTC
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.

Note You need to log in before you can comment on or make changes to this bug.