diff options
Diffstat (limited to 'src/msd-osd-window.c')
-rw-r--r-- | src/msd-osd-window.c | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/src/msd-osd-window.c b/src/msd-osd-window.c index 46dfebd..e15927f 100644 --- a/src/msd-osd-window.c +++ b/src/msd-osd-window.c @@ -191,6 +191,7 @@ 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) @@ -220,6 +221,7 @@ msd_osd_window_color_reverse (const GdkColor *a, b->green = green * 65535.0; b->blue = blue * 65535.0; } +#endif /* This is our expose-event handler when the window is in a compositing manager. * We draw everything by hand, using Cairo, so that we can have a nice @@ -240,9 +242,13 @@ expose_when_composited (GtkWidget *widget, GdkEventExpose *event) cairo_surface_t *surface; int width; int height; +#if GTK_CHECK_VERSION (3, 0, 0) + GtkStyleContext *style; +#else GtkStyle *style; GdkColor color; double r, g, b; +#endif window = MSD_OSD_WINDOW (widget); @@ -250,7 +256,11 @@ expose_when_composited (GtkWidget *widget, GdkEventExpose *event) context = gdk_cairo_create (gtk_widget_get_window (widget)); #endif +#if GTK_CHECK_VERSION (3, 0, 0) + style = gtk_widget_get_style_context (widget); +#else style = gtk_widget_get_style (widget); +#endif cairo_set_operator (context, CAIRO_OPERATOR_SOURCE); gtk_window_get_size (GTK_WINDOW (widget), &width, &height); @@ -267,10 +277,15 @@ expose_when_composited (GtkWidget *widget, GdkEventExpose *event) if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) { goto done; } +#if !GTK_CHECK_VERSION (3, 0, 0) cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0); cairo_set_operator (cr, CAIRO_OPERATOR_OVER); cairo_paint (cr); +#endif +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_render_background (style, 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); msd_osd_window_color_reverse (&style->bg[GTK_STATE_NORMAL], &color); @@ -287,6 +302,7 @@ expose_when_composited (GtkWidget *widget, GdkEventExpose *event) cairo_set_source_rgba (cr, r, g, b, BG_ALPHA / 2); cairo_set_line_width (cr, 1); cairo_stroke (cr); +#endif g_signal_emit (window, signals[EXPOSE_WHEN_COMPOSITED], 0, cr); @@ -339,25 +355,23 @@ expose_when_not_composited (GtkWidget *widget, GdkEventExpose *event) gtk_widget_get_allocation (widget, &allocation); #endif - gtk_paint_shadow (gtk_widget_get_style (widget), #if GTK_CHECK_VERSION (3, 0, 0) + gtk_render_frame (gtk_widget_get_style_context (widget), cr, + 0, + 0, + width, + height); #else + gtk_paint_shadow (gtk_widget_get_style (widget), gtk_widget_get_window (widget), -#endif gtk_widget_get_state (widget), GTK_SHADOW_OUT, -#if !GTK_CHECK_VERSION (3, 0, 0) &event->area, -#endif widget, NULL, /* NULL detail -> themes should use the MsdOsdWindow widget name, probably */ 0, 0, -#if GTK_CHECK_VERSION (3, 0, 0) - width, - height); -#else allocation.width, allocation.height); #endif @@ -571,6 +585,12 @@ msd_osd_window_constructor (GType type, "focus-on-map", FALSE, NULL); +#if GTK_CHECK_VERSION (3, 0, 0) + GtkWidget *widget = GTK_WIDGET (object); + GtkStyleContext *style_context = gtk_widget_get_style_context (widget); + gtk_style_context_add_class (style_context, "osd"); +#endif + return object; } @@ -612,6 +632,11 @@ msd_osd_window_class_init (MsdOsdWindowClass *klass) G_TYPE_NONE, 1, G_TYPE_POINTER); +#if GTK_CHECK_VERSION (3, 20, 0) + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); + gtk_widget_class_set_css_name (widget_class, "MsdOsdWindow"); +#endif + g_type_class_add_private (klass, sizeof (MsdOsdWindowPrivate)); } @@ -659,6 +684,11 @@ msd_osd_window_init (MsdOsdWindow *window) gtk_window_set_decorated (GTK_WINDOW (window), FALSE); gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE); +#if GTK_CHECK_VERSION (3, 0, 0) + GtkStyleContext *style = gtk_widget_get_style_context (GTK_WIDGET (window)); + gtk_style_context_add_class (style, "window-frame"); +#endif + /* assume 130x130 on a 640x480 display and scale from there */ scalew = gdk_screen_get_width (screen) / 640.0; scaleh = gdk_screen_get_height (screen) / 480.0; |