[gtk+/wip/matthiasc/caret: 5/8] Implement the caret shorthand property



commit e76dafbc901af29ea45853426d73a17f9cd8bb1c
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jan 10 22:35:57 2016 -0500

    Implement the caret shorthand property
    
    Implement the caret shorthand property as defined in
    http://www.w3.org/TR/css-ui-4/
    
    This allows to set color-shape, caret-animation and caret-color
    at the same time. We always set -gtk-secondary-caret-color to
    the same color as caret-color.

 gtk/gtkcssshorthandpropertyimpl.c |   48 +++++++++++++++++++++++++++++++++++++
 1 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssshorthandpropertyimpl.c b/gtk/gtkcssshorthandpropertyimpl.c
index 4e5495f..26672e8 100644
--- a/gtk/gtkcssshorthandpropertyimpl.c
+++ b/gtk/gtkcssshorthandpropertyimpl.c
@@ -869,6 +869,47 @@ parse_text_decoration (GtkCssShorthandProperty  *shorthand,
 }
 
 static gboolean
+parse_caret (GtkCssShorthandProperty  *shorthand,
+             GtkCssValue             **values,
+             GtkCssParser             *parser)
+{
+  do
+  {
+    if (values[0] == NULL &&
+        (values[0] = _gtk_css_caret_shape_value_try_parse (parser)))
+      {
+        if (values[0] == NULL)
+          return FALSE;
+      }
+    else if (values[1] == NULL &&
+             (values[1] = _gtk_css_caret_animation_value_try_parse (parser)))
+      {
+        if (values[1] == NULL)
+          return FALSE;
+      }
+    else if (values[2] == NULL)
+      {
+        values[2] = _gtk_css_color_value_parse (parser);
+        if (values[2] == NULL)
+          return FALSE;
+
+        values[3] = _gtk_css_value_ref (values[2]);
+      }
+    else
+      {
+        /* We parsed and there's still stuff left?
+         * Pretend we didn't notice and let the normal code produce
+         * a 'junk at end of value' error
+         */
+        break;
+      }
+  }
+  while (!value_is_done_parsing (parser));
+
+  return TRUE;
+}
+
+static gboolean
 parse_all (GtkCssShorthandProperty  *shorthand,
            GtkCssValue             **values,
            GtkCssParser             *parser)
@@ -1216,6 +1257,7 @@ _gtk_css_shorthand_property_init_properties (void)
   const char *animation_subproperties[] = { "animation-name", "animation-iteration-count", 
"animation-duration", "animation-delay", 
                                             "animation-timing-function", "animation-direction", 
"animation-fill-mode", NULL };
   const char *text_decoration_subproperties[] = { "text-decoration-line", "text-decoration-style", 
"text-decoration-color", NULL };
+  const char *caret_subproperties[] = { "caret-shape", "caret-animation", "caret-color", 
"-gtk-secondary-caret-color", NULL };
 
   const char **all_subproperties;
 
@@ -1334,6 +1376,12 @@ _gtk_css_shorthand_property_init_properties (void)
                                           parse_text_decoration,
                                           NULL,
                                           NULL);
+  _gtk_css_shorthand_property_register   ("caret",
+                                          G_TYPE_NONE,
+                                          caret_subproperties,
+                                          parse_caret,
+                                          NULL,
+                                          NULL);
 
   all_subproperties = get_all_subproperties ();
   _gtk_css_shorthand_property_register   ("all",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]