css: Remove -gtk-icon-effect

-gtk-icon-filter replaces this now.
This commit is contained in:
Benjamin Otte 2016-12-31 02:36:00 +01:00
parent 5b33127692
commit 45fbc25e5e
5 changed files with 2 additions and 132 deletions

View File

@ -930,93 +930,6 @@ _gtk_css_fill_mode_value_get (const GtkCssValue *value)
return value->value; return value->value;
} }
/* GtkCssIconEffect */
static const GtkCssValueClass GTK_CSS_VALUE_ICON_EFFECT = {
gtk_css_value_enum_free,
gtk_css_value_enum_compute,
gtk_css_value_enum_equal,
gtk_css_value_enum_transition,
gtk_css_value_enum_print
};
static GtkCssValue image_effect_values[] = {
{ &GTK_CSS_VALUE_ICON_EFFECT, 1, GTK_CSS_ICON_EFFECT_NONE, "none" },
{ &GTK_CSS_VALUE_ICON_EFFECT, 1, GTK_CSS_ICON_EFFECT_HIGHLIGHT, "highlight" },
{ &GTK_CSS_VALUE_ICON_EFFECT, 1, GTK_CSS_ICON_EFFECT_DIM, "dim" }
};
GtkCssValue *
_gtk_css_icon_effect_value_new (GtkCssIconEffect image_effect)
{
guint i;
for (i = 0; i < G_N_ELEMENTS (image_effect_values); i++)
{
if (image_effect_values[i].value == image_effect)
return _gtk_css_value_ref (&image_effect_values[i]);
}
g_return_val_if_reached (NULL);
}
GtkCssValue *
_gtk_css_icon_effect_value_try_parse (GtkCssParser *parser)
{
guint i;
g_return_val_if_fail (parser != NULL, NULL);
for (i = 0; i < G_N_ELEMENTS (image_effect_values); i++)
{
if (_gtk_css_parser_try (parser, image_effect_values[i].name, TRUE))
return _gtk_css_value_ref (&image_effect_values[i]);
}
return NULL;
}
GtkCssIconEffect
_gtk_css_icon_effect_value_get (const GtkCssValue *value)
{
g_return_val_if_fail (value->class == &GTK_CSS_VALUE_ICON_EFFECT, GTK_CSS_ICON_EFFECT_NONE);
return value->value;
}
void
gtk_css_icon_effect_apply (GtkCssIconEffect icon_effect,
cairo_surface_t *surface)
{
cairo_t *cr;
switch (icon_effect)
{
case GTK_CSS_ICON_EFFECT_DIM:
cr = cairo_create (surface);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_set_source_rgba (cr, 0, 0, 0, 0); /* transparent */
cairo_paint_with_alpha (cr, 0.5);
cairo_destroy (cr);
break;
case GTK_CSS_ICON_EFFECT_HIGHLIGHT:
cr = cairo_create (surface);
cairo_set_source_rgb (cr, 0.1, 0.1, 0.1);
cairo_set_operator (cr, CAIRO_OPERATOR_COLOR_DODGE);
/* DANGER: We mask with ourself - that works for images, but... */
cairo_mask_surface (cr, surface, 0, 0);
cairo_destroy (cr);
break;
default:
g_warn_if_reached ();
/* fall through */
case GTK_CSS_ICON_EFFECT_NONE:
break;
}
}
/* GtkCssIconStyle */ /* GtkCssIconStyle */
static const GtkCssValueClass GTK_CSS_VALUE_ICON_STYLE = { static const GtkCssValueClass GTK_CSS_VALUE_ICON_STYLE = {

View File

@ -81,12 +81,6 @@ GtkCssValue * _gtk_css_fill_mode_value_new (GtkCssFillMode fill_m
GtkCssValue * _gtk_css_fill_mode_value_try_parse (GtkCssParser *parser); GtkCssValue * _gtk_css_fill_mode_value_try_parse (GtkCssParser *parser);
GtkCssFillMode _gtk_css_fill_mode_value_get (const GtkCssValue *value); GtkCssFillMode _gtk_css_fill_mode_value_get (const GtkCssValue *value);
GtkCssValue * _gtk_css_icon_effect_value_new (GtkCssIconEffect image_effect);
GtkCssValue * _gtk_css_icon_effect_value_try_parse (GtkCssParser *parser);
GtkCssIconEffect _gtk_css_icon_effect_value_get (const GtkCssValue *value);
void gtk_css_icon_effect_apply (GtkCssIconEffect icon_effect,
cairo_surface_t *surface);
GtkCssValue * _gtk_css_icon_style_value_new (GtkCssIconStyle icon_style); GtkCssValue * _gtk_css_icon_style_value_new (GtkCssIconStyle icon_style);
GtkCssValue * _gtk_css_icon_style_value_try_parse (GtkCssParser *parser); GtkCssValue * _gtk_css_icon_style_value_try_parse (GtkCssParser *parser);
GtkCssIconStyle _gtk_css_icon_style_value_get (const GtkCssValue *value); GtkCssIconStyle _gtk_css_icon_style_value_get (const GtkCssValue *value);

View File

@ -411,18 +411,6 @@ parse_css_fill_mode (GtkCssStyleProperty *property,
return _gtk_css_array_value_parse (parser, parse_one_css_fill_mode); return _gtk_css_array_value_parse (parser, parse_one_css_fill_mode);
} }
static GtkCssValue *
image_effect_parse (GtkCssStyleProperty *property,
GtkCssParser *parser)
{
GtkCssValue *value = _gtk_css_icon_effect_value_try_parse (parser);
if (value == NULL)
_gtk_css_parser_error (parser, "unknown value for property");
return value;
}
static GtkCssValue * static GtkCssValue *
icon_palette_parse (GtkCssStyleProperty *property, icon_palette_parse (GtkCssStyleProperty *property,
GtkCssParser *parser) GtkCssParser *parser)
@ -1606,15 +1594,6 @@ _gtk_css_style_property_init_properties (void)
opacity_parse, opacity_parse,
opacity_query, opacity_query,
_gtk_css_number_value_new (1, GTK_CSS_NUMBER)); _gtk_css_number_value_new (1, GTK_CSS_NUMBER));
gtk_css_style_property_register ("-gtk-icon-effect",
GTK_CSS_PROPERTY_ICON_EFFECT,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT,
GTK_CSS_AFFECTS_ICON,
image_effect_parse,
NULL,
_gtk_css_icon_effect_value_new (GTK_CSS_ICON_EFFECT_NONE));
_gtk_style_property_add_alias ("-gtk-icon-effect", "-gtk-image-effect");
/* Private property holding the binding sets */ /* Private property holding the binding sets */
gtk_css_style_property_register ("-gtk-key-bindings", gtk_css_style_property_register ("-gtk-key-bindings",

View File

@ -225,7 +225,7 @@ enum { /*< skip >*/
GTK_CSS_PROPERTY_ANIMATION_DELAY, GTK_CSS_PROPERTY_ANIMATION_DELAY,
GTK_CSS_PROPERTY_ANIMATION_FILL_MODE, GTK_CSS_PROPERTY_ANIMATION_FILL_MODE,
GTK_CSS_PROPERTY_OPACITY, GTK_CSS_PROPERTY_OPACITY,
GTK_CSS_PROPERTY_ICON_EFFECT, GTK_CSS_PROPERTY_FILTER,
GTK_CSS_PROPERTY_GTK_KEY_BINDINGS, GTK_CSS_PROPERTY_GTK_KEY_BINDINGS,
GTK_CSS_PROPERTY_CARET_COLOR, GTK_CSS_PROPERTY_CARET_COLOR,
GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR, GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR,
@ -281,12 +281,6 @@ typedef enum /*< skip >*/ {
GTK_CSS_FILL_BOTH GTK_CSS_FILL_BOTH
} GtkCssFillMode; } GtkCssFillMode;
typedef enum /*< skip >*/ {
GTK_CSS_ICON_EFFECT_NONE,
GTK_CSS_ICON_EFFECT_HIGHLIGHT,
GTK_CSS_ICON_EFFECT_DIM
} GtkCssIconEffect;
typedef enum /*< skip >*/ { typedef enum /*< skip >*/ {
GTK_CSS_ICON_STYLE_REQUESTED, GTK_CSS_ICON_STYLE_REQUESTED,
GTK_CSS_ICON_STYLE_REGULAR, GTK_CSS_ICON_STYLE_REGULAR,

View File

@ -379,7 +379,6 @@ ensure_surface_from_pixbuf (GtkIconHelper *self,
gint width, height; gint width, height;
cairo_surface_t *surface; cairo_surface_t *surface;
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
GtkCssIconEffect icon_effect;
if (get_pixbuf_size (self, if (get_pixbuf_size (self,
scale, scale,
@ -393,8 +392,6 @@ ensure_surface_from_pixbuf (GtkIconHelper *self,
pixbuf = g_object_ref (orig_pixbuf); pixbuf = g_object_ref (orig_pixbuf);
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale, gtk_widget_get_window (gtk_css_gadget_get_owner (GTK_CSS_GADGET (self)))); surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale, gtk_widget_get_window (gtk_css_gadget_get_owner (GTK_CSS_GADGET (self))));
icon_effect = _gtk_css_icon_effect_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_EFFECT));
gtk_css_icon_effect_apply (icon_effect, surface);
g_object_unref (pixbuf); g_object_unref (pixbuf);
return surface; return surface;
@ -469,14 +466,7 @@ ensure_surface_for_gicon (GtkIconHelper *self,
surface = gdk_cairo_surface_create_from_pixbuf (destination, scale, gtk_widget_get_window (gtk_css_gadget_get_owner (GTK_CSS_GADGET (self)))); surface = gdk_cairo_surface_create_from_pixbuf (destination, scale, gtk_widget_get_window (gtk_css_gadget_get_owner (GTK_CSS_GADGET (self))));
if (!symbolic) if (symbolic)
{
GtkCssIconEffect icon_effect;
icon_effect = _gtk_css_icon_effect_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_EFFECT));
gtk_css_icon_effect_apply (icon_effect, surface);
}
else
{ {
priv->rendered_surface_is_symbolic = TRUE; priv->rendered_surface_is_symbolic = TRUE;
} }