From 8c3cbb03ae3a333af2582bda1aa893c438814fb0 Mon Sep 17 00:00:00 2001 From: raveit65 Date: Sun, 7 Aug 2016 08:33:16 +0200 Subject: GTK+-3.0 baobab: port GdkColor to GdkRGBA taken from: https://git.gnome.org/browse/baobab/commit/?id=3527995 --- baobab/src/baobab-cell-renderer-progress.c | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/baobab/src/baobab-cell-renderer-progress.c b/baobab/src/baobab-cell-renderer-progress.c index 91fbe440..d4d26db5 100644 --- a/baobab/src/baobab-cell-renderer-progress.c +++ b/baobab/src/baobab-cell-renderer-progress.c @@ -146,6 +146,42 @@ baobab_cell_renderer_progress_get_size (GtkCellRenderer *cell, static void set_color_according_to_perc (cairo_t *cr, double value) { +#if GTK_CHECK_VERSION (3, 0, 0) + static GdkRGBA red; + static GdkRGBA yellow; + static GdkRGBA green; + static gboolean colors_initialized = FALSE; + + if (!colors_initialized) + { + /* hardcoded tango colors */ + gdk_rgba_parse (&red, "#cc0000"); + gdk_rgba_parse (&yellow, "#edd400"); + gdk_rgba_parse (&green, "#73d216"); + + colors_initialized = TRUE; + } + + if (value <= 0) + { + cairo_set_source_rgb (cr, 1, 1, 1); + return; + } + else if (value <= 33.33) + { + gdk_cairo_set_source_rgba (cr, &green); + return; + } + else if (value <= 66.66) + { + gdk_cairo_set_source_rgba (cr, &yellow); + return; + } + else if (value <= 100.0) + { + gdk_cairo_set_source_rgba (cr, &red); + return; +#else static GdkColor red; static GdkColor yellow; static GdkColor green; @@ -180,6 +216,7 @@ set_color_according_to_perc (cairo_t *cr, double value) { gdk_cairo_set_source_color (cr, &red); return; +#endif } else g_assert_not_reached (); -- cgit v1.2.1