Commit e8cb6f31 authored by Benjamin Otte's avatar Benjamin Otte

styleproperty: Add compute_value vfunc

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