diff options
author | Wolfgang Ulbrich <[email protected]> | 2015-12-26 20:47:53 +0100 |
---|---|---|
committer | Wolfgang Ulbrich <[email protected]> | 2016-01-13 15:05:41 +0100 |
commit | 1dffd0e4615ffe0ec3c2b86a61b02d735898ab90 (patch) | |
tree | 6a6d5392ff4e20ea65d08d66b1da190bae1042f5 /eel | |
parent | da1e7f715a4eb882abe97837eef02c7d38bd5e54 (diff) | |
download | caja-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')
-rw-r--r-- | eel/eel-gdk-extensions.c | 49 | ||||
-rw-r--r-- | eel/eel-gdk-extensions.h | 10 |
2 files changed, 42 insertions, 17 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; diff --git a/eel/eel-gdk-extensions.h b/eel/eel-gdk-extensions.h index fedb2c22..ad94ddbd 100644 --- a/eel/eel-gdk-extensions.h +++ b/eel/eel-gdk-extensions.h @@ -114,7 +114,11 @@ guint32 eel_gdk_color_to_rgb (const GdkColor GdkColor eel_gdk_rgb_to_color (guint32 color); char * eel_gdk_rgb_to_color_spec (guint32 color); +#if GTK_CHECK_VERSION(3,0,0) +gboolean eel_gdk_rgba_is_dark (const GdkRGBA *color); +#else gboolean eel_gdk_color_is_dark (GdkColor *color); +#endif /* Wrapper for XParseGeometry */ EelGdkGeometryFlags eel_gdk_parse_geometry (const char *string, @@ -124,15 +128,17 @@ EelGdkGeometryFlags eel_gdk_parse_geometry (const char guint *height_return); #if GTK_CHECK_VERSION(3,0,0) void eel_cairo_draw_layout_with_drop_shadow (cairo_t *cr, + GdkRGBA *text_color, + GdkRGBA *shadow_color, #else void eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable, -#endif GdkColor *text_color, GdkColor *shadow_color, +#endif int x, int y, PangoLayout *layout); #if GTK_CHECK_VERSION(3,0,0) -void eel_make_color_inactive (GdkColor *color); +void eel_make_color_inactive (GdkRGBA *color); #endif #endif /* EEL_GDK_EXTENSIONS_H */ |