-gtk_style_context_notify_state_change (GtkStyleContext *context,
- GdkWindow *window,
- gpointer region_id,
- GtkStateType state,
- gboolean state_value)
-{
- GtkStyleContextPrivate *priv;
- GtkAnimationDescription *desc;
- AnimationInfo *info;
- GtkStateFlags flags;
- GtkCssValue *v;
- StyleData *data;
-
- g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
- g_return_if_fail (GDK_IS_WINDOW (window));
- g_return_if_fail (state > GTK_STATE_NORMAL && state <= GTK_STATE_FOCUSED);
-
- priv = context->priv;
- g_return_if_fail (priv->widget_path != NULL);
-
- state_value = (state_value == TRUE);
-
- switch (state)
- {
- case GTK_STATE_ACTIVE:
- flags = GTK_STATE_FLAG_ACTIVE;
- break;
- case GTK_STATE_PRELIGHT:
- flags = GTK_STATE_FLAG_PRELIGHT;
- break;
- case GTK_STATE_SELECTED:
- flags = GTK_STATE_FLAG_SELECTED;
- break;
- case GTK_STATE_INSENSITIVE:
- flags = GTK_STATE_FLAG_INSENSITIVE;
- break;
- case GTK_STATE_INCONSISTENT:
- flags = GTK_STATE_FLAG_INCONSISTENT;
- break;
- case GTK_STATE_FOCUSED:
- flags = GTK_STATE_FLAG_FOCUSED;
- break;
- case GTK_STATE_NORMAL:
- default:
- flags = 0;
- break;
- }
-
- /* Find out if there is any animation description for the given
- * state, it will fallback to the normal state as well if necessary.
- */
- data = style_data_lookup (context, flags);
- v = _gtk_css_computed_values_get_value_by_name (data->store, "transition");
- if (!v)
- return;
- desc = _gtk_css_value_get_boxed (v);
- if (!desc)
- return;
-
- if (_gtk_animation_description_get_duration (desc) == 0)
- return;
-
- info = animation_info_lookup (context, region_id, state);
-
- if (info &&
- info->target_value != state_value)
- {
- /* Target values are the opposite */
- if (!_gtk_timeline_get_loop (info->timeline))
- {
- /* Reverse the animation */
- if (_gtk_timeline_get_direction (info->timeline) == GTK_TIMELINE_DIRECTION_FORWARD)
- _gtk_timeline_set_direction (info->timeline, GTK_TIMELINE_DIRECTION_BACKWARD);
- else
- _gtk_timeline_set_direction (info->timeline, GTK_TIMELINE_DIRECTION_FORWARD);
-
- info->target_value = state_value;
- }
- else
- {
- /* Take it out of its looping state */
- _gtk_timeline_set_loop (info->timeline, FALSE);
- }
- }
- else if (!info &&
- (!_gtk_animation_description_get_loop (desc) ||
- state_value))
- {
- info = animation_info_new (context, region_id,
- _gtk_animation_description_get_duration (desc),
- _gtk_animation_description_get_progress_type (desc),
- _gtk_animation_description_get_loop (desc),
- state, state_value, window);
-
- priv->animations = g_slist_prepend (priv->animations, info);
- priv->animations_invalidated = TRUE;
- }