diff options
author | Benjamin Otte <otte@redhat.com> | 2012-01-01 18:28:27 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2012-01-09 18:37:53 +0100 |
commit | b904679a111224039a92e6f50acd97f6218a2d3a (patch) | |
tree | 13a8766be3e403bec0a22e762461ea109af2ab6c /gtk/gtkcssstyleproperty.c | |
parent | 078fc725e0a83250ea7e1bf37dfc4f5f95b990c8 (diff) | |
download | gtk+-b904679a111224039a92e6f50acd97f6218a2d3a.tar.gz |
styleproperty: Move value printing to real properties
We can't print shorthands, so don't try.
In particular, I want to get away from shorthands being representable
using GValue, and this function kinda requires that.
Diffstat (limited to 'gtk/gtkcssstyleproperty.c')
-rw-r--r-- | gtk/gtkcssstyleproperty.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/gtk/gtkcssstyleproperty.c b/gtk/gtkcssstyleproperty.c index 66ce7ff020..da90227814 100644 --- a/gtk/gtkcssstyleproperty.c +++ b/gtk/gtkcssstyleproperty.c @@ -22,7 +22,10 @@ #include "gtkcssstylepropertyprivate.h" +#include "gtkcssstylefuncsprivate.h" +#include "gtkcsstypesprivate.h" #include "gtkintl.h" +#include "gtkprivatetypebuiltins.h" enum { PROP_0, @@ -227,3 +230,40 @@ _gtk_css_style_property_get_initial_value (GtkCssStyleProperty *property) return &property->initial_value; } +/** + * _gtk_css_style_property_print_value: + * @property: the property + * @value: the value to print + * @string: the string to print to + * + * Prints @value to the given @string in CSS format. The @value must be a + * valid specified value as parsed using the parse functions or as assigned + * via _gtk_style_property_assign(). + **/ +void +_gtk_css_style_property_print_value (GtkCssStyleProperty *property, + const GValue *value, + GString *string) +{ + g_return_if_fail (GTK_IS_CSS_STYLE_PROPERTY (property)); + g_return_if_fail (value != NULL); + g_return_if_fail (string != NULL); + + if (G_VALUE_HOLDS (value, GTK_TYPE_CSS_SPECIAL_VALUE)) + { + GEnumClass *enum_class; + GEnumValue *enum_value; + + enum_class = g_type_class_ref (GTK_TYPE_CSS_SPECIAL_VALUE); + enum_value = g_enum_get_value (enum_class, g_value_get_enum (value)); + + g_string_append (string, enum_value->value_nick); + + g_type_class_unref (enum_class); + } + else if (GTK_STYLE_PROPERTY (property)->print_func) + (* GTK_STYLE_PROPERTY (property)->print_func) (value, string); + else + _gtk_css_style_print_value (value, string); +} + |