From bdb500291eb7fb5b2477a3fc6226b8c9017a172e Mon Sep 17 00:00:00 2001 From: Denis Gorodnichev Date: Sun, 5 Jun 2016 23:34:31 +0300 Subject: gtk3: progressbar themed background --- plugins/common/msd-osd-window.c | 3 ++- plugins/common/msd-osd-window.h | 2 +- plugins/media-keys/msd-media-keys-window.c | 35 +++++------------------------- 3 files changed, 8 insertions(+), 32 deletions(-) (limited to 'plugins') diff --git a/plugins/common/msd-osd-window.c b/plugins/common/msd-osd-window.c index c902870..5564532 100644 --- a/plugins/common/msd-osd-window.c +++ b/plugins/common/msd-osd-window.c @@ -143,6 +143,7 @@ add_hide_timeout (MsdOsdWindow *window) window); } +#if !GTK_CHECK_VERSION (3, 0, 0) void msd_osd_window_draw_rounded_rectangle (cairo_t* cr, gdouble aspect, @@ -195,7 +196,6 @@ msd_osd_window_draw_rounded_rectangle (cairo_t* cr, cairo_close_path (cr); } -#if !GTK_CHECK_VERSION (3, 0, 0) void msd_osd_window_color_reverse (const GdkColor *a, GdkColor *b) @@ -294,6 +294,7 @@ expose_when_composited (GtkWidget *widget, GdkEventExpose *event) #if GTK_CHECK_VERSION (3, 0, 0) gtk_render_background (context, cr, 0, 0, width, height); + gtk_render_frame (context, cr, 0, 0, width, height); #else /* draw a box */ msd_osd_window_draw_rounded_rectangle (cr, 1.0, 0.5, 0.5, height / 10, width-1, height-1); diff --git a/plugins/common/msd-osd-window.h b/plugins/common/msd-osd-window.h index 52c464f..42229f4 100644 --- a/plugins/common/msd-osd-window.h +++ b/plugins/common/msd-osd-window.h @@ -84,6 +84,7 @@ gboolean msd_osd_window_is_composited (MsdOsdWindow *windo gboolean msd_osd_window_is_valid (MsdOsdWindow *window); void msd_osd_window_update_and_hide (MsdOsdWindow *window); +#if !GTK_CHECK_VERSION (3, 0, 0) void msd_osd_window_draw_rounded_rectangle (cairo_t *cr, gdouble aspect, gdouble x, @@ -92,7 +93,6 @@ void msd_osd_window_draw_rounded_rectangle (cairo_t *cr, gdouble width, gdouble height); -#if !GTK_CHECK_VERSION (3, 0, 0) void msd_osd_window_color_reverse (const GdkColor *a, GdkColor *b); #endif diff --git a/plugins/media-keys/msd-media-keys-window.c b/plugins/media-keys/msd-media-keys-window.c index d6dfb0c..3672281 100644 --- a/plugins/media-keys/msd-media-keys-window.c +++ b/plugins/media-keys/msd-media-keys-window.c @@ -392,26 +392,6 @@ 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, @@ -424,7 +404,6 @@ draw_volume_boxes (MsdMediaKeysWindow *window, gdouble x1; #if GTK_CHECK_VERSION (3, 0, 0) GtkStyleContext *context; - GdkRGBA acolor; #else GdkColor color; double r, g, b; @@ -448,25 +427,21 @@ draw_volume_boxes (MsdMediaKeysWindow *window, #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_render_background (context, cr, _x0, _y0, width, height); + gtk_render_frame (context, cr, _x0, _y0, width, height); 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_render_background (context, cr, _x0 + 0.5, _y0 + 0.5, x1, height -1 ); + gtk_render_frame (context, cr, _x0 + 0.5, _y0 + 0.5, x1, height -1 ); gtk_style_context_restore (context); #else -- cgit v1.2.1