stylecontext: Convert _gtk_style_context_peek_property()

Take the property id instead of the name.
This commit is contained in:
Benjamin Otte 2012-03-31 05:42:28 +02:00
parent 5d8789680e
commit 31565139ba
12 changed files with 38 additions and 44 deletions

View File

@ -40,12 +40,12 @@ _gtk_border_image_init (GtkBorderImage *image,
{
GtkBorder *width;
image->source = _gtk_css_image_value_get_image (_gtk_theming_engine_peek_property (engine, "border-image-source"));
image->source = _gtk_css_image_value_get_image (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE));
if (image->source == NULL)
return FALSE;
image->slice = *(GtkBorder *) _gtk_css_value_get_boxed (_gtk_theming_engine_peek_property (engine, "border-image-slice"));
width = _gtk_css_value_get_boxed (_gtk_theming_engine_peek_property (engine, "border-image-width"));
image->slice = *(GtkBorder *) _gtk_css_value_get_boxed (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE));
width = _gtk_css_value_get_boxed (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH));
if (width)
{
image->width = *width;
@ -54,7 +54,7 @@ _gtk_border_image_init (GtkBorderImage *image,
else
image->has_width = FALSE;
image->repeat = *_gtk_css_value_get_border_image_repeat (_gtk_theming_engine_peek_property (engine, "border-image-repeat"));
image->repeat = *_gtk_css_value_get_border_image_repeat (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT));
return TRUE;
}

View File

@ -157,8 +157,7 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
{
GtkCssValue *parent_value;
/* Set NULL here and do the inheritance upon lookup? */
parent_value = _gtk_style_context_peek_property (parent,
_gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop)));
parent_value = _gtk_style_context_peek_property (parent, id);
g_ptr_array_index (values->values, id) = _gtk_css_value_ref (parent_value);
}

View File

@ -189,13 +189,13 @@ _gtk_css_number_value_compute (GtkCssValue *number,
break;
case GTK_CSS_EM:
return _gtk_css_number_value_new (number->value *
_gtk_css_number_value_get (_gtk_style_context_peek_property (context, "font-size"), 100),
_gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_FONT_SIZE), 100),
GTK_CSS_PX);
break;
case GTK_CSS_EX:
/* for now we pretend ex is half of em */
return _gtk_css_number_value_new (number->value * 0.5 *
_gtk_css_number_value_get (_gtk_style_context_peek_property (context, "font-size"), 100),
_gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_FONT_SIZE), 100),
GTK_CSS_PX);
case GTK_CSS_RAD:
return _gtk_css_number_value_new (number->value * 360.0 / (2 * G_PI),

View File

@ -117,13 +117,13 @@ _gtk_css_rgba_value_compute_from_symbolic (GtkCssValue *rgba,
GtkStyleContext *parent = gtk_style_context_get_parent (context);
if (parent)
return _gtk_css_value_ref (_gtk_style_context_peek_property (parent, "color"));
return _gtk_css_value_ref (_gtk_style_context_peek_property (parent, GTK_CSS_PROPERTY_COLOR));
else
return _gtk_css_rgba_value_compute_from_symbolic (fallback, NULL, context, TRUE);
}
else
{
return _gtk_css_value_ref (_gtk_style_context_peek_property (context, "color"));
return _gtk_css_value_ref (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR));
}
}

View File

@ -224,7 +224,7 @@ rgba_value_compute (GtkStyleContext *context,
GdkRGBA rgba;
if (symbolic == _gtk_symbolic_color_get_current_color ())
rgba = *_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, "color"));
rgba = *_gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR));
else if (!gtk_symbolic_color_resolve (symbolic, NULL, &rgba))
rgba = white;

View File

@ -834,15 +834,12 @@ compute_border_width (GtkCssStyleProperty *property,
GtkStyleContext *context,
GtkCssValue *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 = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, _gtk_style_property_get_name (GTK_STYLE_PROPERTY (style))));
border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, _gtk_css_style_property_get_id (property) - 1));
if (border_style == GTK_BORDER_STYLE_NONE ||
border_style == GTK_BORDER_STYLE_HIDDEN)

View File

