[gtk/dnd-gestures-2: 2/57] drop: Add a convenience api



commit 96b9d047ba182aa7dfd2d6b0046a2b74d52c4612
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jan 2 13:05:29 2020 -0500

    drop: Add a convenience api
    
    This is a question that drag-drop handlers frequently
    need to answer, so make it easy.

 gdk/gdkdrop.c | 27 +++++++++++++++++++++++++++
 gdk/gdkdrop.h |  3 +++
 2 files changed, 30 insertions(+)
---
diff --git a/gdk/gdkdrop.c b/gdk/gdkdrop.c
index eb04ca26ad..d82e90df2c 100644
--- a/gdk/gdkdrop.c
+++ b/gdk/gdkdrop.c
@@ -1001,3 +1001,30 @@ gdk_drop_emit_drop_event (GdkDrop  *self,
   gdk_drop_do_emit_event (event, dont_queue);
 }
 
+/**
+ * gdk_drop_has_value:
+ * @drop: a #GdkDrop
+ * @type: the type to check
+ *
+ * Returns whether calling gdk_drop_read_value_async() for @type
+ * can succeed.
+ *
+ * Returns: %TRUE if the data can be deserialized to the given type
+ */ 
+gboolean
+gdk_drop_has_value (GdkDrop *drop,
+                    GType    type)
+{
+  GdkContentFormats *formats;
+  gboolean ret;
+
+  formats = gdk_content_formats_ref (gdk_drop_get_formats (drop));
+  formats = gdk_content_formats_union_deserialize_gtypes (formats);
+
+  ret = gdk_content_formats_contain_gtype (formats, type);
+
+  gdk_content_formats_unref (formats);
+
+  return ret;
+}
+
diff --git a/gdk/gdkdrop.h b/gdk/gdkdrop.h
index db5acd13e9..6e29864293 100644
--- a/gdk/gdkdrop.h
+++ b/gdk/gdkdrop.h
@@ -92,6 +92,9 @@ char *                  gdk_drop_read_text_finish       (GdkDrop
                                                          GAsyncResult           *result,
                                                          GError                **error);
 
+GDK_AVAILABLE_IN_ALL
+gboolean                gdk_drop_has_value              (GdkDrop                *self,
+                                                         GType                   type);
 
 G_END_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]