diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2013-08-04 11:38:56 +0200 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2013-08-20 02:50:40 +0200 |
commit | 736b350d7a42d01520a8e73c403763765d7fc867 (patch) | |
tree | a4bf3506da9683517653439becf1a6fd5f4586ee /gtk/gtkcssenumvalue.c | |
parent | 723a589bddc635816556f1e2fddc5700f4cb9288 (diff) | |
download | gtk+-736b350d7a42d01520a8e73c403763765d7fc867.tar.gz |
css: Add a GtkCssValue for GtkCssImageEffect
This will allow us to use the CSS machinery to apply a highlight or dim
effect when images are prelit or insensitive.
https://bugzilla.gnome.org/show_bug.cgi?id=705443
Diffstat (limited to 'gtk/gtkcssenumvalue.c')
-rw-r--r-- | gtk/gtkcssenumvalue.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/gtk/gtkcssenumvalue.c b/gtk/gtkcssenumvalue.c index 547edb8ea0..8151d58de2 100644 --- a/gtk/gtkcssenumvalue.c +++ b/gtk/gtkcssenumvalue.c @@ -653,3 +653,56 @@ _gtk_css_fill_mode_value_get (const GtkCssValue *value) return value->value; } +/* GtkCssImageEffect */ + +static const GtkCssValueClass GTK_CSS_VALUE_IMAGE_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[] = { + { >K_CSS_VALUE_IMAGE_EFFECT, 1, GTK_CSS_IMAGE_EFFECT_NONE, "none" }, + { >K_CSS_VALUE_IMAGE_EFFECT, 1, GTK_CSS_IMAGE_EFFECT_HIGHLIGHT, "highlight" }, + { >K_CSS_VALUE_IMAGE_EFFECT, 1, GTK_CSS_IMAGE_EFFECT_DIM, "dim" } +}; + +GtkCssValue * +_gtk_css_image_effect_value_new (GtkCssImageEffect 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_image_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; +} + +GtkCssImageEffect +_gtk_css_image_effect_value_get (const GtkCssValue *value) +{ + g_return_val_if_fail (value->class == >K_CSS_VALUE_IMAGE_EFFECT, GTK_CSS_IMAGE_EFFECT_NONE); + + return value->value; +} |