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.
This commit is contained in:
parent
078fc725e0
commit
b904679a11
@ -3282,13 +3282,13 @@ gtk_css_ruleset_print (const GtkCssRuleset *ruleset,
|
||||
|
||||
for (walk = keys; walk; walk = walk->next)
|
||||
{
|
||||
GtkStyleProperty *prop = walk->data;
|
||||
GtkCssStyleProperty *prop = walk->data;
|
||||
const PropertyValue *value = g_hash_table_lookup (ruleset->style, prop);
|
||||
|
||||
g_string_append (str, " ");
|
||||
g_string_append (str, _gtk_style_property_get_name (prop));
|
||||
g_string_append (str, _gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop)));
|
||||
g_string_append (str, ": ");
|
||||
_gtk_style_property_print_value (prop, &value->value, str);
|
||||
_gtk_css_style_property_print_value (prop, &value->value, str);
|
||||
g_string_append (str, ";\n");
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,10 @@ guint _gtk_css_style_property_get_id (GtkCssStyleProp
|
||||
const GValue * _gtk_css_style_property_get_initial_value
|
||||
(GtkCssStyleProperty *property);
|
||||
|
||||
void _gtk_css_style_property_print_value (GtkCssStyleProperty *property,
|
||||
const GValue *value,
|
||||
GString *string);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_STYLE_PROPERTY_PRIVATE_H__ */
|
||||
|
@ -201,22 +201,6 @@ string_append_string (GString *str,
|
||||
|
||||
/*** IMPLEMENTATIONS ***/
|
||||
|
||||
static void
|
||||
enum_print (int value,
|
||||
GType type,
|
||||
GString *string)
|
||||
{
|
||||
GEnumClass *enum_class;
|
||||
GEnumValue *enum_value;
|
||||
|
||||
enum_class = g_type_class_ref (type);
|
||||
enum_value = g_enum_get_value (enum_class, value);
|
||||
|
||||
g_string_append (string, enum_value->value_nick);
|
||||
|
||||
g_type_class_unref (enum_class);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
font_family_parse (GtkCssParser *parser,
|
||||
GFile *base,
|
||||
@ -453,19 +437,6 @@ _gtk_style_property_parse_value (GtkStyleProperty *property,
|
||||
return _gtk_css_style_parse_value (value, parser, base);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_style_property_print_value (GtkStyleProperty *property,
|
||||
const GValue *value,
|
||||
GString *string)
|
||||
{
|
||||
if (G_VALUE_HOLDS (value, GTK_TYPE_CSS_SPECIAL_VALUE))
|
||||
enum_print (g_value_get_enum (value), GTK_TYPE_CSS_SPECIAL_VALUE, string);
|
||||
else if (property && property->print_func)
|
||||
(* property->print_func) (value, string);
|
||||
else
|
||||
_gtk_css_style_print_value (value, string);
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_style_property_default_value (GtkStyleProperty *property,
|
||||
GtkStyleProperties *properties,
|
||||
|
@ -95,9 +95,6 @@ gboolean _gtk_style_property_parse_value (GtkStyleProperty *
|
||||
GValue *value,
|
||||
GtkCssParser *parser,
|
||||
GFile *base);
|
||||
void _gtk_style_property_print_value (GtkStyleProperty * property,
|
||||
const GValue *value,
|
||||
GString *string);
|
||||
|
||||
GType _gtk_style_property_get_value_type(GtkStyleProperty * property);
|
||||
void _gtk_style_property_query (GtkStyleProperty * property,
|
||||
|
Loading…
Reference in New Issue
Block a user