summaryrefslogtreecommitdiff
path: root/gdk/gdkcontentdeserializer.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-01-17 22:31:51 -0500
committerMatthias Clasen <mclasen@redhat.com>2020-01-17 23:46:37 -0500
commit69fb3648b2e20935b7839f874fb0b52dee32448b (patch)
tree155c7cb22568a7604f121645bf2dc618ad049217 /gdk/gdkcontentdeserializer.c
parent26c4c2806838622e27337c25c8d9ae615de89c48 (diff)
downloadgtk+-69fb3648b2e20935b7839f874fb0b52dee32448b.tar.gz
Tweak the file transfer portal _again_
This is a neverending story. I was seeing problems in tests where the nested mainloop was picking up unrelated timeouts. Break down and make this async. This changes the ordering in which the (de)serializers are registered. If this is causing issues, we can introduce priorities or something else.
Diffstat (limited to 'gdk/gdkcontentdeserializer.c')
-rw-r--r--gdk/gdkcontentdeserializer.c106
1 files changed, 1 insertions, 105 deletions
diff --git a/gdk/gdkcontentdeserializer.c b/gdk/gdkcontentdeserializer.c
index 0015520b3c..12594b1fd8 100644
--- a/gdk/gdkcontentdeserializer.c
+++ b/gdk/gdkcontentdeserializer.c
@@ -692,95 +692,6 @@ string_deserializer (GdkContentDeserializer *deserializer)
g_object_unref (filter);
}
-#ifdef G_OS_UNIX
-static void
-portal_finish (GObject *object,
- GAsyncResult *result,
- gpointer deserializer)
-{
- char **files = NULL;
- GError *error = NULL;
- GValue *value;
-
- if (!file_transfer_portal_retrieve_files_finish (result, &files, &error))
- {
- gdk_content_deserializer_return_error (deserializer, error);
- return;
- }
-
- value = gdk_content_deserializer_get_value (deserializer);
- if (G_VALUE_HOLDS (value, G_TYPE_FILE))
- {
- if (files[0] != NULL)
- g_value_take_object (value, g_file_new_for_path (files[0]));
- }
- else
- {
- GSList *l = NULL;
- gsize i;
-
- for (i = 0; files[i] != NULL; i++)
- l = g_slist_prepend (l, g_file_new_for_path (files[i]));
- g_value_take_boxed (value, g_slist_reverse (l));
- }
- g_strfreev (files);
-
- gdk_content_deserializer_return_success (deserializer);
-}
-
-static void
-portal_file_deserializer_finish (GObject *source,
- GAsyncResult *result,
- gpointer deserializer)
-{
- GOutputStream *stream = G_OUTPUT_STREAM (source);
- GError *error = NULL;
- gssize written;
- char *key;
-
- written = g_output_stream_splice_finish (stream, result, &error);
- if (written < 0)
- {
- gdk_content_deserializer_return_error (deserializer, error);
- return;
- }
-
- /* write terminating NULL */
- if (!g_output_stream_write (stream, "", 1, NULL, &error))
- {
- gdk_content_deserializer_return_error (deserializer, error);
- return;
- }
-
- key = g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM (stream));
- if (key == NULL)
- {
- deserialize_not_found (deserializer);
- return;
- }
-
- file_transfer_portal_retrieve_files (key, portal_finish, deserializer);
- gdk_content_deserializer_set_task_data (deserializer, key, g_free);
-}
-
-static void
-portal_file_deserializer (GdkContentDeserializer *deserializer)
-{
- GOutputStream *output;
-
- output = g_memory_output_stream_new_resizable ();
-
- g_output_stream_splice_async (output,
- gdk_content_deserializer_get_input_stream (deserializer),
- G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE | G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
- gdk_content_deserializer_get_priority (deserializer),
- gdk_content_deserializer_get_cancellable (deserializer),
- portal_file_deserializer_finish,
- deserializer);
- g_object_unref (output);
-}
-#endif /* G_OS_UNIX */
-
static void
file_uri_deserializer_finish (GObject *source,
GAsyncResult *result,
@@ -965,13 +876,7 @@ init (void)
g_slist_free (formats);
#ifdef G_OS_UNIX
- gboolean has_portal = file_transfer_portal_available ();
- if (has_portal)
- gdk_content_register_deserializer ("application/vnd.portal.files",
- GDK_TYPE_FILE_LIST,
- portal_file_deserializer,
- NULL,
- NULL);
+ file_transfer_portal_register ();
#endif
gdk_content_register_deserializer ("text/uri-list",
@@ -980,15 +885,6 @@ init (void)
NULL,
NULL);
-#ifdef G_OS_UNIX
- if (has_portal)
- gdk_content_register_deserializer ("application/vnd.portal.files",
- G_TYPE_FILE,
- portal_file_deserializer,
- NULL,
- NULL);
-#endif
-
gdk_content_register_deserializer ("text/uri-list",
G_TYPE_FILE,
file_uri_deserializer,