cssanimatedstyle: Merge two functions

This commit is contained in:
Benjamin Otte 2014-12-15 01:58:11 +01:00
parent 0bab285fe0
commit 980923c761
3 changed files with 36 additions and 41 deletions

View File

@ -119,20 +119,6 @@ gtk_css_animated_style_init (GtkCssAnimatedStyle *style)
{
}
GtkCssStyle *
gtk_css_animated_style_new (GtkCssStyle *style)
{
GtkCssAnimatedStyle *result;
g_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
result = g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
result->style = g_object_ref (style);
return GTK_CSS_STYLE (result);
}
void
gtk_css_animated_style_set_animated_value (GtkCssAnimatedStyle *style,
guint id,
@ -398,17 +384,30 @@ gtk_css_animated_style_create_css_animations (GtkCssAnimatedStyle *style,
/* PUBLIC API */
void
gtk_css_animated_style_create_animations (GtkCssAnimatedStyle *style,
GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssStyle *source)
GtkCssStyle *
gtk_css_animated_style_new (GtkCssStyle *base_style,
GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssStyle *previous_style)
{
if (source != NULL)
gtk_css_animated_style_create_css_transitions (style, timestamp, source);
gtk_css_animated_style_create_css_animations (style, parent_style, timestamp, provider, scale, source);
GtkCssAnimatedStyle *result;
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (base_style), NULL);
gtk_internal_return_val_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style), NULL);
gtk_internal_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
gtk_internal_return_val_if_fail (previous_style == NULL || GTK_IS_CSS_STYLE (previous_style), NULL);
result = g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
result->style = g_object_ref (base_style);
if (previous_style != NULL)
gtk_css_animated_style_create_css_transitions (result, timestamp, previous_style);
gtk_css_animated_style_create_css_animations (result, parent_style, timestamp, provider, scale, previous_style);
return GTK_CSS_STYLE (result);
}
GtkBitmask *

View File

@ -52,7 +52,12 @@ struct _GtkCssAnimatedStyleClass
GType gtk_css_animated_style_get_type (void) G_GNUC_CONST;
GtkCssStyle * gtk_css_animated_style_new (GtkCssStyle *style);
GtkCssStyle * gtk_css_animated_style_new (GtkCssStyle *base_style,
GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProviderPrivate *provider,
int scale,
GtkCssStyle *previous_style);
void gtk_css_animated_style_set_animated_value(GtkCssAnimatedStyle *style,
guint id,
@ -61,12 +66,6 @@ void gtk_css_animated_style_set_animated_value(GtkCssAnimated
GtkCssValue * gtk_css_animated_style_get_intrinsic_value (GtkCssAnimatedStyle *style,
guint id);
void gtk_css_animated_style_create_animations(GtkCssAnimatedStyle *style,
GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProviderPrivate*provider,
int scale,
GtkCssStyle *source);
GtkBitmask * gtk_css_animated_style_advance (GtkCssAnimatedStyle *style,
gint64 timestamp);
void gtk_css_animated_style_cancel_animations(GtkCssAnimatedStyle *style);

View File

@ -2838,17 +2838,14 @@ _gtk_style_context_validate (GtkStyleContext *context,
style_info_set_values (info, NULL);
values = style_values_lookup (context);
values = gtk_css_animated_style_new (values);
if (values != current)
gtk_css_animated_style_create_animations (GTK_CSS_ANIMATED_STYLE (values),
priv->parent ? style_values_lookup (priv->parent) : NULL,
timestamp,
GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
priv->scale,
gtk_style_context_should_create_transitions (context)
? current
: NULL);
values = gtk_css_animated_style_new (values,
priv->parent ? style_values_lookup (priv->parent) : NULL,
timestamp,
GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
priv->scale,
gtk_style_context_should_create_transitions (context) ? current : NULL);
if (gtk_css_animated_style_is_static (GTK_CSS_ANIMATED_STYLE (values)))
{
change &= ~GTK_CSS_CHANGE_ANIMATE;