styleproperty: Add support for equal_func

This commit is contained in:
Benjamin Otte 2012-03-24 07:02:59 +01:00
parent d5a2392cc7
commit 3cdb9c91ca

View File

@ -59,6 +59,7 @@ gtk_css_style_property_register (const char * name,
GtkCssStylePropertyParseFunc parse_value, GtkCssStylePropertyParseFunc parse_value,
GtkCssStylePropertyPrintFunc print_value, GtkCssStylePropertyPrintFunc print_value,
GtkCssStylePropertyComputeFunc compute_value, GtkCssStylePropertyComputeFunc compute_value,
GtkCssStylePropertyEqualFunc equal_func,
...) ...)
{ {
GtkCssStyleProperty *node; GtkCssStyleProperty *node;
@ -67,7 +68,7 @@ gtk_css_style_property_register (const char * name,
char *error = NULL; char *error = NULL;
va_list args; va_list args;
va_start (args, compute_value); va_start (args, equal_func);
G_VALUE_COLLECT_INIT (&initial_gvalue, specified_type, G_VALUE_COLLECT_INIT (&initial_gvalue, specified_type,
args, 0, &error); args, 0, &error);
if (error) if (error)
@ -95,6 +96,8 @@ gtk_css_style_property_register (const char * name,
node->print_value = print_value; node->print_value = print_value;
if (compute_value) if (compute_value)
node->compute_value = compute_value; node->compute_value = compute_value;
if (equal_func)
node->equal_func = equal_func;
_gtk_css_value_unref (initial_value); _gtk_css_value_unref (initial_value);
} }
@ -905,6 +908,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
color_compute, color_compute,
NULL,
symbolic); symbolic);
gtk_symbolic_color_unref (symbolic); gtk_symbolic_color_unref (symbolic);
gtk_css_style_property_register ("font-size", gtk_css_style_property_register ("font-size",
@ -915,6 +919,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
10.0); 10.0);
/* properties that aren't referenced when computing values /* properties that aren't referenced when computing values
@ -928,6 +933,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
color_compute, color_compute,
NULL,
symbolic); symbolic);
gtk_symbolic_color_unref (symbolic); gtk_symbolic_color_unref (symbolic);
@ -939,6 +945,7 @@ _gtk_css_style_property_init_properties (void)
font_family_parse, font_family_parse,
font_family_value_print, font_family_value_print,
NULL, NULL,
NULL,
default_font_family); default_font_family);
gtk_css_style_property_register ("font-style", gtk_css_style_property_register ("font-style",
PANGO_TYPE_STYLE, PANGO_TYPE_STYLE,
@ -948,6 +955,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
PANGO_STYLE_NORMAL); PANGO_STYLE_NORMAL);
gtk_css_style_property_register ("font-variant", gtk_css_style_property_register ("font-variant",
PANGO_TYPE_VARIANT, PANGO_TYPE_VARIANT,
@ -957,6 +965,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
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_css_style_property_register ("font-weight", gtk_css_style_property_register ("font-weight",
@ -967,6 +976,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
PANGO_WEIGHT_NORMAL); PANGO_WEIGHT_NORMAL);
gtk_css_style_property_register ("text-shadow", gtk_css_style_property_register ("text-shadow",
@ -977,6 +987,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
NULL); NULL);
gtk_css_style_property_register ("icon-shadow", gtk_css_style_property_register ("icon-shadow",
@ -987,6 +998,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
NULL); NULL);
gtk_css_style_property_register ("box-shadow", gtk_css_style_property_register ("box-shadow",
@ -997,6 +1009,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
NULL); NULL);
_gtk_css_number_init (&number, 0, GTK_CSS_PX); _gtk_css_number_init (&number, 0, GTK_CSS_PX);
@ -1008,6 +1021,7 @@ _gtk_css_style_property_init_properties (void)
parse_margin, parse_margin,
NULL, NULL,
compute_margin, compute_margin,
NULL,
&number); &number);
gtk_css_style_property_register ("margin-left", gtk_css_style_property_register ("margin-left",
GTK_TYPE_CSS_NUMBER, GTK_TYPE_CSS_NUMBER,
@ -1017,6 +1031,7 @@ _gtk_css_style_property_init_properties (void)
parse_margin, parse_margin,
NULL, NULL,
compute_margin, compute_margin,
NULL,
&number); &number);
gtk_css_style_property_register ("margin-bottom", gtk_css_style_property_register ("margin-bottom",
GTK_TYPE_CSS_NUMBER, GTK_TYPE_CSS_NUMBER,
@ -1026,6 +1041,7 @@ _gtk_css_style_property_init_properties (void)
parse_margin, parse_margin,
NULL, NULL,
compute_margin, compute_margin,
NULL,
&number); &number);
gtk_css_style_property_register ("margin-right", gtk_css_style_property_register ("margin-right",
GTK_TYPE_CSS_NUMBER, GTK_TYPE_CSS_NUMBER,
@ -1035,6 +1051,7 @@ _gtk_css_style_property_init_properties (void)
parse_margin, parse_margin,
NULL, NULL,
compute_margin, compute_margin,
NULL,
&number); &number);
gtk_css_style_property_register ("padding-top", gtk_css_style_property_register ("padding-top",
GTK_TYPE_CSS_NUMBER, GTK_TYPE_CSS_NUMBER,
@ -1044,6 +1061,7 @@ _gtk_css_style_property_init_properties (void)
parse_padding, parse_padding,
NULL, NULL,
compute_padding, compute_padding,
NULL,
&number); &number);
gtk_css_style_property_register ("padding-left", gtk_css_style_property_register ("padding-left",
GTK_TYPE_CSS_NUMBER, GTK_TYPE_CSS_NUMBER,
@ -1053,6 +1071,7 @@ _gtk_css_style_property_init_properties (void)
parse_padding, parse_padding,
NULL, NULL,
compute_padding, compute_padding,
NULL,
&number); &number);
gtk_css_style_property_register ("padding-bottom", gtk_css_style_property_register ("padding-bottom",
GTK_TYPE_CSS_NUMBER, GTK_TYPE_CSS_NUMBER,
@ -1062,6 +1081,7 @@ _gtk_css_style_property_init_properties (void)
parse_padding, parse_padding,
NULL, NULL,
compute_padding, compute_padding,
NULL,
&number); &number);
gtk_css_style_property_register ("padding-right", gtk_css_style_property_register ("padding-right",
GTK_TYPE_CSS_NUMBER, GTK_TYPE_CSS_NUMBER,
@ -1071,6 +1091,7 @@ _gtk_css_style_property_init_properties (void)
parse_padding, parse_padding,
NULL, NULL,
compute_padding, compute_padding,
NULL,
&number); &number);
/* IMPORTANT: compute_border_width() requires that the border-width /* IMPORTANT: compute_border_width() requires that the border-width
* properties be immeditaly followed by the border-style properties * properties be immeditaly followed by the border-style properties
@ -1083,6 +1104,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
GTK_BORDER_STYLE_NONE); GTK_BORDER_STYLE_NONE);
gtk_css_style_property_register ("border-top-width", gtk_css_style_property_register ("border-top-width",
GTK_TYPE_CSS_NUMBER, GTK_TYPE_CSS_NUMBER,
@ -1092,6 +1114,7 @@ _gtk_css_style_property_init_properties (void)
parse_border_width, parse_border_width,
NULL, NULL,
compute_border_width, compute_border_width,
NULL,
&number); &number);
gtk_css_style_property_register ("border-left-style", gtk_css_style_property_register ("border-left-style",
GTK_TYPE_BORDER_STYLE, GTK_TYPE_BORDER_STYLE,
@ -1101,6 +1124,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
GTK_BORDER_STYLE_NONE); GTK_BORDER_STYLE_NONE);
gtk_css_style_property_register ("border-left-width", gtk_css_style_property_register ("border-left-width",
GTK_TYPE_CSS_NUMBER, GTK_TYPE_CSS_NUMBER,
@ -1110,6 +1134,7 @@ _gtk_css_style_property_init_properties (void)
parse_border_width, parse_border_width,
NULL, NULL,
compute_border_width, compute_border_width,
NULL,
&number); &number);
gtk_css_style_property_register ("border-bottom-style", gtk_css_style_property_register ("border-bottom-style",
GTK_TYPE_BORDER_STYLE, GTK_TYPE_BORDER_STYLE,
@ -1119,6 +1144,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
GTK_BORDER_STYLE_NONE); GTK_BORDER_STYLE_NONE);
gtk_css_style_property_register ("border-bottom-width", gtk_css_style_property_register ("border-bottom-width",
GTK_TYPE_CSS_NUMBER, GTK_TYPE_CSS_NUMBER,
@ -1128,6 +1154,7 @@ _gtk_css_style_property_init_properties (void)
parse_border_width, parse_border_width,
NULL, NULL,
compute_border_width, compute_border_width,
NULL,
&number); &number);
gtk_css_style_property_register ("border-right-style", gtk_css_style_property_register ("border-right-style",
GTK_TYPE_BORDER_STYLE, GTK_TYPE_BORDER_STYLE,
@ -1137,6 +1164,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
GTK_BORDER_STYLE_NONE); GTK_BORDER_STYLE_NONE);
gtk_css_style_property_register ("border-right-width", gtk_css_style_property_register ("border-right-width",
GTK_TYPE_CSS_NUMBER, GTK_TYPE_CSS_NUMBER,
@ -1146,6 +1174,7 @@ _gtk_css_style_property_init_properties (void)
parse_border_width, parse_border_width,
NULL, NULL,
compute_border_width, compute_border_width,
NULL,
&number); &number);
gtk_css_style_property_register ("border-top-left-radius", gtk_css_style_property_register ("border-top-left-radius",
@ -1156,6 +1185,7 @@ _gtk_css_style_property_init_properties (void)
border_corner_radius_value_parse, border_corner_radius_value_parse,
border_corner_radius_value_print, border_corner_radius_value_print,
NULL, NULL,
NULL,
&no_corner_radius); &no_corner_radius);
gtk_css_style_property_register ("border-top-right-radius", gtk_css_style_property_register ("border-top-right-radius",
GTK_TYPE_CSS_BORDER_CORNER_RADIUS, GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
@ -1165,6 +1195,7 @@ _gtk_css_style_property_init_properties (void)
border_corner_radius_value_parse, border_corner_radius_value_parse,
border_corner_radius_value_print, border_corner_radius_value_print,
NULL, NULL,
NULL,
&no_corner_radius); &no_corner_radius);
gtk_css_style_property_register ("border-bottom-right-radius", gtk_css_style_property_register ("border-bottom-right-radius",
GTK_TYPE_CSS_BORDER_CORNER_RADIUS, GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
@ -1174,6 +1205,7 @@ _gtk_css_style_property_init_properties (void)
border_corner_radius_value_parse, border_corner_radius_value_parse,
border_corner_radius_value_print, border_corner_radius_value_print,
NULL, NULL,
NULL,
&no_corner_radius); &no_corner_radius);
gtk_css_style_property_register ("border-bottom-left-radius", gtk_css_style_property_register ("border-bottom-left-radius",
GTK_TYPE_CSS_BORDER_CORNER_RADIUS, GTK_TYPE_CSS_BORDER_CORNER_RADIUS,
@ -1183,6 +1215,7 @@ _gtk_css_style_property_init_properties (void)
border_corner_radius_value_parse, border_corner_radius_value_parse,
border_corner_radius_value_print, border_corner_radius_value_print,
NULL, NULL,
NULL,
&no_corner_radius); &no_corner_radius);
gtk_css_style_property_register ("outline-style", gtk_css_style_property_register ("outline-style",
@ -1193,6 +1226,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
GTK_BORDER_STYLE_NONE); GTK_BORDER_STYLE_NONE);
gtk_css_style_property_register ("outline-width", gtk_css_style_property_register ("outline-width",
GTK_TYPE_CSS_NUMBER, GTK_TYPE_CSS_NUMBER,
@ -1202,6 +1236,7 @@ _gtk_css_style_property_init_properties (void)
parse_border_width, parse_border_width,
NULL, NULL,
compute_border_width, compute_border_width,
NULL,
&number); &number);
gtk_css_style_property_register ("outline-offset", gtk_css_style_property_register ("outline-offset",
G_TYPE_INT, G_TYPE_INT,
@ -1211,6 +1246,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
0); 0);
gtk_css_style_property_register ("background-clip", gtk_css_style_property_register ("background-clip",
@ -1221,6 +1257,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
GTK_CSS_AREA_BORDER_BOX); GTK_CSS_AREA_BORDER_BOX);
gtk_css_style_property_register ("background-origin", gtk_css_style_property_register ("background-origin",
GTK_TYPE_CSS_AREA, GTK_TYPE_CSS_AREA,
@ -1230,6 +1267,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
GTK_CSS_AREA_PADDING_BOX); GTK_CSS_AREA_PADDING_BOX);
gtk_css_style_property_register ("background-size", gtk_css_style_property_register ("background-size",
GTK_TYPE_CSS_BACKGROUND_SIZE, GTK_TYPE_CSS_BACKGROUND_SIZE,
@ -1239,6 +1277,7 @@ _gtk_css_style_property_init_properties (void)
background_size_parse, background_size_parse,
background_size_print, background_size_print,
background_size_compute, background_size_compute,
NULL,
&default_background_size); &default_background_size);
gtk_css_style_property_register ("background-position", gtk_css_style_property_register ("background-position",
GTK_TYPE_CSS_BACKGROUND_POSITION, GTK_TYPE_CSS_BACKGROUND_POSITION,
@ -1248,6 +1287,7 @@ _gtk_css_style_property_init_properties (void)
background_position_parse, background_position_parse,
background_position_print, background_position_print,
background_position_compute, background_position_compute,
NULL,
&default_background_position); &default_background_position);
gtk_css_style_property_register ("border-top-color", gtk_css_style_property_register ("border-top-color",
@ -1258,6 +1298,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
color_compute, color_compute,
NULL,
_gtk_symbolic_color_get_current_color ()); _gtk_symbolic_color_get_current_color ());
gtk_css_style_property_register ("border-right-color", gtk_css_style_property_register ("border-right-color",
GTK_TYPE_SYMBOLIC_COLOR, GTK_TYPE_SYMBOLIC_COLOR,
@ -1267,6 +1308,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
color_compute, color_compute,
NULL,
_gtk_symbolic_color_get_current_color ()); _gtk_symbolic_color_get_current_color ());
gtk_css_style_property_register ("border-bottom-color", gtk_css_style_property_register ("border-bottom-color",
GTK_TYPE_SYMBOLIC_COLOR, GTK_TYPE_SYMBOLIC_COLOR,
@ -1276,6 +1318,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
color_compute, color_compute,
NULL,
_gtk_symbolic_color_get_current_color ()); _gtk_symbolic_color_get_current_color ());
gtk_css_style_property_register ("border-left-color", gtk_css_style_property_register ("border-left-color",
GTK_TYPE_SYMBOLIC_COLOR, GTK_TYPE_SYMBOLIC_COLOR,
@ -1285,6 +1328,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
color_compute, color_compute,
NULL,
_gtk_symbolic_color_get_current_color ()); _gtk_symbolic_color_get_current_color ());
gtk_css_style_property_register ("outline-color", gtk_css_style_property_register ("outline-color",
GTK_TYPE_SYMBOLIC_COLOR, GTK_TYPE_SYMBOLIC_COLOR,
@ -1294,6 +1338,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
color_compute, color_compute,
NULL,
_gtk_symbolic_color_get_current_color ()); _gtk_symbolic_color_get_current_color ());
gtk_css_style_property_register ("background-repeat", gtk_css_style_property_register ("background-repeat",
@ -1304,6 +1349,7 @@ _gtk_css_style_property_init_properties (void)
background_repeat_value_parse, background_repeat_value_parse,
background_repeat_value_print, background_repeat_value_print,
NULL, NULL,
NULL,
GTK_CSS_BACKGROUND_REPEAT | (GTK_CSS_BACKGROUND_REPEAT << GTK_CSS_BACKGROUND_REPEAT_SHIFT)); GTK_CSS_BACKGROUND_REPEAT | (GTK_CSS_BACKGROUND_REPEAT << GTK_CSS_BACKGROUND_REPEAT_SHIFT));
gtk_css_style_property_register ("background-image", gtk_css_style_property_register ("background-image",
GTK_TYPE_CSS_IMAGE, GTK_TYPE_CSS_IMAGE,
@ -1313,6 +1359,7 @@ _gtk_css_style_property_init_properties (void)
css_image_value_parse, css_image_value_parse,
css_image_value_print, css_image_value_print,
css_image_value_compute, css_image_value_compute,
NULL,
NULL); NULL);
gtk_css_style_property_register ("border-image-source", gtk_css_style_property_register ("border-image-source",
@ -1323,6 +1370,7 @@ _gtk_css_style_property_init_properties (void)
css_image_value_parse, css_image_value_parse,
css_image_value_print, css_image_value_print,
css_image_value_compute, css_image_value_compute,
NULL,
NULL); NULL);
gtk_css_style_property_register ("border-image-repeat", gtk_css_style_property_register ("border-image-repeat",
GTK_TYPE_CSS_BORDER_IMAGE_REPEAT, GTK_TYPE_CSS_BORDER_IMAGE_REPEAT,
@ -1332,6 +1380,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
&border_image_repeat); &border_image_repeat);
/* XXX: The initial value is wrong, it should be 100% */ /* XXX: The initial value is wrong, it should be 100% */
@ -1343,6 +1392,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
&border_of_ones); &border_of_ones);
gtk_css_style_property_register ("border-image-width", gtk_css_style_property_register ("border-image-width",
GTK_TYPE_BORDER, GTK_TYPE_BORDER,
@ -1352,6 +1402,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
NULL); NULL);
gtk_css_style_property_register ("engine", gtk_css_style_property_register ("engine",
GTK_TYPE_THEMING_ENGINE, GTK_TYPE_THEMING_ENGINE,
@ -1361,6 +1412,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
gtk_theming_engine_load (NULL)); gtk_theming_engine_load (NULL));
gtk_css_style_property_register ("transition", gtk_css_style_property_register ("transition",
GTK_TYPE_ANIMATION_DESCRIPTION, GTK_TYPE_ANIMATION_DESCRIPTION,
@ -1370,6 +1422,7 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
NULL); NULL);
/* Private property holding the binding sets */ /* Private property holding the binding sets */
@ -1381,6 +1434,7 @@ _gtk_css_style_property_init_properties (void)
bindings_value_parse, bindings_value_parse,
bindings_value_print, bindings_value_print,
NULL, NULL,
NULL,
NULL); NULL);
} }