[gtk/matthiasc/for-master] gtk-demo: Improve drag icon handling in dnd example
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master] gtk-demo: Improve drag icon handling in dnd example
- Date: Fri, 22 May 2020 19:39:52 +0000 (UTC)
commit d2f979ffaf6cac2ba360a6cfe08e8163ce619c5b
Author: Matthias Clasen <mclasen redhat com>
Date: Fri May 22 13:25:17 2020 -0400
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.
demos/gtk-demo/dnd.c | 10 ++++++++--
1 file 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]