gtk-demo: Use proper drag icons in the dnd demo
authorMatthias Clasen <mclasen@redhat.com>
Fri, 22 May 2020 14:50:09 +0000 (10:50 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 22 May 2020 14:50:09 +0000 (10:50 -0400)
Use a widget paintable to make the drag icon appear
in two places at once.

demos/gtk-demo/dnd.c

index 5510e61c6a0430b48166e88a88a46ccb55142683..5d7e11273cd6b784865ca47d2b12177374a0e2c1 100644 (file)
@@ -32,10 +32,15 @@ drag_begin (GtkDragSource *source,
 {
   GtkWidget *canvas;
   GtkWidget *item;
+  GdkPaintable *paintable;
 
   canvas = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
   item = g_object_get_data (G_OBJECT (canvas), "dragged-item");
 
+  paintable = gtk_widget_paintable_new (item);
+  gtk_drag_source_set_icon (source, paintable, 0, 0);
+  g_object_unref (paintable);
+
   gtk_widget_set_opacity (item, 0.5);
 }