Commit e8cb6f31 authored by Benjamin Otte's avatar Benjamin Otte

styleproperty: Add compute_value vfunc

parent c3d33731
......@@ -50,6 +50,7 @@ _gtk_style_property_register (const char * name,
GtkStylePropertyFlags flags,
GtkCssStylePropertyParseFunc parse_value,
GtkCssStylePropertyPrintFunc print_value,
GtkCssStylePropertyComputeFunc compute_value,
const GValue * initial_value)
{
GtkCssStyleProperty *node;
......@@ -65,6 +66,8 @@ _gtk_style_property_register (const char * name,
node->parse_value = parse_value;
if (print_value)
node->print_value = print_value;
if (compute_value)
node->compute_value = compute_value;
}
static void
......@@ -73,13 +76,14 @@ gtk_style_property_register (const char * name,
GtkStylePropertyFlags flags,
GtkCssStylePropertyParseFunc parse_value,
GtkCssStylePropertyPrintFunc print_value,
GtkCssStylePropertyComputeFunc compute_value,
...)
{
GValue initial_value = G_VALUE_INIT;
char *error = NULL;
va_list args;
va_start (args, print_value);
va_start (args, compute_value);
G_VALUE_COLLECT_INIT (&initial_value, value_type,
args, 0, &error);
if (error)
......@@ -91,7 +95,13 @@ gtk_style_property_register (const char * name,
va_end (args);
_gtk_style_property_register (name, value_type, flags, parse_value, print_value, &initial_value);
_gtk_style_property_register (name,
value_type,
flags,
parse_value,
print_value,
compute_value,
&initial_value);
g_value_unset (&initial_value);
}
......@@ -357,6 +367,7 @@ _gtk_css_style_property_init_properties (void)
GTK_STYLE_PROPERTY_INHERIT,
NULL,
NULL,
NULL,
&rgba);
rgba_init (&rgba, 0, 0, 0, 0);
gtk_style_property_register ("background-color",
......@@ -364,6 +375,7 @@ _gtk_css_style_property_init_properties (void)
0,
NULL,
NULL,
NULL,
&rgba);
gtk_style_property_register ("font-family",
......@@ -371,18 +383,21 @@ _gtk_css_style_property_init_properties (void)
GTK_STYLE_PROPERTY_INHERIT,
font_family_parse,
font_family_value_print,
NULL,
default_font_family);
gtk_style_property_register ("font-style",
PANGO_TYPE_STYLE,
GTK_STYLE_PROPERTY_INHERIT,
NULL,
NULL,
NULL,
PANGO_STYLE_NORMAL);
gtk_style_property_register ("font-variant",
PANGO_TYPE_VARIANT,
GTK_STYLE_PROPERTY_INHERIT,
NULL,
NULL,
NULL,
PANGO_VARIANT_NORMAL);
/* xxx: need to parse this properly, ie parse the numbers */
gtk_style_property_register ("font-weight",
......@@ -390,12 +405,14 @@ _gtk_css_style_property_init_properties (void)
GTK_STYLE_PROPERTY_INHERIT,
NULL,
NULL,
NULL,
PANGO_WEIGHT_NORMAL);
gtk_style_property_register ("font-size",
G_TYPE_DOUBLE,
GTK_STYLE_PROPERTY_INHERIT,
NULL,
NULL,
NULL,
10.0);
gtk_style_property_register ("text-shadow",
......@@ -403,6 +420,7 @@ _gtk_css_style_property_init_properties (void)
GTK_STYLE_PROPERTY_INHERIT,
NULL,
NULL,
NULL,
NULL);
gtk_style_property_register ("icon-shadow",
......@@ -410,6 +428,7 @@ _gtk_css_style_property_init_properties (void)
GTK_STYLE_PROPERTY_INHERIT,
NULL,
NULL,
NULL,
NULL);
gtk_style_property_register ("box-shadow",
......@@ -417,6 +436,7 @@ _gtk_css_style_property_init_properties (void)
0,
NULL,
NULL,
NULL,
NULL);
gtk_style_property_register ("margin-top",
......@@ -424,72 +444,84 @@ _gtk_css_style_property_init_properties (void)
0,
NULL,
NULL,
NULL,
0);
gtk_style_property_register ("margin-left",
G_TYPE_INT,
0,
NULL,
NULL,
NULL,
0);
gtk_style_property_register ("margin-bottom",
G_TYPE_INT,
0,
NULL,
NULL,
NULL,
0);
gtk_style_property_register ("margin-right",
G_TYPE_INT,
0,
NULL,
NULL,
NULL,
0);
gtk_style_property_register ("padding-top",
G_TYPE_INT,
0,
NULL,
NULL,
NULL,
0);
gtk_style_property_register ("padding-left",
G_TYPE_INT,
0,
NULL,
NULL,
NULL,
0);
gtk_style_property_register ("padding-bottom",
G_TYPE_INT,
0,
NULL,
NULL,
NULL,
0);
gtk_style_property_register ("padding-right",
G_TYPE_INT,
0,
NULL,
NULL,
NULL,
0);
gtk_style_property_register ("border-top-width",
G_TYPE_INT,
0,
NULL,
NULL,
NULL,
0);
gtk_style_property_register ("border-left-width",
G_TYPE_INT,
0,
NULL,
NULL,
NULL,
0);
gtk_style_property_register ("border-bottom-width",
G_TYPE_INT,
0,
NULL,
NULL,
NULL,
0);
gtk_style_property_register ("border-right-width",
G_TYPE_INT,
0,
NULL,
NULL,
NULL,
0);
gtk_style_property_register ("border-top-left-radius",
......@@ -497,24 +529,28 @@ _gtk_css_style_property_init_properties (void)
0,
border_corner_radius_value_parse,
border_corner_radius_value_print,
NULL,
&no_corner_radius);
gtk_style_property_register ("border-top-right-radius",
GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
0,
border_corner_radius_value_parse,
border_corner_radius_value_print,
NULL,
&no_corner_radius);
gtk_style_property_register ("border-bottom-right-radius",
GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
0,
border_corner_radius_value_parse,
border_corner_radius_value_print,
NULL,
&no_corner_radius);
gtk_style_property_register ("border-bottom-left-radius",
GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
0,
border_corner_radius_value_parse,
border_corner_radius_value_print,
NULL,
&no_corner_radius);
gtk_style_property_register ("border-style",
......@@ -522,12 +558,14 @@ _gtk_css_style_property_init_properties (void)
0,
NULL,
NULL,
NULL,
GTK_BORDER_STYLE_NONE);
gtk_style_property_register ("background-clip",
GTK_TYPE_CSS_AREA,
0,
NULL,
NULL,
NULL,
GTK_CSS_AREA_BORDER_BOX);
gtk_style_property_register ("background-origin",
......@@ -535,6 +573,7 @@ _gtk_css_style_property_init_properties (void)
0,
NULL,
NULL,
NULL,
GTK_CSS_AREA_PADDING_BOX);
g_value_init (&value, GTK_TYPE_CSS_SPECIAL_VALUE);
......@@ -544,24 +583,28 @@ _gtk_css_style_property_init_properties (void)
0,
NULL,
NULL,
NULL,
&value);
_gtk_style_property_register ("border-right-color",
GDK_TYPE_RGBA,
0,
NULL,
NULL,
NULL,
&value);
_gtk_style_property_register ("border-bottom-color",
GDK_TYPE_RGBA,
0,
NULL,
NULL,
NULL,
&value);
_gtk_style_property_register ("border-left-color",
GDK_TYPE_RGBA,
0,
NULL,
NULL,
NULL,
&value);
g_value_unset (&value);
......@@ -570,12 +613,14 @@ _gtk_css_style_property_init_properties (void)
0,
NULL,
NULL,
NULL,
NULL);
gtk_style_property_register ("background-repeat",
GTK_TYPE_CSS_BACKGROUND_REPEAT,
0,
NULL,
NULL,
NULL,
&background_repeat);
gtk_style_property_register ("border-image-source",
......@@ -583,12 +628,14 @@ _gtk_css_style_property_init_properties (void)
0,
NULL,
NULL,
NULL,
NULL);
gtk_style_property_register ("border-image-repeat",
GTK_TYPE_CSS_BORDER_IMAGE_REPEAT,
0,
NULL,
NULL,
NULL,
&border_image_repeat);
/* XXX: The initial vaue is wrong, it should be 100% */
......@@ -597,24 +644,28 @@ _gtk_css_style_property_init_properties (void)
0,
NULL,
NULL,
NULL,
&border_of_ones);
gtk_style_property_register ("border-image-width",
GTK_TYPE_BORDER,
0,
NULL,
NULL,
NULL,
NULL);
gtk_style_property_register ("engine",
GTK_TYPE_THEMING_ENGINE,
0,
NULL,
NULL,
NULL,
gtk_theming_engine_load (NULL));
gtk_style_property_register ("transition",
GTK_TYPE_ANIMATION_DESCRIPTION,
0,
NULL,
NULL,
NULL,
NULL);
/* Private property holding the binding sets */
......@@ -623,6 +674,7 @@ _gtk_css_style_property_init_properties (void)
0,
bindings_value_parse,
bindings_value_print,
NULL,
NULL);
}
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