diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c index 3a8861a188..e324c18faa 100644 --- a/gdk/gdkdnd.c +++ b/gdk/gdkdnd.c @@ -29,6 +29,20 @@ #include "gdkwindow.h" #include "gdkintl.h" #include "gdkenumtypes.h" +#include "gdkcursor.h" + +static struct { + GdkDragAction action; + const gchar *name; + GdkCursor *cursor; +} drag_cursors[] = { + { GDK_ACTION_DEFAULT, NULL, NULL }, + { GDK_ACTION_ASK, "dnd-ask", NULL }, + { GDK_ACTION_COPY, "dnd-copy", NULL }, + { GDK_ACTION_MOVE, "dnd-move", NULL }, + { GDK_ACTION_LINK, "dnd-link", NULL }, + { 0, "dnd-none", NULL }, +}; enum { CANCEL, @@ -712,3 +726,18 @@ gdk_drag_context_handle_source_event (GdkEvent *event) return FALSE; } + +GdkCursor * +gdk_drag_get_cursor (GdkDragAction action) +{ + gint i; + + for (i = 0 ; i < G_N_ELEMENTS (drag_cursors) - 1; i++) + if (drag_cursors[i].action == action) + break; + + if (drag_cursors[i].cursor == NULL) + drag_cursors[i].cursor = gdk_cursor_new_from_name (gdk_display_get_default (), + drag_cursors[i].name); + return drag_cursors[i].cursor; +} diff --git a/gdk/gdkdndprivate.h b/gdk/gdkdndprivate.h index 2404293b55..e62435d3f8 100644 --- a/gdk/gdkdndprivate.h +++ b/gdk/gdkdndprivate.h @@ -112,6 +112,7 @@ void gdk_drag_context_set_cursor (GdkDragContext *context, GdkCursor *cursor); void gdk_drag_context_cancel (GdkDragContext *context); gboolean gdk_drag_context_handle_source_event (GdkEvent *event); +GdkCursor * gdk_drag_get_cursor (GdkDragAction action); G_END_DECLS