colorbutton: Port dnd icon to paintable
authorBenjamin Otte <otte@redhat.com>
Mon, 26 Mar 2018 04:26:34 +0000 (06:26 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 26 Mar 2018 16:16:36 +0000 (18:16 +0200)
Patch is untested, because colorbuttons can't do DND at the moment.

gtk/gtkcolorbutton.c

index 91d23956204f9205ed8bbcc1a71b5e10f9f9e04f..4ef68a18759f14522d90d422b67d978865801717 100644 (file)
@@ -31,7 +31,6 @@
 #include "gtkcolorbutton.h"
 
 #include "gtkbutton.h"
-#include "gtkmain.h"
 #include "gtkcolorchooser.h"
 #include "gtkcolorchooserprivate.h"
 #include "gtkcolorchooserdialog.h"
 #include "gtkdnd.h"
 #include "gtkdragdest.h"
 #include "gtkdragsource.h"
+#include "gtkintl.h"
+#include "gtkmain.h"
 #include "gtkmarshalers.h"
 #include "gtkprivate.h"
-#include "gtkintl.h"
+#include "gtksnapshot.h"
 
 
 /**
@@ -322,19 +323,17 @@ static void
 set_color_icon (GdkDragContext *context,
                 const GdkRGBA  *rgba)
 {
-  cairo_surface_t *surface;
-  cairo_t *cr;
-
-  surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 48, 32);
-  cr = cairo_create (surface);
-
-  gdk_cairo_set_source_rgba (cr, rgba);
-  cairo_paint (cr);
+  GtkSnapshot *snapshot;
+  GdkPaintable *paintable;
 
-  gtk_drag_set_icon_surface (context, surface);
+  snapshot = gtk_snapshot_new (FALSE, NULL, "ColorDragIcon");
+  gtk_snapshot_append_color (snapshot,
+                             rgba,
+                             &GRAPHENE_RECT_INIT(0, 0, 48, 32),
+                             "ColorDragColor");
+  paintable = gtk_snapshot_free_to_paintable (snapshot);
 
-  cairo_destroy (cr);
-  cairo_surface_destroy (surface);
+  gtk_drag_set_icon_paintable (context, paintable, 0, 0);
 }
 
 static void