diff --git a/gtk/gtkdnd-quartz.c b/gtk/gtkdnd-quartz.c index eb5fa95dc7..7505482a63 100644 --- a/gtk/gtkdnd-quartz.c +++ b/gtk/gtkdnd-quartz.c @@ -1453,6 +1453,43 @@ set_icon_stock_pixbuf (GdkDragContext *context, cairo_surface_destroy (surface); } +void +gtk_drag_set_icon_definition (GdkDragContext *context, + GtkImageDefinition *def, + gint hot_x, + gint hot_y) +{ + switch (gtk_image_definition_get_storage_type (def)) + { + case GTK_IMAGE_EMPTY: + gtk_drag_set_icon_default (context); + break; + + case GTK_IMAGE_PIXBUF: + gtk_drag_set_icon_pixbuf (context, + gtk_image_definition_get_pixbuf (def), + hot_x, hot_y); + break; + + case GTK_IMAGE_STOCK: + gtk_drag_set_icon_stock (context, + gtk_image_definition_get_stock (def), + hot_x, hot_y); + break; + + case GTK_IMAGE_ICON_NAME: + gtk_drag_set_icon_name (context, + gtk_image_definition_get_icon_name (def), + hot_x, hot_y); + break; + + default: + g_warning ("FIXME: setting drag icon of type %u not implemented, using default.", gtk_image_definition_get_storage_type (def)); + gtk_drag_set_icon_default (context); + break; + } +} + /** * gtk_drag_set_icon_pixbuf: * @context: the context for a drag. (This must be called diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c index 81abab0dca..d29e2f6370 100644 --- a/gtk/gtkdnd.c +++ b/gtk/gtkdnd.c @@ -2853,6 +2853,18 @@ set_icon_helper (GdkDragContext *context, } } +void +gtk_drag_set_icon_definition (GdkDragContext *context, + GtkImageDefinition *def, + gint hot_x, + gint hot_y) +{ + g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); + g_return_if_fail (def != NULL); + + set_icon_helper (context, def, hot_x, hot_y, FALSE); +} + /** * gtk_drag_set_icon_pixbuf: (method) * @context: the context for a drag (This must be called diff --git a/gtk/gtkdndprivate.h b/gtk/gtkdndprivate.h index 43df858b86..016f2634dc 100644 --- a/gtk/gtkdndprivate.h +++ b/gtk/gtkdndprivate.h @@ -35,6 +35,10 @@ GdkDragContext * gtk_drag_begin_internal (GtkWidget const GdkEvent *event, int x, int y); +void gtk_drag_set_icon_definition (GdkDragContext *context, + GtkImageDefinition *def, + gint hot_x, + gint hot_y); void _gtk_drag_source_handle_event (GtkWidget *widget, GdkEvent *event); void _gtk_drag_dest_handle_event (GtkWidget *toplevel, diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index ff608693c8..68704532e5 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -36,6 +36,7 @@ #include "gtkclipboard.h" #include "gtkdebug.h" #include "gtkdnd.h" +#include "gtkdndprivate.h" #include "gtkentry.h" #include "gtkentrybuffer.h" #include "gtkiconhelperprivate.h" @@ -10054,14 +10055,9 @@ gtk_entry_drag_begin (GtkWidget *widget, { if (icon_info->in_drag) { - GdkPixbuf *pix; - - pix = _gtk_icon_helper_ensure_pixbuf - (icon_info->icon_helper, - gtk_widget_get_style_context (GTK_WIDGET (entry))); - gtk_drag_set_icon_pixbuf (context, pix, -2, -2); - - g_object_unref (pix); + gtk_drag_set_icon_definition (context, + gtk_icon_helper_get_definition (icon_info->icon_helper), + -2, -2); return; } }