From: Benjamin Otte Date: Fri, 11 May 2018 22:13:11 +0000 (+0200) Subject: dnd: Add gdk_drag_action_is_unique() X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~22^2~129 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=74a8ffc4a86d4b6e3c258be0f1fd0ac020db3b27;p=gtk4.git dnd: Add gdk_drag_action_is_unique() This will be necessary once we remove the ASK action. --- diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt index b99d2ea559..1da322155d 100644 --- a/docs/reference/gdk/gdk4-sections.txt +++ b/docs/reference/gdk/gdk4-sections.txt @@ -798,6 +798,9 @@ gdk_drag_context_get_dest_surface gdk_drag_context_get_drag_surface gdk_drag_context_set_hotspot + +gdk_drag_action_is_unique + 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,