themingengine: Draw "icon-shadow" on icons

This commit is contained in:
Benjamin Otte 2014-05-12 03:16:07 +02:00
parent 59b6dee480
commit ce0835e539
3 changed files with 21 additions and 0 deletions

View File

@ -241,6 +241,14 @@ _gtk_css_shadows_value_parse (GtkCssParser *parser)
return result;
}
gboolean
_gtk_css_shadows_value_is_none (const GtkCssValue *shadows)
{
g_return_val_if_fail (shadows->class == &GTK_CSS_VALUE_SHADOWS, TRUE);
return shadows->len == 0;
}
void
_gtk_css_shadows_value_paint_layout (const GtkCssValue *shadows,
cairo_t *cr,

View File

@ -33,6 +33,8 @@ G_BEGIN_DECLS
GtkCssValue * _gtk_css_shadows_value_new_none (void);
GtkCssValue * _gtk_css_shadows_value_parse (GtkCssParser *parser);
gboolean _gtk_css_shadows_value_is_none (const GtkCssValue *shadows);
void _gtk_css_shadows_value_paint_layout (const GtkCssValue *shadows,
cairo_t *cr,
PangoLayout *layout);

View File

@ -1031,12 +1031,15 @@ render_icon_image (GtkThemingEngine *engine,
double width,
double height)
{
const GtkCssValue *shadows;
GtkCssImage *image;
image = _gtk_css_image_value_get_image (_gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_SOURCE));
if (image == NULL)
return FALSE;
shadows = _gtk_theming_engine_peek_property (engine, GTK_CSS_PROPERTY_ICON_SHADOW);
cairo_translate (cr, x, y);
cairo_translate (cr, width / 2, height / 2);
@ -1044,6 +1047,14 @@ render_icon_image (GtkThemingEngine *engine,
{
cairo_translate (cr, -width / 2, -height / 2);
if (!_gtk_css_shadows_value_is_none (shadows))
{
cairo_push_group (cr);
_gtk_css_image_draw (image, cr, width, height);
cairo_pop_group_to_source (cr);
_gtk_css_shadows_value_paint_icon (shadows, cr);
}
_gtk_css_image_draw (image, cr, width, height);
}