From 7d1b9bf2802fc3d8160f8483e1adc1535aac5b89 Mon Sep 17 00:00:00 2001 From: Matthijs Velsink Date: Sat, 24 Aug 2024 17:45:46 +0200 Subject: [PATCH] selection: Fix portal retrieval of GVFS files When drag-and-dropping a file from Nautilus to for example Firefox, this does not work if the file is from a GVFS mounted source. The retrieved URI with `g_file_get_uri()` still contains the protocol. Instead, we can use `g_filename_to_uri()`, which resolves to the local `file://...` URI instead. A similar fix was applied to GTK4 on the sending side in commit ea056d26. --- gtk/gtkselection.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c index 82755e9a66..bb68775561 100644 --- a/gtk/gtkselection.c +++ b/gtk/gtkselection.c @@ -2024,11 +2024,7 @@ gtk_selection_data_get_uris (const GtkSelectionData *selection_data) GPtrArray *uris = g_ptr_array_new (); for (int i = 0; files[i]; i++) - { - GFile *file = g_file_new_for_path (files[i]); - g_ptr_array_add (uris, g_file_get_uri (file)); - g_object_unref (file); - } + g_ptr_array_add (uris, g_filename_to_uri (files[i], NULL, NULL)); g_ptr_array_add (uris, NULL); result = (char **) g_ptr_array_free (uris, FALSE);