testdnd2: Use GDK content formats api

This commit is contained in:
Matthias Clasen 2020-01-07 00:46:37 -05:00
parent 379166e1ff
commit 009228471c

View File

@ -220,8 +220,7 @@ get_data (const char *mimetype,
GdkContentFormats *formats; GdkContentFormats *formats;
gboolean want_text; gboolean want_text;
formats = gdk_content_formats_new (NULL, 0); formats = gdk_content_formats_new_for_gtype (G_TYPE_STRING);
formats = gtk_content_formats_add_text_targets (formats);
want_text = gdk_content_formats_contain_mime_type (formats, mimetype); want_text = gdk_content_formats_contain_mime_type (formats, mimetype);
gdk_content_formats_unref (formats); gdk_content_formats_unref (formats);
@ -288,14 +287,16 @@ make_image (const gchar *icon_name, int hotspot)
GtkDragSource *source; GtkDragSource *source;
GtkDropTarget *dest; GtkDropTarget *dest;
GdkContentFormats *formats; GdkContentFormats *formats;
GdkContentFormatsBuilder *builder;
GdkContentProvider *content; GdkContentProvider *content;
image = gtk_image_new_from_icon_name (icon_name); image = gtk_image_new_from_icon_name (icon_name);
gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE); gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
formats = gdk_content_formats_new (NULL, 0); builder = gdk_content_formats_builder_new ();
formats = gtk_content_formats_add_image_targets (formats, FALSE); gdk_content_formats_builder_add_gtype (builder, GDK_TYPE_TEXTURE);
formats = gtk_content_formats_add_text_targets (formats); gdk_content_formats_builder_add_gtype (builder, G_TYPE_STRING);
formats = gdk_content_formats_builder_free_to_formats (builder);
content = gdk_content_provider_new_with_formats (formats, get_data, image); content = gdk_content_provider_new_with_formats (formats, get_data, image);
source = gtk_drag_source_new (); source = gtk_drag_source_new ();