forked from AuroraMiddleware/gtk
contentserializer: Serialize to file:// if possible
Try to get a native file:// URI instead of any other GVFS scheme, for interoperability with apps only handling file:// URIs. This is what GTK3 Nautilus and Thunar do, so apps should be tuned for this behavior. See also https://bugzilla.xfce.org/show_bug.cgi?id=13845 Fixes: #5422
This commit is contained in:
parent
200f31f285
commit
ea056d261f
@ -795,6 +795,22 @@ file_serializer_finish (GObject *source,
|
|||||||
gdk_content_serializer_return_success (serializer);
|
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
|
static void
|
||||||
file_uri_serializer (GdkContentSerializer *serializer)
|
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));
|
file = g_value_get_object (gdk_content_serializer_get_value (serializer));
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
uri = g_file_get_uri (file);
|
uri = file_get_native_uri (file);
|
||||||
g_string_append (str, uri);
|
g_string_append (str, uri);
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
}
|
}
|
||||||
@ -827,7 +843,7 @@ file_uri_serializer (GdkContentSerializer *serializer)
|
|||||||
|
|
||||||
for (l = g_value_get_boxed (value); l; l = l->next)
|
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_string_append (str, uri);
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
g_string_append (str, "\r\n");
|
g_string_append (str, "\r\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user