[gtk/wip/otte/dnd: 7/10] dragdest: Handle NULL content formats everywhere



commit a5a86f3e23ac9fb8912ed385d9b8bf4667c17cbb
Author: Benjamin Otte <otte redhat com>
Date:   Mon Feb 17 03:04:37 2020 +0100

    dragdest: Handle NULL content formats everywhere
    
    NULL means we don't do content formats checks and accept everything.
    
    We use this for notebook arrows or expanders that react to ongoing
    drags.

 gtk/gtkdragdest.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkdragdest.c b/gtk/gtkdragdest.c
index 26cdc6eb53..eddd79b709 100644
--- a/gtk/gtkdragdest.c
+++ b/gtk/gtkdragdest.c
@@ -448,7 +448,9 @@ gtk_drop_target_set_formats (GtkDropTarget     *dest,
  *
  * Gets the data formats that this drop target accepts.
  *
- * Returns: the supported data formats
+ * If the result is %NULL, all formats are expected to be supported.
+ *
+ * Returns: (nullable): the supported data formats
  */
 GdkContentFormats *
 gtk_drop_target_get_formats (GtkDropTarget *dest)
@@ -563,6 +565,9 @@ gtk_drop_target_find_mimetype (GtkDropTarget *dest)
   if (!dest->drop)
     return NULL;
 
+  if (dest->formats == NULL)
+    return NULL;
+
   return gtk_drop_target_match (dest, dest->drop);
 }
 
@@ -573,6 +578,9 @@ gtk_drop_target_accept (GtkDropTarget *dest,
   if ((gdk_drop_get_actions (drop) & gtk_drop_target_get_actions (dest)) == 0)
     return FALSE;
 
+  if (dest->formats == NULL)
+    return TRUE;
+
   return gdk_content_formats_match (dest->formats, gdk_drop_get_formats (drop));
 }
 


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