[gtk/wip/otte/for-master: 1/3] demo: Add a dnd special-case for textures
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/for-master: 1/3] demo: Add a dnd special-case for textures
- Date: Thu, 19 Aug 2021 01:26:59 +0000 (UTC)
commit 7bc1c9a5626aa5d681b65507524aacd5da2d079f
Author: Benjamin Otte <otte redhat com>
Date: Thu Aug 19 02:15:59 2021 +0200
demo: Add a dnd special-case for textures
If the DND/clipboard machinery knows a texture is a texture, it will try
to serialize it. Paintables can't be serialized, so it wouldn't try.
demos/gtk-demo/demoimage.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/demos/gtk-demo/demoimage.c b/demos/gtk-demo/demoimage.c
index a7ecb6e213..8fdc4257a5 100644
--- a/demos/gtk-demo/demoimage.c
+++ b/demos/gtk-demo/demoimage.c
@@ -100,7 +100,11 @@ prepare_drag (GtkDragSource *source,
DemoImage *demo = DEMO_IMAGE (widget);
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (demo->image));
- return gdk_content_provider_new_typed (GDK_TYPE_PAINTABLE, paintable);
+ /* Textures can be serialized, paintables can't, so special case the textures */
+ if (GDK_IS_TEXTURE (paintable))
+ return gdk_content_provider_new_typed (GDK_TYPE_TEXTURE, paintable);
+ else
+ return gdk_content_provider_new_typed (GDK_TYPE_PAINTABLE, paintable);
}
static gboolean
@@ -129,7 +133,11 @@ copy_image (GtkWidget *widget,
GdkPaintable *paintable = get_image_paintable (GTK_IMAGE (demo->image));
GValue value = G_VALUE_INIT;
- g_value_init (&value, GDK_TYPE_PAINTABLE);
+ /* Textures can be serialized, paintables can't, so special case the textures */
+ if (GDK_IS_TEXTURE (paintable))
+ g_value_init (&value, GDK_TYPE_TEXTURE);
+ else
+ g_value_init (&value, GDK_TYPE_PAINTABLE);
g_value_set_object (&value, paintable);
gdk_clipboard_set_value (clipboard, &value);
g_value_unset (&value);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]