Method

GtkStyleContextnotify_state_change

deprecated: 3.6 since: 3.0

Declaration [src]

void
gtk_style_context_notify_state_change (
  GtkStyleContext* context,
  GdkWindow* window,
  gpointer region_id,
  GtkStateType state,
  gboolean state_value
)

Description [src]

Notifies a state change on context, so if the current style makes use of transition animations, one will be started so all rendered elements under region_id are animated for state state being set to value state_value.

The window parameter is used in order to invalidate the rendered area as the animation runs, so make sure it is the same window that is being rendered on by the gtk_render_*() functions.

If region_id is NULL, all rendered elements using context will be affected by this state transition.

As a practical example, a GtkButton notifying a state transition on the prelight state:

gtk_style_context_notify_state_change (context,
                                       gtk_widget_get_window (widget),
                                       NULL,
                                       GTK_STATE_PRELIGHT,
                                       button->in_button);

Can be handled in the CSS file like this:

button {
    background-color: #f00
}

button:hover {
    background-color: #fff;
    transition: 200ms linear
}

This combination will animate the button background from red to white if a pointer enters the button, and back to red if the pointer leaves the button.

Note that state is used when finding the transition parameters, which is why the style places the transition under the :hover pseudo-class.

Available since: 3.0

Deprecated since: 3.6

This function does nothing.

Parameters

window

Type: GdkWindow

A GdkWindow.

The data is owned by the caller of the method.
region_id

Type: gpointer

Animatable region to notify on, or NULL. See gtk_style_context_push_animatable_region().

The argument can be NULL.
The data is owned by the caller of the method.
state

Type: GtkStateType

State to trigger transition for.

state_value

Type: gboolean

TRUE if state is the state we are changing to, FALSE if we are changing away from it.