diff options
author | Peter Eisenmann <650-p3732@users.noreply.gitlab.gnome.org> | 2023-01-23 05:11:10 +0000 |
---|---|---|
committer | Corey Berla <corey@berla.me> | 2023-01-23 05:11:10 +0000 |
commit | d084a7209fa2c890b9ec98ae17bd78c56572f2b8 (patch) | |
tree | 882df7e02ffcc0a8bc525914d25aedb3fe99c644 /src | |
parent | a126b55045ba83b31283de02072032787e922ad7 (diff) | |
download | nautilus-d084a7209fa2c890b9ec98ae17bd78c56572f2b8.tar.gz |
dnd: Don't handle drops without uris
Add a check to assert nautilus_files_view_drop_proxy_received_uris is
not called with an empty source uri list.
Make nautilus_dnd_perform_drop return whether the drop event was
actually handled. Adjust callers accordingly.
Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2787
Diffstat (limited to 'src')
-rw-r--r-- | src/nautilus-dnd.c | 13 | ||||
-rw-r--r-- | src/nautilus-dnd.h | 2 | ||||
-rw-r--r-- | src/nautilus-list-base.c | 8 | ||||
-rw-r--r-- | src/nautilus-window.c | 4 |
4 files changed, 16 insertions, 11 deletions
diff --git a/src/nautilus-dnd.c b/src/nautilus-dnd.c index a6039fe29..cd6fd110d 100644 --- a/src/nautilus-dnd.c +++ b/src/nautilus-dnd.c @@ -230,7 +230,7 @@ nautilus_dnd_get_preferred_action (NautilusFile *target_file, return GDK_ACTION_COPY; } -void +gboolean nautilus_dnd_perform_drop (NautilusFilesView *view, const GValue *value, GdkDragAction action, @@ -241,18 +241,25 @@ nautilus_dnd_perform_drop (NautilusFilesView *view, if (!gdk_drag_action_is_unique (action)) { /* TODO: Implement */ + return FALSE; } else if (G_VALUE_HOLDS (value, G_TYPE_STRING)) { nautilus_files_view_handle_text_drop (view, g_value_get_string (value), target_uri, action); + return TRUE; } else if (G_VALUE_HOLDS (value, GDK_TYPE_FILE_LIST)) { GSList *source_file_list = g_value_get_boxed (value); GList *source_uri_list = NULL; + if (source_file_list == NULL) + { + return FALSE; + } + for (GSList *l = source_file_list; l != NULL; l = l->next) { source_uri_list = g_list_prepend (source_uri_list, g_file_get_uri (l->data)); @@ -264,7 +271,11 @@ nautilus_dnd_perform_drop (NautilusFilesView *view, target_uri, action); g_list_free_full (source_uri_list, g_free); + + return TRUE; } + + return FALSE; } #define MAX_DRAWN_DRAG_ICONS 10 diff --git a/src/nautilus-dnd.h b/src/nautilus-dnd.h index 426d7f89a..8fc59905a 100644 --- a/src/nautilus-dnd.h +++ b/src/nautilus-dnd.h @@ -26,7 +26,7 @@ GdkDragAction nautilus_dnd_get_preferred_action (NautilusFile GdkPaintable * get_paintable_for_drag_selection (GList *selection, int scale); -void nautilus_dnd_perform_drop (NautilusFilesView *view, +gboolean nautilus_dnd_perform_drop (NautilusFilesView *view, const GValue *value, GdkDragAction action, GFile *target_location); diff --git a/src/nautilus-list-base.c b/src/nautilus-list-base.c index 05385f561..5bd797a36 100644 --- a/src/nautilus-list-base.c +++ b/src/nautilus-list-base.c @@ -785,9 +785,7 @@ on_item_drop (GtkDropTarget *target, /* In x11 the leave signal isn't emitted on a drop so we need to clear the timeout */ g_clear_handle_id (&priv->hover_timer_id, g_source_remove); - nautilus_dnd_perform_drop (NAUTILUS_FILES_VIEW (self), value, actions, target_location); - - return TRUE; + return nautilus_dnd_perform_drop (NAUTILUS_FILES_VIEW (self), value, actions, target_location); } static GdkDragAction @@ -880,9 +878,7 @@ on_view_drop (GtkDropTarget *target, } #endif - nautilus_dnd_perform_drop (NAUTILUS_FILES_VIEW (self), value, actions, target_location); - - return TRUE; + return nautilus_dnd_perform_drop (NAUTILUS_FILES_VIEW (self), value, actions, target_location); } void diff --git a/src/nautilus-window.c b/src/nautilus-window.c index 285febf0a..30299b19d 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -1520,9 +1520,7 @@ extra_drag_drop_cb (AdwTabBar *self, GFile *target_location = nautilus_window_slot_get_location (slot); GdkDragAction action = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (page), "drag-action")); - nautilus_dnd_perform_drop (view, value, action, target_location); - - return TRUE; + return nautilus_dnd_perform_drop (view, value, action, target_location); } const GActionEntry win_entries[] = |