summaryrefslogtreecommitdiff
path: root/mate-screenshot/src/screenshot-utils.c
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2016-08-07 11:34:59 +0200
committerraveit65 <[email protected]>2016-09-01 08:21:55 +0200
commit206323736d82a707230e02eab1f891fdfd652e7f (patch)
tree7bbaca7020273229071c8fdf42bc1477ef530183 /mate-screenshot/src/screenshot-utils.c
parent7d859a9e17f0c4f0b790e8b2a3d8ac25481d7fe6 (diff)
downloadmate-utils-206323736d82a707230e02eab1f891fdfd652e7f.tar.bz2
mate-utils-206323736d82a707230e02eab1f891fdfd652e7f.tar.xz
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
Diffstat (limited to 'mate-screenshot/src/screenshot-utils.c')
-rw-r--r--mate-screenshot/src/screenshot-utils.c26
1 files changed, 24 insertions, 2 deletions
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)