From 22a65bcd82a3b2d2bfe3cc4423b83599b5609a52 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 2 Jan 2012 17:50:32 +0100 Subject: [PATCH] styleproperty: Add a compute vfunc --- gtk/gtkcssstyleproperty.c | 15 ++++++++++++--- gtk/gtkcssstylepropertyprivate.h | 6 ++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gtk/gtkcssstyleproperty.c b/gtk/gtkcssstyleproperty.c index 2f542449f9..e3580775ab 100644 --- a/gtk/gtkcssstyleproperty.c +++ b/gtk/gtkcssstyleproperty.c @@ -218,10 +218,20 @@ _gtk_css_style_property_class_init (GtkCssStylePropertyClass *klass) klass->style_properties = g_ptr_array_new (); } +static void +gtk_css_style_property_real_compute_value (GtkCssStyleProperty *property, + GValue *computed, + GtkStyleContext *context, + const GValue *specified) +{ + g_value_init (computed, _gtk_style_property_get_value_type (GTK_STYLE_PROPERTY (property))); + _gtk_css_style_compute_value (computed, context, specified); +} static void -_gtk_css_style_property_init (GtkCssStyleProperty *style_property) +_gtk_css_style_property_init (GtkCssStyleProperty *property) { + property->compute_value = gtk_css_style_property_real_compute_value; } /** @@ -338,8 +348,7 @@ _gtk_css_style_property_compute_value (GtkCssStyleProperty *property, g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (G_IS_VALUE (specified)); - g_value_init (computed, _gtk_style_property_get_value_type (GTK_STYLE_PROPERTY (property))); - _gtk_css_style_compute_value (computed, context, specified); + property->compute_value (property, computed, context, specified); } /** diff --git a/gtk/gtkcssstylepropertyprivate.h b/gtk/gtkcssstylepropertyprivate.h index c02a766892..a8f6dce38d 100644 --- a/gtk/gtkcssstylepropertyprivate.h +++ b/gtk/gtkcssstylepropertyprivate.h @@ -35,6 +35,10 @@ G_BEGIN_DECLS typedef struct _GtkCssStyleProperty GtkCssStyleProperty; typedef struct _GtkCssStylePropertyClass GtkCssStylePropertyClass; +typedef void (* GtkCssStylePropertyComputeFunc)(GtkCssStyleProperty *property, + GValue *computed, + GtkStyleContext *context, + const GValue *specified); struct _GtkCssStyleProperty { GtkStyleProperty parent; @@ -42,6 +46,8 @@ struct _GtkCssStyleProperty GValue initial_value; guint id; guint inherit :1; + + GtkCssStylePropertyComputeFunc compute_value; }; struct _GtkCssStylePropertyClass