Merge branch 'wip/otte/for-5422' into 'main'

contentserializer: Serialize to file:// if possible

Closes #5422

See merge request GNOME/gtk!5330
This commit is contained in:
Corey Berla 2022-12-14 01:56:04 +00:00
commit e8f70be2c1

View File

@ -795,6 +795,22 @@ file_serializer_finish (GObject *source,
gdk_content_serializer_return_success (serializer);
}
static char *
file_get_native_uri (GFile *file)
{
char *path;
path = g_file_get_path (file);
if (path != NULL)
{
char *uri = g_filename_to_uri (path, NULL, NULL);
g_free (path);
return uri;
}
return g_file_get_uri (file);
}
static void
file_uri_serializer (GdkContentSerializer *serializer)
{
@ -811,7 +827,7 @@ file_uri_serializer (GdkContentSerializer *serializer)
file = g_value_get_object (gdk_content_serializer_get_value (serializer));
if (file)
{
uri = g_file_get_uri (file);
uri = file_get_native_uri (file);
g_string_append (str, uri);
g_free (uri);
}
@ -827,7 +843,7 @@ file_uri_serializer (GdkContentSerializer *serializer)
for (l = g_value_get_boxed (value); l; l = l->next)
{
uri = g_file_get_uri (l->data);
uri = file_get_native_uri (l->data);
g_string_append (str, uri);
g_free (uri);
g_string_append (str, "\r\n");