[gtk+] Use the caret-color properties for drawing carets



commit 9b86d6da2cb26893223e64be29d2d016d18af77a
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Jan 6 22:07:09 2016 -0500

    Use the caret-color properties for drawing carets
    
    Replace the cursor-color and secondary-cursor-color style
    properties with the caret-color and -gtk-secondary-caret-color
    CSS properties.
    
    For the 'auto' value of these properties, we keep the same
    behavior that we used to have when the style properties are
    not explicitly set.

 gtk/gtkstylecontext.c |   61 ++++++++++--------------------------------------
 1 files changed, 13 insertions(+), 48 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index d108e0f..a6a6a3b 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -35,6 +35,7 @@
 #include "gtkcssnumbervalueprivate.h"
 #include "gtkcsspathnodeprivate.h"
 #include "gtkcssrgbavalueprivate.h"
+#include "gtkcsscolorvalueprivate.h"
 #include "gtkcssshadowsvalueprivate.h"
 #include "gtkcssstaticstyleprivate.h"
 #include "gtkcssstylepropertyprivate.h"
@@ -2755,62 +2756,26 @@ gtk_style_context_get_font (GtkStyleContext *context,
   return description;
 }
 
-static void
-get_cursor_color (GtkStyleContext *context,
-                  gboolean         primary,
-                  GdkRGBA         *color)
-{
-  GdkColor *style_color;
-
-  gtk_style_context_get_style (context,
-                               primary ? "cursor-color" : "secondary-cursor-color",
-                               &style_color,
-                               NULL);
-
-  if (style_color)
-    {
-      color->red = style_color->red / 65535.0;
-      color->green = style_color->green / 65535.0;
-      color->blue = style_color->blue / 65535.0;
-      color->alpha = 1;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-      gdk_color_free (style_color);
-G_GNUC_END_IGNORE_DEPRECATIONS
-    }
-  else
-    {
-      GtkStateFlags state;
-
-      state = gtk_style_context_get_state (context);
-
-      gtk_style_context_get_color (context, state, color);
-
-      if (!primary)
-      {
-        GdkRGBA bg;
-
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-        gtk_style_context_get_background_color (context, state, &bg);
-G_GNUC_END_IGNORE_DEPRECATIONS
-
-        color->red = (color->red + bg.red) * 0.5;
-        color->green = (color->green + bg.green) * 0.5;
-        color->blue = (color->blue + bg.blue) * 0.5;
-      }
-    }
-}
-
 void
 _gtk_style_context_get_cursor_color (GtkStyleContext *context,
                                      GdkRGBA         *primary_color,
                                      GdkRGBA         *secondary_color)
 {
+  GdkRGBA *pc, *sc;
+
+  gtk_style_context_get (context,
+                         gtk_style_context_get_state (context),
+                         "caret-color", &pc,
+                         "-gtk-secondary-caret-color", &sc,
+                         NULL);
   if (primary_color)
-    get_cursor_color (context, TRUE, primary_color);
+    *primary_color = *pc;
 
   if (secondary_color)
-    get_cursor_color (context, FALSE, secondary_color);
+    *secondary_color = *sc;
+
+  gdk_rgba_free (pc);
+  gdk_rgba_free (sc);
 }
 
 static void


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