[gtk+/wip/alexl/file-chooser-portal] portal: Allow forcing it off



commit 108ae05a7673fdfa68e6b96a7725c32784d16cc4
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 11 10:23:27 2016 -0400

    portal: Allow forcing it off
    
    With GTK_USE_PORTAL=1, try to use the portal even if we if we use
    unsupported features. With GTK_USE_PORTAL=0, never use the portal,
    as before. What we really want here is to detect the situation
    of "sandboxed without full $HOME access" and use the portal in
    those cases. If we make the portal smart enough to hand back
    direct uris for files that the app can access, we may simplify
    the check to just "sandboxed".

 gtk/gtkfilechoosernativeportal.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkfilechoosernativeportal.c b/gtk/gtkfilechoosernativeportal.c
index 4ef2247..61ef899 100644
--- a/gtk/gtkfilechoosernativeportal.c
+++ b/gtk/gtkfilechoosernativeportal.c
@@ -277,16 +277,24 @@ gtk_file_chooser_native_portal_show (GtkFileChooserNative *self)
   const char *method_name;
   const char *signal_name;
   GDBusSignalCallback signal_callback;
+  const char *use_portal;
 
-  if (g_getenv ("GTK_USE_PORTAL") == NULL)
-    return FALSE;
+  use_portal = g_getenv ("GTK_USE_PORTAL");
+  if (!use_portal)
+    use_portal = "";
 
-  if (gtk_file_chooser_get_extra_widget (GTK_FILE_CHOOSER (self)) != NULL)
+  if (g_str_equal (use_portal, "0"))
     return FALSE;
 
-  update_preview_signal = g_signal_lookup ("update-preview", GTK_TYPE_FILE_CHOOSER);
-  if (g_signal_has_handler_pending (self, update_preview_signal, 0, TRUE))
-    return FALSE;
+  if (!g_str_equal (use_portal, "1"))
+    {
+      if (gtk_file_chooser_get_extra_widget (GTK_FILE_CHOOSER (self)) != NULL)
+        return FALSE;
+
+      update_preview_signal = g_signal_lookup ("update-preview", GTK_TYPE_FILE_CHOOSER);
+      if (g_signal_has_handler_pending (self, update_preview_signal, 0, TRUE))
+        return FALSE;
+    }
 
   connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
   if (connection == NULL)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]