@ -158,12 +158,12 @@ _gtk_css_number_compute (GtkCssNumber *dest,
dest->unit = GTK_CSS_PX;
break;
case GTK_CSS_EM:
dest->value = src->value * _gtk_css_number_value_get (_gtk_style_context_peek_property (context, "font-size"), 100);
dest->value = src->value * _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_FONT_SIZE), 100);
dest->unit = GTK_CSS_PX;
break;
case GTK_CSS_EX:
/* for now we pretend ex is half of em */
dest->value = src->value * _gtk_css_number_value_get (_gtk_style_context_peek_property (context, "font-size"), 100);
dest->value = src->value * _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_FONT_SIZE), 100);
dest->unit = GTK_CSS_PX;
break;
case GTK_CSS_RAD:

View File

@ -2241,21 +2241,21 @@ style_property_values_cmp (gconstpointer bsearch_node1,
GtkCssValue *
_gtk_style_context_peek_property (GtkStyleContext *context,
const char *property_name)
guint property_id)
{
StyleData *data = style_data_lookup (context);
return _gtk_css_computed_values_get_value_by_name (data->store, property_name);
return _gtk_css_computed_values_get_value (data->store, property_id);
}
double
_gtk_style_context_get_number (GtkStyleContext *context,
const char *property_name,
guint property_id,
double one_hundred_percent)
{
GtkCssValue *value;
value = _gtk_style_context_peek_property (context, property_name);
value = _gtk_style_context_peek_property (context, property_id);
return _gtk_css_number_value_get (value, one_hundred_percent);
}

View File

@ -27,9 +27,9 @@ G_BEGIN_DECLS
void _gtk_style_context_set_widget (GtkStyleContext *context,
GtkWidget *widget);
GtkCssValue * _gtk_style_context_peek_property (GtkStyleContext *context,
const char *property_name);
guint property_id);
double _gtk_style_context_get_number (GtkStyleContext *context,
const char *property_name,
guint property_id,
double one_hundred_percent);
const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context,
GType widget_type,

View File

