[gtk+/wip/garnacho/dnd-grab: 213/222] gdk: Add gdk_drag_get_cursor()
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/garnacho/dnd-grab: 213/222] gdk: Add gdk_drag_get_cursor()
- Date: Mon, 18 Jan 2016 21:34:30 +0000 (UTC)
commit 81681df0061e5288fda0ad5ba58e7bba77f09182
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Jan 13 20:51:19 2016 +0100
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.
gdk/gdkdnd.c | 29 +++++++++++++++++++++++++++++
gdk/gdkdndprivate.h | 1 +
2 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c
index 32b4528..5803e9f 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 2404293..e62435d 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]