diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-05-22 13:25:17 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-05-22 13:25:17 -0400 |
commit | d2f979ffaf6cac2ba360a6cfe08e8163ce619c5b (patch) | |
tree | 6418e76f11315051b625eb99d7710b9d65dd2535 /demos/gtk-demo | |
parent | e54060bac209f3a4bd5d52fb941de075a88484e3 (diff) | |
download | gtk+-d2f979ffaf6cac2ba360a6cfe08e8163ce619c5b.tar.gz |
gtk-demo: Improve drag icon handling in dnd example
Make the opacity change only apply to the 'ghost' of
the item, not the drag icon.
Diffstat (limited to 'demos/gtk-demo')
-rw-r--r-- | demos/gtk-demo/dnd.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/demos/gtk-demo/dnd.c b/demos/gtk-demo/dnd.c index 0d901af6de..a3f0097648 100644 --- a/demos/gtk-demo/dnd.c +++ b/demos/gtk-demo/dnd.c @@ -187,6 +187,12 @@ canvas_item_new (double x, return GTK_WIDGET (item); } +static GdkPaintable * +canvas_item_get_drag_icon (CanvasItem *item) +{ + return gtk_widget_paintable_new (item->label); +} + static GdkContentProvider * prepare (GtkDragSource *source, double x, @@ -218,11 +224,11 @@ drag_begin (GtkDragSource *source, 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); + paintable = canvas_item_get_drag_icon (CANVAS_ITEM (item)); gtk_drag_source_set_icon (source, paintable, 0, 0); g_object_unref (paintable); - gtk_widget_set_opacity (item, 0.5); + gtk_widget_set_opacity (item, 0.3); } static void |