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.
This commit is contained in:
Matthijs Velsink
2024-08-24 17:45:46 +02:00
parent f22e5b0b23
commit 7d1b9bf280

View File

@ -2024,11 +2024,7 @@ gtk_selection_data_get_uris (const GtkSelectionData *selection_data)
GPtrArray *uris = g_ptr_array_new (); GPtrArray *uris = g_ptr_array_new ();
for (int i = 0; files[i]; i++) for (int i = 0; files[i]; i++)
{ g_ptr_array_add (uris, g_filename_to_uri (files[i], NULL, NULL));
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, NULL); g_ptr_array_add (uris, NULL);
result = (char **) g_ptr_array_free (uris, FALSE); result = (char **) g_ptr_array_free (uris, FALSE);