summaryrefslogtreecommitdiff
path: root/eel
diff options
context:
space:
mode:
authorWolfgang Ulbrich <[email protected]>2016-01-08 20:16:20 +0100
committerWolfgang Ulbrich <[email protected]>2016-01-13 15:05:40 +0100
commit2848d0359a8bc433ba9de56ccc93a04d2f6bbdf2 (patch)
treed4f8a868b83e7cac26c2654402bf93fac1e75f41 /eel
parent3c5a4ef68906a73850fa2ffe403cfcd37dc31ff9 (diff)
downloadcaja-2848d0359a8bc433ba9de56ccc93a04d2f6bbdf2.tar.bz2
caja-2848d0359a8bc433ba9de56ccc93a04d2f6bbdf2.tar.xz
GTK3 eel-gdk-extensions: add eel_make_color_inactive() to public API
taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=42e7268
Diffstat (limited to 'eel')
-rw-r--r--eel/eel-gdk-extensions.c32
-rw-r--r--eel/eel-gdk-extensions.h3
2 files changed, 35 insertions, 0 deletions
diff --git a/eel/eel-gdk-extensions.c b/eel/eel-gdk-extensions.c
index 3d68d9a5..bbb8a69a 100644
--- a/eel/eel-gdk-extensions.c
+++ b/eel/eel-gdk-extensions.c
@@ -510,6 +510,38 @@ eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable,
#endif
}
+#if GTK_CHECK_VERSION(3,0,0)
+#define CLAMP_COLOR(v) (t = (v), CLAMP (t, 0, G_MAXUSHORT))
+#define SATURATE(v) ((1.0 - saturation) * intensity + saturation * (v))
+
+void
+eel_make_color_inactive (GdkColor *color)
+{
+ double intensity, saturation;
+ gushort t;
+
+ saturation = 0.7;
+ intensity = color->red * 0.30 + color->green * 0.59 + color->blue * 0.11;
+ color->red = SATURATE (color->red);
+ color->green = SATURATE (color->green);
+ color->blue = SATURATE (color->blue);
+
+ if (intensity > G_MAXUSHORT / 2) {
+ color->red *= 0.9;
+ color->green *= 0.9;
+ color->blue *= 0.9;
+ } else {
+ color->red *= 1.25;
+ color->green *= 1.25;
+ color->blue *= 1.25;
+ }
+
+ color->red = CLAMP_COLOR (color->red);
+ color->green = CLAMP_COLOR (color->green);
+ color->blue = CLAMP_COLOR (color->blue);
+}
+#endif
+
#if ! defined (EEL_OMIT_SELF_CHECK)
static char *
diff --git a/eel/eel-gdk-extensions.h b/eel/eel-gdk-extensions.h
index 2036eec4..fedb2c22 100644
--- a/eel/eel-gdk-extensions.h
+++ b/eel/eel-gdk-extensions.h
@@ -132,4 +132,7 @@ void eel_gdk_draw_layout_with_drop_shadow (GdkDrawable
int x,
int y,
PangoLayout *layout);
+#if GTK_CHECK_VERSION(3,0,0)
+void eel_make_color_inactive (GdkColor *color);
+#endif
#endif /* EEL_GDK_EXTENSIONS_H */