Set border-width to 0 in compute function

This reverts commit c276f53796 and
implements the same feature using the compute function.
A nice side effect is that gtk_style_property_get_border() and
gtk_style_property_get("border") to the same thing now.
This commit is contained in:
Benjamin Otte
2012-01-06 22:25:05 +01:00
parent e69f14cf2b
commit 2c5a8420b5
2 changed files with 63 additions and 51 deletions

View File

@ -103,7 +103,7 @@ _gtk_style_property_register (const char * name,
"name", name, "name", name,
"value-type", value_type, "value-type", value_type,
NULL); NULL);
if (parse_value) if (parse_value)
node->parse_value = parse_value; node->parse_value = parse_value;
if (print_value) if (print_value)
@ -432,6 +432,28 @@ css_image_value_compute (GtkCssStyleProperty *property,
g_value_take_object (computed, image); g_value_take_object (computed, image);
} }
static void
compute_border_width (GtkCssStyleProperty *property,
GValue *computed,
GtkStyleContext *context,
const GValue *specified)
{
GtkCssStyleProperty *style;
GtkBorderStyle border_style;
/* The -1 is magic that is only true because we register the style
* properties directly after the width properties.
*/
style = _gtk_css_style_property_lookup_by_id (_gtk_css_style_property_get_id (property) - 1);
border_style = g_value_get_enum (_gtk_style_context_peek_property (context, _gtk_style_property_get_name (GTK_STYLE_PROPERTY (style))));
g_value_init (computed, G_TYPE_INT);
if (border_style == GTK_BORDER_STYLE_NONE)
g_value_set_int (computed, 0);
else
g_value_copy (specified, computed);
}
static gboolean static gboolean
background_repeat_value_parse (GtkCssStyleProperty *property, background_repeat_value_parse (GtkCssStyleProperty *property,
GValue *value, GValue *value,
@ -657,33 +679,64 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
NULL, NULL,
0); 0);
/* IMPORTANT: compute_border_width() requires that the border-width
* properties be immeditaly followed by the border-style properties
*/
gtk_style_property_register ("border-top-style",
GTK_TYPE_BORDER_STYLE,
0,
NULL,
NULL,
NULL,
GTK_BORDER_STYLE_NONE);
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, compute_border_width,
0); 0);
gtk_style_property_register ("border-left-style",
GTK_TYPE_BORDER_STYLE,
0,
NULL,
NULL,
NULL,
GTK_BORDER_STYLE_NONE);
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, compute_border_width,
0); 0);
gtk_style_property_register ("border-bottom-style",
GTK_TYPE_BORDER_STYLE,
0,
NULL,
NULL,
NULL,
GTK_BORDER_STYLE_NONE);
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, compute_border_width,
0); 0);
gtk_style_property_register ("border-right-style",
GTK_TYPE_BORDER_STYLE,
0,
NULL,
NULL,
NULL,
GTK_BORDER_STYLE_NONE);
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, compute_border_width,
0); 0);
gtk_style_property_register ("border-top-left-radius", gtk_style_property_register ("border-top-left-radius",
@ -715,35 +768,6 @@ _gtk_css_style_property_init_properties (void)
NULL, NULL,
&no_corner_radius); &no_corner_radius);
gtk_style_property_register ("border-top-style",
GTK_TYPE_BORDER_STYLE,
0,
NULL,
NULL,
NULL,
GTK_BORDER_STYLE_NONE);
gtk_style_property_register ("border-left-style",
GTK_TYPE_BORDER_STYLE,
0,
NULL,
NULL,
NULL,
GTK_BORDER_STYLE_NONE);
gtk_style_property_register ("border-bottom-style",
GTK_TYPE_BORDER_STYLE,
0,
NULL,
NULL,
NULL,
GTK_BORDER_STYLE_NONE);
gtk_style_property_register ("border-right-style",
GTK_TYPE_BORDER_STYLE,
0,
NULL,
NULL,
NULL,
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,

View File

@ -3533,7 +3533,6 @@ gtk_style_context_get_border (GtkStyleContext *context,
GtkStyleContextPrivate *priv; GtkStyleContextPrivate *priv;
StyleData *data; StyleData *data;
int top, left, bottom, right; int top, left, bottom, right;
GtkBorderStyle border_style;
g_return_if_fail (border != NULL); g_return_if_fail (border != NULL);
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
@ -3544,27 +3543,16 @@ gtk_style_context_get_border (GtkStyleContext *context,
data = style_data_lookup (context, state); data = style_data_lookup (context, state);
gtk_style_properties_get (data->store, gtk_style_properties_get (data->store,
0, 0,
"border-style", &border_style,
"border-top-width", &top,
"border-top-width", &top, "border-top-width", &top,
"border-left-width", &left, "border-left-width", &left,
"border-bottom-width", &bottom, "border-bottom-width", &bottom,
"border-right-width", &right, "border-right-width", &right,
NULL); NULL);
if (border_style == GTK_BORDER_STYLE_NONE)
{ border->top = top;
border->top = 0; border->left = left;
border->left = 0; border->bottom = bottom;
border->bottom = 0; border->right = right;
border->right = 0;
}
else
{
border->top = top;
border->left = left;
border->bottom = bottom;
border->right = right;
}
} }
/** /**