[gtk+/wip/matthiasc/caret: 6/8] text view: Respect caret-animation CSS property



commit 465a844bad8eeb4699ef2193bcbc5a2dfefce845
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jan 10 22:50:21 2016 -0500

    text view: Respect caret-animation CSS property
    
    When deciding whether to blink the caret in an entry, consult
    the caret-animation property.

 gtk/gtktextview.c |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index c5c45fe..8fb99e4 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -57,6 +57,7 @@
 #include "gtktoolbar.h"
 #include "gtkpixelcacheprivate.h"
 #include "gtkmagnifierprivate.h"
+#include "gtkcssenumvalueprivate.h"
 
 #include "a11y/gtktextviewaccessibleprivate.h"
 
@@ -6094,8 +6095,10 @@ gtk_text_view_forall (GtkContainer *container,
 static gboolean
 cursor_blinks (GtkTextView *text_view)
 {
-  GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (text_view));
   gboolean blink;
+  GtkStyleContext *context;
+  GtkCssValue *value;
+  GtkCssCaretAnimation anim;
 
 #ifdef DEBUG_VALIDATION_AND_SCROLLING
   return FALSE;
@@ -6105,7 +6108,21 @@ cursor_blinks (GtkTextView *text_view)
     return FALSE;
 #endif
 
-  g_object_get (settings, "gtk-cursor-blink", &blink, NULL);
+  context = gtk_widget_get_style_context (GTK_WIDGET (text_view));
+  value = _gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_CARET_ANIMATION);
+  anim = _gtk_css_caret_animation_value_get (value);
+
+  if (anim == GTK_CSS_CARET_ANIMATION_AUTO)
+    {
+      GtkSettings *settings;
+
+      settings = gtk_widget_get_settings (GTK_WIDGET (text_view));
+      g_object_get (settings, "gtk-cursor-blink", &blink, NULL);
+    }
+  else if (anim == GTK_CSS_CARET_ANIMATION_BLINK)
+    blink = TRUE;
+  else
+    blink = FALSE;
 
   if (!blink)
     return FALSE;


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