[gtk/wip/otte/inspector: 4/6] recorder: Make the render nodes in the list draggable
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/inspector: 4/6] recorder: Make the render nodes in the list draggable
- Date: Fri, 20 Aug 2021 03:56:37 +0000 (UTC)
commit a4e5f15f5104419a0d87b379fd47d58b5ed2dbad
Author: Benjamin Otte <otte redhat com>
Date: Fri Aug 20 05:52:10 2021 +0200
recorder: Make the render nodes in the list draggable
You can (soon) drag any of the nodes directly into the node-editor.
gtk/inspector/recorder.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
---
diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c
index 7b3ead81ee..7b9793b98a 100644
--- a/gtk/inspector/recorder.c
+++ b/gtk/inspector/recorder.c
@@ -21,6 +21,8 @@
#include <gtk/gtkbinlayout.h>
#include <gtk/gtkbox.h>
+#include <gtk/gtkdragsource.h>
+#include <gtk/gtkeventcontroller.h>
#include <gtk/gtkfilechooserdialog.h>
#include <gtk/gtksignallistitemfactory.h>
#include <gtk/gtklabel.h>
@@ -344,15 +346,39 @@ node_name (GskRenderNode *node)
}
}
+static GdkContentProvider *
+prepare_render_node_drag (GtkDragSource *source,
+ double x,
+ double y,
+ GtkListItem *list_item)
+{
+ GtkTreeListRow *row_item;
+ GdkPaintable *paintable;
+ GskRenderNode *node;
+
+ row_item = gtk_list_item_get_item (list_item);
+ if (row_item == NULL)
+ return NULL;
+
+ paintable = gtk_tree_list_row_get_item (row_item);
+ node = gtk_render_node_paintable_get_render_node (GTK_RENDER_NODE_PAINTABLE (paintable));
+
+ return gdk_content_provider_new_typed (GSK_TYPE_RENDER_NODE, node);
+}
+
static void
setup_widget_for_render_node (GtkSignalListItemFactory *factory,
GtkListItem *list_item)
{
GtkWidget *expander, *box, *child;
+ GtkDragSource *source;
/* expander */
expander = gtk_tree_expander_new ();
gtk_list_item_set_child (list_item, expander);
+ source = gtk_drag_source_new ();
+ g_signal_connect (source, "prepare", G_CALLBACK (prepare_render_node_drag), list_item);
+ gtk_widget_add_controller (expander, GTK_EVENT_CONTROLLER (source));
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
gtk_tree_expander_set_child (GTK_TREE_EXPANDER (expander), box);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]