[gtk+/wip/matthiasc/caret-color: 3/4] Use the caret-color properties for drawing carets
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/matthiasc/caret-color: 3/4] Use the caret-color properties for drawing carets
- Date: Thu, 7 Jan 2016 03:22:42 +0000 (UTC)
commit 0afc0c3a528b0d7d4714f2fb0d8ea6e531f45356
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 | 38 ++++++++++++++------------------------
1 files changed, 14 insertions(+), 24 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index dd242f1..429d6c6 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"
@@ -2759,25 +2760,11 @@ get_cursor_color (GtkStyleContext *context,
gboolean primary,
GdkRGBA *color)
{
- GdkColor *style_color;
+ GtkCssValue *value;
- gtk_style_context_get_style (context,
- primary ? "cursor-color" : "secondary-cursor-color",
- &style_color,
- NULL);
+ value = _gtk_style_context_peek_property (context, primary ? GTK_CSS_PROPERTY_CARET_COLOR :
GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR);
- 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
+ if (_gtk_css_color_value_is_auto (value))
{
GtkStateFlags state;
@@ -2786,18 +2773,21 @@ G_GNUC_END_IGNORE_DEPRECATIONS
gtk_style_context_get_color (context, state, color);
if (!primary)
- {
- GdkRGBA bg;
+ {
+ GdkRGBA bg;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- gtk_style_context_get_background_color (context, state, &bg);
+ 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;
- }
+ color->red = (color->red + bg.red) * 0.5;
+ color->green = (color->green + bg.green) * 0.5;
+ color->blue = (color->blue + bg.blue) * 0.5;
+ color->alpha = (color->alpha + bg.alpha) * 0.5;
+ }
}
+ else
+ *color = *_gtk_css_rgba_value_get_rgba (value);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]