From: Matthias Clasen Date: Thu, 17 Nov 2022 20:51:11 +0000 (-0500) Subject: filedialog: Use portals X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~9^2~94^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b0148972fdeb03765f73ade8ffa0b4be4bfb35ef;p=gtk4.git filedialog: Use portals We want this new API to be portal-first. Make it so. --- 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);