Commit 759d8daf authored by Benjamin Otte's avatar Benjamin Otte

cssstyle: Add gtk_css_style_is_static()

Gets rid of the need to do

  if (ANIMATED_STYLE() &&
      animated_style_is_static(ANIMATED_STYLE(style))
parent d9727290
......@@ -63,6 +63,21 @@ gtk_css_animated_style_get_section (GtkCssStyle *style,
return gtk_css_style_get_section (animated->style, id);
}
static gboolean
gtk_css_animated_style_is_static (GtkCssStyle *style)
{
GtkCssAnimatedStyle *animated = GTK_CSS_ANIMATED_STYLE (style);
GSList *list;
for (list = animated->animations; list; list = list->next)
{
if (!_gtk_style_animation_is_static (list->data, animated->current_time))
return FALSE;
}
return TRUE;
}
static void
gtk_css_animated_style_dispose (GObject *object)
{
......@@ -101,6 +116,7 @@ gtk_css_animated_style_class_init (GtkCssAnimatedStyleClass *klass)
style_class->get_value = gtk_css_animated_style_get_value;
style_class->get_section = gtk_css_animated_style_get_section;
style_class->is_static = gtk_css_animated_style_is_static;
}
static void
......@@ -472,19 +488,3 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
return GTK_CSS_STYLE (result);
}
gboolean
gtk_css_animated_style_is_static (GtkCssAnimatedStyle *style)
{
GSList *list;
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style), TRUE);
for (list = style->animations; list; list = list->next)
{
if (!_gtk_style_animation_is_static (list->data, style->current_time))
return FALSE;
}
return TRUE;
}
......@@ -68,8 +68,6 @@ void gtk_css_animated_style_set_animated_value(GtkCssAnimated
GtkCssValue * gtk_css_animated_style_get_intrinsic_value (GtkCssAnimatedStyle *style,
guint id);
gboolean gtk_css_animated_style_is_static (GtkCssAnimatedStyle *style);
G_END_DECLS
#endif /* __GTK_CSS_ANIMATED_STYLE_PRIVATE_H__ */
......@@ -271,8 +271,7 @@ gtk_css_node_real_update_style (GtkCssNode *cssnode,
new_style = g_object_ref (style);
}
if (GTK_IS_CSS_ANIMATED_STYLE (new_style) &&
!gtk_css_animated_style_is_static (GTK_CSS_ANIMATED_STYLE (new_style)))
if (!gtk_css_style_is_static (new_style))
gtk_css_node_set_invalid (cssnode, TRUE);
g_object_unref (new_static_style);
......@@ -901,8 +900,7 @@ gtk_css_node_validate_internal (GtkCssNode *cssnode,
/* need to set to FALSE then to TRUE here to make it chain up */
gtk_css_node_set_invalid (cssnode, FALSE);
if (GTK_IS_CSS_ANIMATED_STYLE (cssnode->style) &&
!gtk_css_animated_style_is_static (GTK_CSS_ANIMATED_STYLE (cssnode->style)))
if (!gtk_css_style_is_static (cssnode->style))
gtk_css_node_set_invalid (cssnode, TRUE);
GTK_CSS_NODE_GET_CLASS (cssnode)->validate (cssnode);
......
......@@ -46,10 +46,17 @@ gtk_css_style_real_get_section (GtkCssStyle *style,
return NULL;
}
static gboolean
gtk_css_style_real_is_static (GtkCssStyle *style)
{
return TRUE;
}
static void
gtk_css_style_class_init (GtkCssStyleClass *klass)
{
klass->get_section = gtk_css_style_real_get_section;
klass->is_static = gtk_css_style_real_is_static;
}
static void
......@@ -97,6 +104,15 @@ gtk_css_style_get_difference (GtkCssStyle *style,
return result;
}
gboolean
gtk_css_style_is_static (GtkCssStyle *style)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (style), TRUE);
return GTK_CSS_STYLE_GET_CLASS (style)->is_static (style);
}
void
gtk_css_style_print (GtkCssStyle *style,
GString *string)
......
......@@ -54,6 +54,8 @@ struct _GtkCssStyleClass
* Optional: default impl will just return NULL */
GtkCssSection * (* get_section) (GtkCssStyle *style,
guint id);
/* TRUE if this style will require changes based on timestamp */
gboolean (* is_static) (GtkCssStyle *style);
};
GType gtk_css_style_get_type (void) G_GNUC_CONST;
......@@ -64,6 +66,7 @@ GtkCssSection * gtk_css_style_get_section (GtkCssStyle
guint id);
GtkBitmask * gtk_css_style_get_difference (GtkCssStyle *style,
GtkCssStyle *other);
gboolean gtk_css_style_is_static (GtkCssStyle *style);
char * gtk_css_style_to_string (GtkCssStyle *style);
void gtk_css_style_print (GtkCssStyle *style,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment