From b0148972fdeb03765f73ade8ffa0b4be4bfb35ef Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 17 Nov 2022 15:51:11 -0500 Subject: [PATCH] filedialog: Use portals We want this new API to be portal-first. Make it so. --- gtk/gtkfilechoosernative.c | 7 +++++++ gtk/gtkfilechoosernativeportal.c | 2 +- gtk/gtkfilechoosernativeprivate.h | 4 ++++ gtk/gtkfiledialog.c | 3 ++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gtk/gtkfilechoosernative.c b/gtk/gtkfilechoosernative.c index 7ec767c427..d28eb23f39 100644 --- a/gtk/gtkfilechoosernative.c +++ b/gtk/gtkfilechoosernative.c @@ -561,6 +561,13 @@ gtk_file_chooser_native_new (const char *title, return result; } +void +gtk_file_chooser_native_set_use_portal (GtkFileChooserNative *self, + gboolean use_portal) +{ + self->use_portal = use_portal; +} + static void dialog_response_cb (GtkDialog *dialog, int response_id, diff --git a/gtk/gtkfilechoosernativeportal.c b/gtk/gtkfilechoosernativeportal.c index 530e63cff0..8c5903ce30 100644 --- a/gtk/gtkfilechoosernativeportal.c +++ b/gtk/gtkfilechoosernativeportal.c @@ -468,7 +468,7 @@ gtk_file_chooser_native_portal_show (GtkFileChooserNative *self, GtkFileChooserAction action; const char *method_name; - if (!gdk_should_use_portal ()) + if (!self->use_portal && !gdk_should_use_portal ()) return FALSE; connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); diff --git a/gtk/gtkfilechoosernativeprivate.h b/gtk/gtkfilechoosernativeprivate.h index eacb92cce3..bc4633dfe5 100644 --- a/gtk/gtkfilechoosernativeprivate.h +++ b/gtk/gtkfilechoosernativeprivate.h @@ -52,9 +52,13 @@ struct _GtkFileChooserNative GtkWidget *accept_button; GtkWidget *cancel_button; + gboolean use_portal; gpointer mode_data; }; +void gtk_file_chooser_native_set_use_portal (GtkFileChooserNative *self, + gboolean use_portal); + gboolean gtk_file_chooser_native_win32_show (GtkFileChooserNative *self); void gtk_file_chooser_native_win32_hide (GtkFileChooserNative *self); diff --git a/gtk/gtkfiledialog.c b/gtk/gtkfiledialog.c index 26c662f65e..a1ad1c9731 100644 --- a/gtk/gtkfiledialog.c +++ b/gtk/gtkfiledialog.c @@ -22,7 +22,7 @@ #include "gtkfiledialog.h" #include "deprecated/gtkdialog.h" -#include "deprecated/gtkfilechoosernative.h" +#include "gtkfilechoosernativeprivate.h" #include "gtkdialogerror.h" #include @@ -679,6 +679,7 @@ create_file_chooser (GtkFileDialog *self, } chooser = gtk_file_chooser_native_new (title, parent, action, accept, _("_Cancel")); + gtk_file_chooser_native_set_use_portal (chooser, TRUE); gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (chooser), self->modal); gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (chooser), select_multiple); -- 2.30.2