diff options
author | raveit65 <[email protected]> | 2016-06-01 13:12:40 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2016-06-05 10:57:55 +0200 |
commit | b2c6ddcb6778322c826178a033457ead91f9c0e8 (patch) | |
tree | b1b8e54805848925684b7924813741a153e99bfb /plugins/media-keys | |
parent | 1e8a8409cc45028a342bbbd9fa33266588c74240 (diff) | |
download | mate-settings-daemon-b2c6ddcb6778322c826178a033457ead91f9c0e8.tar.bz2 mate-settings-daemon-b2c6ddcb6778322c826178a033457ead91f9c0e8.tar.xz |
GTK+3 media-keys: Port OSD to GtkStyleContext
- Port OSD to GtkStyleContext
- Port style_set to style_updated
- fixes also a -Wincompatible-pointer-types warning
- Use correct argument to GtkStyle functions
taken from:
https://git.gnome.org/browse/gnome-settings-daemon/commit/?h=gnome-3-0&id=f6e55cb
https://git.gnome.org/browse/gnome-settings-daemon/commit/?id=45a88f2
GTK+3 media-keys: fix deprecated gtk_style_context_get_background_color
taken from mate-notification-daemon
GTK+3 media-keys: do not use hardcoded colors for osd progressbar
- If we use the OSD style class let the themes handle that.
- drop useless color functions
inspired from:
https://git.gnome.org/browse/gnome-settings-daemon/commit/?id=a0cefe6
Diffstat (limited to 'plugins/media-keys')
-rw-r--r-- | plugins/media-keys/msd-media-keys-window.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/plugins/media-keys/msd-media-keys-window.c b/plugins/media-keys/msd-media-keys-window.c index 7dde696..d6dfb0c 100644 --- a/plugins/media-keys/msd-media-keys-window.c +++ b/plugins/media-keys/msd-media-keys-window.c @@ -392,6 +392,26 @@ render_speaker (MsdMediaKeysWindow *window, return TRUE; } +#if GTK_CHECK_VERSION(3, 0, 0) +static void +msd_get_background_color (GtkStyleContext *context, + GtkStateFlags state, + GdkRGBA *color) +{ + GdkRGBA *c; + + g_return_if_fail (color != NULL); + g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); + + gtk_style_context_get (context, + state, + "background-color", &c, + NULL); + *color = *c; + gdk_rgba_free (c); +} +#endif + static void draw_volume_boxes (MsdMediaKeysWindow *window, cairo_t *cr, @@ -402,18 +422,54 @@ draw_volume_boxes (MsdMediaKeysWindow *window, double height) { gdouble x1; +#if GTK_CHECK_VERSION (3, 0, 0) + GtkStyleContext *context; + GdkRGBA acolor; +#else GdkColor color; double r, g, b; GtkStyle *style; +#endif +#if !GTK_CHECK_VERSION (3, 0, 0) _x0 += 0.5; _y0 += 0.5; +#endif height = round (height) - 1; width = round (width) - 1; x1 = round ((width - 1) * percentage); +#if GTK_CHECK_VERSION (3, 0, 0) + context = gtk_widget_get_style_context (GTK_WIDGET (window)); +#else style = gtk_widget_get_style (GTK_WIDGET (window)); +#endif /* bar background */ +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_TROUGH); + msd_get_background_color (context, GTK_STATE_FLAG_NORMAL, &acolor); + gtk_render_frame (context, cr, _x0, _y0, width, height); + + msd_osd_window_draw_rounded_rectangle (cr, 1.0, _x0, _y0, height / 6, width, height); + gdk_cairo_set_source_rgba (cr, &acolor); + cairo_fill (cr); + + gtk_style_context_restore (context); + + /* bar progress */ + if (percentage < 0.01) + return; + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR); + msd_get_background_color (context, GTK_STATE_FLAG_NORMAL, &acolor); + + msd_osd_window_draw_rounded_rectangle (cr, 1.0, _x0 + 0.5, _y0 + 0.5, height / 6 - 0.5, x1, height - 1); + gdk_cairo_set_source_rgba (cr, &acolor); + cairo_fill (cr); + + gtk_style_context_restore (context); +#else msd_osd_window_color_reverse (&style->dark[GTK_STATE_NORMAL], &color); r = (float)color.red / 65535.0; g = (float)color.green / 65535.0; @@ -441,6 +497,7 @@ draw_volume_boxes (MsdMediaKeysWindow *window, 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); cairo_fill (cr); +#endif } static void |