filedialog: Use portals
authorMatthias Clasen <mclasen@redhat.com>
Thu, 17 Nov 2022 20:51:11 +0000 (15:51 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 17 Nov 2022 20:52:53 +0000 (15:52 -0500)
We want this new API to be portal-first.
Make it so.

gtk/gtkfilechoosernative.c
gtk/gtkfilechoosernativeportal.c
gtk/gtkfilechoosernativeprivate.h
gtk/gtkfiledialog.c

index 7ec767c427a90e8306807315a7fc36e99a45841d..d28eb23f391295b335016cfa977e89d1a7d405b7 100644 (file)
@@ -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,
index 530e63cff04a58ae5002fd78c28d024219ede5f9..8c5903ce306185653f730d9dfbcd8e8f35094438 100644 (file)
@@ -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);
index eacb92cce3bab314c460e8c20bd9f4083bd3cd1f..bc4633dfe5da7c3ea4a97ffec3e1cf57a7486a86 100644 (file)
@@ -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);
 
index 26c662f65eaa214d728dce8b8fb0bd70ae3c1a21..a1ad1c9731720ec16794e87ea79cc9cf5d3d2bf6 100644 (file)
@@ -22,7 +22,7 @@
 #include "gtkfiledialog.h"
 
 #include "deprecated/gtkdialog.h"
-#include "deprecated/gtkfilechoosernative.h"
+#include "gtkfilechoosernativeprivate.h"
 #include "gtkdialogerror.h"
 #include <glib/gi18n-lib.h>
 
@@ -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);