@ -55,7 +55,7 @@ _gtk_theming_background_apply_origin (GtkThemingBackground *bg)
GtkCssArea origin;
cairo_rectangle_t image_rect;
origin = _gtk_css_area_value_get (_gtk_style_context_peek_property (bg->context, "background-clip"));
origin = _gtk_css_area_value_get (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_CLIP));
/* The default size of the background image depends on the
background-origin value as this affects the top left
@ -90,7 +90,7 @@ _gtk_theming_background_apply_origin (GtkThemingBackground *bg)
static void
_gtk_theming_background_apply_clip (GtkThemingBackground *bg)
{
GtkCssArea clip = _gtk_css_area_value_get (_gtk_style_context_peek_property (bg->context, "background-clip"));
GtkCssArea clip = _gtk_css_area_value_get (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_CLIP));
if (clip == GTK_CSS_AREA_PADDING_BOX)
{
@ -163,8 +163,8 @@ _gtk_theming_background_paint (GtkThemingBackground *bg,
double image_width, image_height;
double width, height;
size = _gtk_css_value_get_background_size (_gtk_style_context_peek_property (bg->context, "background-size"));
pos = _gtk_css_value_get_background_position (_gtk_style_context_peek_property (bg->context, "background-position"));
size = _gtk_css_value_get_background_size (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_SIZE));
pos = _gtk_css_value_get_background_position (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_POSITION));
gtk_style_context_get (bg->context, bg->flags,
"background-repeat", &hrepeat,
NULL);
@ -298,7 +298,7 @@ static void
_gtk_theming_background_apply_shadow (GtkThemingBackground *bg,
cairo_t *cr)
{
_gtk_css_shadow_value_paint_box (_gtk_style_context_peek_property (bg->context, "box-shadow"),
_gtk_css_shadow_value_paint_box (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BOX_SHADOW),
cr,
&bg->padding_box);
}
@ -332,7 +332,7 @@ _gtk_theming_background_init_context (GtkThemingBackground *bg)
_gtk_theming_background_apply_clip (bg);
_gtk_theming_background_apply_origin (bg);
bg->image = _gtk_css_image_value_get_image (_gtk_style_context_peek_property (bg->context, "background-image"));
bg->image = _gtk_css_image_value_get_image (_gtk_style_context_peek_property (bg->context, GTK_CSS_PROPERTY_BACKGROUND_IMAGE));
}
void

View File

@ -342,23 +342,21 @@ _gtk_theming_engine_get_context (GtkThemingEngine *engine)
GtkCssValue *
_gtk_theming_engine_peek_property (GtkThemingEngine *engine,
const char *property_name)
guint property_id)
{
g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
return _gtk_style_context_peek_property (engine->priv->context, property_name);
return _gtk_style_context_peek_property (engine->priv->context, property_id);
}
double
_gtk_theming_engine_get_number (GtkThemingEngine *engine,
const char *property_name,
guint property_id,
double one_hundred_percent)
{
g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0.0);
g_return_val_if_fail (property_name != NULL, 0.0);
return _gtk_style_context_get_number (engine->priv->context, property_name, one_hundred_percent);
return _gtk_style_context_get_number (engine->priv->context, property_id, one_hundred_percent);
}
/**
@ -1822,17 +1820,17 @@ render_frame_internal (GtkThemingEngine *engine,
render_border (cr, &border_box, &border, hidden_side, colors, border_style);
}
border_style[0] = _gtk_css_border_style_value_get (_gtk_theming_engine_peek_property (engine, "outline-style"));
border_style[0] = _gtk_css_border_style_value_get (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_OUTLINE_STYLE));
if (border_style[0] != GTK_BORDER_STYLE_NONE)
{
int offset;
border_style[1] = border_style[2] = border_style[3] = border_style[0];
border.top = _gtk_css_value_get_int (_gtk_theming_engine_peek_property (engine, "outline-width"));
border.top = _gtk_css_value_get_int (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_OUTLINE_WIDTH));
border.left = border.right = border.bottom = border.top;
colors[0] = *_gtk_css_rgba_value_get_rgba (_gtk_theming_engine_peek_property (engine, "outline-color"));
colors[0] = *_gtk_css_rgba_value_get_rgba (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_OUTLINE_COLOR));
colors[3] = colors[2] = colors[1] = colors[0];
offset = _gtk_css_value_get_int (_gtk_theming_engine_peek_property (engine, "outline-offset"));
offset = _gtk_css_value_get_int (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_OUTLINE_OFFSET));
/* reinit box here - outlines don't have a border radius */
_gtk_rounded_box_init_rect (&border_box, x, y, width, height);
@ -2134,7 +2132,7 @@ gtk_theming_engine_render_layout (GtkThemingEngine *engine,
fg_color.alpha = CLAMP (fg_color.alpha + ((other_fg.alpha - fg_color.alpha) * progress), 0, 1);
}
text_shadow = _gtk_theming_engine_peek_property (engine, "text-shadow");
text_shadow = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_TEXT_SHADOW);
prepare_context_for_layout (cr, x, y, layout);
@ -2765,7 +2763,7 @@ render_spinner (GtkThemingEngine *engine,
radius = MIN (width / 2, height / 2);
gtk_theming_engine_get_color (engine, state, &color);
shadow = _gtk_theming_engine_peek_property (engine, "icon-shadow");
shadow = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_SHADOW);
cairo_save (cr);
cairo_translate (cr, x + width / 2, y + height / 2);
@ -2943,7 +2941,7 @@ gtk_theming_engine_render_icon (GtkThemingEngine *engine,
gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
_gtk_css_shadow_value_paint_icon (_gtk_theming_engine_peek_property (engine, "icon-shadow"), cr);
_gtk_css_shadow_value_paint_icon (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_SHADOW), cr);
cairo_paint (cr);

View File

@ -28,9 +28,9 @@ void _gtk_theming_engine_paint_spinner (cairo_t *cr,
GdkRGBA *color);
GtkCssValue *_gtk_theming_engine_peek_property (GtkThemingEngine *engine,
const char *property_name);
guint property_id);
double _gtk_theming_engine_get_number (GtkThemingEngine *engine,
const char *property_name,
guint property_id,
double one_hundred_percent);
void _gtk_theming_engine_set_context (GtkThemingEngine *engine,
GtkStyleContext *context);