dnd: Add gdk_drag_action_is_unique()
authorBenjamin Otte <otte@redhat.com>
Fri, 11 May 2018 22:13:11 +0000 (00:13 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 18 Jun 2018 21:49:19 +0000 (23:49 +0200)
This will be necessary once we remove the ASK action.

docs/reference/gdk/gdk4-sections.txt
gdk/gdkdnd.c
gdk/gdkdnd.h

index b99d2ea5592018608ef87c91fbb900b636b174c4..1da322155df245f49e7d75f46c9693cfb72d8533 100644 (file)
@@ -798,6 +798,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
index 47da69eda347af9aedfaab8f0c330abb4de754b7..98801fcde32f2fea836ca49bae199b15935e5ca8 100644 (file)
@@ -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;
+}
+
index 74c65e4f67a99ea5c921632ec52d87900a40bbfd..f153af44a10a9e4b69fc31cf06cab24b0a5c20bd 100644 (file)
@@ -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,