diff options
Diffstat (limited to 'src/gsd-media-keys-window.c')
-rw-r--r-- | src/gsd-media-keys-window.c | 65 |
1 files changed, 16 insertions, 49 deletions
diff --git a/src/gsd-media-keys-window.c b/src/gsd-media-keys-window.c index 67d2402..e59ba44 100644 --- a/src/gsd-media-keys-window.c +++ b/src/gsd-media-keys-window.c @@ -402,45 +402,33 @@ draw_volume_boxes (MsdMediaKeysWindow *window, double height) { gdouble x1; - GdkColor color; - double r, g, b; - GtkStyle *style; + GtkStyleContext *context; - _x0 += 0.5; - _y0 += 0.5; height = round (height) - 1; width = round (width) - 1; x1 = round ((width - 1) * percentage); - style = gtk_widget_get_style (GTK_WIDGET (window)); + context = gtk_widget_get_style_context (GTK_WIDGET (window)); /* bar background */ - 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); - cairo_fill_preserve (cr); + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_TROUGH); - /* bar border */ - 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); - cairo_set_line_width (cr, 1); - cairo_stroke (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; - 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); - cairo_fill (cr); + + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR); + + 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); } static void @@ -471,19 +459,6 @@ draw_action_volume (MsdMediaKeysWindow *window, volume_box_x0 = round (icon_box_x0); volume_box_y0 = round (icon_box_height + icon_box_y0); -#if 0 - g_message ("icon box: w=%f h=%f _x0=%f _y0=%f", - icon_box_width, - icon_box_height, - icon_box_x0, - icon_box_y0); - g_message ("volume box: w=%f h=%f _x0=%f _y0=%f", - volume_box_width, - volume_box_height, - volume_box_x0, - volume_box_y0); -#endif - res = render_speaker (window, cr, icon_box_x0, icon_box_y0, @@ -645,11 +620,7 @@ draw_action_custom (MsdMediaKeysWindow *window, } static void -#if GTK_CHECK_VERSION (3, 0, 0) msd_media_keys_window_draw_when_composited (MsdOsdWindow *osd_window, -#else -msd_media_keys_window_expose_when_composited (MsdOsdWindow *osd_window, -#endif cairo_t *cr) { MsdMediaKeysWindow *window = MSD_MEDIA_KEYS_WINDOW (osd_window); @@ -671,11 +642,7 @@ msd_media_keys_window_class_init (MsdMediaKeysWindowClass *klass) { MsdOsdWindowClass *osd_window_class = MSD_OSD_WINDOW_CLASS (klass); -#if GTK_CHECK_VERSION (3, 0, 0) osd_window_class->draw_when_composited = msd_media_keys_window_draw_when_composited; -#else - osd_window_class->expose_when_composited = msd_media_keys_window_expose_when_composited; -#endif g_type_class_add_private (klass, sizeof (MsdMediaKeysWindowPrivate)); } |