diff options
author | raveit65 <[email protected]> | 2016-08-07 08:33:16 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2016-09-01 08:14:34 +0200 |
commit | 8c3cbb03ae3a333af2582bda1aa893c438814fb0 (patch) | |
tree | ce3243b1419fa619fe9a9f4f3883a5b0b6161793 /baobab/src | |
parent | 26a504d27f2fba1cf2ad16b0bec5e88cbd11071c (diff) | |
download | mate-utils-8c3cbb03ae3a333af2582bda1aa893c438814fb0.tar.bz2 mate-utils-8c3cbb03ae3a333af2582bda1aa893c438814fb0.tar.xz |
GTK+-3.0 baobab: port GdkColor to GdkRGBA
taken from:
https://git.gnome.org/browse/baobab/commit/?id=3527995
Diffstat (limited to 'baobab/src')
-rw-r--r-- | baobab/src/baobab-cell-renderer-progress.c | 37 |
1 files changed, 37 insertions, 0 deletions
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 (); |