[nautilus: 1/9] eel-gdk-extensions: add eel_make_color_inactive() to public API
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus: 1/9] eel-gdk-extensions: add eel_make_color_inactive() to public API
- Date: Sat, 9 Oct 2010 17:39:26 +0000 (UTC)
commit 42e726853157e561dc99d61180cae036f751fef8
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu Oct 7 11:24:16 2010 +0200
eel-gdk-extensions: add eel_make_color_inactive() to public API
eel/eel-gdk-extensions.c | 30 ++++++++++++++++++++++++++++++
eel/eel-gdk-extensions.h | 2 ++
2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/eel/eel-gdk-extensions.c b/eel/eel-gdk-extensions.c
index 31ff008..2dc66c3 100644
--- a/eel/eel-gdk-extensions.c
+++ b/eel/eel-gdk-extensions.c
@@ -474,6 +474,36 @@ eel_cairo_draw_layout_with_drop_shadow (cairo_t *cr,
cairo_restore (cr);
}
+#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);
+}
+
#if ! defined (EEL_OMIT_SELF_CHECK)
static char *
diff --git a/eel/eel-gdk-extensions.h b/eel/eel-gdk-extensions.h
index b3778c6..b135264 100644
--- a/eel/eel-gdk-extensions.h
+++ b/eel/eel-gdk-extensions.h
@@ -123,4 +123,6 @@ void eel_cairo_draw_layout_with_drop_shadow (cairo_t
int x,
int y,
PangoLayout *layout);
+void eel_make_color_inactive (GdkColor *color);
+
#endif /* EEL_GDK_EXTENSIONS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]