Merge branch 'static-style-getter' into 'master'

css: Add gtk_css_style_get_static_style

See merge request GNOME/gtk!1323
This commit is contained in:
Matthias Clasen 2020-01-16 17:10:31 +00:00
commit 5910e5ac6d
4 changed files with 30 additions and 9 deletions

View File

@ -79,6 +79,15 @@ gtk_css_animated_style_is_static (GtkCssStyle *style)
return TRUE;
}
static GtkCssStyle *
gtk_css_animated_style_get_static_style (GtkCssStyle *style)
{
/* This is called a lot, so we avoid a dynamic type check here */
GtkCssAnimatedStyle *animated = (GtkCssAnimatedStyle *) style;
return animated->style;
}
static void
gtk_css_animated_style_dispose (GObject *object)
{
@ -123,6 +132,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;
style_class->get_static_style = gtk_css_animated_style_get_static_style;
}
static void

View File

@ -407,14 +407,7 @@ gtk_css_node_real_update_style (GtkCssNode *cssnode,
{
GtkCssStyle *static_style, *new_static_style, *new_style;
if (GTK_IS_CSS_ANIMATED_STYLE (style))
{
static_style = GTK_CSS_ANIMATED_STYLE (style)->style;
}
else
{
static_style = style;
}
static_style = gtk_css_style_get_static_style (style);
if (gtk_css_style_needs_recreation (static_style, change))
new_static_style = gtk_css_node_create_style (cssnode);
@ -436,7 +429,7 @@ gtk_css_node_real_update_style (GtkCssNode *cssnode,
}
else if (static_style != style && (change & GTK_CSS_CHANGE_TIMESTAMP))
{
new_style = gtk_css_animated_style_new_advance (GTK_CSS_ANIMATED_STYLE (style),
new_style = gtk_css_animated_style_new_advance ((GtkCssAnimatedStyle *)style,
static_style,
timestamp);
}

View File

@ -53,11 +53,18 @@ gtk_css_style_real_is_static (GtkCssStyle *style)
return TRUE;
}
static GtkCssStyle *
gtk_css_style_real_get_static_style (GtkCssStyle *style)
{
return style;
}
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;
klass->get_static_style = gtk_css_style_real_get_static_style;
}
static void
@ -89,6 +96,14 @@ gtk_css_style_is_static (GtkCssStyle *style)
return GTK_CSS_STYLE_GET_CLASS (style)->is_static (style);
}
GtkCssStyle *
gtk_css_style_get_static_style (GtkCssStyle *style)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
return GTK_CSS_STYLE_GET_CLASS (style)->get_static_style (style);
}
/*
* gtk_css_style_print:
* @style: a #GtkCssStyle

View File

@ -56,6 +56,8 @@ struct _GtkCssStyleClass
guint id);
/* TRUE if this style will require changes based on timestamp */
gboolean (* is_static) (GtkCssStyle *style);
GtkCssStyle * (* get_static_style) (GtkCssStyle *style);
};
GType gtk_css_style_get_type (void) G_GNUC_CONST;
@ -74,6 +76,7 @@ gboolean gtk_css_style_print (GtkCssStyle
PangoAttrList * gtk_css_style_get_pango_attributes (GtkCssStyle *style);
PangoFontDescription * gtk_css_style_get_pango_font (GtkCssStyle *style);
GtkCssStyle * gtk_css_style_get_static_style (GtkCssStyle *style);
G_END_DECLS