Commit ed5da43a authored by Carlos Garnacho's avatar Carlos Garnacho
Browse files

gdk: Add gdk_drag_get_cursor()

This function (most similar to gtk_drag_get_cursor() helps figure out
the right cursor that applies to a given action. To be used by the
various backends.
parent f6b8fb5a
...@@ -29,6 +29,20 @@ ...@@ -29,6 +29,20 @@
#include "gdkwindow.h" #include "gdkwindow.h"
#include "gdkintl.h" #include "gdkintl.h"
#include "gdkenumtypes.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 { enum {
CANCEL, CANCEL,
...@@ -712,3 +726,18 @@ gdk_drag_context_handle_source_event (GdkEvent *event) ...@@ -712,3 +726,18 @@ gdk_drag_context_handle_source_event (GdkEvent *event)
return FALSE; 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;
}
...@@ -112,6 +112,7 @@ void gdk_drag_context_set_cursor (GdkDragContext *context, ...@@ -112,6 +112,7 @@ void gdk_drag_context_set_cursor (GdkDragContext *context,
GdkCursor *cursor); GdkCursor *cursor);
void gdk_drag_context_cancel (GdkDragContext *context); void gdk_drag_context_cancel (GdkDragContext *context);
gboolean gdk_drag_context_handle_source_event (GdkEvent *event); gboolean gdk_drag_context_handle_source_event (GdkEvent *event);
GdkCursor * gdk_drag_get_cursor (GdkDragAction action);
G_END_DECLS G_END_DECLS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment