diff options
author | Wolfgang Ulbrich <[email protected]> | 2015-12-26 20:20:19 +0100 |
---|---|---|
committer | Wolfgang Ulbrich <[email protected]> | 2016-01-13 15:05:41 +0100 |
commit | b1b2cb896d0cbe4a210af4bf3b867cb89580c4c3 (patch) | |
tree | 302886089bfb5a989af894e3e80840b29dfec485 | |
parent | a781d9bffc37f71f4eeb68641f34095d92820507 (diff) | |
download | caja-b1b2cb896d0cbe4a210af4bf3b867cb89580c4c3.tar.bz2 caja-b1b2cb896d0cbe4a210af4bf3b867cb89580c4c3.tar.xz |
GTK3 eel-gdk-pixbuf: use GdkRGBA everywhere
taken from:
https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=020adaf
-rw-r--r-- | eel/eel-gdk-pixbuf-extensions.c | 12 | ||||
-rw-r--r-- | eel/eel-gdk-pixbuf-extensions.h | 4 | ||||
-rw-r--r-- | eel/eel-graphic-effects.c | 17 | ||||
-rw-r--r-- | eel/eel-graphic-effects.h | 9 |
4 files changed, 42 insertions, 0 deletions
diff --git a/eel/eel-gdk-pixbuf-extensions.c b/eel/eel-gdk-pixbuf-extensions.c index b4cd9394..bbbffc3a 100644 --- a/eel/eel-gdk-pixbuf-extensions.c +++ b/eel/eel-gdk-pixbuf-extensions.c @@ -1265,7 +1265,11 @@ eel_gdk_pixbuf_render (GdkPixbuf *pixbuf, guint saturation, guint brightness, guint lighten_value, +#if GTK_CHECK_VERSION(3,0,0) + GdkRGBA *color) +#else guint color) +#endif { GdkPixbuf *temp_pixbuf, *old_pixbuf; @@ -1277,19 +1281,27 @@ eel_gdk_pixbuf_render (GdkPixbuf *pixbuf, else if (render_mode == 2) { /* colorize icon */ +#if GTK_CHECK_VERSION(3,0,0) + temp_pixbuf = eel_create_colorized_pixbuf (pixbuf, color); +#else temp_pixbuf = eel_create_colorized_pixbuf (pixbuf, EEL_RGBA_COLOR_GET_R (color), EEL_RGBA_COLOR_GET_G (color), EEL_RGBA_COLOR_GET_B (color)); +#endif } else if (render_mode == 3) { /* monochromely colorize icon */ old_pixbuf = eel_create_darkened_pixbuf (pixbuf, 0, 255); +#if GTK_CHECK_VERSION(3,0,0) + temp_pixbuf = eel_create_colorized_pixbuf (old_pixbuf, color); +#else temp_pixbuf = eel_create_colorized_pixbuf (old_pixbuf, EEL_RGBA_COLOR_GET_R (color), EEL_RGBA_COLOR_GET_G (color), EEL_RGBA_COLOR_GET_B (color)); +#endif g_object_unref (old_pixbuf); } else diff --git a/eel/eel-gdk-pixbuf-extensions.h b/eel/eel-gdk-pixbuf-extensions.h index 7d31defe..87f79a7a 100644 --- a/eel/eel-gdk-pixbuf-extensions.h +++ b/eel/eel-gdk-pixbuf-extensions.h @@ -151,6 +151,10 @@ GdkPixbuf * eel_gdk_pixbuf_render (GdkPixbuf *pixbuf guint saturation, guint brightness, guint lighten_value, +#if GTK_CHECK_VERSION(3,0,0) + GdkRGBA *color); +#else guint color); +#endif #endif /* EEL_GDK_PIXBUF_EXTENSIONS_H */ diff --git a/eel/eel-graphic-effects.c b/eel/eel-graphic-effects.c index ffb5beba..39309de9 100644 --- a/eel/eel-graphic-effects.c +++ b/eel/eel-graphic-effects.c @@ -26,7 +26,10 @@ and selection hilighting */ #include <config.h> + #include "eel-graphic-effects.h" +#include "eel-glib-extensions.h" + #include <string.h> /* shared utility to create a new pixbuf from the passed-in one */ @@ -169,9 +172,13 @@ eel_create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken) GdkPixbuf * eel_create_colorized_pixbuf (GdkPixbuf *src, +#if GTK_CHECK_VERSION(3,0,0) + GdkRGBA *color) +#else int red_value, int green_value, int blue_value) +#endif { int i, j; int width, height, has_alpha, src_row_stride, dst_row_stride; @@ -181,6 +188,10 @@ eel_create_colorized_pixbuf (GdkPixbuf *src, guchar *pixdest; GdkPixbuf *dest; +#if GTK_CHECK_VERSION(3,0,0) + gint red_value, green_value, blue_value; +#endif + g_return_val_if_fail (gdk_pixbuf_get_colorspace (src) == GDK_COLORSPACE_RGB, NULL); g_return_val_if_fail ((!gdk_pixbuf_get_has_alpha (src) && gdk_pixbuf_get_n_channels (src) == 3) @@ -188,6 +199,12 @@ eel_create_colorized_pixbuf (GdkPixbuf *src, && gdk_pixbuf_get_n_channels (src) == 4), NULL); g_return_val_if_fail (gdk_pixbuf_get_bits_per_sample (src) == 8, NULL); +#if GTK_CHECK_VERSION(3,0,0) + red_value = eel_round (color->red * 255); + green_value = eel_round (color->green * 255); + blue_value = eel_round (color->blue * 255); +#endif + dest = create_new_pixbuf (src); has_alpha = gdk_pixbuf_get_has_alpha (src); diff --git a/eel/eel-graphic-effects.h b/eel/eel-graphic-effects.h index 6ae00421..7291629b 100644 --- a/eel/eel-graphic-effects.h +++ b/eel/eel-graphic-effects.h @@ -26,6 +26,11 @@ #define EEL_GRAPHIC_EFFECTS_H #include <gdk-pixbuf/gdk-pixbuf.h> +#include <gtk/gtk.h> +#if GTK_CHECK_VERSION(3,0,0) +#include <gdk/gdk.h> +#endif + /* return a lightened pixbuf for pre-lighting */ GdkPixbuf *eel_create_spotlight_pixbuf (GdkPixbuf *source_pixbuf); @@ -37,9 +42,13 @@ GdkPixbuf *eel_create_darkened_pixbuf (GdkPixbuf *source_pixbuf, /* return a pixbuf colorized with the color specified by the parameters */ GdkPixbuf* eel_create_colorized_pixbuf (GdkPixbuf *source_pixbuf, +#if GTK_CHECK_VERSION(3,0,0) + GdkRGBA *color); +#else int red_value, int green_value, int blue_value); +#endif /* stretch a image frame */ GdkPixbuf *eel_stretch_frame_image (GdkPixbuf *frame_image, |