dragicon: Add a default drag icon for GskRenderNode

Somebody should make this default drag icon machinery pluggable.
This commit is contained in:
Benjamin Otte 2021-08-20 05:51:20 +02:00
parent 0b7a36ce33
commit 18affbd390

View File

@ -31,7 +31,9 @@
/* for the drag icons */
#include "gtkcolorswatchprivate.h"
#include "gtkimage.h"
#include "gtklabel.h"
#include "gtkrendernodepaintableprivate.h"
#include "gtktextutil.h"
@ -555,6 +557,25 @@ gtk_drag_icon_create_widget_for_value (const GValue *value)
return picture;
}
else if (G_VALUE_HOLDS (value, GSK_TYPE_RENDER_NODE))
{
GskRenderNode *node;
GdkPaintable *paintable;
graphene_rect_t bounds;
GtkWidget *image;
node = gsk_value_get_render_node (value);
if (node == NULL)
return NULL;
gsk_render_node_get_bounds (node, &bounds);
paintable = gtk_render_node_paintable_new (node, &bounds);
image = gtk_image_new_from_paintable (paintable);
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
g_object_unref (paintable);
return image;
}
else
{
return NULL;