From 206323736d82a707230e02eab1f891fdfd652e7f Mon Sep 17 00:00:00 2001 From: raveit65 Date: Sun, 7 Aug 2016 11:34:59 +0200 Subject: GTK+-3 screenshot-utils: use GtkStyleContext to draw the area selection taken from: https://git.gnome.org/browse/gnome-screenshot/commit/?h=gnome-3-4&id=e25c879 --- mate-screenshot/src/screenshot-utils.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'mate-screenshot') diff --git a/mate-screenshot/src/screenshot-utils.c b/mate-screenshot/src/screenshot-utils.c index f2350184..3ea49b57 100644 --- a/mate-screenshot/src/screenshot-utils.c +++ b/mate-screenshot/src/screenshot-utils.c @@ -401,28 +401,49 @@ draw (GtkWidget *window, cairo_t *cr, gpointer unused) expose (GtkWidget *window, GdkEventExpose *event, gpointer unused) #endif { +#if GTK_CHECK_VERSION (3, 0, 0) + GtkStyleContext *style; + + style = gtk_widget_get_style_context (window); +#else GtkAllocation allocation; GtkStyle *style; -#if !GTK_CHECK_VERSION (3, 0, 0) cairo_t *cr; cr = gdk_cairo_create (event->window); gdk_cairo_region (cr, event->region); cairo_clip (cr); -#endif style = gtk_widget_get_style (window); +#endif if (gtk_widget_get_app_paintable (window)) { +#if !GTK_CHECK_VERSION (3, 0, 0) cairo_set_line_width (cr, 1.0); gtk_widget_get_allocation (window, &allocation); +#endif cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); cairo_set_source_rgba (cr, 0, 0, 0, 0); cairo_paint (cr); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_style_context_save (style); + gtk_style_context_add_class (style, GTK_STYLE_CLASS_RUBBERBAND); + + gtk_render_background (style, cr, + 0, 0, + gtk_widget_get_allocated_width (window), + gtk_widget_get_allocated_height (window)); + gtk_render_frame (style, cr, + 0, 0, + gtk_widget_get_allocated_width (window), + gtk_widget_get_allocated_height (window)); + + gtk_style_context_restore (style); +#else cairo_set_operator (cr, CAIRO_OPERATOR_OVER); gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_SELECTED]); cairo_paint_with_alpha (cr, 0.25); @@ -436,6 +457,7 @@ expose (GtkWidget *window, GdkEventExpose *event, gpointer unused) { gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_SELECTED]); cairo_paint (cr); +#endif } #if !GTK_CHECK_VERSION (3, 0, 0) -- cgit v1.2.1