[gtk/wip/otte/dnd2] dnd: Add gdk_drag_action_is_unique()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/dnd2] dnd: Add gdk_drag_action_is_unique()
- Date: Sun, 13 May 2018 15:07:27 +0000 (UTC)
commit 29b7160854df09735f68483cbf694f510c2b5720
Author: Benjamin Otte <otte redhat com>
Date: Sat May 12 00:13:11 2018 +0200
dnd: Add gdk_drag_action_is_unique()
This will be necessary once we remove the ASK action.
docs/reference/gdk/gdk4-sections.txt | 3 +++
gdk/gdkdnd.c | 19 +++++++++++++++++++
gdk/gdkdnd.h | 3 +++
3 files changed, 25 insertions(+)
---
diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt
index 2948955fb8..6ebf719e32 100644
--- a/docs/reference/gdk/gdk4-sections.txt
+++ b/docs/reference/gdk/gdk4-sections.txt
@@ -799,6 +799,9 @@ gdk_drag_context_get_dest_surface
gdk_drag_context_get_drag_surface
gdk_drag_context_set_hotspot
+<SUBSECTION>
+gdk_drag_action_is_unique
+
<SUBSECTION Standard>
GDK_DRAG_CONTEXT
GDK_TYPE_DRAG_CONTEXT
diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c
index 47da69eda3..98801fcde3 100644
--- a/gdk/gdkdnd.c
+++ b/gdk/gdkdnd.c
@@ -876,3 +876,22 @@ gdk_drag_context_handle_dest_event (GdkEvent *event)
gdk_drag_context_commit_drag_status (context);
return TRUE;;
}
+
+/**
+ * gdk_drag_action_is_unique:
+ * @action: a #GdkDragAction
+ *
+ * Checks if @action represents a single action or if it
+ * includes multiple flags that can be selected from.
+ *
+ * When @action is 0 - ie no action was given, %TRUE
+ * is returned.
+ *
+ * Returns: %TRUE if exactly one action was given
+ **/
+GdkDragAction
+gdk_drag_action_is_unique (GdkDragAction action)
+{
+ return (action & (action - 1)) == 0;
+}
+
diff --git a/gdk/gdkdnd.h b/gdk/gdkdnd.h
index 74c65e4f67..f153af44a1 100644
--- a/gdk/gdkdnd.h
+++ b/gdk/gdkdnd.h
@@ -97,6 +97,9 @@ GdkSurface *gdk_drag_context_get_source_surface (GdkDragContext *contex
GDK_AVAILABLE_IN_ALL
GdkSurface *gdk_drag_context_get_dest_surface (GdkDragContext *context);
+GDK_AVAILABLE_IN_ALL
+GdkDragAction gdk_drag_action_is_unique (GdkDragAction action);
+
/* Destination side */
GDK_AVAILABLE_IN_ALL
void gdk_drag_status (GdkDragContext *context,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]