colorswatch: Port drag icon to paintables
authorBenjamin Otte <otte@redhat.com>
Mon, 26 Mar 2018 04:29:06 +0000 (06:29 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 26 Mar 2018 16:16:36 +0000 (18:16 +0200)
gtk/gtkcolorswatch.c

index b763f558efe5a66fdc1f2609118b1b387b9293fd..a40b334c0e995f9c8d47650a4a266af527dcf8ee 100644 (file)
@@ -167,19 +167,17 @@ static void
 drag_set_color_icon (GdkDragContext *context,
                      const GdkRGBA  *color)
 {
-  cairo_surface_t *surface;
-  cairo_t *cr;
+  GtkSnapshot *snapshot;
+  GdkPaintable *paintable;
 
-  surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 48, 32);
-  cr = cairo_create (surface);
-  gdk_cairo_set_source_rgba (cr, color);
-  cairo_paint (cr);
+  snapshot = gtk_snapshot_new (FALSE, NULL, "ColorDragIcon");
+  gtk_snapshot_append_color (snapshot,
+                             color,
+                             &GRAPHENE_RECT_INIT(0, 0, 48, 32),
+                             "ColorDragColor");
+  paintable = gtk_snapshot_free_to_paintable (snapshot);
 
-  cairo_surface_set_device_offset (surface, -4, -4);
-  gtk_drag_set_icon_surface (context, surface);
-
-  cairo_destroy (cr);
-  cairo_surface_destroy (surface);
+  gtk_drag_set_icon_paintable (context, paintable, 4, 4);
 }
 
 static void