[gtk+/wip/matthiasc/caret: 3/8] Add the caret-animation CSS property
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/matthiasc/caret: 3/8] Add the caret-animation CSS property
- Date: Mon, 11 Jan 2016 05:10:52 +0000 (UTC)
commit fe2b16afda990301d4f7964bf4f999c6722c207d
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jan 10 18:53:47 2016 -0500
Add the caret-animation CSS property
This allows to override the caret blinking from the theme.
The default value, auto, means to do things as we always have.
gtk/gtkcssenumvalue.c | 54 +++++++++++++++++++++++++++++++++++++++++
gtk/gtkcssenumvalueprivate.h | 4 +++
gtk/gtkcssstylepropertyimpl.c | 23 ++++++++++++++++-
gtk/gtkcsstypesprivate.h | 7 +++++
4 files changed, 87 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkcssenumvalue.c b/gtk/gtkcssenumvalue.c
index 67ffef0..f7773ae 100644
--- a/gtk/gtkcssenumvalue.c
+++ b/gtk/gtkcssenumvalue.c
@@ -1064,3 +1064,57 @@ _gtk_css_caret_shape_value_get (const GtkCssValue *value)
return value->value;
}
+
+/* GtkCssCaretAnimation */
+
+static const GtkCssValueClass GTK_CSS_VALUE_CARET_ANIMATION = {
+ 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 caret_animation_values[] = {
+ { >K_CSS_VALUE_CARET_ANIMATION, 1, GTK_CSS_CARET_ANIMATION_AUTO, "auto" },
+ { >K_CSS_VALUE_CARET_ANIMATION, 1, GTK_CSS_CARET_ANIMATION_BLINK, "blink" },
+ { >K_CSS_VALUE_CARET_ANIMATION, 1, GTK_CSS_CARET_ANIMATION_NONE, "none" },
+};
+
+GtkCssValue *
+_gtk_css_caret_animation_value_new (GtkCssCaretAnimation caret_animation)
+{
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (caret_animation_values); i++)
+ {
+ if (caret_animation_values[i].value == caret_animation)
+ return _gtk_css_value_ref (&caret_animation_values[i]);
+ }
+
+ g_return_val_if_reached (NULL);
+}
+
+GtkCssValue *
+_gtk_css_caret_animation_value_try_parse (GtkCssParser *parser)
+{
+ guint i;
+
+ g_return_val_if_fail (parser != NULL, NULL);
+
+ for (i = 0; i < G_N_ELEMENTS (caret_animation_values); i++)
+ {
+ if (_gtk_css_parser_try (parser, caret_animation_values[i].name, TRUE))
+ return _gtk_css_value_ref (&caret_animation_values[i]);
+ }
+
+ return NULL;
+}
+
+GtkCssCaretAnimation
+_gtk_css_caret_animation_value_get (const GtkCssValue *value)
+{
+ g_return_val_if_fail (value->class == >K_CSS_VALUE_CARET_ANIMATION, GTK_CSS_CARET_ANIMATION_AUTO);
+
+ return value->value;
+}
diff --git a/gtk/gtkcssenumvalueprivate.h b/gtk/gtkcssenumvalueprivate.h
index 4d774c9..31d680e 100644
--- a/gtk/gtkcssenumvalueprivate.h
+++ b/gtk/gtkcssenumvalueprivate.h
@@ -90,6 +90,10 @@ GtkCssValue * _gtk_css_caret_shape_value_new (GtkCssCaretShape caret_
GtkCssValue * _gtk_css_caret_shape_value_try_parse (GtkCssParser *parser);
GtkCssCaretShape _gtk_css_caret_shape_value_get (const GtkCssValue *value);
+GtkCssValue * _gtk_css_caret_animation_value_new (GtkCssCaretAnimation caret_animation);
+GtkCssValue * _gtk_css_caret_animation_value_try_parse (GtkCssParser *parser);
+GtkCssCaretAnimation _gtk_css_caret_animation_value_get (const GtkCssValue *value);
+
G_END_DECLS
#endif /* __GTK_CSS_ENUM_VALUE_PRIVATE_H__ */
diff --git a/gtk/gtkcssstylepropertyimpl.c b/gtk/gtkcssstylepropertyimpl.c
index 7048dd2..4e5548d 100644
--- a/gtk/gtkcssstylepropertyimpl.c
+++ b/gtk/gtkcssstylepropertyimpl.c
@@ -1009,7 +1009,7 @@ icon_theme_value_parse (GtkCssStyleProperty *property,
static GtkCssValue *
caret_shape_parse (GtkCssStyleProperty *property,
- GtkCssParser *parser)
+ GtkCssParser *parser)
{
GtkCssValue *value = _gtk_css_caret_shape_value_try_parse (parser);
@@ -1019,6 +1019,18 @@ caret_shape_parse (GtkCssStyleProperty *property,
return value;
}
+static GtkCssValue *
+caret_animation_parse (GtkCssStyleProperty *property,
+ GtkCssParser *parser)
+{
+ GtkCssValue *value = _gtk_css_caret_animation_value_try_parse (parser);
+
+ if (value == NULL)
+ _gtk_css_parser_error (parser, "unknown value for property");
+
+ return value;
+}
+
/*** REGISTRATION ***/
void
@@ -1841,4 +1853,13 @@ G_GNUC_END_IGNORE_DEPRECATIONS
NULL,
NULL,
_gtk_css_caret_shape_value_new (GTK_CSS_CARET_SHAPE_AUTO));
+ gtk_css_style_property_register ("caret-animation",
+ GTK_CSS_PROPERTY_CARET_ANIMATION,
+ G_TYPE_NONE,
+ GTK_STYLE_PROPERTY_INHERIT,
+ GTK_CSS_AFFECTS_TEXT,
+ caret_animation_parse,
+ NULL,
+ NULL,
+ _gtk_css_caret_animation_value_new (GTK_CSS_CARET_ANIMATION_AUTO));
}
diff --git a/gtk/gtkcsstypesprivate.h b/gtk/gtkcsstypesprivate.h
index 597c293..03b7b98 100644
--- a/gtk/gtkcsstypesprivate.h
+++ b/gtk/gtkcsstypesprivate.h
@@ -225,6 +225,7 @@ enum { /*< skip >*/
GTK_CSS_PROPERTY_CARET_COLOR,
GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR,
GTK_CSS_PROPERTY_CARET_SHAPE,
+ GTK_CSS_PROPERTY_CARET_ANIMATION,
/* add more */
GTK_CSS_PROPERTY_N_PROPERTIES
};
@@ -371,6 +372,12 @@ typedef enum /*< skip >*/ {
GTK_CSS_CARET_SHAPE_UNDERSCORE
} GtkCssCaretShape;
+typedef enum /*< skip >*/ {
+ GTK_CSS_CARET_ANIMATION_AUTO,
+ GTK_CSS_CARET_ANIMATION_BLINK,
+ GTK_CSS_CARET_ANIMATION_NONE
+} GtkCssCaretAnimation;
+
GtkCssChange _gtk_css_change_for_sibling (GtkCssChange match);
GtkCssChange _gtk_css_change_for_child (GtkCssChange match);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]