[gtk+/portal: 9/17] file chooser portal: Port to new Request API
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/portal: 9/17] file chooser portal: Port to new Request API
- Date: Wed, 6 Jul 2016 03:07:40 +0000 (UTC)
commit 8c7e5ec583ba3f5cd0329164461b72d41e7afd7b
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jun 26 14:35:12 2016 -0400
file chooser portal: Port to new Request API
The portal API has changed, we need to adapt.
gtk/gtkfilechoosernativeportal.c | 51 ++++++++++++++++---------------------
1 files changed, 22 insertions(+), 29 deletions(-)
---
diff --git a/gtk/gtkfilechoosernativeportal.c b/gtk/gtkfilechoosernativeportal.c
index 9cc2610..87a9906 100644
--- a/gtk/gtkfilechoosernativeportal.c
+++ b/gtk/gtkfilechoosernativeportal.c
@@ -55,6 +55,7 @@ typedef struct {
GDBusConnection *connection;
char *portal_handle;
guint portal_response_signal_id;
+ GDBusSignalCallback signal_callback;
gboolean modal;
gboolean hidden;
@@ -236,6 +237,19 @@ open_file_msg_cb (GObject *source_object,
send_close (data);
filechooser_portal_data_free (data);
}
+ else
+ {
+ data->portal_response_signal_id =
+ g_dbus_connection_signal_subscribe (data->connection,
+ "org.freedesktop.portal.Desktop",
+ "org.freedesktop.portal.Request",
+ "Response",
+ data->portal_handle,
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE,
+ data->signal_callback,
+ self, NULL);
+ }
g_object_unref (reply);
}
@@ -263,7 +277,6 @@ gtk_file_chooser_native_portal_show (GtkFileChooserNative *self)
{
FilechooserPortalData *data;
GtkWindow *transient_for;
- guint update_preview_signal;
GDBusConnection *connection;
char *parent_window_str;
GDBusMessage *message;
@@ -271,8 +284,6 @@ gtk_file_chooser_native_portal_show (GtkFileChooserNative *self)
GtkFileChooserAction action;
gboolean multiple;
const char *method_name;
- const char *signal_name;
- GDBusSignalCallback signal_callback;
if (!gtk_should_use_portal ())
return FALSE;
@@ -285,23 +296,11 @@ gtk_file_chooser_native_portal_show (GtkFileChooserNative *self)
multiple = gtk_file_chooser_get_select_multiple (GTK_FILE_CHOOSER (self));
if (action == GTK_FILE_CHOOSER_ACTION_OPEN && !multiple)
- {
- method_name = "OpenFile";
- signal_name = "OpenFileResponse";
- signal_callback = one_file_response;
- }
+ method_name = "OpenFile";
else if (action == GTK_FILE_CHOOSER_ACTION_OPEN && multiple)
- {
- method_name = "OpenFiles";
- signal_name = "OpenFilesResponse";
- signal_callback = multi_file_response;
- }
+ method_name = "OpenFiles";
else if (action == GTK_FILE_CHOOSER_ACTION_SAVE)
- {
- method_name = "SaveFile";
- signal_name = "SaveFileResponse";
- signal_callback = one_file_response;
- }
+ method_name = "SaveFile";
else
{
g_warning ("GTK_FILE_CHOOSER_ACTION_%s is not supported by GtkFileChooserNativePortal", action ==
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ? "SELECT_FOLDER" : "CREATE_FOLDER");
@@ -312,6 +311,11 @@ gtk_file_chooser_native_portal_show (GtkFileChooserNative *self)
data->self = g_object_ref (self);
data->connection = connection;
+ if (strcmp (method_name, "OpenFiles") == 0)
+ data->signal_callback = multi_file_response;
+ else
+ data->signal_callback = one_file_response;
+
message = g_dbus_message_new_method_call ("org.freedesktop.portal.Desktop",
"/org/freedesktop/portal/desktop",
"org.freedesktop.portal.FileChooser",
@@ -376,17 +380,6 @@ gtk_file_chooser_native_portal_show (GtkFileChooserNative *self)
g_variant_builder_end (&opt_builder)));
g_free (parent_window_str);
- data->portal_response_signal_id =
- g_dbus_connection_signal_subscribe (data->connection,
- "org.freedesktop.portal.Desktop",
- "org.freedesktop.portal.FileChooser",
- signal_name,
- "/org/freedesktop/portal/desktop",
- NULL,
- G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE,
- signal_callback,
- self, NULL);
-
g_dbus_connection_send_message_with_reply (data->connection,
message,
G_DBUS_SEND_MESSAGE_FLAGS_NONE,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]