[gtk/wip/otte/inspector: 6/10] dragicon: Add a default drag icon for GskRenderNode




commit 0f24e911d3a6470987ea1017bf16514c29428c9f
Author: Benjamin Otte <otte redhat com>
Date:   Fri Aug 20 05:51:20 2021 +0200

    dragicon: Add a default drag icon for GskRenderNode
    
    Somebody should make this default drag icon machinery pluggable.

 gtk/gtkdragicon.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
---
diff --git a/gtk/gtkdragicon.c b/gtk/gtkdragicon.c
index b8b31671f9..a58cf474dc 100644
--- a/gtk/gtkdragicon.c
+++ b/gtk/gtkdragicon.c
@@ -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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]