summaryrefslogtreecommitdiff
path: root/eel/eel-gdk-extensions.c
diff options
context:
space:
mode:
authorWolfgang Ulbrich <[email protected]>2015-12-26 20:47:53 +0100
committerWolfgang Ulbrich <[email protected]>2016-01-13 15:05:41 +0100
commit1dffd0e4615ffe0ec3c2b86a61b02d735898ab90 (patch)
tree6a6d5392ff4e20ea65d08d66b1da190bae1042f5 /eel/eel-gdk-extensions.c
parentda1e7f715a4eb882abe97837eef02c7d38bd5e54 (diff)
downloadcaja-1dffd0e4615ffe0ec3c2b86a61b02d735898ab90.tar.bz2
caja-1dffd0e4615ffe0ec3c2b86a61b02d735898ab90.tar.xz
GTK3 eel-gdk-extensions: port to GtkStyleContext
taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=1d3dd96
Diffstat (limited to 'eel/eel-gdk-extensions.c')
-rw-r--r--eel/eel-gdk-extensions.c49
1 files changed, 34 insertions, 15 deletions
diff --git a/eel/eel-gdk-extensions.c b/eel/eel-gdk-extensions.c
index bbb8a69a..2da5bb03 100644
--- a/eel/eel-gdk-extensions.c
+++ b/eel/eel-gdk-extensions.c
@@ -420,6 +420,15 @@ eel_gdk_rgb_to_color_spec (const guint32 color)
* Return true if the given color is `dark'
*/
gboolean
+#if GTK_CHECK_VERSION(3,0,0)
+eel_gdk_rgba_is_dark (const GdkRGBA *color)
+{
+ int intensity;
+
+ intensity = ((((int) (color->red) >> 8) * 77)
+ + (((int) (color->green) >> 8) * 150)
+ + (((int) (color->blue) >> 8) * 28)) >> 8;
+#else
eel_gdk_color_is_dark (GdkColor *color)
{
int intensity;
@@ -427,6 +436,7 @@ eel_gdk_color_is_dark (GdkColor *color)
intensity = (((color->red >> 8) * 77)
+ ((color->green >> 8) * 150)
+ ((color->blue >> 8) * 28)) >> 8;
+#endif
return intensity < 128;
}
@@ -478,22 +488,34 @@ eel_gdk_parse_geometry (const char *string, int *x_return, int *y_return,
void
#if GTK_CHECK_VERSION(3,0,0)
-eel_cairo_draw_layout_with_drop_shadow (cairo_t *cr,
+eel_cairo_draw_layout_with_drop_shadow (cairo_t *cr,
+ GdkRGBA *text_color,
+ GdkRGBA *shadow_color,
+ int x,
+ int y,
+ PangoLayout *layout)
+{
+ cairo_save (cr);
+
+ gdk_cairo_set_source_rgba (cr, shadow_color);
+ cairo_move_to (cr, x+1, y+1);
+ pango_cairo_show_layout (cr, layout);
+
+ gdk_cairo_set_source_rgba (cr, text_color);
+ cairo_move_to (cr, x, y);
+ pango_cairo_show_layout (cr, layout);
+
+ cairo_restore (cr);
#else
eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable,
-#endif
GdkColor *text_color,
GdkColor *shadow_color,
- int x,
- int y,
+ int x,
+ int y,
PangoLayout *layout)
{
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_save (cr);
-#else
cairo_t *cr;
cr = gdk_cairo_create (drawable);
-#endif
gdk_cairo_set_source_color (cr, shadow_color);
cairo_move_to (cr, x+1, y+1);
@@ -503,22 +525,19 @@ eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable,
cairo_move_to (cr, x, y);
pango_cairo_show_layout (cr, layout);
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_restore (cr);
-#else
cairo_destroy (cr);
#endif
}
#if GTK_CHECK_VERSION(3,0,0)
-#define CLAMP_COLOR(v) (t = (v), CLAMP (t, 0, G_MAXUSHORT))
+#define CLAMP_COLOR(v) (t = (v), CLAMP (t, 0, 1))
#define SATURATE(v) ((1.0 - saturation) * intensity + saturation * (v))
void
-eel_make_color_inactive (GdkColor *color)
+eel_make_color_inactive (GdkRGBA *color)
{
double intensity, saturation;
- gushort t;
+ gdouble t;
saturation = 0.7;
intensity = color->red * 0.30 + color->green * 0.59 + color->blue * 0.11;
@@ -526,7 +545,7 @@ eel_make_color_inactive (GdkColor *color)
color->green = SATURATE (color->green);
color->blue = SATURATE (color->blue);
- if (intensity > G_MAXUSHORT / 2) {
+ if (intensity > 0.5) {
color->red *= 0.9;
color->green *= 0.9;
color->blue *= 0.9;