diff options
author | Denis Gorodnichev <[email protected]> | 2016-05-10 23:38:44 +0300 |
---|---|---|
committer | Denis Gorodnichev <[email protected]> | 2016-05-10 23:53:03 +0300 |
commit | e342e7ae390c4496cea301bf1942a03916d4de44 (patch) | |
tree | 9b9fb2a4e2ae6f2605f265a49dbf6ec731243d35 /src/gsd-media-keys-window.c | |
parent | aaa724ca786fccc97b6857097c5bcdf80f972940 (diff) | |
download | mate-power-manager-e342e7ae390c4496cea301bf1942a03916d4de44.tar.bz2 mate-power-manager-e342e7ae390c4496cea301bf1942a03916d4de44.tar.xz |
gtk3: css themes for MsdOsdWindow
Diffstat (limited to 'src/gsd-media-keys-window.c')
-rw-r--r-- | src/gsd-media-keys-window.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/gsd-media-keys-window.c b/src/gsd-media-keys-window.c index 63f93a5..5bcca8e 100644 --- a/src/gsd-media-keys-window.c +++ b/src/gsd-media-keys-window.c @@ -30,6 +30,11 @@ #include <glib/gi18n.h> #include <gtk/gtk.h> +#if GTK_CHECK_VERSION (3, 0, 0) +#define MATE_DESKTOP_USE_UNSTABLE_API +#include <libmate-desktop/mate-desktop-utils.h> +#endif + #include "gsd-media-keys-window.h" #define MSD_MEDIA_KEYS_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MSD_TYPE_MEDIA_KEYS_WINDOW, MsdMediaKeysWindowPrivate)) @@ -402,44 +407,74 @@ draw_volume_boxes (MsdMediaKeysWindow *window, double height) { gdouble x1; +#if GTK_CHECK_VERSION (3, 0, 0) + GdkRGBA color; + GtkStyleContext *style; +#else GdkColor color; double r, g, b; GtkStyle *style; +#endif _x0 += 0.5; _y0 += 0.5; height = round (height) - 1; width = round (width) - 1; x1 = round ((width - 1) * percentage); + +#if GTK_CHECK_VERSION (3, 0, 0) + style = gtk_widget_get_style_context (GTK_WIDGET (window)); +#else style = gtk_widget_get_style (GTK_WIDGET (window)); +#endif /* bar background */ + msd_osd_window_draw_rounded_rectangle (cr, 1.0, _x0, _y0, height / 6, width, height); +#if GTK_CHECK_VERSION (3, 0, 0) + mate_desktop_gtk_style_get_dark_color (style, GTK_STATE_FLAG_NORMAL, &color); + cairo_set_operator (cr, CAIRO_OPERATOR_DIFFERENCE); + cairo_set_source_rgba (cr, color.red, color.green, color.blue, MSD_OSD_WINDOW_FG_ALPHA / 2); +#else msd_osd_window_color_reverse (&style->dark[GTK_STATE_NORMAL], &color); r = (float)color.red / 65535.0; g = (float)color.green / 65535.0; b = (float)color.blue / 65535.0; msd_osd_window_draw_rounded_rectangle (cr, 1.0, _x0, _y0, height / 6, width, height); cairo_set_source_rgba (cr, r, g, b, MSD_OSD_WINDOW_FG_ALPHA / 2); +#endif cairo_fill_preserve (cr); /* bar border */ +#if GTK_CHECK_VERSION (3, 0, 0) + mate_desktop_gtk_style_get_light_color (style, GTK_STATE_FLAG_NORMAL, &color); + cairo_set_operator (cr, CAIRO_OPERATOR_DIFFERENCE); + cairo_set_source_rgba (cr, color.red, color.green, color.blue, MSD_OSD_WINDOW_FG_ALPHA / 2); +#else msd_osd_window_color_reverse (&style->light[GTK_STATE_NORMAL], &color); r = (float)color.red / 65535.0; g = (float)color.green / 65535.0; b = (float)color.blue / 65535.0; cairo_set_source_rgba (cr, r, g, b, MSD_OSD_WINDOW_FG_ALPHA / 2); +#endif cairo_set_line_width (cr, 1); cairo_stroke (cr); /* bar progress */ if (percentage < 0.01) return; + + msd_osd_window_draw_rounded_rectangle (cr, 1.0, _x0 + 0.5, _y0 + 0.5, height / 6 - 0.5, x1, height - 1); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, GTK_STYLE_PROPERTY_COLOR, &color, NULL); + cairo_set_operator (cr, CAIRO_OPERATOR_DIFFERENCE); + cairo_set_source_rgba (cr, color.red, color.green, color.blue, MSD_OSD_WINDOW_FG_ALPHA); +#else color = style->bg[GTK_STATE_NORMAL]; r = (float)color.red / 65535.0; g = (float)color.green / 65535.0; b = (float)color.blue / 65535.0; - msd_osd_window_draw_rounded_rectangle (cr, 1.0, _x0 + 0.5, _y0 + 0.5, height / 6 - 0.5, x1, height - 1); cairo_set_source_rgba (cr, r, g, b, MSD_OSD_WINDOW_FG_ALPHA); +#endif cairo_fill (cr); } |