... with gtk_drag_source_set_icon_paintable().
gtk_drag_set_icon_default
gtk_drag_check_threshold
gtk_drag_source_set
-gtk_drag_source_set_icon_surface
gtk_drag_source_set_icon_name
gtk_drag_source_set_icon_gicon
+gtk_drag_source_set_icon_paintable
gtk_drag_source_unset
gtk_drag_source_set_target_list
gtk_drag_source_get_target_list
gdk_content_formats_unref (target_list);
}
-/**
- * gtk_drag_source_set_icon_surface: (method)
- * @widget: a #GtkWidget
- * @surface: the cairo surface for the drag icon
- *
- * Sets the icon that will be used for drags from a particular widget
- * from a cairo surface. GTK+ retains a reference for @surface and will
- * release it when it is no longer needed.
- */
-void
-gtk_drag_source_set_icon_surface (GtkWidget *widget,
- cairo_surface_t *surface)
-{
- GtkDragSourceSite *site;
-
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- site = g_object_get_data (G_OBJECT (widget), "gtk-site-data");
- g_return_if_fail (site != NULL);
-
- g_clear_pointer (&site->image_def, gtk_image_definition_unref);
- site->image_def = gtk_image_definition_new_surface (surface);
-}
-
/**
* gtk_drag_source_set_icon_name: (method)
* @widget: a #GtkWidget
site->image_def = gtk_image_definition_new_gicon (icon);
}
+/**
+ * gtk_drag_source_set_icon_paintable: (method)
+ * @widget: a #GtkWidget
+ * @paintable: A #GdkPaintable
+ *
+ * Sets the icon that will be used for drags from a particular source
+ * to @paintable.
+ */
+void
+gtk_drag_source_set_icon_paintable (GtkWidget *widget,
+ GdkPaintable *paintable)
+{
+ GtkDragSourceSite *site;
+
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (GDK_IS_PAINTABLE (paintable));
+
+ site = g_object_get_data (G_OBJECT (widget), "gtk-site-data");
+ g_return_if_fail (site != NULL);
+
+ gtk_image_definition_unref (site->image_def);
+ site->image_def = gtk_image_definition_new_paintable (paintable);
+}
+
GDK_AVAILABLE_IN_ALL
void gtk_drag_source_add_uri_targets (GtkWidget *widget);
-GDK_AVAILABLE_IN_ALL
-void gtk_drag_source_set_icon_surface (GtkWidget *widget,
- cairo_surface_t *surface);
GDK_AVAILABLE_IN_ALL
void gtk_drag_source_set_icon_name (GtkWidget *widget,
const gchar *icon_name);
GDK_AVAILABLE_IN_ALL
void gtk_drag_source_set_icon_gicon (GtkWidget *widget,
GIcon *icon);
+GDK_AVAILABLE_IN_ALL
+void gtk_drag_source_set_icon_paintable (GtkWidget *widget,
+ GdkPaintable *paintable);
G_END_DECLS
*
* The ::drag-begin signal is emitted on the drag source when a drag is
* started. A typical reason to connect to this signal is to set up a
- * custom drag icon with e.g. gtk_drag_source_set_icon_surface().
+ * custom drag icon with e.g. gtk_drag_source_set_icon_paintable().
*
* Note that some widgets set up a drag icon in the default handler of
* this signal, so you may have to use g_signal_connect_after() to
GtkWidget *pixmap;
GtkWidget *button;
GdkPixbuf *drag_icon;
- cairo_surface_t *surface;
+ GdkTexture *texture;
GdkContentFormats *targets;
test_init ();
gtk_container_add (GTK_CONTAINER (window), grid);
drag_icon = gdk_pixbuf_new_from_xpm_data (drag_icon_xpm);
- surface = gdk_cairo_surface_create_from_pixbuf (drag_icon, 1, NULL);
+ texture = gdk_texture_new_for_pixbuf (drag_icon);
g_object_unref (drag_icon);
trashcan_open = gdk_pixbuf_new_from_xpm_data (trashcan_open_xpm);
trashcan_closed = gdk_pixbuf_new_from_xpm_data (trashcan_closed_xpm);
gtk_drag_source_set (button, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
- gtk_drag_source_set_icon_surface (button, surface);
+ gtk_drag_source_set_icon_paintable (button, GDK_PAINTABLE (texture));
gdk_content_formats_unref (targets);
- cairo_surface_destroy (surface);
+ g_object_unref (texture);
gtk_widget_set_hexpand (button, TRUE);
gtk_widget_set_vexpand (button, TRUE);