[gtk/fix-file-transfer-portal: 2/3] Make the file transfer portal setup sync
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/fix-file-transfer-portal: 2/3] Make the file transfer portal setup sync
- Date: Wed, 7 Sep 2022 03:46:14 +0000 (UTC)
commit 4180b4402fc0d2e51bca48d731e2869d71aacc14
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Sep 6 23:38:08 2022 -0400
Make the file transfer portal setup sync
We need to register the portal mime types before
the others to prefer them, doing this call async
messes up that ordering.
gdk/filetransferportal.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
---
diff --git a/gdk/filetransferportal.c b/gdk/filetransferportal.c
index a658d086a8..18f733af60 100644
--- a/gdk/filetransferportal.c
+++ b/gdk/filetransferportal.c
@@ -196,6 +196,7 @@ file_transfer_portal_register_files (const char **files,
AddFileData *afd;
GVariantBuilder options;
+ g_print ("register files\n");
task = g_task_new (NULL, NULL, callback, data);
if (file_transfer_proxy == NULL)
@@ -229,6 +230,7 @@ file_transfer_portal_register_files_finish (GAsyncResult *result,
if (g_task_propagate_boolean (G_TASK (result), error))
{
*key = g_strdup (g_object_get_data (G_OBJECT (result), "key"));
+ g_print ("register files done: %s\n", *key);
return TRUE;
}
@@ -246,6 +248,8 @@ retrieve_files_done (GObject *object,
GVariant *ret;
char **files;
+ g_print ("retrieve files done\n");
+
ret = g_dbus_proxy_call_finish (proxy, result, &error);
if (ret == NULL)
{
@@ -271,6 +275,7 @@ file_transfer_portal_retrieve_files (const char *key,
GTask *task;
GVariantBuilder options;
+ g_print ("retrieve files: %s\n", key);
task = g_task_new (NULL, NULL, callback, data);
if (file_transfer_proxy == NULL)
@@ -480,20 +485,8 @@ connection_closed (GDBusConnection *connection,
}
static void
-got_proxy (GObject *source,
- GAsyncResult *result,
- gpointer data)
+finish_registration (void)
{
- GError *error = NULL;
-
- file_transfer_proxy = g_dbus_proxy_new_for_bus_finish (result, &error);
- if (!file_transfer_proxy)
- {
- g_message ("Failed to get file transfer portal: %s", error->message);
- g_clear_error (&error);
- return;
- }
-
gdk_content_register_serializer (G_TYPE_FILE,
"application/vnd.portal.files",
portal_file_serializer,
@@ -531,7 +524,8 @@ file_transfer_portal_register (void)
if (!called)
{
called = TRUE;
- g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
+
+ file_transfer_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES
| G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS
| G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
@@ -540,8 +534,9 @@ file_transfer_portal_register (void)
"/org/freedesktop/portal/documents",
"org.freedesktop.portal.FileTransfer",
NULL,
- got_proxy,
NULL);
+ if (file_transfer_proxy)
+ finish_registration ();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]